public String getName() { return dataSource.getName(); }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex); RemoteMap map = (RemoteMap) value; switch (columnIndex) { case DATASOURCE_COLUMN: label.setText(map.getDataSource().getName()); label.setToolTipText(map.getUrl()); label.setHorizontalAlignment(LEFT); break; case DESCRIPTION_COLUMN: label.setText(map.getDescription()); label.setToolTipText(map.getUrl()); label.setHorizontalAlignment(LEFT); break; case SIZE_COLUMN: label.setText(formatSize(getContentLength(map))); label.setToolTipText(map.getUrl()); label.setHorizontalAlignment(RIGHT); break; default: throw new IllegalArgumentException("Row " + rowIndex + ", column " + columnIndex + " does not exist"); } return label; }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex); RemoteTheme theme = (RemoteTheme) value; switch (columnIndex) { case DATASOURCE_COLUMN: label.setText(theme.getDataSource().getName()); label.setToolTipText(theme.getUrl()); label.setHorizontalAlignment(LEFT); break; case DESCRIPTION_COLUMN: label.setText(theme.getDescription()); label.setToolTipText(theme.getUrl()); label.setHorizontalAlignment(LEFT); break; case SIZE_COLUMN: label.setText(formatSize(getContentLength(theme))); label.setToolTipText(theme.getUrl()); label.setHorizontalAlignment(RIGHT); break; default: throw new IllegalArgumentException("Row " + rowIndex + ", column " + columnIndex + " does not exist"); } return label; } }
public Download queueForDownload(DataSource dataSource, Downloadable downloadable) { Action action = Action.valueOf(dataSource.getAction()); File directory = getApplicationDirectory(dataSource.getDirectory()); File target = new File(directory, downloadable.getUri()); if (action.equals(Extract) || action.equals(Flatten)) target = ensureDirectory(target.getParentFile()); return downloadManager.queueForDownload(dataSource.getName() + ": " + downloadable.getUri(), dataSource.getBaseUrl() + downloadable.getUri(), action, new FileAndChecksum(target, downloadable.getLatestChecksum()), asFragments(target, downloadable.getFragments(), false)); }
private void addOrUpdateInQueue(DataSource dataSource, Downloadable downloadable) { Action action = Action.valueOf(dataSource.getAction()); File directory = getApplicationDirectory(dataSource.getDirectory()); File target = directory; // Flatten if (action.equals(Copy)) target = new File(directory, downloadable.getUri()); else if (action.equals(Extract)) target = target.getParentFile(); downloadManager.addOrUpdateInQueue(dataSource.getName() + ": " + downloadable.getUri(), dataSource.getBaseUrl() + downloadable.getUri(), action, new FileAndChecksum(target, downloadable.getLatestChecksum()), asFragments(directory, downloadable.getFragments(), action.equals(Extract))); }
public static DatasourceType asDatasourceType(DataSource dataSource) { DatasourceType datasourceType = new ObjectFactory().createDatasourceType(); datasourceType.setId(dataSource.getId()); datasourceType.setName(dataSource.getName()); datasourceType.setBaseUrl(dataSource.getBaseUrl()); datasourceType.setDirectory(dataSource.getDirectory()); datasourceType.setAction(ActionType.fromValue(dataSource.getAction())); return datasourceType; }