List of usage examples for java.nio.file Path toAbsolutePath
Path toAbsolutePath();
From source file:org.xlrnet.tibaija.tools.fontgen.FontgenApplication.java
@NotNull private Font importFont(String source, String fontIdentifier) throws IOException { Path sourcePath = Paths.get(source); Pattern filePattern = Pattern.compile("[0-9A-F]{2}h_" + fontIdentifier + "[a-zA-Z0-9]*.gif"); List<Path> fileList = Files.list(sourcePath) .filter(p -> filePattern.matcher(p.getFileName().toString()).matches()) .collect(Collectors.toList()); Font font = new Font(); List<Symbol> symbols = new ArrayList<>(); for (Path path : fileList) { try {//from w w w .ja va2 s . co m Symbol symbol = importFile(path, font, fontIdentifier); if (symbol == null) continue; String filename = path.getFileName().toString(); String hexValue = StringUtils.substring(filename, 0, 2); String internalIdentifier = StringUtils.substringBetween(filename, "_" + fontIdentifier, ".gif"); symbol.setHexValue(hexValue); symbol.setInternalIdentifier(internalIdentifier); symbols.add(symbol); } catch (ImageReadException e) { LOGGER.error("Reading image {} failed", path.toAbsolutePath(), e); } } Collections.sort(symbols); font.setSymbols(symbols); return font; }
From source file:com.nridge.connector.fs.con_fs.core.FileCrawler.java
private void processCSVFile(Path aPath, BasicFileAttributes aFileAttributes, String aViewURL) throws IOException { String docId;/* w ww .j av a2s .c om*/ StopWatch stopWatch; Document fsDocument; Logger appLogger = mAppMgr.getLogger(this, "processCSVFile"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); File fsFile = aPath.toFile(); String pathFileName = aPath.toAbsolutePath().toString(); appLogger.debug(String.format("Processing CSV File: %s", pathFileName)); CSVDocument csvDocument = new CSVDocument(mAppMgr, mBag); csvDocument.open(pathFileName); int row = 1; DataBag csvBag = csvDocument.extractNext(); while (csvBag != null) { stopWatch = new StopWatch(); stopWatch.start(); docId = csvBag.generateUniqueHash(true); appLogger.debug(String.format(" Expanding Row [%d]: %s", row++, docId)); csvBag.setValueByName("nsd_id", mIdValuePrefix + docId); csvBag.setValueByName("nsd_url", fsFile.toURI().toURL().toString()); csvBag.setValueByName("nsd_url_view", aViewURL); csvBag.setValueByName("nsd_url_display", aViewURL); csvBag.setValueByName("nsd_file_name", fsFile.getName()); csvBag.setValueByName("nsd_mime_type", Content.CONTENT_TYPE_TXT_CSV); FileTime creationTime = aFileAttributes.creationTime(); Date cDate = new Date(creationTime.toMillis()); csvBag.setValueByName("nsd_doc_created_ts", cDate); FileTime lastModifiedTime = aFileAttributes.lastModifiedTime(); Date lmDate = new Date(lastModifiedTime.toMillis()); csvBag.setValueByName("nsd_doc_modified_ts", lmDate); csvBag.setValueByName("nsd_crawl_type", mCrawlQueue.getCrawlType()); fsDocument = new Document(Constants.FS_DOCUMENT_TYPE, csvBag); csvBag.setValueByName("nsd_doc_hash", fsDocument.generateUniqueHash(false)); saveAddQueueDocument(fsDocument, stopWatch); csvBag = csvDocument.extractNext(); } csvDocument.close(); appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); }
From source file:org.neo4j.ogm.testutil.TestServer.java
private String createAuthStore() { // creates a temp auth store, with encrypted credentials "neo4j:password" if the server is authenticating connections try {//from w w w . j a va 2s. c o m Path authStore = Files.createTempFile("neo4j", "credentials"); authStore.toFile().deleteOnExit(); if (enableAuthentication) { try (Writer authStoreWriter = new FileWriter(authStore.toFile())) { IOUtils.write( "neo4j:SHA-256,03C9C54BF6EEF1FF3DFEB75403401AA0EBA97860CAC187D6452A1FCF4C63353A,819BDB957119F8DFFF65604C92980A91:", authStoreWriter); } this.username = "neo4j"; this.password = "password"; } return authStore.toAbsolutePath().toString(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.github.ferstl.depgraph.AbstractGraphMojo.java
private String determineDotExecutable() throws IOException { if (this.dotExecutable == null) { return "dot"; }/*from w w w . j a va2s . com*/ Path dotExecutablePath = this.dotExecutable.toPath(); if (!Files.exists(dotExecutablePath)) { throw new NoSuchFileException("The dot executable '" + this.dotExecutable + "' does not exist."); } else if (Files.isDirectory(dotExecutablePath) || !Files.isExecutable(dotExecutablePath)) { throw new IOException( "The dot executable '" + this.dotExecutable + "' is not a file or cannot be executed."); } return dotExecutablePath.toAbsolutePath().toString(); }
From source file:com.nartex.RichFileManager.java
@Override public JSONObject getFolder(HttpServletRequest request) throws JSONException, IOException { JSONObject array = null;/*from w w w . j ava2 s .com*/ boolean showThumbs = false; String paramshowThumbs = request.getParameter("showThumbs"); if (paramshowThumbs != null) { showThumbs = true; } Path root = documentRoot.resolve(this.get.get("path")); log.debug("path absolute:" + root.toAbsolutePath()); Path docDir = documentRoot.resolve(this.get.get("path")).toRealPath(LinkOption.NOFOLLOW_LINKS); File dir = docDir.toFile(); //new File(documentRoot + this.get.get("path")); File file = null; if (!dir.isDirectory()) { this.error(sprintf(lang("DIRECTORY_NOT_EXIST"), this.get.get("path"))); } else { if (!dir.canRead()) { this.error(sprintf(lang("UNABLE_TO_OPEN_DIRECTORY"), this.get.get("path"))); } else { array = new JSONObject(); String[] files = dir.list(); JSONObject data = null; JSONObject props = null; for (int i = 0; i < files.length; i++) { data = new JSONObject(); props = new JSONObject(); file = docDir.resolve(files[i]).toFile(); //new File(documentRoot + this.get.get("path") + files[i]); if (file.isDirectory() && !contains(config.getProperty("unallowed_dirs"), files[i])) { try { props.put("Date Created", (String) null); props.put("Date Modified", (String) null); props.put("Height", (String) null); props.put("Width", (String) null); props.put("Size", (String) null); data.put("Path", this.get.get("path") + files[i] + "/"); data.put("Filename", files[i]); data.put("File Type", "dir"); data.put("Thumbnail", config.getProperty("icons-path") + config.getProperty("icons-directory")); data.put("Error", ""); data.put("Code", 0); data.put("Properties", props); array.put(this.get.get("path") + files[i] + "/", data); } catch (Exception e) { this.error("JSONObject error"); } } else if (file.canRead() && (!contains(config.getProperty("unallowed_files"), files[i]))) { this.item = new HashMap<String, Object>(); this.item.put("properties", this.properties); this.getFileInfo(this.get.get("path") + files[i], showThumbs); //if (this.params.get("type") == null || (this.params.get("type") != null && (!this.params.get("type").equals("Image") || checkImageType()))) { if (this.params.get("type") == null || (this.params.get("type") != null && ((!this.params.get("type").equals("Image") && !this.params.get("type").equals("Flash")) || checkImageType() || checkFlashType()))) { try { //data.put("Path", this.get.get("path") + files[i]); data.put("Path", this.item.get("path")); data.put("Filename", this.item.get("filename")); data.put("File Type", this.item.get("filetype")); data.put("Properties", this.item.get("properties")); data.put("Error", ""); data.put("Code", 0); log.debug("data now :" + data.toString()); array.put(this.get.get("path") + files[i], data); } catch (Exception e) { this.error("JSONObject error"); } } } else { log.warn("not allowed file or dir:" + files[i]); } } } } log.debug("array size ready:" + ((array != null) ? array.toString() : "")); return array; }
From source file:org.opencb.hpg.bigdata.app.cli.local.VariantCommandExecutor.java
private void convertToAvro(Path inputPath, String compression, String dataModel, OutputStream outputStream) throws Exception { // Creating reader VcfBlockIterator iterator = (StringUtils.equals("-", inputPath.toAbsolutePath().toString())) ? new VcfBlockIterator(new BufferedInputStream(System.in), new FullVcfCodec()) : new VcfBlockIterator(inputPath.toFile(), new FullVcfCodec()); DataReader<CharBuffer> vcfDataReader = iterator.toCharBufferDataReader(); ArrayList<String> sampleNamesInOrder = iterator.getHeader().getSampleNamesInOrder(); // System.out.println("sampleNamesInOrder = " + sampleNamesInOrder); // main loop/*from www. j ava 2 s. c o m*/ int numTasks = Math.max(variantCommandOptions.convertVariantCommandOptions.numThreads, 1); int batchSize = 1024 * 1024; //Batch size in bytes int capacity = numTasks + 1; // VariantConverterContext variantConverterContext = new VariantConverterContext(); // long start = System.currentTimeMillis(); // final VariantContextToVariantConverter converter = new VariantContextToVariantConverter("", "", sampleNamesInOrder); // List<CharBuffer> read; // while ((read = vcfDataReader.read()) != null { // converter.convert(read.) // } // Old implementation: ParallelTaskRunner.Config config = new ParallelTaskRunner.Config(numTasks, batchSize, capacity, false); ParallelTaskRunner<CharBuffer, ByteBuffer> runner; switch (dataModel.toLowerCase()) { case "opencb": { Schema classSchema = VariantAvro.getClassSchema(); // Converter final VariantContextToVariantConverter converter = new VariantContextToVariantConverter("", "", sampleNamesInOrder); // Writer AvroFileWriter<VariantAvro> avroFileWriter = new AvroFileWriter<>(classSchema, compression, outputStream); runner = new ParallelTaskRunner<>(vcfDataReader, () -> new VariantAvroEncoderTask<>(iterator.getHeader(), iterator.getVersion(), variantContext -> converter.convert(variantContext).getImpl(), classSchema), avroFileWriter, config); break; } case "ga4gh": { Schema classSchema = org.ga4gh.models.Variant.getClassSchema(); // Converter final VariantContext2VariantConverter converter = new VariantContext2VariantConverter(); converter.setVariantSetId(""); //TODO: Set VariantSetId // Writer AvroFileWriter<org.ga4gh.models.Variant> avroFileWriter = new AvroFileWriter<>(classSchema, compression, outputStream); runner = new ParallelTaskRunner<>(vcfDataReader, () -> new VariantAvroEncoderTask<>(iterator.getHeader(), iterator.getVersion(), converter, classSchema), avroFileWriter, config); break; } default: throw new IllegalArgumentException("Unknown dataModel \"" + dataModel + "\""); } long start = System.currentTimeMillis(); runner.run(); logger.debug("Time " + (System.currentTimeMillis() - start) / 1000.0 + "s"); }
From source file:org.exist.launcher.Launcher.java
private Path getJettyConfig() { final String jettyProperty = Optional.ofNullable(System.getProperty("jetty.home")).orElseGet(() -> { final Optional<Path> home = ConfigurationHelper.getExistHome(); final Path jettyHome = FileUtils.resolve(home, "tools").resolve("jetty"); final String jettyPath = jettyHome.toAbsolutePath().toString(); System.setProperty("jetty.home", jettyPath); return jettyPath; });/*from ww w . ja va2s.c o m*/ return Paths.get(jettyProperty).normalize().resolve("etc").resolve(Main.STANDARD_ENABLED_JETTY_CONFIGS); }
From source file:com.nridge.connector.fs.con_fs.core.FileCrawler.java
private void processFile(Path aPath, BasicFileAttributes aFileAttributes) throws IOException { Logger appLogger = mAppMgr.getLogger(this, "processFile"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); StopWatch stopWatch = new StopWatch(); stopWatch.start();//from w w w . jav a 2 s .c o m File fsFile = aPath.toFile(); String docId = generateDocumentId(aPath); String pathFileName = aPath.toAbsolutePath().toString(); appLogger.debug(String.format("Processing File (%s): %s", docId, pathFileName)); boolean isFileFlat = true; Document fsDocument = new Document(Constants.FS_DOCUMENT_TYPE, mBag); DataBag fileBag = fsDocument.getBag(); fileBag.resetValuesWithDefaults(); fileBag.setValueByName("nsd_id", docId); String fileName = fsFile.getName(); fileBag.setValueByName("nsd_url", fsFile.toURI().toURL().toString()); String viewURL = createViewURL(docId); fileBag.setValueByName("nsd_url_view", viewURL); fileBag.setValueByName("nsd_url_display", viewURL); fileBag.setValueByName("nsd_name", fileName); fileBag.setValueByName("nsd_file_name", fileName); fileBag.setValueByName("nsd_file_size", aFileAttributes.size()); FileTime creationTime = aFileAttributes.creationTime(); Date cDate = new Date(creationTime.toMillis()); fileBag.setValueByName("nsd_doc_created_ts", cDate); FileTime lastModifiedTime = aFileAttributes.lastModifiedTime(); Date lmDate = new Date(lastModifiedTime.toMillis()); fileBag.setValueByName("nsd_doc_modified_ts", lmDate); fileBag.setValueByName("nsd_crawl_type", mCrawlQueue.getCrawlType()); DataField dataField = fileBag.getFirstFieldByFeatureName(Field.FEATURE_IS_CONTENT); if (dataField != null) { ContentExtractor contentExtractor = new ContentExtractor(mAppMgr); contentExtractor.setCfgPropertyPrefix(Constants.CFG_PROPERTY_PREFIX + ".extract"); try { String mimeType = contentExtractor.detectType(fsFile); if (StringUtils.isNotEmpty(mimeType)) fileBag.setValueByName("nsd_mime_type", mimeType); if (isExpandableCSVFile(mimeType)) { isFileFlat = false; processCSVFile(aPath, aFileAttributes, viewURL); } else contentExtractor.process(pathFileName, dataField); } catch (NSException e) { String msgStr = String.format("%s: %s", pathFileName, e.getMessage()); appLogger.error(msgStr); } } if (isFileFlat) { fileBag.setValueByName("nsd_doc_hash", fsDocument.generateUniqueHash(false)); saveAddQueueDocument(fsDocument, stopWatch); } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); }
From source file:org.codice.ddf.catalog.content.impl.FileSystemStorageProvider.java
private ContentItem generateContentFile(ContentItem item, Path contentDirectory) throws IOException, StorageException { LOGGER.trace("ENTERING: generateContentFile"); if (!Files.exists(contentDirectory)) { Files.createDirectories(contentDirectory); }//from ww w . ja va 2s.co m Path contentItemPath = Paths.get(contentDirectory.toAbsolutePath().toString(), item.getFilename()); long copy = Files.copy(item.getInputStream(), contentItemPath); if (copy != item.getSize()) { LOGGER.warn("Created content item {} size {} does not match expected size {}", item.getId(), copy, item.getSize()); } ContentItemImpl contentItem = new ContentItemImpl(item.getId(), item.getQualifier(), com.google.common.io.Files.asByteSource(contentItemPath.toFile()), item.getMimeType().toString(), contentItemPath.getFileName().toString(), copy, item.getMetacard()); LOGGER.trace("EXITING: generateContentFile"); return contentItem; }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSettingsPanel.java
/** * Instantiates a new tv show settings panel. *///from w ww . j a v a2 s .co m public TvShowSettingsPanel() { 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, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(3)"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { 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"), 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, })); lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 2"); chckbxImageCache = new JCheckBox(""); panelGeneral.add(chckbxImageCache, "4, 2"); lblImageCacheHint = new JLabel(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ panelGeneral.add(lblImageCacheHint, "6, 2, 3, 1"); TmmFontHelper.changeFont(lblImageCacheHint, 0.833); final JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 4, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 6"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 6"); btnClearTraktTvShows = new JButton(BUNDLE.getString("Settings.trakt.cleartvshows"));//$NON-NLS-1$ btnClearTraktTvShows.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.cleartvshows.hint"), BUNDLE.getString("Settings.trakt.cleartvshows"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(false, true); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvShows, "6, 6"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshow.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.tvshow.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = TvShowModuleManager.SETTINGS.getBadWords().get(row); TvShowModuleManager.SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { TvShowModuleManager.SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); { JPanel panelTvShowDataSources = new JPanel(); panelTvShowDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshowdatasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelTvShowDataSources, "2, 4, 3, 1, fill, top"); panelTvShowDataSources.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("160px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelTvShowDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblSkipFolders = new JLabel(BUNDLE.getString("Settings.ignore"));//$NON-NLS-1$ panelTvShowDataSources.add(lblSkipFolders, "12, 2, 3, 1"); JScrollPane scrollPaneDatasource = new JScrollPane(); panelTvShowDataSources.add(scrollPaneDatasource, "2, 4, 5, 1, fill, fill"); listDatasources = new JList<>(); scrollPaneDatasource.setViewportView(listDatasources); JPanel panelTvShowSourcesButtons = new JPanel(); panelTvShowDataSources.add(panelTvShowSourcesButtons, "8, 4, default, top"); panelTvShowSourcesButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper .selectDirectory(BUNDLE.getString("Settings.tvshowdatasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addTvShowDataSources(file.toAbsolutePath().toString()); } } }); panelTvShowSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDatasources.getSelectedIndex(); if (row != -1) { // nothing selected String path = settings.getTvShowDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), //$NON-NLS-1$ BUNDLE.getString("Button.abort") }; int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.tvshowdatasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); settings.removeTvShowDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelTvShowSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPane = new JScrollPane(); panelTvShowDataSources.add(scrollPane, "12, 4, fill, fill"); listExclude = new JList<>(); scrollPane.setViewportView(listExclude); JPanel panelSkipFolderButtons = new JPanel(); panelTvShowDataSources.add(panelSkipFolderButtons, "14, 4, fill, fill"); panelSkipFolderButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddSkipFolder = new JButton(IconManager.LIST_ADD); btnAddSkipFolder.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddSkipFolder.setMargin(new Insets(2, 2, 2, 2)); btnAddSkipFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addTvShowSkipFolder(file.toAbsolutePath().toString()); } } }); panelSkipFolderButtons.add(btnAddSkipFolder, "1, 1"); JButton btnRemoveSkipFolder = new JButton(IconManager.LIST_REMOVE); btnRemoveSkipFolder.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveSkipFolder.setMargin(new Insets(2, 2, 2, 2)); btnRemoveSkipFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listExclude.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getTvShowSkipFolders().get(row); settings.removeTvShowSkipFolder(ingore); } } }); panelSkipFolderButtons.add(btnRemoveSkipFolder, "1, 3"); JLabel lblDvdOrder = new JLabel(BUNDLE.getString("Settings.dvdorder")); //$NON-NLS-1$ panelTvShowDataSources.add(lblDvdOrder, "2, 6, right, default"); cbDvdOrder = new JCheckBox(""); panelTvShowDataSources.add(cbDvdOrder, "4, 6"); } initDataBindings(); if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvShows.setEnabled(false); } }