List of usage examples for javax.swing JFileChooser setDialogTitle
@BeanProperty(preferred = true, description = "The title of the JFileChooser dialog window.") public void setDialogTitle(String dialogTitle)
JFileChooser
window's title bar. From source file:marytts.tools.redstart.AdminWindow.java
private void jMenuItem_ImportTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_ImportTextActionPerformed JFileChooser fc = new JFileChooser(new File(voiceFolderPathString)); fc.setDialogTitle("Choose text file to import"); //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal != JFileChooser.APPROVE_OPTION) return;/* ww w .j ava 2 s . c om*/ File file = fc.getSelectedFile(); if (file == null) return; String[] lines = null; try { lines = StringUtils.readTextFile(file.getAbsolutePath(), "UTF-8"); } catch (IOException ioe) { ioe.printStackTrace(); } if (lines == null || lines.length == 0) return; Object[] options = new Object[] { "Keep first column", "Discard first column" }; int answer = JOptionPane.showOptionDialog(this, "File contains " + lines.length + " sentences.\n" + "Sample line:\n" + lines[0] + "\n" + "Keep or discard first column?", "Import details", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); boolean discardFirstColumn = (answer == JOptionPane.NO_OPTION); String prefix = (String) JOptionPane.showInputDialog(this, "Prefix to use for individual sentence filenames:", "Choose filename prefix", JOptionPane.PLAIN_MESSAGE, null, null, "s"); int numDigits = (int) Math.log10(lines.length) + 1; String pattern = prefix + "%0" + numDigits + "d.txt"; File scriptFile = new File(voiceFolderPathString + "/" + file.getName() + ".script.txt"); PrintWriter scriptWriter = null; try { scriptWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(scriptFile), "UTF-8")); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Cannot write to script file " + scriptFile.getAbsolutePath() + ":\n" + e.getMessage()); if (scriptWriter != null) scriptWriter.close(); return; } File textFolder = getPromptFolderPath(); // if filename ends with ".txt_tr" then it has also transcriptions in it String selectedFile_ext = FilenameUtils.getExtension(file.getName()); Boolean inputHasAlsoTranscription = false; File transcriptionFolder = new File(""); // transcription folder name, and makedir if (selectedFile_ext.equals("txt_tr")) { System.out.println("txt_tr"); if (lines.length % 2 == 0) { // even } else { // odd System.err.println(".txt_tr file has an odd number of lines, so it's corrupted, exiting."); System.exit(0); } inputHasAlsoTranscription = true; String transcriptionFolderName = voiceFolderPathString + AdminWindow.TRANSCRIPTION_FOLDER_NAME; transcriptionFolder = new File(transcriptionFolderName); if (transcriptionFolder.exists()) { System.out.println("transcription folder already exists"); } else { if (transcriptionFolder.mkdirs()) { System.out.println("transcription folder created"); } else { System.err.println("Cannot create transcription folder -- exiting."); System.exit(0); } } } else { System.out.println("input file extension is not txt_tr, but " + selectedFile_ext + ", so it contains ortographic sentences without transcriptions."); } for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (discardFirstColumn) line = line.substring(line.indexOf(' ') + 1); int sent_index = i + 1; if (inputHasAlsoTranscription == true) { sent_index = i / 2 + 1; } String filename = String.format(pattern, sent_index); System.out.println(filename + " " + line); File textFile = new File(textFolder, filename); if (textFile.exists()) { JOptionPane.showMessageDialog(this, "Cannot writing file " + filename + ":\n" + "File exists!\n" + "Aborting text file import."); return; } PrintWriter pw = null; try { pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(textFile), "UTF-8")); pw.println(line); scriptWriter.println(filename.substring(0, filename.lastIndexOf('.')) + " " + line); } catch (IOException ioe) { JOptionPane.showMessageDialog(this, "Error writing file " + filename + ":\n" + ioe.getMessage()); ioe.printStackTrace(); return; } finally { if (pw != null) pw.close(); } // transcription case: if (inputHasAlsoTranscription == true) { // modify pattern: best would be something like sed "s/.txt$/.tr$/" // easy but dirty: String transc_pattern = pattern.replace(".txt", ".tr"); filename = String.format(transc_pattern, sent_index); i++; line = lines[i]; if (discardFirstColumn) line = line.substring(line.indexOf(' ') + 1); File transcriptionTextFile = new File(transcriptionFolder, filename); if (transcriptionTextFile.exists()) { JOptionPane.showMessageDialog(this, "Cannot writing file " + transcriptionTextFile.getName() + ":\n" + "File exists!\n" + "Aborting text file import."); return; } pw = null; try { pw = new PrintWriter( new OutputStreamWriter(new FileOutputStream(transcriptionTextFile), "UTF-8")); pw.println(line); scriptWriter.println(filename.substring(0, filename.lastIndexOf('.')) + " " + line); } catch (IOException ioe) { JOptionPane.showMessageDialog(this, "Error writing file " + filename + ":\n" + ioe.getMessage()); ioe.printStackTrace(); return; } finally { if (pw != null) pw.close(); } } } scriptWriter.close(); setupVoice(); }
From source file:com.jug.MoMA.java
/** * Shows a JFileChooser set up to accept the selection of folders. If * 'cancel' is pressed this method terminates the MotherMachine app. * * @param guiFrame//from w w w .j a v a 2 s. c o m * parent frame * @param path * path to the folder to open initially * @return an instance of {@link File} pointing at the selected folder. */ private File showFolderChooser(final JFrame guiFrame, final String path) { File selectedFile = null; if (SystemUtils.IS_OS_MAC) { // --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- ON MAC SYSTEMS --- System.setProperty("apple.awt.fileDialogForDirectories", "true"); final FileDialog fd = new FileDialog(guiFrame, "Select folder containing image sequence...", FileDialog.LOAD); fd.setDirectory(path); // fd.setLocation(50,50); fd.setVisible(true); selectedFile = new File(fd.getDirectory() + "/" + fd.getFile()); if (fd.getFile() == null) { System.exit(0); return null; } System.setProperty("apple.awt.fileDialogForDirectories", "false"); } else { // --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- NOT ON A MAC --- final JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(path)); chooser.setDialogTitle("Select folder containing image sequence..."); chooser.setFileFilter(new FileFilter() { @Override public final boolean accept(final File file) { return file.isDirectory(); } @Override public String getDescription() { return "We only take directories"; } }); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(guiFrame) == JFileChooser.APPROVE_OPTION) { selectedFile = chooser.getSelectedFile(); } else { System.exit(0); return null; } } return selectedFile; }
From source file:org.biojava.bio.view.MotifAnalyzer.java
public void actionPerformed(ActionEvent e) { final JFileChooser readVoter = new JFileChooser(); readVoter.setFileFilter(new Filter("voter")); readVoter.setDialogTitle("Select Motifs file (in MotifVoter format)"); final JFileChooser reader = new JFileChooser(); reader.setDialogTitle("Select Motifs file"); final JFileChooser readFASTA = new JFileChooser(); readFASTA.setFileFilter(new Filter("fasta")); readFASTA.setDialogTitle("Select Sequence File (in FASTA format)"); final JFileChooser readTompa = new JFileChooser(); readTompa.setFileFilter(new Filter("tompa")); readTompa.setDialogTitle("Select Motifs File (in Tompa's fromat)"); final JFileChooser readDirectory = new JFileChooser(); readDirectory.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); readDirectory.setDialogTitle("Select Directory"); final Dataset dataset = (Dataset) datasetComboBox.getSelectedItem(); final DatasetType datasetType = (DatasetType) datasetTypeComboBox.getSelectedItem(); final boolean readReverse = checkReverse.isSelected(); final OrganismCode org = OrganismCode.getOrganism(organismType.getSelectedIndex()); final int minPoints = (Integer) this.minPoints.getSelectedItem(); final double epsilon = Double.parseDouble((String) this.clusteringEpsilon.getSelectedItem()); final int numOfClusters = (Integer) this.numOfClusters.getSelectedItem(); final boolean multipleDataSets = this.multipleDataSets.isSelected(); try {/*w ww .j a va2 s . c o m*/ if (((JMenuItem) e.getSource()).getText().equals(convertMotifVoterMenuName)) { if (reader.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { String fileName = reader.getSelectedFile().getCanonicalPath(); if (reader.getSelectedFile().getName().contains(".zip")) // if file is zipped, extract it { fileName = UnZip.unZip(reader.getSelectedFile(), ".txt", ".MVW2"); (new File(fileName)).deleteOnExit(); } if (fileName != null) FileConverterTools.readMotifVoterWeb(new File(fileName), readReverse, true); } } else if (((JMenuItem) e.getSource()).getText().equals(runPatchConverMVMenuName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File[] directories = readDirectory.getSelectedFile().listFiles(); File out2 = new File(readDirectory.getSelectedFile().getParentFile() + "\\MVW2"); File out = new File(readDirectory.getSelectedFile().getParentFile() + "\\MVW"); out.mkdir(); out2.mkdir(); for (int i = 0; i < directories.length; i++) { File[] files2 = directories[i].listFiles(new Filter("zip")); File[] files = directories[i].listFiles(new Filter("MVW.voter")); if (files2.length > 0) { String fileName = UnZip.unZip(files2[0], ".txt", ".MVW2"); if (fileName != null) { fileName = FileConverterTools.readMotifVoterWeb(new File(fileName), readReverse, true); FileConverterTools.copy(new File(fileName), out2); } } if (files.length > 0) { FileConverterTools.copy(files[0], out); } } } } else if (((JMenuItem) e.getSource()).getText().equals(convertAllMenuName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { controller.convertFilesAndMerge(readDirectory.getSelectedFile(), dataset, readReverse); } } else if (((JMenuItem) e.getSource()).getText().equals(runPatchConverAllMenuName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File[] directories = readDirectory.getSelectedFile().listFiles(); for (int i = 0; i < directories.length; i++) { String datasetName = directories[i].getName(); if (datasetName.contains("_")) datasetName = datasetName.substring(0, datasetName.indexOf("_")); datasetName = datasetName.substring(0, datasetName.length() - 1); // remove g,m,r controller.convertFilesAndMerge(directories[i], Dataset.getValue(datasetName), readReverse); } } } else if (((JMenuItem) e.getSource()).getText().equals(copyCleanInputFilesName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File[] directories = readDirectory.getSelectedFile().listFiles(); File out = new File(readDirectory.getSelectedFile().getParentFile() + "\\clean"); out.mkdir(); for (int i = 0; i < directories.length; i++) { File[] files = directories[i].listFiles(new Filter("clean.voter")); if (files.length > 0) { FileConverterTools.copy(files[0], out); } } } } else if (((JMenuItem) e.getSource()).getText().equals(loadMenuName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { loadAnalysis(readDirectory.getSelectedFile()); } } else if (((JMenuItem) e.getSource()).getText().equals(saveMenuName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { saveAnalysis(readDirectory.getSelectedFile()); } } else if (((JMenuItem) e.getSource()).getText().equals(gibbsMenuName)) { readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame); FileConverterTools.createLengthFile(readDirectory.getSelectedFile(), new File(readDirectory.getSelectedFile() + "//len.txt")); /* if (readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { Thread t = new Thread(){ public void run() { SimpleGibbsAlignerDemo demo = new SimpleGibbsAlignerDemo(); int i = Integer.parseInt(numOfTrials.getText()); int w = Integer.parseInt(motifWidth.getText()); demo.runDemo(readFASTA.getSelectedFile(), false, w, i);} }; t.start(); } */ } else if (((JMenuItem) e.getSource()).getText().equals(compareSetsName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File dir = readDirectory.getSelectedFile(); if (multipleDataSets) controller.compareSetsAllDir(dir); else controller.compareSets(dir); } } else if (((JMenuItem) e.getSource()).getText().equals(mergeCompareSetsName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File dir = readDirectory.getSelectedFile(); controller.mergeComputeSets(dir); } } else if (((JMenuItem) e.getSource()).getText().equals(infoContentMenuName)) { if (reader.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { List<String> sequences = null; if (inputTextArea.getText() != null) { String temp = inputTextArea.getText(); sequences = new ArrayList<String>(); while (temp.contains("\n")) { String seq = temp.substring(0, temp.indexOf('\n')); temp = temp.substring(temp.indexOf('\n') + 1, temp.length() - 1); if (seq.contains(">")) continue; sequences.add(seq); } sequences.add(temp); } Double[] score = MotifTools.getsequenceScore(reader.getSelectedFile(), sequences); StringBuffer buff = new StringBuffer(); for (int i = 0; i < score.length; i++) buff.append(score[i].doubleValue() + "\n"); getOutputPane().setText(buff.toString()); LinesSeriesChart linesChart = new LinesSeriesChart(); String[] labels = new String[1]; labels[0] = "label"; String x[] = new String[score.length]; Double[][] values = new Double[1][score.length]; for (int i = 0; i < score.length; i++) { values[0][i] = score[i]; x[i] = i + 1 + ""; } //linesChart.createChartImage("e://images//chart1.jpg", labels, x, values, false); tabs.add("Info Content", new ChartPanel(linesChart.createCategoryChart("", "", "", labels, x, values))); } } else if (((JMenuItem) e.getSource()).getText().equals(removeRedundantSitesName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { SequenceIterator seqItr; if (returnVal == JFileChooser.APPROVE_OPTION) seqItr = TompaDataset.getSequences(readFASTA.getSelectedFile()); else seqItr = TompaDataset.getDatasetSequences(dataset); List<Motif> m = controller .removeRedundantSites(readVoter.getSelectedFile().getCanonicalPath(), dataset); if (m != null) { showMotifs(seqItr, m); for (int i = 0; i < controller.numOfEvaluations; i++) displayCharts(i); } } } } else if (((JMenuItem) e.getSource()).getText().equals(extractSitesName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { SequenceIterator seqItr; if (returnVal == JFileChooser.APPROVE_OPTION) seqItr = TompaDataset.getSequences(readFASTA.getSelectedFile()); else seqItr = TompaDataset.getDatasetSequences(dataset); List<Motif> m = controller.extractSites(readVoter.getSelectedFile().getCanonicalPath(), dataset); if (m != null) { showMotifs(seqItr, m); for (int i = 0; i < controller.numOfEvaluations; i++) displayCharts(i); } } } } else if (((JMenuItem) e.getSource()).getText().equals(drawKDistanceGraphName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { String fileName = controller.drawKDistanceGraph(readVoter.getSelectedFile(), dataset, minPoints); displayCharts(fileName); } } } else if (((JMenuItem) e.getSource()).getText().equals(computeWeightName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { List<Double> list = controller .computeSimilarity(readVoter.getSelectedFile().getCanonicalPath(), dataset); double sim = list.get(0); double w = list.get(1); String out = String.format("Compactness=%.5f, Weight=%.5f", sim, w); System.out.println(out); JOptionPane.showMessageDialog(mainFrame, out, "Info", JOptionPane.INFORMATION_MESSAGE); } } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateTompaMotifEachName)) { if (readTompa.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { controller.evaluateTompaMotifEach(readTompa.getSelectedFile().getCanonicalPath()); displayCharts(); } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateTompaMotifAccName)) { if (readTompa.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { controller.evaluateTompaMotifAcc(readTompa.getSelectedFile().getCanonicalPath()); displayCharts(); } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateTompaMotifTotalName)) { if (readTompa.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { controller.evaluateTompaMotifTotal(readTompa.getSelectedFile().getCanonicalPath()); displayCharts(); } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateMotifVoterName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { SequenceIterator seqItr; if (returnVal == JFileChooser.APPROVE_OPTION) seqItr = TompaDataset.getSequences(readFASTA.getSelectedFile()); else seqItr = TompaDataset.getDatasetSequences(dataset); Vector<Motif> motifs = controller.evaluateMotifVoterEach(readVoter.getSelectedFile(), dataset); showMotifs(seqItr, motifs); displayCharts(); } } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateMotifVoterTotalName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { SequenceIterator seqItr; if (returnVal == JFileChooser.APPROVE_OPTION) seqItr = TompaDataset.getSequences(readFASTA.getSelectedFile()); else seqItr = TompaDataset.getDatasetSequences(dataset); Vector<Motif> motifs = controller.evaluateMotifVoterTotal(readVoter.getSelectedFile(), dataset); showMotifs(seqItr, motifs); displayCharts(); } } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateMVDirFirstEleName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File[] files = readDirectory.getSelectedFile().listFiles(new Filter("voter")); controller.evaluateMotifVoterDirFirstEle(files, org, datasetType, readReverse); displayCharts(); } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateMVDirMergedName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File[] files = readDirectory.getSelectedFile().listFiles(new Filter("voter")); controller.evaluateMotifVoterDirMerged(files, org, datasetType, readReverse); displayCharts(); } } else if (((JMenuItem) e.getSource()).getText().equals(compareMotifVoterFirstName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File file1 = readVoter.getSelectedFile(); if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { SequenceIterator seqItr; if (returnVal == JFileChooser.APPROVE_OPTION) seqItr = TompaDataset.getSequences(readFASTA.getSelectedFile()); else seqItr = TompaDataset.getDatasetSequences(dataset); Vector<Motif> motifs = new Vector<Motif>(2); motifs.add(FileConverterTools.readMotifVoter(file1, readReverse).firstElement()); motifs.add(FileConverterTools.readMotifVoter(readVoter.getSelectedFile(), readReverse) .firstElement()); EvaluationController.evaluateMotifList(motifs, dataset); motifs.add(TompaDataset.getAnswer(dataset)); showMotifs(seqItr, motifs); displayCharts(); } } } } else if (((JMenuItem) e.getSource()).getText().equals(compareMotifVoterAllName)) { int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File file1 = readVoter.getSelectedFile(); if (readVoter.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { SequenceIterator seqItr; if (returnVal == JFileChooser.APPROVE_OPTION) seqItr = TompaDataset.getSequences(readFASTA.getSelectedFile()); else seqItr = TompaDataset.getDatasetSequences(dataset); Vector<Motif> motifs = new Vector<Motif>(2); Vector<Motif> temp = FileConverterTools.readMotifVoter(file1, readReverse); for (Iterator<Motif> i = temp.iterator(); i.hasNext();) temp.firstElement().merge(i.next()); temp.firstElement().setFinder(MotifFinder.MotifVoter); motifs.add(temp.firstElement()); temp = FileConverterTools.readMotifVoter(readVoter.getSelectedFile(), readReverse); for (Iterator<Motif> i = temp.iterator(); i.hasNext();) temp.firstElement().merge(i.next()); motifs.add(temp.firstElement()); EvaluationController.evaluateMotifList(motifs, dataset); motifs.add(TompaDataset.getAnswer(dataset)); showMotifs(seqItr, motifs); displayCharts(); } } } } else if (((JMenuItem) e.getSource()).getText().equals(evaluateAllResultsName)) { if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { File[] files = readDirectory.getSelectedFile().listFiles(new Filter("voter")); controller.evaluateMotifVoterDirAllDataset(files, datasetType, readReverse); displayCharts(); } } else if (((JMenuItem) e.getSource()).getText().equals(runBioProspectorName)) runMethod(MotifFinder.BP); /*else if (((JMenuItem)e.getSource()).getText().equals(runDBScanName) || ((JMenuItem)e.getSource()).getText().equals(runKMeansName) || ((JMenuItem)e.getSource()).getText().equals(runOPTICSName) || ((JMenuItem)e.getSource()).getText().equals(runCliqueName) || ((JMenuItem)e.getSource()).getText().equals(runMotifVoterName)) { int type = -1; if (((JMenuItem)e.getSource()).getText().equals(runMotifVoterName)) type = 0; else if (((JMenuItem)e.getSource()).getText().equals(runKMeansName)) type = 1; else if (((JMenuItem)e.getSource()).getText().equals(runDBScanName)) type = 2; else if (((JMenuItem)e.getSource()).getText().equals(runOPTICSName)) type = 3; else if (((JMenuItem)e.getSource()).getText().equals(runCliqueName)) type = 4; */ else if (Method.valueOf(((JMenuItem) e.getSource()).getText()) != null) { final Method methodType = Method.valueOf(((JMenuItem) e.getSource()).getText()); int returnVal = JFileChooser.CANCEL_OPTION; if (!multipleDataSets && datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = readFASTA.showOpenDialog(MotifAnalyzer.this.mainFrame); if (multipleDataSets || !datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { if (!multipleDataSets && readVoter .showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { final SequenceIterator seqItr = (returnVal == JFileChooser.APPROVE_OPTION) ? TompaDataset.getSequences(readFASTA.getSelectedFile()) : TompaDataset.getDatasetSequences(dataset); Thread t = new Thread() { public void run() { try { List<Motif> m = controller.runMotifVoter( readVoter.getSelectedFile().getCanonicalPath(), dataset, multipleDataSets, methodType, minPoints, epsilon, numOfClusters); if (m != null) { showMotifs(seqItr, m); for (int i = 0; i < controller.numOfEvaluations; i++) displayCharts(i); } } catch (Exception e) { e.printStackTrace(); } } }; t.start(); } else if (multipleDataSets && readDirectory .showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { Thread t2 = new Thread() { public void run() { try { controller.runMotifVoter(readDirectory.getSelectedFile().getCanonicalPath(), dataset, multipleDataSets, methodType, minPoints, epsilon, numOfClusters); } catch (Exception e) { e.printStackTrace(); } } }; t2.start(); } } } } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(mainFrame, "An Error occured", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:org.fhaes.jsea.JSEAFrame.java
@Override public void actionPerformed(ActionEvent event) { if (event.getActionCommand().equals("SegmentationMode")) { Boolean $success = this.validateDataFiles(); if ($success == null) { log.debug("Files not set yet"); return; } else if ($success == false) { log.debug("Invalid file ranges"); return; }/*from w w w. ja v a2 s . co m*/ if (segmentationPanel.chkSegmentation.isSelected() && chronologyYears.size() > 1) { segmentationPanel.table.setEarliestYear(Integer.parseInt(this.firstPossibleYear.toString())); segmentationPanel.table.setLatestYear(Integer.parseInt(this.lastPossibleYear.toString())); } else { // cannot perform segmentation if there are less than 2 years in the chronology segmentationPanel.chkSegmentation.setSelected(false); } } else if (event.getActionCommand().equals("AllYearsCheckbox")) { setYearRangeGUI(); } else if (event.getActionCommand().equals("TimeSeriesFileBrowse")) { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_READ_TIME_SERIES_FOLDER, App.prefs.getPref(PrefKey.PREF_LAST_READ_FOLDER, null)); JFileChooser fc; if (lastVisitedFolder != null) { fc = new JFileChooser(lastVisitedFolder); } else { fc = new JFileChooser(); } fc.setMultiSelectionEnabled(false); fc.setDialogTitle("Open file"); fc.addChoosableFileFilter(new TXTFileFilter()); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(new CSVFileFilter()); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { txtTimeSeriesFile.setText(fc.getSelectedFile().getAbsolutePath()); txtwrapper.updatePref(); App.prefs.setPref(PrefKey.PREF_LAST_READ_TIME_SERIES_FOLDER, fc.getSelectedFile().getPath()); if (parseTimeSeriesFile()) { setYearRangeGUI(); } else { txtTimeSeriesFile.setText(""); } validateForm(); } } else if (event.getActionCommand().equals("EventListFileBrowse")) { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_READ_EVENT_LIST_FOLDER, App.prefs.getPref(PrefKey.PREF_LAST_READ_FOLDER, null)); JFileChooser fc; if (lastVisitedFolder != null) { fc = new JFileChooser(lastVisitedFolder); } else { fc = new JFileChooser(); } fc.setMultiSelectionEnabled(false); fc.setDialogTitle("Open file"); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { txtEventListFile.setText(fc.getSelectedFile().getAbsolutePath()); App.prefs.setPref(PrefKey.PREF_LAST_READ_EVENT_LIST_FOLDER, fc.getSelectedFile().getPath()); parseEventListFile(); validateForm(); } } }
From source file:org.jets3t.apps.uploader.Uploader.java
/** * Handles GUI actions./* w w w.j a va2s.c om*/ */ public void actionPerformed(ActionEvent actionEvent) { if ("Next".equals(actionEvent.getActionCommand())) { wizardStepForward(); } else if ("Back".equals(actionEvent.getActionCommand())) { wizardStepBackward(); } else if ("ChooseFile".equals(actionEvent.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); if (validFileExtensions.size() > 0) { UploaderFileExtensionFilter filter = new UploaderFileExtensionFilter("Allowed files", validFileExtensions); fileChooser.setFileFilter(filter); } fileChooser.setMultiSelectionEnabled(fileMaxCount > 1); fileChooser.setDialogTitle("Choose file" + (fileMaxCount > 1 ? "s" : "") + " to upload"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setApproveButtonText("Choose file" + (fileMaxCount > 1 ? "s" : "")); int returnVal = fileChooser.showOpenDialog(ownerFrame); if (returnVal != JFileChooser.APPROVE_OPTION) { return; } List fileList = new ArrayList(); if (fileChooser.getSelectedFiles().length > 0) { fileList.addAll(Arrays.asList(fileChooser.getSelectedFiles())); } else { fileList.add(fileChooser.getSelectedFile()); } if (checkProposedUploadFiles(fileList)) { wizardStepForward(); } } else if ("CancelUpload".equals(actionEvent.getActionCommand())) { if (uploadCancelEventTrigger != null) { uploadCancelEventTrigger.cancelTask(this); progressBar.setValue(0); } else { log.warn("Ignoring attempt to cancel file upload when cancel trigger is not available"); } } else { log.warn("Unrecognised action command, ignoring: " + actionEvent.getActionCommand()); } }
From source file:musite.ui.MusiteResultPanel.java
private void exportComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportComboBoxActionPerformed String name = panelName.replaceAll("[\\\\/:\\*\\?\"<>\\|]+", "-"); String defaultFile = MusiteInit.defaultPath + File.separator + name; if (sliderTitleComboBox.getSelectedItem().equals(SPECIFICITY)) { defaultFile += String.format("-Sp_%.2f", specificity); } else {/*ww w .j a v a 2 s. c om*/ defaultFile += String.format("-Score_%.3f", threshold); } defaultFile += ".result"; switch (exportComboBox.getSelectedIndex()) { case 1: // tab-delimited text file { JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); fc.setSelectedFile(new File(defaultFile)); ArrayList<String> exts = new ArrayList<String>(1); String fasta = "txt"; exts.add(fasta); FileExtensionsFilter fastaFilter = new FileExtensionsFilter(exts, "Tab-delimited file (.txt)"); fc.addChoosableFileFilter(fastaFilter); //fc.setAcceptAllFileFilterUsed(true); fc.setDialogTitle("Save the the result to..."); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); MusiteInit.defaultPath = file.getParent(); String filePath = MusiteInit.defaultPath + File.separator + file.getName(); String ext = FilePathParser.getExt(filePath); if (ext == null || !ext.equalsIgnoreCase("txt")) { filePath += ".txt"; } if (IOUtil.fileExist(filePath)) { int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) break; } Vector<Vector> data = formatData(proteinList, false, true); int n = data.size(); ArrayList<String> dataOut = new ArrayList(n + 1); dataOut.add(StringUtils.join(header.iterator(), '\t')); for (Vector vec : data) { dataOut.add(StringUtils.join(vec.iterator(), '\t')); } try { IOUtil.writeCollectionAscii(dataOut, filePath); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, "Error: failed to write the file."); break; } JOptionPane.showMessageDialog(this, "Successfully exported."); } break; } // case 2: // fasta // { // JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); // fc.setSelectedFile(new File(defaultFile)); // // ArrayList<String> exts = new ArrayList<String>(1); // String fasta = "fasta"; // exts.add(fasta); // FileExtensionsFilter fastaFilter = new FileExtensionsFilter(exts,"Fasta file (.fasta)"); // fc.addChoosableFileFilter(fastaFilter); // // //fc.setAcceptAllFileFilterUsed(true); // fc.setDialogTitle("Save the the result to..."); // int returnVal = fc.showSaveDialog(this); // if (returnVal == JFileChooser.APPROVE_OPTION) { // File file = fc.getSelectedFile(); // MusiteInit.defaultPath = file.getParent(); // // String filePath = MusiteInit.defaultPath + File.separator + file.getName(); // // String ext = FilePathParser.getExt(filePath); // if (ext==null||!ext.equalsIgnoreCase("fasta")) { // filePath += ".fasta"; // } // // if (IOUtil.fileExist(filePath)) { // int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); // if (ret==JOptionPane.NO_OPTION) // break; // } // // ProteinsWriter writer = new ModifiedProteinsFastaWriter(); // WriteTask writeTask = new WriteTask(resultDisplay, writer, filePath); // TaskUtil.execute(writeTask); // if (!writeTask.success()) { // JOptionPane.showMessageDialog(this, "Failed to export."); // break; // } // // JOptionPane.showMessageDialog(this, "Successfully exported."); // } // // break; // } // case 3: // xml // { // JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); // fc.setSelectedFile(new File(defaultFile)); // // ArrayList<String> exts = new ArrayList<String>(1); // String xml = "xml"; // exts.add(xml); // FileExtensionsFilter xmlFilter = new FileExtensionsFilter(exts,"XML file (.xml)"); // fc.addChoosableFileFilter(xmlFilter); // // //fc.setAcceptAllFileFilterUsed(true); // fc.setDialogTitle("Save the the result to..."); // int returnVal = fc.showSaveDialog(this); // if (returnVal == JFileChooser.APPROVE_OPTION) { // File file = fc.getSelectedFile(); // MusiteInit.defaultPath = file.getParent(); // // String filePath = MusiteInit.defaultPath + File.separator + file.getName(); // // String ext = FilePathParser.getExt(filePath); // if (ext==null||!ext.equalsIgnoreCase("xml")) { // filePath += ".xml"; // } // // if (IOUtil.fileExist(filePath)) { // int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); // if (ret==JOptionPane.NO_OPTION) // break; // } // // ProteinsXMLWriter writer = ProteinsXMLWriter.createWriter(); // WriteTask xmlWriteTask = new WriteTask(resultDisplay, writer, filePath); // TaskUtil.execute(xmlWriteTask); // if (!xmlWriteTask.success()) { // JOptionPane.showMessageDialog(this, "Failed to export."); // break; // } // // JOptionPane.showMessageDialog(this, "Successfully exported."); // } // // break; // } } exportComboBox.setSelectedIndex(0); }
From source file:domain.Excel.java
private boolean showOpenFileDialog() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Specify a file to save"); FileFilter filter1 = new ExtensionFileFilter("XLS", "XLS"); fileChooser.setFileFilter(filter1); int userSelection = fileChooser.showSaveDialog(parent); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = fileChooser.getSelectedFile(); XLSFile = fileToSave.getAbsolutePath() + ".xls"; System.out.println("Save as file: " + fileToSave.getAbsolutePath()); return true; }/* w ww .ja v a 2 s. c o m*/ return false; }
From source file:musite.ui.MusiteResultPanel.java
public boolean saveResult(boolean showConfirm) { JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); // TODO: windows reserverd String fileName = panelName.replaceAll("[" + StringUtil.toOct("|\\?*<\":>+[]/") + "]+", "_"); fc.setSelectedFile(new File(MusiteInit.defaultPath + File.separator + fileName + ".pred.xml.gz")); ArrayList<String> exts = new ArrayList<String>(2); exts.add("xml"); exts.add("xml.gz"); fc.addChoosableFileFilter(new FileExtensionsFilter(exts, "Prediction XML file (.xml, .xml.gz)")); exts = new ArrayList<String>(2); exts.add("pred.xml"); exts.add("pred.xml.gz"); fc.addChoosableFileFilter(new FileExtensionsFilter(exts, "Prediction result file (pred.xml, pred.xml.gz)")); //fc.setAcceptAllFileFilterUsed(true); fc.setDialogTitle("Save the the result to..."); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); MusiteInit.defaultPath = file.getParent(); String filePath = MusiteInit.defaultPath + File.separator + file.getName(); // if (!filePath.toLowerCase().endsWith(".xml")&&!filePath.toLowerCase().endsWith(".xml.gz")) { // filePath += ".pred.xml.gz"; // } if (IOUtil.fileExist(filePath)) { int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) return false; }//from ww w.j a v a 2 s . com PredictionResultXMLWriter writer = PredictionResultXMLWriter.createWriter(); WriteTask task = new WriteTask(result, writer, filePath); TaskUtil.execute(task); if (task.success()) { if (showConfirm) JOptionPane.showMessageDialog(this, "Result saved!"); saved = true; return true; } else { JOptionPane.showMessageDialog(this, "Failed to save the result."); return false; } } else { return false; } }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuOpenProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuOpenProjectActionPerformed final JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileView(new FileView() { private Icon KNOWLEDGE_FOLDER_ICO = null; @Override//from w w w. j a va2 s.co m public Icon getIcon(final File f) { if (f.isDirectory()) { final File knowledge = new File(f, ".projectKnowledge"); if (knowledge.isDirectory()) { if (KNOWLEDGE_FOLDER_ICO == null) { final Icon icon = UIManager.getIcon("FileView.directoryIcon"); if (icon != null) { KNOWLEDGE_FOLDER_ICO = new ImageIcon( UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(fileChooser, icon), Icons.MMDBADGE.getIcon().getImage())); } } return KNOWLEDGE_FOLDER_ICO; } else { return super.getIcon(f); } } else if (f.isFile() && f.getName().toLowerCase(Locale.ENGLISH).endsWith(".mmd")) { return Icons.DOCUMENT.getIcon(); } else { return super.getIcon(f); } } }); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setMultiSelectionEnabled(false); fileChooser.setDialogTitle("Open project folder"); if (fileChooser.showOpenDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) { openProject(fileChooser.getSelectedFile(), false); } }
From source file:base.BasePlayer.AddGenome.java
@Override public void mousePressed(MouseEvent e) { if (e.getSource() == tree) { if (selectedNode != null && selectedNode.toString().contains("Add new refe")) { try { FileDialog fs = new FileDialog(frame, "Select reference fasta-file", FileDialog.LOAD); fs.setDirectory(Main.downloadDir); fs.setVisible(true);/*from w w w . j a v a 2 s . c o m*/ String filename = fs.getFile(); fs.setFile("*.fasta;*.fa"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().contains(".fasta") || name.toLowerCase().contains(".fa"); } }); if (filename != null) { File addfile = new File(fs.getDirectory() + "/" + filename); if (addfile.exists()) { genomeFile = addfile; Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); OutputRunner runner = new OutputRunner(genomeFile.getName().replace(".fasta", "") .replace(".fa", "").replace(".gz", ""), genomeFile, null); runner.createGenome = true; runner.execute(); } else { Main.showError("File does not exists.", "Error", frame); } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterFasta fastaFilter = new MyFilterFasta(); chooser.addChoosableFileFilter(fastaFilter); chooser.setDialogTitle("Select reference fasta-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { genomeFile = chooser.getSelectedFile(); Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, null); runner.createGenome = true; runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } else if (selectedNode != null && selectedNode.isLeaf() && selectedNode.toString().contains("Add new anno")) { try { FileDialog fs = new FileDialog(frame, "Select annotation gff3/gtf-file", FileDialog.LOAD); fs.setDirectory(Main.downloadDir); fs.setVisible(true); String filename = fs.getFile(); fs.setFile("*.gff3;*.gtf"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().contains(".gff3") || name.toLowerCase().contains(".gtf"); } }); if (filename != null) { File addfile = new File(fs.getDirectory() + "/" + filename); if (addfile.exists()) { annotationFile = addfile; Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner(selectedNode.getParent().toString(), null, annotationFile); runner.createGenome = true; runner.execute(); } else { Main.showError("File does not exists.", "Error", frame); } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterGFF gffFilter = new MyFilterGFF(); chooser.addChoosableFileFilter(gffFilter); chooser.setDialogTitle("Select annotation gff3-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { annotationFile = chooser.getSelectedFile(); Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner(selectedNode.getParent().toString(), null, annotationFile); runner.createGenome = true; runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } } if (e.getSource() == genometable) { if (new File(".").getFreeSpace() / 1048576 < sizeHash.get(genometable.getValueAt(genometable.getSelectedRow(), 0))[0] / 1048576) { sizeError.setVisible(true); download.setEnabled(false); AddGenome.getLinks.setEnabled(false); } else { sizeError.setVisible(false); download.setEnabled(true); AddGenome.getLinks.setEnabled(true); } tree.clearSelection(); remove.setEnabled(false); checkUpdates.setEnabled(false); } }