List of usage examples for java.nio.file Path toAbsolutePath
Path toAbsolutePath();
From source file:org.tinymediamanager.core.tvshow.entities.TvShowEpisode.java
/** * (re)sets the path (when renaming tv show/season folder).<br> * Exchanges the beginning path from oldPath with newPath<br> *///from w w w . ja va 2 s. co m public void replacePathForRenamedFolder(Path oldPath, Path newPath) { String p = getPathNIO().toAbsolutePath().toString(); p = p.replace(oldPath.toAbsolutePath().toString(), newPath.toAbsolutePath().toString()); setPath(p); }
From source file:org.tinymediamanager.ui.movies.settings.MovieImageSettingsPanel.java
/** * Instantiates a new movie image settings panel. */// ww w .ja v a 2s .c o m public MovieImageSettingsPanel() { // data init List<String> enabledArtworkProviders = settings.getMovieArtworkScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableArtworkScrapers()) { ArtworkScraper artworkScraper = new ArtworkScraper(scraper); if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) { artworkScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(artworkScraper); counter++; } // init UI setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelMovieImages = new JPanel(); panelMovieImages.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.poster"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMovieImages, "2, 2, default, fill"); panelMovieImages.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setBorder(null); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelMovieImages.add(scrollPaneScraperDetails, "6, 1, 1, 7, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails .setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); scrollPaneScraper = new JScrollPane(); panelMovieImages.add(scrollPaneScraper, "2, 2, 3, 1, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); JSeparator separator = new JSeparator(); panelMovieImages.add(separator, "2, 3, 3, 1"); JLabel lblImageTmdbPosterSize = new JLabel(BUNDLE.getString("image.poster.size")); panelMovieImages.add(lblImageTmdbPosterSize, "2, 5"); cbImagePosterSize = new JComboBox(PosterSizes.values()); panelMovieImages.add(cbImagePosterSize, "4, 5"); JLabel lblImageTmdbFanartSize = new JLabel(BUNDLE.getString("image.fanart.size")); panelMovieImages.add(lblImageTmdbFanartSize, "2, 7"); cbImageFanartSize = new JComboBox(FanartSizes.values()); panelMovieImages.add(cbImageFanartSize, "4, 7"); separator = new JSeparator(); panelMovieImages.add(separator, "2, 9, 5, 1"); panelFileNaming = new JPanel(); panelMovieImages.add(panelFileNaming, "2, 11, 5, 1, fill, fill"); panelFileNaming.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblPosterFilename = new JLabel(BUNDLE.getString("image.poster.naming")); panelFileNaming.add(lblPosterFilename, "1, 1"); cbMoviePosterFilename7 = new JCheckBox("<dynamic>.ext"); panelFileNaming.add(cbMoviePosterFilename7, "3, 1"); cbMoviePosterFilename4 = new JCheckBox("poster.ext"); panelFileNaming.add(cbMoviePosterFilename4, "5, 1"); cbMoviePosterFilename2 = new JCheckBox("movie.ext"); panelFileNaming.add(cbMoviePosterFilename2, "7, 1"); cbMoviePosterFilename8 = new JCheckBox("<dynamic>-poster.ext"); panelFileNaming.add(cbMoviePosterFilename8, "9, 1"); cbMoviePosterFilename6 = new JCheckBox("folder.ext"); panelFileNaming.add(cbMoviePosterFilename6, "11, 1"); JLabel lblFanartFileNaming = new JLabel(BUNDLE.getString("image.fanart.naming")); panelFileNaming.add(lblFanartFileNaming, "1, 3"); cbMovieFanartFilename1 = new JCheckBox("<dynamic>-fanart.ext"); panelFileNaming.add(cbMovieFanartFilename1, "3, 3"); cbMovieFanartFilename3 = new JCheckBox("<dynamic>.fanart.ext"); panelFileNaming.add(cbMovieFanartFilename3, "5, 3"); cbMovieFanartFilename2 = new JCheckBox("fanart.ext"); panelFileNaming.add(cbMovieFanartFilename2, "7, 3"); tpFileNamingHint = new JTextPane(); panelFileNaming.add(tpFileNamingHint, "1, 5, 11, 1, fill, fill"); tpFileNamingHint.setText(BUNDLE.getString("Settings.naming.info")); //$NON-NLS-1$ tpFileNamingHint.setBackground(UIManager.getColor("Panel.background")); TmmFontHelper.changeFont(tpFileNamingHint, 0.833); panelExtraArtwork = new JPanel(); panelExtraArtwork.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.extraartwork"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelExtraArtwork, "2, 4, default, fill"); panelExtraArtwork.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxBanner = new JCheckBox(BUNDLE.getString("mediafiletype.banner")); panelExtraArtwork.add(chckbxBanner, "2, 2"); chckbxClearArt = new JCheckBox(BUNDLE.getString("mediafiletype.clearart")); panelExtraArtwork.add(chckbxClearArt, "4, 2"); chckbxThumb = new JCheckBox(BUNDLE.getString("mediafiletype.thumb")); panelExtraArtwork.add(chckbxThumb, "6, 2"); chckbxLogo = new JCheckBox(BUNDLE.getString("mediafiletype.logo")); panelExtraArtwork.add(chckbxLogo, "8, 2"); chckbxDiscArt = new JCheckBox(BUNDLE.getString("mediafiletype.discart")); panelExtraArtwork.add(chckbxDiscArt, "10, 2"); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 4, 9, 1"); chckbxEnableExtrathumbs = new JCheckBox(BUNDLE.getString("Settings.enable.extrathumbs")); panelExtraArtwork.add(chckbxEnableExtrathumbs, "2, 6, 3, 1"); chckbxResizeExtrathumbsTo = new JCheckBox(BUNDLE.getString("Settings.resize.extrathumbs")); panelExtraArtwork.add(chckbxResizeExtrathumbsTo, "6, 6, 3, 1"); spExtrathumbWidth = new JSpinner(); panelExtraArtwork.add(spExtrathumbWidth, "10, 6"); spExtrathumbWidth.setPreferredSize(new Dimension(49, 20)); lblDownload = new JLabel(BUNDLE.getString("Settings.amount.autodownload")); panelExtraArtwork.add(lblDownload, "2, 8, 7, 1, right, default"); spDownloadCountExtrathumbs = new JSpinner(); panelExtraArtwork.add(spDownloadCountExtrathumbs, "10, 8"); spDownloadCountExtrathumbs.setPreferredSize(new Dimension(49, 20)); chckbxEnableExtrafanart = new JCheckBox(BUNDLE.getString("Settings.enable.extrafanart")); panelExtraArtwork.add(chckbxEnableExtrafanart, "2, 10, 9, 1"); lblDownloadCount = new JLabel(BUNDLE.getString("Settings.amount.autodownload")); panelExtraArtwork.add(lblDownloadCount, "2, 12, 7, 1, right, default"); spDownloadCountExtrafanart = new JSpinner(); panelExtraArtwork.add(spDownloadCountExtrafanart, "10, 12"); spDownloadCountExtrafanart.setPreferredSize(new Dimension(49, 20)); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 14, 9, 1"); cbActorImages = new JCheckBox(BUNDLE.getString("Settings.actor.download")); panelExtraArtwork.add(cbActorImages, "2, 16, 9, 1"); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 18, 9, 1"); chckbxMovieSetArtwork = new JCheckBox(BUNDLE.getString("Settings.movieset.store.movie")); //$NON-NLS-1$ panelExtraArtwork.add(chckbxMovieSetArtwork, "2, 20, 9, 1"); chckbxStoreMoviesetArtwork = new JCheckBox(BUNDLE.getString("Settings.movieset.store")); //$NON-NLS-1$ panelExtraArtwork.add(chckbxStoreMoviesetArtwork, "2, 22, 9, 1"); lblFoldername = new JLabel(BUNDLE.getString("Settings.movieset.foldername")); //$NON-NLS-1$ panelExtraArtwork.add(lblFoldername, "2, 24, 3, 1, right, default"); tfMovieSetArtworkFolder = new JTextField(); panelExtraArtwork.add(tfMovieSetArtworkFolder, "6, 24, 3, 1"); tfMovieSetArtworkFolder.setColumns(10); btnSelectFolder = new JButton(BUNDLE.getString("Settings.movieset.buttonselect")); //$NON-NLS-1$ panelExtraArtwork.add(btnSelectFolder, "10, 24"); btnSelectFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.movieset.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { tfMovieSetArtworkFolder.setText(file.toAbsolutePath().toString()); } } }); initDataBindings(); // poster filenames List<MoviePosterNaming> moviePosterFilenames = settings.getMoviePosterFilenames(); if (moviePosterFilenames.contains(MoviePosterNaming.MOVIE_JPG)) { cbMoviePosterFilename2.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.POSTER_JPG)) { cbMoviePosterFilename4.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FOLDER_JPG)) { cbMoviePosterFilename6.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FILENAME_JPG)) { cbMoviePosterFilename7.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FILENAME_POSTER_JPG)) { cbMoviePosterFilename8.setSelected(true); } // fanart filenames List<MovieFanartNaming> movieFanartFilenames = settings.getMovieFanartFilenames(); if (movieFanartFilenames.contains(MovieFanartNaming.FILENAME_FANART_JPG)) { cbMovieFanartFilename1.setSelected(true); } if (movieFanartFilenames.contains(MovieFanartNaming.FANART_JPG)) { cbMovieFanartFilename2.setSelected(true); } if (movieFanartFilenames.contains(MovieFanartNaming.FILENAME_FANART2_JPG)) { cbMovieFanartFilename3.setSelected(true); } // listen to changes of the checkboxes ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbMovieFanartFilename2.addItemListener(listener); cbMovieFanartFilename3.addItemListener(listener); cbMovieFanartFilename1.addItemListener(listener); cbMoviePosterFilename2.addItemListener(listener); cbMoviePosterFilename4.addItemListener(listener); cbMoviePosterFilename7.addItemListener(listener); cbMoviePosterFilename8.addItemListener(listener); cbMoviePosterFilename6.addItemListener(listener); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); ArtworkScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieArtworkScraper(changedScraper.getScraperId()); } else { settings.removeMovieArtworkScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default artwork scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.codice.ddf.configuration.migration.ExportMigrationContextImplTest.java
@Test public void testEntriesWithFilterAndAbsolutePathUnderDDFHome() throws Exception { final Path etc = createDirectory("etc"); final Path ks = createDirectory("etc", "keystores"); final Path other = createDirectory("other"); final List<Path> paths = createFiles(etc, "test.cfg", "test2.config", "test3.properties"); createFiles(ks, "serverKeystore.jks", "serverTruststore.jks"); createFiles(other, "a", "b"); createDirectory("etc", "keystores", "empty"); final List<ExportMigrationEntry> entries = context .entries(etc.toAbsolutePath(), p -> p.getFileName().toString().startsWith("test")) .collect(Collectors.toList()); Assert.assertThat(entries.stream().map(ExportMigrationEntry::getPath).collect(Collectors.toList()), Matchers.containsInAnyOrder(paths.toArray())); // finally make sure no warnings or errors were recorded Assert.assertThat(report.hasErrors(), Matchers.equalTo(false)); Assert.assertThat(report.hasWarnings(), Matchers.equalTo(false)); }
From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java
protected void initialize(AFCliRequest cliRequest) throws ExitException { if (cliRequest.getWorkingDirectory() == null) { cliRequest.setWorkingDirectory(System.getProperty("user.dir")); }/* w ww. j a v a 2 s. c o m*/ if (cliRequest.getMultiModuleProjectDirectory() == null) { String basedirProperty = System.getProperty(MULTIMODULE_PROJECT_DIRECTORY); if (basedirProperty == null) { System.err.format( "-D%s system propery is not set." + " Check $M2_HOME environment variable and mvn script match.", MULTIMODULE_PROJECT_DIRECTORY); throw new ExitException(1); } Path basedir = basedirProperty != null ? Paths.get(basedirProperty) : Paths.get(""); cliRequest.setMultiModuleProjectDirectory(basedir.toAbsolutePath().toString()); } }
From source file:org.tinymediamanager.core.movie.MovieList.java
/** * Gets the movie by path.//from w ww . j av a 2 s .c o m * * @param path * the path * @return the movie by path */ public synchronized Movie getMovieByPath(Path path) { for (Movie movie : movieList) { if (movie.getPathNIO().compareTo(path.toAbsolutePath()) == 0) { LOGGER.debug( "Ok, found already existing movie '" + movie.getTitle() + "' in DB (path: " + path + ")"); return movie; } } return null; }
From source file:org.esa.s2tbx.dataio.s2.Sentinel2ProductReader.java
/** * From a product path, search a jpeg file for the given resolution, extract tile layout * information and update/* w ww .j a v a2 s .c o m*/ * * @param productMetadataFilePath the complete path to the product metadata file * @param resolution the resolution for which we wan to find the tile layout * @return the tile layout for the resolution, or {@code null} if none was found */ public TileLayout retrieveTileLayoutFromProduct(Path productMetadataFilePath, S2SpatialResolution resolution) { TileLayout tileLayoutForResolution = null; if (Files.exists(productMetadataFilePath) && productMetadataFilePath.toString().endsWith(".xml")) { Path productFolder = productMetadataFilePath.getParent(); Path granulesFolder = productFolder.resolve("GRANULE"); try { DirectoryStream<Path> granulesFolderStream = Files.newDirectoryStream(granulesFolder); for (Path granulePath : granulesFolderStream) { tileLayoutForResolution = retrieveTileLayoutFromGranuleDirectory(granulePath, resolution); if (tileLayoutForResolution != null) { break; } } } catch (IOException e) { SystemUtils.LOG.warning("Could not retrieve tile layout for product " + productMetadataFilePath.toAbsolutePath().toString() + " error returned: " + e.getMessage()); } } return tileLayoutForResolution; }
From source file:codes.thischwa.c5c.impl.LocalConnector.java
/** * Construct from dir request.//from w w w . j ava 2 s .c o m * @param dir the dir * @param needSize the need size * @return the folder info * @throws C5CException the connector exception */ private Set<FileProperties> constructFromDirRequest(Path dir, boolean needSize) throws C5CException { Set<FileProperties> props = new HashSet<>(); // add dirs try { for (Path d : Files.newDirectoryStream(dir, new DirectoryStream.Filter<Path>() { @Override public boolean accept(Path entry) throws IOException { return Files.isDirectory(entry) && checkFolderName(entry.getFileName().toString()); } })) { boolean isProtected = isProtected(d); FileProperties fp = buildForDirectory(d.getFileName().toString(), isProtected, new Date(Files.getLastModifiedTime(d).toMillis())); props.add(fp); } } catch (IOException | SecurityException e) { throw new C5CException(String.format("Error while fetching sub-directories from [%s]: %s", dir.toAbsolutePath().toString(), e.getMessage())); } // add files try { for (Path f : Files.newDirectoryStream(dir, new DirectoryStream.Filter<Path>() { @Override public boolean accept(Path entry) throws IOException { return Files.isRegularFile(entry) && checkFilename(entry.getFileName().toString()); } })) { props.add(constructFileInfo(f, needSize)); } } catch (IOException | SecurityException e) { throw new C5CException(String.format("Error while fetching files from [%s]: %s", dir.toAbsolutePath().toString(), e.getMessage())); } return props; }
From source file:org.tinymediamanager.core.movie.tasks.MovieUpdateDatasourceTask2.java
public void searchAndParse(Path datasource, Path folder, int deep) { folder = folder.toAbsolutePath(); SearchAndParseVisitor visitor = new SearchAndParseVisitor(datasource); try {/*from ww w . j a va 2 s . co m*/ Files.walkFileTree(folder, EnumSet.of(FileVisitOption.FOLLOW_LINKS), deep, visitor); } catch (IOException e) { // can not happen, since we override visitFileFailed, which throws no // exception ;) } }
From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeEditorDialog.java
/** * Instantiates a new tv show episode scrape dialog. * // w ww .j a v a 2s . com * @param episode * the episode * @param inQueue * the in queue */ public TvShowEpisodeEditorDialog(TvShowEpisode episode, boolean inQueue) { super(BUNDLE.getString("tvshowepisode.scrape"), "tvShowEpisodeScraper"); //$NON-NLS-1$ setBounds(5, 5, 964, 632); for (MediaFile mf : episode.getMediaFiles()) { mediaFiles.add(new MediaFile(mf)); } this.episodeToEdit = episode; getContentPane().setLayout(new BorderLayout()); { JPanel panelFilename = new JPanel(); getContentPane().add(panelFilename, BorderLayout.NORTH); panelFilename.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblFilenameT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ panelFilename.add(lblFilenameT, "2, 2, left, top"); lblFilename = new JLabel(""); TmmFontHelper.changeFont(lblFilename, 1.166, Font.BOLD); panelFilename.add(lblFilename, "5, 2, left, top"); } JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH); getContentPane().add(tabbedPane, BorderLayout.CENTER); /** * DetailsPanel */ { JPanel detailsPanel = new JPanel(); tabbedPane.addTab(BUNDLE.getString("metatag.details"), detailsPanel); //$NON-NLS-1$ detailsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("40dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("30dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("35dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$ detailsPanel.add(lblTitle, "2, 4, right, default"); tfTitle = new JTextField(); detailsPanel.add(tfTitle, "4, 4, 19, 1"); tfTitle.setColumns(10); JLabel lblSeason = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$ detailsPanel.add(lblSeason, "2, 6, right, default"); spSeason = new JSpinner(); detailsPanel.add(spSeason, "4, 6"); JLabel lblEpisode = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$ detailsPanel.add(lblEpisode, "8, 6, right, default"); spEpisode = new JSpinner(); detailsPanel.add(spEpisode, "10, 6"); JLabel lblDvdSeason = new JLabel(BUNDLE.getString("metatag.dvdseason")); //$NON-NLS-1$ detailsPanel.add(lblDvdSeason, "2, 8, right, default"); spDvdSeason = new JSpinner(); detailsPanel.add(spDvdSeason, "4, 8"); JLabel lblDvdEpisode = new JLabel(BUNDLE.getString("metatag.dvdepisode")); //$NON-NLS-1$ detailsPanel.add(lblDvdEpisode, "8, 8, right, default"); spDvdEpisode = new JSpinner(); detailsPanel.add(spDvdEpisode, "10, 8"); JLabel lblDvdOrder = new JLabel(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$ detailsPanel.add(lblDvdOrder, "14, 8, right, default"); cbDvdOrder = new JCheckBox(""); detailsPanel.add(cbDvdOrder, "16, 8"); cbDvdOrder.setSelected(episodeToEdit.isDvdOrder()); JLabel lblDisplaySeason = new JLabel(BUNDLE.getString("metatag.displayseason")); //$NON-NLS-1$ detailsPanel.add(lblDisplaySeason, "2, 10, right, default"); spDisplaySeason = new JSpinner(); detailsPanel.add(spDisplaySeason, "4, 10"); JLabel lblDisplayEpisode = new JLabel(BUNDLE.getString("metatag.displayepisode")); //$NON-NLS-1$ detailsPanel.add(lblDisplayEpisode, "8, 10, right, default"); spDisplayEpisode = new JSpinner(); detailsPanel.add(spDisplayEpisode, "10, 10"); JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ detailsPanel.add(lblRating, "2, 12, right, default"); spRating = new JSpinner(); detailsPanel.add(spRating, "4, 12"); JLabel lblFirstAired = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$ detailsPanel.add(lblFirstAired, "8, 12, right, default"); dpFirstAired = new DatePicker(episode.getFirstAired()); detailsPanel.add(dpFirstAired, "10, 12, 3, 1, fill, default"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ detailsPanel.add(lblWatched, "2, 14, right, default"); chckbxWatched = new JCheckBox(""); detailsPanel.add(chckbxWatched, "4, 14"); JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ detailsPanel.add(lblDateAdded, "8, 14, right, default"); spDateAdded = new JSpinner(new SpinnerDateModel()); detailsPanel.add(spDateAdded, "10, 14, 3, 1, fill, default"); JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ detailsPanel.add(lblMediasource, "2, 16, right, default"); cbMediaSource = new JComboBox(MediaSource.values()); detailsPanel.add(cbMediaSource, "4, 16, 4, 1, fill, default"); JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ detailsPanel.add(lblPlot, "2, 18, right, top"); JScrollPane scrollPane = new JScrollPane(); detailsPanel.add(scrollPane, "4, 18, 13, 1, fill, fill"); taPlot = new JTextArea(); taPlot.setLineWrap(true); taPlot.setWrapStyleWord(true); scrollPane.setViewportView(taPlot); lblThumb = new ImageLabel(); lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$ lblThumb.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("image.choose")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file)) { String fileName = file.toAbsolutePath().toString(); lblThumb.setImageUrl("file:/" + fileName); } } }); lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); detailsPanel.add(lblThumb, "20, 6, 3, 13"); JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$ detailsPanel.add(lblDirector, "2, 20, right, default"); tfDirector = new JTextField(); tfDirector.setText((String) null); tfDirector.setColumns(10); detailsPanel.add(tfDirector, "4, 20, 13, 1, fill, default"); JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$ detailsPanel.add(lblWriter, "2, 22, right, default"); tfWriter = new JTextField(); tfWriter.setText((String) null); tfWriter.setColumns(10); detailsPanel.add(tfWriter, "4, 22, 13, 1, fill, default"); JLabel lblGuests = new JLabel(BUNDLE.getString("metatag.guests")); //$NON-NLS-1$ detailsPanel.add(lblGuests, "2, 24, right, top"); JScrollPane scrollPaneGuests = new JScrollPane(); detailsPanel.add(scrollPaneGuests, "4, 24, 13, 7, fill, fill"); tableGuests = new JTable(); tableGuests.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollPaneGuests.setViewportView(tableGuests); JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ detailsPanel.add(lblTags, "20, 24, default, top"); JScrollPane scrollPaneTags = new JScrollPane(); detailsPanel.add(scrollPaneTags, "22, 24, 1, 5, fill, fill"); listTags = new JList(); scrollPaneTags.setViewportView(listTags); JButton btnAddActor = new JButton(""); btnAddActor.setMargin(new Insets(2, 2, 2, 2)); btnAddActor.setAction(new AddActorAction()); btnAddActor.setIcon(IconManager.LIST_ADD); detailsPanel.add(btnAddActor, "2, 26, right, top"); JButton btnAddTag = new JButton(""); btnAddTag.setMargin(new Insets(2, 2, 2, 2)); btnAddTag.setAction(new AddTagAction()); btnAddTag.setIcon(IconManager.LIST_ADD); detailsPanel.add(btnAddTag, "20, 26, right, top"); JButton btnRemoveActor = new JButton(""); btnRemoveActor.setMargin(new Insets(2, 2, 2, 2)); btnRemoveActor.setAction(new RemoveActorAction()); btnRemoveActor.setIcon(IconManager.LIST_REMOVE); detailsPanel.add(btnRemoveActor, "2, 28, right, top"); JButton btnRemoveTag = new JButton(""); btnRemoveTag.setMargin(new Insets(2, 2, 2, 2)); btnRemoveTag.setAction(new RemoveTagAction()); btnRemoveTag.setIcon(IconManager.LIST_REMOVE); detailsPanel.add(btnRemoveTag, "20, 28, right, top"); cbTags = new AutocompleteComboBox(tvShowList.getTagsInEpisodes().toArray()); cbTags.setEditable(true); detailsPanel.add(cbTags, "22, 30, fill, default"); } /** * Media Files panel */ { mediaFilesPanel = new MediaFileEditorPanel(mediaFiles); tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$ } { JPanel bottomPanel = new JPanel(); getContentPane().add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"), FormFactory.RELATED_GAP_ROWSPEC, })); cbScraper = new MediaScraperComboBox(tvShowList.getAvailableMediaScrapers()); MediaScraper defaultScraper = tvShowList.getDefaultMediaScraper(); cbScraper.setSelectedItem(defaultScraper); bottomPanel.add(cbScraper, "2, 2, fill, default"); JButton btnScrape = new JButton(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ btnScrape.setPreferredSize(new Dimension(100, 23)); btnScrape.setMaximumSize(new Dimension(0, 0)); btnScrape.setMinimumSize(new Dimension(100, 23)); btnScrape.setActionCommand("Scrape"); btnScrape.addActionListener(this); bottomPanel.add(btnScrape, "4, 2, left, fill"); JButton btnSearch = new JButton(BUNDLE.getString("tvshowepisodechooser.search")); //$NON-NLS-1$ btnSearch.setActionCommand("Search"); btnSearch.addActionListener(this); btnSearch.setIcon(IconManager.SEARCH); bottomPanel.add(btnSearch, "6, 2, left, fill"); { JPanel buttonPane = new JPanel(); bottomPanel.add(buttonPane, "8, 2, fill, fill"); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); buttonPane.setLayout(layout); JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$ okButton.setToolTipText(BUNDLE.getString("tvshow.change")); okButton.setIcon(IconManager.APPLY); buttonPane.add(okButton); okButton.setActionCommand("OK"); okButton.addActionListener(this); JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$ cancelButton.setToolTipText(BUNDLE.getString("edit.discard")); cancelButton.setIcon(IconManager.CANCEL); buttonPane.add(cancelButton); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); if (inQueue) { JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$ abortButton.setToolTipText(BUNDLE.getString("tvshow.edit.abortqueue.desc")); //$NON-NLS-1$ abortButton.setIcon(IconManager.PROCESS_STOP); buttonPane.add(abortButton); abortButton.setActionCommand("Abort"); abortButton.addActionListener(this); } } } initDataBindings(); // fill data { MediaFile mediaFile = episodeToEdit.getMediaFiles().get(0); lblFilename.setText(mediaFile.getFileAsPath().toString()); tfTitle.setText(episodeToEdit.getTitle()); spSeason.setModel(new SpinnerNumberModel(episodeToEdit.getAiredSeason(), -1, Integer.MAX_VALUE, 1)); spEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getAiredEpisode(), -1, Integer.MAX_VALUE, 1)); spDvdSeason.setModel(new SpinnerNumberModel(episodeToEdit.getDvdSeason(), -1, Integer.MAX_VALUE, 1)); spDvdEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getDvdEpisode(), -1, Integer.MAX_VALUE, 1)); spDisplaySeason .setModel(new SpinnerNumberModel(episodeToEdit.getDisplaySeason(), -1, Integer.MAX_VALUE, 1)); spDisplayEpisode .setModel(new SpinnerNumberModel(episodeToEdit.getDisplayEpisode(), -1, Integer.MAX_VALUE, 1)); spDateAdded.setValue(episodeToEdit.getDateAdded()); lblThumb.setImagePath(episodeToEdit.getArtworkFilename(MediaFileType.THUMB)); spRating.setModel(new SpinnerNumberModel(episodeToEdit.getRating(), 0.0, 10.0, 0.1)); spRating.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { voteCount = 1; } }); voteCount = episodeToEdit.getVotes(); chckbxWatched.setSelected(episodeToEdit.isWatched()); taPlot.setText(episodeToEdit.getPlot()); taPlot.setCaretPosition(0); tfDirector.setText(episodeToEdit.getDirector()); tfWriter.setText(episodeToEdit.getWriter()); cbMediaSource.setSelectedItem(episodeToEdit.getMediaSource()); for (TvShowActor origCast : episodeToEdit.getGuests()) { TvShowActor actor = new TvShowActor(); actor.setName(origCast.getName()); actor.setCharacter(origCast.getCharacter()); actor.setThumbUrl(origCast.getThumbUrl()); cast.add(actor); } for (String tag : episodeToEdit.getTags()) { tags.add(tag); } } // adjust table columns tableGuests.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$ tableGuests.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$ }
From source file:org.opencb.cellbase.app.transform.VariationParser.java
private void sortFileByNumericColumn(Path inputFile, Path outputFile, int columnIndex) throws InterruptedException, IOException { this.logger.info("Sorting file " + inputFile + " into " + outputFile + " ..."); // increment column index by 1, beacause Java indexes are 0-based and 'sort' command uses 1-based indexes columnIndex++;/*ww w . j a va 2 s. c o m*/ ProcessBuilder pb = new ProcessBuilder("sort", "-t", "\t", "-k", Integer.toString(columnIndex), "-n", "--stable", inputFile.toAbsolutePath().toString(), "-T", variationDirectoryPath.toString(), "-o", outputFile.toAbsolutePath().toString()); // System.getProperty("java.io.tmpdir") this.logger.debug("Executing '" + StringUtils.join(pb.command(), " ") + "' ..."); Stopwatch stopwatch = Stopwatch.createStarted(); Process process = pb.start(); process.waitFor(); int returnedValue = process.exitValue(); if (returnedValue != 0) { String errorMessage = IOUtils.toString(process.getErrorStream()); logger.error("Error sorting " + inputFile); logger.error(errorMessage); throw new RuntimeException("Error sorting " + inputFile); } this.logger.info("Sorted"); this.logger.debug("Elapsed time sorting file: " + stopwatch); }