Example usage for javax.swing JFileChooser DIRECTORIES_ONLY

List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY

Introduction

In this page you can find the example usage for javax.swing JFileChooser DIRECTORIES_ONLY.

Prototype

int DIRECTORIES_ONLY

To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.

Click Source Link

Document

Instruction to display only directories.

Usage

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

/**
 * ?;//from ww  w.  j a va  2 s.com
 * @param evt
 */
private void btnWorkGenActionPerformed(java.awt.event.ActionEvent evt) {
    if (model != null) {
        fileChooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG | JFileChooser.DIRECTORIES_ONLY);
        fileChooser.setCurrentDirectory(new File("D:\\home\\Desktop"));
        int opt = fileChooser.showSaveDialog(null);
        // ?;
        if (JFileChooser.APPROVE_OPTION == opt) {
            TaskHelper.runInNonEDT(new Callable<Integer[]>() {
                public Integer[] call() throws Exception {
                    File saveFile = fileChooser.getSelectedFile();
                    if (!saveFile.exists())
                        saveFile.mkdirs();
                    // ;
                    // ModelHelper.complexGetAndSimpleSet(TableView.this,
                    // model);

                    //?EditViewModel;
                    EditView ev = perspective.getEditView();
                    ev.setModelValue();
                    EditViewModel evm = ev.getModel();

                    // model;ok
                    ModelHelper.processTableViewModel(model, evm);

                    String java1 = VelocityHelper.commonJava(model, "template/velocity/work20170417/pojo.vm");
                    // System.out.println(javaContent);
                    FileHelper.genCommonJavaFile(saveFile.getAbsolutePath(), model.getPojoFullPackageName(),
                            model.getEntity().getEntityBeanName(), java1);

                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            JOptionPane.showMessageDialog(null, "??!");
                        }
                    });
                    return null;
                }
            });
        }
    }
}

From source file:ca.osmcanada.osvuploadr.JPMain.java

private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAddActionPerformed
    try {//w  ww.  j ava 2s  . co  m
        JFileChooser fc = new JFileChooser();
        if (!last_dir.isEmpty()) {
            fc.setCurrentDirectory(new java.io.File(last_dir)); // start at application current directory
        }
        fc.setMultiSelectionEnabled(true);
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = fc.showSaveDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFiles().length == 1) {
                int response = JOptionPane.showConfirmDialog(null,
                        new String(r.getString("immediate_sub_folders").getBytes(), "UTF-8"),
                        new String(r.getString("add_subfolders").getBytes(), "UTF-8"),
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (response == JOptionPane.NO_OPTION) {
                    File folder = fc.getSelectedFile();
                    listDir.add(folder.getPath());
                    last_dir = folder.getPath();
                } else if (response == JOptionPane.YES_OPTION) {
                    //Get a list of subdirectories
                    String[] subDirs = fc.getSelectedFile().list(new FilenameFilter() {
                        @Override
                        public boolean accept(File current, String name) {
                            return new File(current, name).isDirectory();
                        }
                    });

                    for (String subDir : subDirs) {
                        listDir.add(new File(fc.getSelectedFile() + "/" + subDir).getPath());
                    }
                }
            } else if (fc.getSelectedFiles().length > 1) {
                File[] folders = fc.getSelectedFiles();
                for (File folder : folders) {
                    listDir.add(folder.getPath());
                    last_dir = folder.getPath();
                }
            }

        }
    } catch (UnsupportedEncodingException ex) {
    }
}

From source file:cc.creativecomputing.io.CCIOUtil.java

static public String selectFolder(final String prompt, String theFolder) {

    fileChooser = new JFileChooser();
    fileChooser.setDialogTitle(prompt);/* w  w  w .  j a  v  a 2s  . c om*/
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (theFolder != null)
        fileChooser.setCurrentDirectory(new File(theFolder));

    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    int returned = fileChooser.showSaveDialog(null);

    if (returned == JFileChooser.CANCEL_OPTION) {
        selectedFile = null;
    } else {
        selectedFile = fileChooser.getSelectedFile();
    }
    return (selectedFile == null) ? null : selectedFile.getAbsolutePath();
}

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 {/*from  w  w w .j a  va2  s.  co 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:net.pms.newgui.NavigationShareTab.java

private PanelBuilder initSharedFoldersGuiComponents(CellConstraints cc) {
    // Apply the orientation for the locale
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());
    String colSpec = FormLayoutUtil.getColSpec(SHARED_FOLDER_COL_SPEC, orientation);

    FormLayout layoutFolders = new FormLayout(colSpec, SHARED_FOLDER_ROW_SPEC);
    PanelBuilder builderFolder = new PanelBuilder(layoutFolders);
    builderFolder.opaque(true);/*from  w  ww .ja v a  2 s .  com*/

    JComponent cmp = builderFolder.addSeparator(Messages.getString("FoldTab.7"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 7), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    folderTableModel = new SharedFoldersTableModel();
    sharedFolders = new JTable(folderTableModel);

    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem menuItemMarkPlayed = new JMenuItem(Messages.getString("FoldTab.75"));
    JMenuItem menuItemMarkUnplayed = new JMenuItem(Messages.getString("FoldTab.76"));

    menuItemMarkPlayed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0);
            TableFilesStatus.setDirectoryFullyPlayed(path, true);
        }
    });

    menuItemMarkUnplayed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0);
            TableFilesStatus.setDirectoryFullyPlayed(path, false);
        }
    });

    popupMenu.add(menuItemMarkPlayed);
    popupMenu.add(menuItemMarkUnplayed);

    sharedFolders.setComponentPopupMenu(popupMenu);

    /* An attempt to set the correct row height adjusted for font scaling.
     * It sets all rows based on the font size of cell (0, 0). The + 4 is
     * to allow 2 pixels above and below the text. */
    DefaultTableCellRenderer cellRenderer = (DefaultTableCellRenderer) sharedFolders.getCellRenderer(0, 0);
    FontMetrics metrics = cellRenderer.getFontMetrics(cellRenderer.getFont());
    sharedFolders.setRowHeight(metrics.getLeading() + metrics.getMaxAscent() + metrics.getMaxDescent() + 4);
    sharedFolders.setIntercellSpacing(new Dimension(8, 2));

    final JPanel tmpsharedPanel = sharedPanel;

    addButton.setToolTipText(Messages.getString("FoldTab.9"));
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser;
            try {
                chooser = new JFileChooser();
            } catch (Exception ee) {
                chooser = new JFileChooser(new RestrictedFileSystemView());
            }
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog((Component) e.getSource());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                int firstSelectedRow = sharedFolders.getSelectedRow();
                if (firstSelectedRow >= 0) {
                    ((SharedFoldersTableModel) sharedFolders.getModel()).insertRow(firstSelectedRow,
                            new Object[] { chooser.getSelectedFile().getAbsolutePath(), true });
                } else {
                    ((SharedFoldersTableModel) sharedFolders.getModel())
                            .addRow(new Object[] { chooser.getSelectedFile().getAbsolutePath(), true });
                }
            }
        }
    });
    builderFolder.add(addButton, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation));

    removeButton.setToolTipText(Messages.getString("FoldTab.36"));
    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = sharedFolders.getSelectedRows();
            if (rows.length > 0) {
                if (rows.length > 1) {
                    if (JOptionPane.showConfirmDialog(tmpsharedPanel,
                            String.format(Messages.getString("SharedFolders.ConfirmRemove"), rows.length),
                            Messages.getString("Dialog.Confirm"), JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                        return;
                    }
                }
                for (int i = rows.length - 1; i >= 0; i--) {
                    PMS.get().getDatabase().removeMediaEntriesInFolder(
                            (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0));
                    ((SharedFoldersTableModel) sharedFolders.getModel()).removeRow(rows[i]);
                }
            }
        }
    });
    builderFolder.add(removeButton, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    arrowDownButton.setToolTipText(Messages.getString("SharedFolders.ArrowDown"));
    arrowDownButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < sharedFolders.getRowCount() - 1; i++) {
                if (sharedFolders.isRowSelected(i)) {
                    Object value1 = sharedFolders.getValueAt(i, 0);
                    boolean value2 = (boolean) sharedFolders.getValueAt(i, 1);

                    sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 0), i, 0);
                    sharedFolders.setValueAt(value1, i + 1, 0);
                    sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 1), i, 1);
                    sharedFolders.setValueAt(value2, i + 1, 1);
                    sharedFolders.changeSelection(i + 1, 1, false, false);

                    break;
                }
            }
        }
    });
    builderFolder.add(arrowDownButton, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation));

    arrowUpButton.setToolTipText(Messages.getString("SharedFolders.ArrowUp"));
    arrowUpButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 1; i < sharedFolders.getRowCount(); i++) {
                if (sharedFolders.isRowSelected(i)) {
                    Object value1 = sharedFolders.getValueAt(i, 0);
                    boolean value2 = (boolean) sharedFolders.getValueAt(i, 1);

                    sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 0), i, 0);
                    sharedFolders.setValueAt(value1, i - 1, 0);
                    sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 1), i, 1);
                    sharedFolders.setValueAt(value2, i - 1, 1);
                    sharedFolders.changeSelection(i - 1, 1, false, false);

                    break;

                }
            }
        }
    });
    builderFolder.add(arrowUpButton, FormLayoutUtil.flip(cc.xy(5, 3), colSpec, orientation));

    scanButton.setToolTipText(Messages.getString("FoldTab.2"));
    scanBusyIcon.start();
    scanBusyDisabledIcon.start();
    scanButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (configuration.getUseCache()) {
                DLNAMediaDatabase database = PMS.get().getDatabase();

                if (database != null) {
                    if (database.isScanLibraryRunning()) {
                        int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("FoldTab.10"),
                                Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION);
                        if (option == JOptionPane.YES_OPTION) {
                            database.stopScanLibrary();
                            looksFrame.setStatusLine(Messages.getString("FoldTab.41"));
                            scanButton.setEnabled(false);
                            scanButton.setToolTipText(Messages.getString("FoldTab.41"));
                        }
                    } else {
                        database.scanLibrary();
                        scanButton.setIcon(scanBusyIcon);
                        scanButton.setRolloverIcon(scanBusyRolloverIcon);
                        scanButton.setPressedIcon(scanBusyPressedIcon);
                        scanButton.setDisabledIcon(scanBusyDisabledIcon);
                        scanButton.setToolTipText(Messages.getString("FoldTab.40"));
                    }
                }
            }
        }
    });

    /*
     * Hide the scan button in basic mode since it's better to let it be done in
     * realtime.
     */
    if (!configuration.isHideAdvancedOptions()) {
        builderFolder.add(scanButton, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation));
    }

    scanButton.setEnabled(configuration.getUseCache());

    isScanSharedFoldersOnStartup = new JCheckBox(Messages.getString("NetworkTab.StartupScan"),
            configuration.isScanSharedFoldersOnStartup());
    isScanSharedFoldersOnStartup.setToolTipText(Messages.getString("NetworkTab.StartupScanTooltip"));
    isScanSharedFoldersOnStartup.setContentAreaFilled(false);
    isScanSharedFoldersOnStartup.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setScanSharedFoldersOnStartup((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    builderFolder.add(isScanSharedFoldersOnStartup, FormLayoutUtil.flip(cc.xy(7, 3), colSpec, orientation));

    updateSharedFolders();

    JScrollPane pane = new JScrollPane(sharedFolders);
    Dimension d = sharedFolders.getPreferredSize();
    pane.setPreferredSize(new Dimension(d.width, sharedFolders.getRowHeight() * 2));
    builderFolder.add(pane, FormLayoutUtil.flip(cc.xyw(1, 5, 7, CellConstraints.DEFAULT, CellConstraints.FILL),
            colSpec, orientation));

    return builderFolder;
}

From source file:gui.LauncherFrame.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.// w  ww . j  a v a 2  s  . c  om
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    modulePathChooser = new javax.swing.JFileChooser();
    logPathChooser = new javax.swing.JFileChooser();
    runPanel = new javax.swing.JPanel();
    infoPanel = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    infoLabel1 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    infoLabel2 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    infoLabel3 = new javax.swing.JLabel();
    infoLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    startCosmosButton = new javax.swing.JButton();
    stopCosmosButton = new javax.swing.JButton();
    moduleComboBox = new javax.swing.JComboBox<>();
    elapsedTimeLabel = new javax.swing.JLabel();
    statusLabel = new javax.swing.JLabel();
    procPanel = new javax.swing.JPanel();
    procScrollPane = new javax.swing.JScrollPane();
    procTable = new javax.swing.JTable();
    controlTabbedPane = new javax.swing.JTabbedPane();
    setupPanel = new javax.swing.JPanel();
    straceCheckBox = new javax.swing.JCheckBox();
    copyLogfilesButton = new javax.swing.JButton();
    modpathButton = new javax.swing.JButton();
    logpathTextField = new javax.swing.JTextField();
    copyModuleButton = new javax.swing.JButton();
    modpathTextField = new javax.swing.JTextField();
    logpathButton = new javax.swing.JButton();
    debugPanel = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    commandExecuteButton = new javax.swing.JButton();
    commandComboBox = new javax.swing.JComboBox<>();
    pidTextField = new javax.swing.JTextField();
    commandTerminateButton = new javax.swing.JButton();
    termTypeComboBox = new javax.swing.JComboBox<>();
    hmfmScrollPane = new javax.swing.JScrollPane();
    hmfmTable = new javax.swing.JTable();
    logTabbedPane = new javax.swing.JTabbedPane();
    debugScrollPane = new javax.swing.JScrollPane();
    debugTextPane = new javax.swing.JTextPane();
    portScrollPane = new javax.swing.JScrollPane();
    portTable = new javax.swing.JTable();

    modulePathChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);

    logPathChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("CosmosLauncher");

    runPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    runPanel.setPreferredSize(new java.awt.Dimension(567, 137));

    jLabel2.setText("QEMU");

    infoLabel1.setText("----");
    infoLabel1.setPreferredSize(new java.awt.Dimension(180, 15));

    jLabel3.setText("COSMOS");

    infoLabel2.setText("----");
    infoLabel2.setPreferredSize(new java.awt.Dimension(180, 15));

    jLabel4.setText("Module");

    infoLabel3.setText("----");
    infoLabel3.setPreferredSize(new java.awt.Dimension(180, 15));

    infoLabel4.setText("----");
    infoLabel4.setPreferredSize(new java.awt.Dimension(180, 15));

    jLabel5.setText("State");

    javax.swing.GroupLayout infoPanelLayout = new javax.swing.GroupLayout(infoPanel);
    infoPanel.setLayout(infoPanelLayout);
    infoPanelLayout.setHorizontalGroup(infoPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(infoPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(infoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(infoLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 68,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(infoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3).addComponent(infoLabel2,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 68,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(infoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4).addComponent(infoLabel3,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 211,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(13, 13, 13)
                    .addGroup(infoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(infoPanelLayout.createSequentialGroup().addComponent(jLabel5).addGap(0, 0,
                                    Short.MAX_VALUE))
                            .addComponent(infoLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 1,
                                    Short.MAX_VALUE))
                    .addContainerGap()));
    infoPanelLayout.setVerticalGroup(infoPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(infoPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(infoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2).addComponent(jLabel3).addComponent(jLabel4)
                            .addComponent(jLabel5))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(infoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(infoLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(infoLabel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(infoLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(infoLabel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));

    startCosmosButton.setBackground(new java.awt.Color(204, 255, 204));
    startCosmosButton.setText("Launch");
    startCosmosButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            startCosmosButtonActionPerformed(evt);
        }
    });

    stopCosmosButton.setBackground(new java.awt.Color(255, 204, 204));
    stopCosmosButton.setText("Stop");
    stopCosmosButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            stopCosmosButtonActionPerformed(evt);
        }
    });

    moduleComboBox.setModel(
            new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    moduleComboBox.setPreferredSize(new java.awt.Dimension(206, 24));

    elapsedTimeLabel.setText("Elapsed: 00:00");
    elapsedTimeLabel.setMaximumSize(new java.awt.Dimension(66, 25));
    elapsedTimeLabel.setMinimumSize(new java.awt.Dimension(66, 25));
    elapsedTimeLabel.setPreferredSize(new java.awt.Dimension(66, 25));

    statusLabel.setText("Status: ");
    statusLabel.setPreferredSize(new java.awt.Dimension(146, 25));

    javax.swing.GroupLayout runPanelLayout = new javax.swing.GroupLayout(runPanel);
    runPanel.setLayout(runPanelLayout);
    runPanelLayout.setHorizontalGroup(runPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(infoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addGroup(runPanelLayout.createSequentialGroup()
                    .addComponent(startCosmosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 85,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(11, 11, 11).addComponent(stopCosmosButton).addGap(18, 18, 18)
                    .addComponent(moduleComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(29, 29, 29)
                    .addComponent(elapsedTimeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 135,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            .addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    runPanelLayout.setVerticalGroup(runPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(runPanelLayout.createSequentialGroup()
                    .addComponent(infoPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(runPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(moduleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(startCosmosButton).addComponent(stopCosmosButton)
                            .addComponent(elapsedTimeLabel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)));

    procPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    procPanel.setPreferredSize(new java.awt.Dimension(567, 127));

    procTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

    }, new String[] { "Type", "Status", "UID", "PID", "Name" }) {
        Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class,
                java.lang.String.class, java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    procScrollPane.setViewportView(procTable);

    javax.swing.GroupLayout procPanelLayout = new javax.swing.GroupLayout(procPanel);
    procPanel.setLayout(procPanelLayout);
    procPanelLayout.setHorizontalGroup(procPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)
            .addGroup(procPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(procScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 563, Short.MAX_VALUE)));
    procPanelLayout.setVerticalGroup(procPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 124, Short.MAX_VALUE)
            .addGroup(procPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(procScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)));

    controlTabbedPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    controlTabbedPane.setPreferredSize(new java.awt.Dimension(389, 270));

    straceCheckBox.setText("Enable STrace on Launch");

    copyLogfilesButton.setBackground(new java.awt.Color(204, 204, 255));
    copyLogfilesButton.setText("Copy Logs");
    copyLogfilesButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            copyLogfilesButtonActionPerformed(evt);
        }
    });

    modpathButton.setText("Module Path");
    modpathButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            modpathButtonActionPerformed(evt);
        }
    });

    copyModuleButton.setBackground(new java.awt.Color(204, 204, 255));
    copyModuleButton.setText("Copy Module");
    copyModuleButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            copyModuleButtonActionPerformed(evt);
        }
    });

    logpathButton.setText("Logfile Path");
    logpathButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            logpathButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout setupPanelLayout = new javax.swing.GroupLayout(setupPanel);
    setupPanel.setLayout(setupPanelLayout);
    setupPanelLayout.setHorizontalGroup(setupPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(setupPanelLayout.createSequentialGroup().addContainerGap().addGroup(setupPanelLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(setupPanelLayout
                            .createSequentialGroup()
                            .addGroup(setupPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(logpathButton, javax.swing.GroupLayout.PREFERRED_SIZE, 131,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(modpathButton, javax.swing.GroupLayout.PREFERRED_SIZE, 131,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(setupPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(logpathTextField).addComponent(modpathTextField)))
                    .addGroup(setupPanelLayout.createSequentialGroup()
                            .addGroup(setupPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(straceCheckBox)
                                    .addComponent(copyModuleButton, javax.swing.GroupLayout.PREFERRED_SIZE, 131,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(copyLogfilesButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            131, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 154, Short.MAX_VALUE)))
                    .addContainerGap()));
    setupPanelLayout.setVerticalGroup(setupPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(setupPanelLayout.createSequentialGroup().addContainerGap().addComponent(straceCheckBox)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
                    .addGroup(setupPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(modpathButton).addComponent(modpathTextField,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(8, 8, 8).addComponent(copyModuleButton)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(setupPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(logpathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(logpathButton))
                    .addGap(8, 8, 8).addComponent(copyLogfilesButton).addContainerGap()));

    controlTabbedPane.addTab("Setup", setupPanel);

    jLabel1.setText("PID");

    commandExecuteButton.setText("Execute");
    commandExecuteButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            commandExecuteButtonActionPerformed(evt);
        }
    });

    commandComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "getCosmosInfo",
            "getCosmosPartitions", "getCosmosProcesses", "getCosmosConnections", "getCosmosPorts",
            "getCosmosHmfm", "getScheduling", "getRunningProcesses", "getCosmosInitPid", "getModuleList" }));

    pidTextField.setMinimumSize(new java.awt.Dimension(4, 25));
    pidTextField.setPreferredSize(new java.awt.Dimension(60, 25));

    commandTerminateButton.setText("Terminate");
    commandTerminateButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            commandTerminateButtonActionPerformed(evt);
        }
    });

    termTypeComboBox
            .setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "SIGUSR1", "SIGTERM", "SIGKILL" }));

    javax.swing.GroupLayout debugPanelLayout = new javax.swing.GroupLayout(debugPanel);
    debugPanel.setLayout(debugPanelLayout);
    debugPanelLayout.setHorizontalGroup(debugPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, debugPanelLayout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(pidTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 47,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(debugPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(commandTerminateButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(commandExecuteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 106,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(debugPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(commandComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 150,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(termTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 150,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));
    debugPanelLayout.setVerticalGroup(debugPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(debugPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(debugPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(commandComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(commandExecuteButton))
                    .addGap(7, 7, 7)
                    .addGroup(
                            debugPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(termTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(commandTerminateButton)
                                    .addComponent(pidTextField, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel1))
                    .addContainerGap(170, Short.MAX_VALUE)));

    controlTabbedPane.addTab("Debug", debugPanel);

    hmfmTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

    }, new String[] { "Timestamp", "Process", "Error", "Name" }) {
        Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class,
                java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    hmfmScrollPane.setViewportView(hmfmTable);

    controlTabbedPane.addTab("HMFM", hmfmScrollPane);

    debugScrollPane.setViewportView(debugTextPane);

    logTabbedPane.addTab("Debug", debugScrollPane);

    portTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

    }, new String[] { "Source Port", "Port ID", "Partition", "Status", "Count", "Timestamp", "Dest Port",
            "Port ID", "Partition", "Status", "Count", "Timestamp" }) {
        Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class,
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class,
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class,
                java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false, false, false,
                false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    portScrollPane.setViewportView(portTable);

    logTabbedPane.addTab("Ports", portScrollPane);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(logTabbedPane)
                            .addGroup(layout.createSequentialGroup().addGroup(
                                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(procPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(runPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGap(8, 8, 8).addComponent(controlTabbedPane,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(runPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                    procPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))
                    .addComponent(controlTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(logTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
                    .addContainerGap()));

    pack();
}

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  av  a  2 s  . com
 *            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:edu.ku.brc.specify.tools.StrLocalizerApp.java

/**
 * New language 'project'//w w  w.j a  va 2 s  .com
 */
protected void doNewLocale() {
    if (!checkForChanges()) {
        return;
    }

    ChooseFromListDlg<LanguageEntry> ldlg = new ChooseFromListDlg<LanguageEntry>((Frame) getTopWindow(),
            getResourceString("StrLocalizerApp.ChooseLanguageDlgTitle"), languages);
    UIHelper.centerAndShow(ldlg);
    if (ldlg.isCancelled() || ldlg.getSelectedObject() == null) {
        return;
    }

    JFileChooser fdlg = new JFileChooser();
    fdlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int fdlgResult = fdlg.showOpenDialog(null);
    if (fdlgResult != JFileChooser.APPROVE_OPTION) {
        return;
    }

    File destDir = fdlg.getSelectedFile();

    destLanguage = ldlg.getSelectedObject();
    final String newLang = destLanguage.getEnglishName();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            destLbl.setText(newLang + ":");
        }
    });

    setupSrcFiles(getDefaultPath());
    setupDestFiles(ldlg.getSelectedObject().getCode(), destDir.getPath());

    for (StrLocaleFile file : destFiles) {
        file.save();
    }
    currentPath = destDir.getPath();
    newSrcFile(getResourcesFile());
}

From source file:com.yifanlu.PSXperiaTool.Interface.GUI.java

private void chooseOutputDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseOutputDirActionPerformed
    FILE_CHOOSER.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int returnVal = FILE_CHOOSER.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = FILE_CHOOSER.getSelectedFile();
        extractOutputInput.setText(file.getPath());
        dataInput.setText(file.getPath());
    }/*from   ww  w .j  a  va 2s  .c  o m*/
}

From source file:com.yifanlu.PSXperiaTool.Interface.GUI.java

private void chooseDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseDataActionPerformed
    FILE_CHOOSER.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int returnVal = FILE_CHOOSER.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = FILE_CHOOSER.getSelectedFile();
        extractOutputInput.setText(file.getPath());
        dataInput.setText(file.getPath());
    }//w w w.  j  a v  a 2  s. c  o  m
}