Example usage for javax.swing DefaultListModel addElement

List of usage examples for javax.swing DefaultListModel addElement

Introduction

In this page you can find the example usage for javax.swing DefaultListModel addElement.

Prototype

public void addElement(E element) 

Source Link

Document

Adds the specified component to the end of this list.

Usage

From source file:search2go.UIFrame.java

public UIFrame() throws IOException, ParseException {
    topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs };

    this.addWindowListener(new WindowAdapter() {
        @Override/*www  .  ja v a2 s  .  co m*/
        public void windowClosing(WindowEvent et) {
            try {
                if (os.isWindows()) {
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F");
                } else {
                    Runtime.getRuntime().exec("killAll -KILL blastx");
                    Runtime.getRuntime().exec("killAll -KILL blastn");
                    Runtime.getRuntime().exec("killAll -KILL blastp");
                    Runtime.getRuntime().exec("killAll -KILL python");
                }
            } catch (IOException ex) {
                System.out.println("Error closing child processes");
            }
        }
    });

    initComponents();

    txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput));
    txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput));
    txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput));

    ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    webSaveMenu = new JPopupMenu();
    JMenuItem saveWeb = new JMenuItem();
    saveWeb.setText("Save");
    saveWeb.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            webSaveDialogue.showSaveDialog(pnlChartHolder);
            File saveFile = webSaveDialogue.getSelectedFile();
            if (!saveFile.getPath().contains(".png"))
                saveFile = new File(saveFile.getPath() + ".png");
            try {
                BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(),
                        pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB);
                pnlChartHolder.print(webChartImage.getGraphics());
                ImageIO.write(webChartImage, "png", saveFile);
            } catch (Exception ex) {
                javax.swing.JOptionPane.showMessageDialog(pnlChartHolder,
                        "Error saving chart. Please try again.");
            }
        }

    });
    webSaveMenu.add(saveWeb);
    pnlChartHolder.add(webSaveMenu);
    pnlChartHolder.setLayout(new java.awt.BorderLayout());

    try {
        currentProj = Workspace.open(new Path("Search2GO_Data"));
        chkDoCCs.setState(currentProj.willDoCC());
        chkDoBPs.setState(currentProj.willDoBP());
        chkDoMFs.setState(currentProj.willDoMF());
        txtQuery.setText(currentProj.getQueryPath());
        txtQueryFP.setText(currentProj.getQueryPath());
        txtDatabase.setText(currentProj.getPathToDB());
        txtDatabaseFP.setText(currentProj.getPathToDB());
        txtThreads.setValue(currentProj.getThreadNo());
        txtThreadsFP.setValue(currentProj.getThreadNo());
        cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex());
        cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex());
        cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex());
        cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex());
        txtBitScore.setValue(currentProj.getBitScoreThreshold());
        txtBitScoreFP.setValue(currentProj.getBitScoreThreshold());
        txtBlastE.setValue(currentProj.getEThreshold());
        txtMapE.setValue(currentProj.getEThreshold());
        txtEFP.setValue(currentProj.getEThreshold());
    } catch (FileNotFoundException e) {
        currentProj = Workspace.create(new Path("Search2GO_Data"));
        chkDoCCs.setState(currentProj.willDoCC());
        chkDoBPs.setState(currentProj.willDoBP());
        chkDoMFs.setState(currentProj.willDoMF());
    }
    this.setTitle("Search2GO " + currentProj.getPath().toString());

    GTermTableModel = new DefaultTableModel();
    GTermTableModel.setColumnCount(2);
    GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" });

    ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel();
    GTermSelector.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (tblGOFreq.getSelectedRow() > -1) {
                    DefaultListModel emptyModel = new DefaultListModel();
                    lstQueries.setModel(emptyModel);
                    txtTermInfo.setText("");
                    String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0);
                    JTextArea tempHolderInfo = new JTextArea();
                    JTextArea tempHolderQueries = new JTextArea();

                    if (tblGOFreq.getSelectedRow() != -1) {
                        ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries);
                        gTermInfoGetter.getProcess(0).addParameter("id",
                                selectedID.substring(0, selectedID.indexOf("[")));
                        gTermInfoGetter.getProcess(1).addParameter("id",
                                selectedID.substring(0, selectedID.indexOf("[")));
                        GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("[")));
                        gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode());
                        gTermInfoGetter.setTail(new ProcessSequenceEnd() {
                            @Override
                            public void run() {
                                tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText());
                                txtTermInfo.setText(tempHolderInfo.getText());

                                DefaultListModel queryList = new DefaultListModel();
                                for (String str : tempHolderQueries.getText().split(";")) {
                                    queryList.addElement(str.replaceAll("Query: ", ""));
                                }

                                lstQueries.setModel(queryList);
                                prgIdentification.setIndeterminate(false);
                            }
                        });
                        try {
                            gTermInfoGetter.start();
                            prgIdentification.setIndeterminate(true);
                        } catch (IOException ex) {
                            Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
            }
        }
    });

    lstQueries.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting() && !e.toString().contains("invalid")
                    && lstQueries.getSelectedValue() != null) {
                JTextArea tempHolder = new JTextArea();

                ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() {
                    @Override
                    public void run() {
                        if (txtTermInfo.getText().contains("Score")) {
                            txtTermInfo.setText(
                                    txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score")));
                        }
                        txtTermInfo.append(tempHolder.getText());
                        prgIdentification.setIndeterminate(false);
                    }
                });
                Path fetchLocusPath = new Path("Processes");
                fetchLocusPath.append("fetchLocus.py");
                Process fetchLocus = new Process(tempHolder);
                fetchLocus.setScriptCommand(fetchLocusPath.toEscString());
                fetchLocus.addParameter("dir", currentProj.getPath().toEscString());
                fetchLocus.addParameter("q",
                        new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString());

                String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0);
                GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("[")));
                fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode());
                fetchLocus.addParameter("id", currentGTerm.getID());
                fetchLocusSequence.addProcess(fetchLocus);

                try {
                    fetchLocusSequence.start();
                    prgIdentification.setIndeterminate(true);
                } catch (IOException ex) {
                    Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });

    DocumentListener filterListener = new DocumentListener() {
        private void anyUpdate() {
            gTerms.getFilter().setFilterString(txtSearchTerms.getText());
            if (!txtMinFreqFilter.getText().equals(""))
                gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText()));
            else
                gTerms.getFilter().setMinFreq(0);
            if (!txtMaxFreqFilter.getText().equals(""))
                gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText()));
            else
                gTerms.getFilter().setMaxFreq(-1);
            fillIdentTable(gTerms.stringFilter(), false);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            anyUpdate();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            anyUpdate();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            anyUpdate();
        }
    };
    txtSearchTerms.getDocument().addDocumentListener(filterListener);
    txtMinFreqFilter.getDocument().addDocumentListener(filterListener);
    txtMaxFreqFilter.getDocument().addDocumentListener(filterListener);

    NumberFormat numberMask = NumberFormat.getIntegerInstance();
    numberMask.setGroupingUsed(false);
    NumberFormatter numberMasker = new NumberFormatter(numberMask);
    NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) {
        @Override
        public Object stringToValue(String s) throws ParseException {
            if (s == null || s.length() == 0)
                return null;
            return super.stringToValue(s);
        }
    };
    DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker);
    DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank);

    txtThreads.setFormatterFactory(numberMaskFactory);
    txtThreadsFP.setFormatterFactory(numberMaskFactory);
    txtBitScore.setFormatterFactory(numberMaskAndBlankFactory);
    txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory);
    txtMinFreqFilter.setFormatterFactory(numberMaskFactory);
    txtMaxFreqFilter.setFormatterFactory(numberMaskFactory);
    txtBlastE.setFormatterFactory(numberMaskAndBlankFactory);
    txtMapE.setFormatterFactory(numberMaskAndBlankFactory);
    txtEFP.setFormatterFactory(numberMaskAndBlankFactory);

    blastButton = new StopButton(btnBlast);
    mapButton = new StopButton(btnMapIDs);
    identButton = new StopButton(btnGTermIdent);
    fullButton = new StopButton(btnProcessFP);

    if (currentProj.getStage() >= 2)
        identify(false);
}

From source file:GUI.MainWindow.java

private void showVulnerability(Vulnerability vulnerability) {

    // Unmap document listeners IF at all possible
    removeDocumentListeners();//w w  w .  ja  va2s  .c  o m

    this.VulnTitleTextField.setText(vulnerability.getTitle());
    if (vulnerability.isIs_custom_risk() == true) {
        this.VulnCVSSVectorTextField.setText("NO CVSS VECTOR");
    } else {
        this.VulnCVSSVectorTextField.setText(vulnerability.getCvss_vector_string());
    }
    // Set vuln category
    this.VulnRiskCategory.setText(vulnerability.getRisk_category());
    this.VulnScore.setText("" + vulnerability.getRiskScore());
    this.VulnDescriptionTextPane.setText(vulnerability.getDescription());
    this.VulnRecommendationTextPane.setText(vulnerability.getRecommendation());

    // clear old references
    DefaultListModel ref_model = (DefaultListModel) this.VulnReferencesList.getModel();
    ref_model.removeAllElements();
    // add in the new references
    Enumeration ref_enums = vulnerability.getReferences().elements();
    while (ref_enums.hasMoreElements()) {
        Reference ref = (Reference) ref_enums.nextElement();
        ref_model.addElement(ref);
    }

    // Now setup undo listeners
    setupUndoListeners();
    setupDocumentListeners();

    DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel();
    // Clear the existing table
    dtm.setRowCount(0);

    // Set affected hosts into table
    Enumeration enums = vulnerability.getAffectedHosts().elements();
    while (enums.hasMoreElements()) {
        Object obj = enums.nextElement();
        if (obj instanceof Host) {
            Host host = (Host) obj;
            Vector row = host.getAsVector(); // Gets the first two columns from the host
            dtm.addRow(row);
        }
    }

}

From source file:gtu._work.mvn.MavenRepositoryUI.java

private void initGUI() {
    try {//from  w w w .  jav  a 2  s .  co  m
        {
        }
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                scanList = new JList();
                jTabbedPane1.addTab("repository", null, jPanel1, null);
                {
                    scanText = new JTextField();
                    jPanel1.add(scanText, BorderLayout.NORTH);
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        ListModel scanListModel = new DefaultListModel();
                        jScrollPane1.setViewportView(scanList);
                        scanList.setModel(scanListModel);
                        scanList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(scanList, evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("repository only jar", null, jPanel4, null);
                jPanel4.setPreferredSize(new java.awt.Dimension(520, 298));
                {
                    scanText2 = new JTextField();
                    jPanel4.add(scanText2, BorderLayout.NORTH);
                }
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel4.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        scanList2 = new JList();
                        jScrollPane3.setViewportView(scanList2);
                        ListModel scanList2Model = new DefaultListModel();
                        scanList2.setModel(scanList2Model);
                        scanList2.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(scanList2, evt);
                            }
                        });
                    }
                }
                {
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("jar find", null, jPanel2, null);
                {
                    jarFindText = new JTextField();
                    jPanel2.add(jarFindText, BorderLayout.NORTH);
                }
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        ListModel jarFindListModel = new DefaultListModel();
                        jarFindList = new JList();
                        jScrollPane2.setViewportView(jarFindList);
                        jarFindList.setModel(jarFindListModel);
                        jarFindList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(jarFindList, evt);
                            }
                        });
                    }
                }
                {
                    jarFindExecute = new JButton();
                    jPanel2.add(jarFindExecute, BorderLayout.SOUTH);
                    jarFindExecute.setText("find");
                    jarFindExecute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            String searchtext = jarFindText.getText();
                            if (StringUtils.isEmpty(searchtext) || searchtext.length() < 2) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("", "error");
                                return;
                            }
                            try {
                                DefaultListModel model = new DefaultListModel();
                                jarFindList.setModel(model);

                                searchtext = searchtext.trim();
                                searchtext = searchtext.replace('/', '.');
                                searchtext = searchtext.replace('\\', '.');

                                if (jarfinder == null) {
                                    jarfinder = JarFinder.newInstance();
                                } else {
                                    jarfinder.clear();
                                }

                                jarfinder.pattern(searchtext);

                                DefaultListModel scanModel = (DefaultListModel) scanList.getModel();
                                PomFile pomFile = null;
                                for (int ii = 0; ii < scanModel.getSize(); ii++) {
                                    pomFile = (PomFile) scanModel.getElementAt(ii);
                                    if (pomFile.jarFile == null) {
                                        continue;
                                    }
                                    jarfinder.setDir(pomFile.jarFile);
                                    if (!jarfinder.execute().isEmpty()) {
                                        model.addElement(pomFile);
                                    }
                                    jarfinder.getMap().clear();
                                }
                            } catch (Exception ex) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog(ex.getMessage(), "error");
                                ex.printStackTrace();
                            }
                        }
                    });
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jTabbedPane1.addTab("detail", null, jPanel5, null);
                jPanel5.setLayout(jPanel5Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel5.add(jScrollPane4, BorderLayout.CENTER);
                    {
                        TableModel scanTableModel = new DefaultTableModel();
                        scanTable = new JTable();
                        BorderLayout scanTableLayout = new BorderLayout();
                        scanTable.setLayout(scanTableLayout);
                        jScrollPane4.setViewportView(scanTable);
                        scanTable.setModel(scanTableModel);
                        JTableUtil.defaultSetting(scanTable);

                        scanTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                tableMouseClicked(scanTable, 0, evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel3, null);
                GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                jPanel3.setLayout(jPanel3Layout);
                {
                    copyToDir = new JButton();
                    copyToDir.setText("set copy to dir");
                    copyToDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.exists() || !file.isDirectory()) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("dir is not correct!, set default desktop", "error");
                                file = FileUtil.DESKTOP_DIR;
                            }
                            copyTo = file;
                            System.out.println("copyTo: " + copyTo);
                        }
                    });
                }
                {
                    resetM2Dir = new JButton();
                    resetM2Dir.setText("set .m2 dir");
                    resetM2Dir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.exists() || !file.isDirectory()) {
                                showErrorMsg();
                                repositoryDir = DEFAULT_REPOSITORY_DIR;
                                reloadRepositoryDir();
                                return;
                            }
                            File newRepository = new File(file, "repository");
                            File settings = new File(file, "settings.xml");
                            if (settings.exists() && settings.isFile() && newRepository.exists()
                                    && newRepository.isDirectory()) {
                                repositoryDir = newRepository;
                                reloadRepositoryDir();
                            } else {
                                showErrorMsg();
                            }
                        }

                        void showErrorMsg() {
                            JOptionPaneUtil.newInstance().iconErrorMessage()
                                    .showMessageDialog("dir is not correct!, set default .m2 dir", "error");
                        }
                    });
                }
                {
                    saveCurrentDataBtn = new JButton();
                    saveCurrentDataBtn.setText("save current data");
                    saveCurrentDataBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File cfgFile = new File(PropertiesUtil.getJarCurrentPath(MavenRepositoryUI.class),
                                    MavenRepositoryUI.class.getSimpleName() + "_" + DateFormatUtil
                                            .format(System.currentTimeMillis(), "yyyyMMdd_HHmmss") + ".cfg");
                            try {
                                ObjectOutputStream writer = new ObjectOutputStream(
                                        new FileOutputStream(cfgFile));
                                writer.writeObject(pomFileList);
                                writer.writeObject(pomFileJarList);
                                writer.writeObject(pomFileMap);
                                writer.flush();
                                writer.close();
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("save completed!\n" + cfgFile, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                                ex.printStackTrace();
                            }
                        }
                    });
                }
                {
                    loadConfigDataBtn = new JButton();
                    loadConfigDataBtn.setText("load config data");
                    loadConfigDataBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File cfgFile = JFileChooserUtil.newInstance().selectFileOnly()
                                    .addAcceptFile("cfg", ".cfg").showOpenDialog().getApproveSelectedFile();
                            if (cfgFile == null) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("file is not correct!", "ERROR");
                                return;
                            }
                            try {
                                ObjectInputStream reader = new ObjectInputStream(new FileInputStream(cfgFile));
                                pomFileList = (Set<PomFile>) reader.readObject();
                                pomFileJarList = (Set<PomFile>) reader.readObject();
                                pomFileMap = (Map<DependencyKey, PomFile>) reader.readObject();
                                reader.close();
                                resetUIStatus();
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("load completed!\n" + cfgFile, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                                ex.printStackTrace();
                            }
                        }
                    });

                }
                jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(24, 24)
                        .addGroup(jPanel3Layout.createParallelGroup()
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(loadConfigDataBtn,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(saveCurrentDataBtn,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(copyToDir,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(resetM2Dir,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(getJButton1(),
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(281, Short.MAX_VALUE));
                jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(25, 25)
                        .addComponent(copyToDir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addGap(22)
                        .addComponent(resetM2Dir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addGap(24)
                        .addComponent(saveCurrentDataBtn, GroupLayout.PREFERRED_SIZE, 31,
                                GroupLayout.PREFERRED_SIZE)
                        .addGap(25)
                        .addComponent(loadConfigDataBtn, GroupLayout.PREFERRED_SIZE, 31,
                                GroupLayout.PREFERRED_SIZE)
                        .addGap(28)
                        .addComponent(getJButton1(), GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(34, Short.MAX_VALUE));
            }
            {
                jPanel6 = new JPanel();
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("pom dency", null, jPanel6, null);
                {
                    openPom = new JButton();
                    jPanel6.add(openPom, BorderLayout.NORTH);
                    openPom.setText("open");
                    openPom.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectFileAndDirectory()
                                    .showDialog("?pom,pom").getApproveSelectedFile();
                            if (file == null) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("file is not correct!!", "ERROR");
                                return;
                            }
                            List<File> pomList = new ArrayList<File>();
                            if (file.isFile()
                                    && (file.getName().endsWith(".xml") || file.getName().endsWith(".pom"))) {
                                pomList.add(file);
                            } else {
                                FileUtil.searchFileMatchs(file, "pom.xml", pomList);
                            }
                            Set<PomFile> poms = loadPomList(pomList);
                            resetUIStatus();

                            Map<DependencyKey, PomFile> map = new HashMap<DependencyKey, PomFile>();
                            Set<LoadPomListDependency.DependencyKey> errorSet = new HashSet<LoadPomListDependency.DependencyKey>();
                            for (PomFile p : poms) {
                                openPomFetchDependency(p.pom, map, errorSet);
                            }

                            PomFile pfile = null;
                            DefaultTableModel model = JTableUtil.createModel(true, "groupId", "artifactId",
                                    "jar", "pomFile");
                            for (DependencyKey key : map.keySet()) {
                                pfile = map.get(key);
                                model.addRow(new Object[] { pfile.pom.groupId, pfile.pom.artifactId,
                                        (pfile.jarFile == null ? "" : pfile.jarFile.getName()), pfile });
                            }
                            for (LoadPomListDependency.DependencyKey key : errorSet) {
                                model.addRow(new Object[] { key.groupId, key.artifactId, "ERROR" });
                            }
                            pomDenpendencyTable.setModel(model);
                        }
                    });
                }
                {
                    jScrollPane5 = new JScrollPane();
                    jPanel6.add(jScrollPane5, BorderLayout.CENTER);
                    {
                        TableModel pomDenpendencyTableModel = new DefaultTableModel();
                        pomDenpendencyTable = new JTable();
                        jScrollPane5.setViewportView(pomDenpendencyTable);
                        pomDenpendencyTable.setModel(pomDenpendencyTableModel);
                        pomDenpendencyTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                tableMouseClicked(pomDenpendencyTable, 3, evt);
                            }
                        });
                        JTableUtil.defaultSetting(pomDenpendencyTable);
                    }
                }
                {
                    jPanel7 = new JPanel();
                    FlowLayout jPanel7Layout = new FlowLayout();
                    jPanel7Layout.setAlignOnBaseline(true);
                    jPanel6.add(jPanel7, BorderLayout.SOUTH);
                    jPanel7.setLayout(jPanel7Layout);
                    jPanel7.setPreferredSize(new java.awt.Dimension(520, 36));
                    {
                        clipboardListJar = new JButton();
                        jPanel7.add(clipboardListJar);
                        clipboardListJar.setText("jar list to clipboard");
                        clipboardListJar.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                List<File> list = fetchPomDependencyTableJarList();
                                StringBuilder sb = new StringBuilder();
                                for (File f : list) {
                                    sb.append(f + "\n");
                                }
                                ClipboardUtil.getInstance().setContents(sb);
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("clipboard set ok!", "SUCCESS");
                            }
                        });
                    }
                    {
                        pomOutputJarDir = new JButton();
                        jPanel7.add(pomOutputJarDir);
                        pomOutputJarDir.setText("set output jar dir");
                        pomOutputJarDir.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                File file = JFileChooserUtil.newInstance().selectDirectoryOnly()
                                        .showDialog("?Jar").getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("dir is not correct!!", "ERROR");
                                    return;
                                }
                                pomOutputJarDir_ = file;
                            }
                        });
                    }
                    {
                        exportListJar = new JButton();
                        jPanel7.add(exportListJar);
                        exportListJar.setText("export list jar");
                        exportListJar.setPreferredSize(new java.awt.Dimension(113, 24));
                        exportListJar.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                List<File> list = fetchPomDependencyTableJarList();
                                if (pomOutputJarDir_ == null || !pomOutputJarDir_.exists()
                                        || !pomOutputJarDir_.isDirectory()) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("output dir is not correct!!", "ERROR");
                                    return;
                                }
                                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil
                                        .newInstance().confirmButtonYesNo().iconWaringMessage()
                                        .showConfirmDialog("are you sure copy list jar count:(" + list.size()
                                                + ") to\n" + pomOutputJarDir_, "WARN")) {
                                    StringBuilder sb = new StringBuilder();
                                    StringBuilder fsb = new StringBuilder();
                                    sb.append("total : " + list.size() + "\n");
                                    int ok = 0;
                                    int noOk = 0;
                                    for (File f : list) {
                                        try {
                                            FileUtil.copyFile(f, new File(pomOutputJarDir_, f.getName()));
                                            ok++;
                                        } catch (IOException e) {
                                            e.printStackTrace();
                                            noOk++;
                                            fsb.append(f + "\n");
                                        }
                                    }
                                    sb.append("success : " + ok + "\n");
                                    sb.append("failed : " + noOk + "\n");
                                    sb.append("Failed jar :\n");
                                    sb.append(fsb);

                                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(sb,
                                            "COPY RESULT");
                                }

                            }
                        });
                    }
                }
            }
        }
        this.setSize(541, 365);

        reloadRepositoryDir();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:dbseer.gui.actions.ExplainChartAction.java

public void printPredicates() {
    final StatisticalPackageRunner runner = DBSeerGUI.runner;
    int predicateColumnCount = 5;

    DefaultListModel predicateListModel = panel.getControlPanel().getPredicateListModel();
    predicateListModel.clear();/* w w  w  . j  a  va2 s . co  m*/

    try {
        Object[] predicates = (Object[]) runner.getVariableCell("predicates");
        int predicateRowCount = predicates.length / predicateColumnCount;
        String[] predicateNames = new String[predicateRowCount];
        double[] lowerBounds = new double[predicateRowCount];
        double[] upperBounds = new double[predicateRowCount];
        double[] relativeRatio = new double[predicateRowCount];

        if (predicateRowCount == 0) {
            console.append("There is no valid predicate.\n");
            return;
        }

        for (int r = 0; r < predicateRowCount; ++r) {
            predicateNames[r] = (String) predicates[r];
            if (predicateNames[r].contains("numTrans_")) {
                Pattern p = Pattern.compile("\\d+");
                Matcher m = p.matcher(predicateNames[r]);
                if (m.find()) {
                    int txIndex = Integer.parseInt(m.group());

                    predicateNames[r] = String.format("# of '%s' transactions",
                            DBSeerGUI.currentDataset.getTransactionTypeNames().get(txIndex - 1));
                }
            }
            double[] range = (double[]) predicates[r + predicateRowCount * 1];
            double[] ratio = (double[]) predicates[r + predicateRowCount * 2];
            lowerBounds[r] = range[0];
            upperBounds[r] = range[1];
            relativeRatio[r] = ratio[0];
        }

        // print x greater than y first.
        for (int r = 0; r < predicateRowCount; ++r) {
            if (!Double.isInfinite(lowerBounds[r]) && Double.isInfinite(upperBounds[r])) {
                String output = null;
                if (isPredicateAbsolute)
                    output = String.format("%s > %.2f\n", predicateNames[r], lowerBounds[r]);
                else {
                    String higher_lower = (relativeRatio[r] > 0) ? "HIGHER" : "LOWER";
                    if (relativeRatio[r] == 0) {
                        output = String.format("%s is EQUAL in abnormal and normal regions", predicateNames[r]);
                    } else {
                        output = String.format("%s is %.2f%% %s than normal", predicateNames[r],
                                Math.abs(relativeRatio[r]), higher_lower);
                    }
                }
                predicateListModel.addElement(output);
            }
        }

        // print x less than y.
        for (int r = 0; r < predicateRowCount; ++r) {
            if (Double.isInfinite(lowerBounds[r]) && !Double.isInfinite(upperBounds[r])) {
                String output = null;
                if (isPredicateAbsolute)
                    output = String.format("%s < %.2f\n", predicateNames[r], upperBounds[r]);
                else {
                    String higher_lower = (relativeRatio[r] > 0) ? "HIGHER" : "LOWER";
                    if (relativeRatio[r] == 0) {
                        output = String.format("%s is EQUAL in abnormal and normal regions", predicateNames[r]);
                    } else {
                        output = String.format("%s is %.2f%% %s than normal", predicateNames[r],
                                Math.abs(relativeRatio[r]), higher_lower);
                    }
                }
                predicateListModel.addElement(output);
            }
        }

        // print a < x < b
        for (int r = 0; r < predicateRowCount; ++r) {
            if (!Double.isInfinite(lowerBounds[r]) && !Double.isInfinite(upperBounds[r])) {
                String output = null;
                if (isPredicateAbsolute)
                    output = String.format("%.2f < %s < %.2f\n", lowerBounds[r], predicateNames[r],
                            upperBounds[r]);
                else {
                    String higher_lower = (relativeRatio[r] > 0) ? "HIGHER" : "LOWER";
                    if (relativeRatio[r] == 0) {
                        output = String.format("%s is EQUAL in abnormal and normal regions", predicateNames[r]);
                    } else {
                        output = String.format("%s is %.2f%% %s than normal", predicateNames[r],
                                Math.abs(relativeRatio[r]), higher_lower);
                    }
                }
                predicateListModel.addElement(output);
            }
        }
    } catch (Exception e) {
        DBSeerExceptionHandler.handleException(e);
    }
}

From source file:gtu._work.ui.ExecuteOpener.java

private void initGUI() {
    final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this);
    ToolTipManager.sharedInstance().setInitialDelay(0);
    try {/*  w ww  .  j  a  v  a 2s . c om*/
        {
            this.setTitle("execute browser");
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            this.setPreferredSize(new java.awt.Dimension(870, 551));
            this.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    swingUtil.invokeAction("frame.mouseClicked", evt);
                }
            });
        }
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(384, 265));
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent evt) {
                    swingUtil.invokeAction("jTabbedPane1.stateChanged", evt);
                }
            });
            jTabbedPane1.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    swingUtil.invokeAction("jTabbedPane1.mouseClicked", evt);
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("file list", null, jPanel1, null);
                {
                    jPanel4 = new JPanel();
                    BorderLayout jPanel4Layout = new BorderLayout();
                    jPanel4.setLayout(jPanel4Layout);
                    jPanel1.add(jPanel4, BorderLayout.NORTH);
                    jPanel4.setPreferredSize(new java.awt.Dimension(508, 81));
                    {
                        jScrollPane1 = new JScrollPane();
                        jPanel4.add(jScrollPane1, BorderLayout.CENTER);
                        {
                            exeArea = new JTextArea();
                            jScrollPane1.setViewportView(exeArea);
                        }
                    }
                    {
                        jPanel5 = new JPanel();
                        BorderLayout jPanel5Layout = new BorderLayout();
                        jPanel5.setLayout(jPanel5Layout);
                        jPanel4.add(jPanel5, BorderLayout.EAST);
                        jPanel5.setPreferredSize(new java.awt.Dimension(202, 81));
                        {
                            addArea = new JButton();
                            jPanel5.add(addArea, BorderLayout.CENTER);
                            addArea.setText("addArea");
                            addArea.setPreferredSize(new java.awt.Dimension(58, 30));
                            addArea.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent evt) {
                                    swingUtil.invokeAction("addArea.actionPerformed", evt);
                                }
                            });
                        }
                    }
                    {
                        queryText = new JTextField();
                        jPanel4.add(queryText, BorderLayout.NORTH);
                        queryText.getDocument()
                                .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                    public void process(DocumentEvent event) {
                                        try {
                                            String query = JCommonUtil.getDocumentText(event);
                                            Pattern ptn = Pattern.compile(query);
                                            DefaultListModel model = new DefaultListModel();
                                            for (Object key : prop.keySet()) {
                                                String val = key.toString();
                                                if (val.contains(query)) {
                                                    model.addElement(key);
                                                    continue;
                                                }
                                                if (ptn.matcher(val).find()) {
                                                    model.addElement(key);
                                                    continue;
                                                }
                                            }
                                            execList.setModel(model);
                                        } catch (Exception ex) {
                                        }
                                    }
                                }));
                    }
                }
                {
                    jPanel3 = new JPanel();
                    jPanel1.add(jPanel3, BorderLayout.CENTER);
                    BorderLayout jPanel3Layout = new BorderLayout();
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel3.setPreferredSize(new java.awt.Dimension(480, 220));
                    {
                        jScrollPane2 = new JScrollPane();
                        jPanel3.add(jScrollPane2, BorderLayout.CENTER);
                        {
                            DefaultListModel execListModel = new DefaultListModel();
                            for (Object obj : prop.keySet()) {
                                execListModel.addElement((String) obj);
                            }
                            execList = new JList();
                            jScrollPane2.setViewportView(execList);
                            execList.setModel(execListModel);
                            execList.addKeyListener(new KeyAdapter() {
                                public void keyPressed(KeyEvent evt) {
                                    swingUtil.invokeAction("execList.keyPressed", evt);
                                }
                            });
                            execList.addListSelectionListener(new ListSelectionListener() {
                                public void valueChanged(ListSelectionEvent evt) {
                                    swingUtil.invokeAction("execList.valueChanged", evt);
                                }
                            });
                            execList.addMouseListener(new MouseAdapter() {
                                public void mouseClicked(MouseEvent evt) {
                                    swingUtil.invokeAction("execList.mouseClicked", evt);
                                }
                            });
                        }
                    }
                }
                {
                    jPanel6 = new JPanel();
                    jPanel1.add(jPanel6, BorderLayout.SOUTH);
                    jPanel6.setPreferredSize(new java.awt.Dimension(741, 47));
                    {
                        saveList = new JButton();
                        jPanel6.add(saveList);
                        saveList.setText("save list to default properties");
                        saveList.setPreferredSize(new java.awt.Dimension(227, 28));
                        saveList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("saveList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        clearExecList = new JButton();
                        jPanel6.add(clearExecList);
                        clearExecList.setText("clear properties");
                        clearExecList.setPreferredSize(new java.awt.Dimension(170, 28));
                        clearExecList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("clearExecList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        reloadList = new JButton();
                        jPanel6.add(reloadList);
                        reloadList.setText("reload list");
                        reloadList.setPreferredSize(new java.awt.Dimension(156, 28));
                        reloadList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("reloadList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        contentFilterBtn = new JButton();
                        jPanel6.add(contentFilterBtn);
                        contentFilterBtn.setText("content filter");
                        contentFilterBtn.setPreferredSize(new java.awt.Dimension(176, 27));
                        contentFilterBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("contentFilterBtn.actionPerformed", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                FlowLayout jPanel2Layout = new FlowLayout();
                jTabbedPane1.addTab("config", null, jPanel2, null);
                jPanel2.setPreferredSize(new java.awt.Dimension(573, 300));
                jPanel2.setLayout(jPanel2Layout);
                {
                    executeAll = new JButton();
                    jPanel2.add(executeAll);
                    executeAll.setText("execute all files");
                    executeAll.setPreferredSize(new java.awt.Dimension(137, 27));
                    executeAll.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("execute.actionPerformed", evt);
                        }
                    });
                }
                {
                    browser = new JButton();
                    jPanel2.add(browser);
                    browser.setText("add file");
                    browser.setPreferredSize(new java.awt.Dimension(140, 28));
                    browser.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("browser.actionPerformed", evt);
                        }
                    });
                }
                {
                    loadProp = new JButton();
                    jPanel2.add(loadProp);
                    loadProp.setText("load properties");
                    loadProp.setPreferredSize(new java.awt.Dimension(158, 32));
                    loadProp.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("loadProp.actionPerformed", evt);
                        }
                    });
                }
                {
                    executeExport = new JButton();
                    jPanel2.add(executeExport);
                    executeExport.setText("export list");
                    executeExport.setPreferredSize(new java.awt.Dimension(145, 31));
                    executeExport.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("executeExport.actionPerformed", evt);
                        }
                    });
                }
                {
                    exportListHasOrignTree = new JButton();
                    jPanel2.add(exportListHasOrignTree);
                    exportListHasOrignTree.setText("export list has orign tree");
                    exportListHasOrignTree.setPreferredSize(new java.awt.Dimension(204, 32));
                    exportListHasOrignTree.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("exportListHasOrignTree.actionPerformed", evt);
                        }
                    });
                }
                {
                    moveFiles = new JButton();
                    jPanel2.add(moveFiles);
                    moveFiles.setText("move selected");
                    moveFiles.setPreferredSize(new java.awt.Dimension(161, 31));
                    moveFiles.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("moveFiles.actionPerformed", evt);
                        }
                    });
                }
                {
                    deleteSelected = new JButton();
                    jPanel2.add(deleteSelected);
                    deleteSelected.setText("delete selected");
                    deleteSelected.setPreferredSize(new java.awt.Dimension(165, 31));
                    deleteSelected.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("deleteSelected.actionPerformed", evt);
                        }
                    });
                }
                {
                    loadClipboardPath = new JButton();
                    jPanel2.add(loadClipboardPath);
                    loadClipboardPath.setText("load clipboard path");
                    loadClipboardPath.setPreferredSize(new java.awt.Dimension(222, 31));
                    loadClipboardPath.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("loadClipboardPath.actionPerformed", evt);
                        }
                    });
                }
                {
                    deleteEmptyDir = new JButton();
                    jPanel2.add(deleteEmptyDir);
                    deleteEmptyDir.setText("delete empty dir");
                    deleteEmptyDir.setPreferredSize(new java.awt.Dimension(222, 31));
                    deleteEmptyDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("deleteEmptyDir.actionPerformed", evt);
                        }
                    });
                }
                {
                    openSvnUpdate = new JButton();
                    jPanel2.add(openSvnUpdate);
                    openSvnUpdate.setText("list svn new or modify file");
                    openSvnUpdate.setPreferredSize(new java.awt.Dimension(210, 34));
                    openSvnUpdate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("openSvnUpdate.actionPerformed", evt);
                        }
                    });
                }
            }
            {
                jPanel7 = new JPanel();
                BorderLayout jPanel7Layout = new BorderLayout();
                jPanel7.setLayout(jPanel7Layout);
                jTabbedPane1.addTab("properties", null, jPanel7, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel7.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(741, 415));
                    {
                        DefaultListModel propertiesListModel = new DefaultListModel();
                        propertiesList = new JList();
                        reloadCurrentDirPropertiesList();
                        jScrollPane3.setViewportView(propertiesList);
                        propertiesList.setModel(propertiesListModel);
                        propertiesList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("propertiesList.keyPressed", evt);
                            }
                        });
                        propertiesList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("propertiesList.mouseClicked", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel8 = new JPanel();
                BorderLayout jPanel8Layout = new BorderLayout();
                jTabbedPane1.addTab("scanner", null, jPanel8, null);
                jPanel8.setLayout(jPanel8Layout);
                {
                    jPanel9 = new JPanel();
                    jPanel8.add(jPanel9, BorderLayout.NORTH);
                    jPanel9.setPreferredSize(new java.awt.Dimension(741, 187));
                    {
                        scanDirText = new JTextField();
                        scanDirText.setToolTipText("scan dir");
                        jPanel9.add(scanDirText);
                        scanDirText.setPreferredSize(new java.awt.Dimension(225, 24));
                        scanDirText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("scanDirText.mouseClicked", evt);
                            }
                        });
                    }
                    {
                        jScrollPane6 = new JScrollPane();
                        jPanel9.add(jScrollPane6);
                        jScrollPane6.setPreferredSize(new java.awt.Dimension(168, 69));
                        {
                            scannerText = new JTextArea();
                            scannerText.setToolTipText("query condition");
                            jScrollPane6.setViewportView(scannerText);
                        }
                    }
                    {
                        fileScan = new JButton();
                        jPanel9.add(fileScan);
                        fileScan.setText("start / stop");
                        fileScan.setPreferredSize(new java.awt.Dimension(113, 24));
                        fileScan.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("fileScan.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        useRegexOnly = new JCheckBox();
                        jPanel9.add(useRegexOnly);
                        useRegexOnly.setText("regex only");
                    }
                    {
                        DefaultComboBoxModel scanTypeModel = new DefaultComboBoxModel();
                        for (ScanType s : ScanType.values()) {
                            scanTypeModel.addElement(s);
                        }
                        scanType = new JComboBox();
                        scanType.setToolTipText("scan type");
                        jPanel9.add(scanType);
                        scanType.setModel(scanTypeModel);
                        scanType.setPreferredSize(new java.awt.Dimension(147, 24));
                    }
                    {
                        DefaultComboBoxModel jComboBox1Model = new DefaultComboBoxModel();
                        for (FileOrDirType f : FileOrDirType.values()) {
                            jComboBox1Model.addElement(f);
                        }
                        fileOrDirTypeCombo = new JComboBox();
                        jPanel9.add(fileOrDirTypeCombo);
                        fileOrDirTypeCombo.setModel(jComboBox1Model);
                        fileOrDirTypeCombo.setToolTipText("scan file or directory!");
                    }
                    {
                        addListToExecList = new JButton();
                        jPanel9.add(addListToExecList);
                        addListToExecList.setText("add list to file list");
                        addListToExecList.setPreferredSize(new java.awt.Dimension(158, 24));
                        addListToExecList.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("addListToExecList.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        ignoreScanText = new JTextField();
                        ignoreScanText.setToolTipText("ignore scan condition");
                        ignoreScanText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }
                                String ignore = null;
                                if (StringUtils.isBlank(ignore = ignoreScanText.getText())) {
                                    return;
                                }
                                DefaultListModel model = (DefaultListModel) ignoreScanList.getModel();
                                model.addElement(ignore);
                            }
                        });
                        jPanel9.add(ignoreScanText);
                        ignoreScanText.setPreferredSize(new java.awt.Dimension(153, 24));
                    }
                    {
                        jScrollPane5 = new JScrollPane();
                        jPanel9.add(jScrollPane5);
                        jScrollPane5.setPreferredSize(new java.awt.Dimension(125, 73));
                        jScrollPane5.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
                        jScrollPane5.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                        {
                            DefaultListModel ignoreScanListModel = new DefaultListModel();
                            ignoreScanList = new JList();
                            ignoreScanList.setToolTipText("ignore scan condition list");
                            jScrollPane5.setViewportView(ignoreScanList);
                            ignoreScanList.setModel(ignoreScanListModel);
                            ignoreScanList.setPreferredSize(new java.awt.Dimension(125, 73));
                            ignoreScanList.addKeyListener(new KeyAdapter() {
                                public void keyPressed(KeyEvent evt) {
                                    JListUtil.newInstance(ignoreScanList).defaultJListKeyPressed(evt);
                                }
                            });
                        }
                    }
                    {
                        innerScannerText = new JTextField();
                        innerScannerText.setToolTipText("inner scan query condition");
                        jPanel9.add(innerScannerText);
                        innerScannerText.setPreferredSize(new java.awt.Dimension(164, 24));
                        innerScannerText.addMouseListener(new MouseAdapter() {

                            Thread innerScanThread = null;
                            boolean innerScanStop = false;

                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }
                                final String innerText = innerScannerText.getText();
                                if (arrayBackupForInnerScan == null) {
                                    return;
                                }

                                innerScanStop = true;

                                if (innerScanThread == null
                                        || innerScanThread.getState() == Thread.State.TERMINATED) {
                                    innerScanThread = new Thread(Thread.currentThread().getThreadGroup(),
                                            new Runnable() {
                                                public void run() {
                                                    innerScanStop = false;
                                                    System.out.println(
                                                            toString() + " ... start!! ==> " + innerScanStop);
                                                    DefaultListModel model = new DefaultListModel();
                                                    scanList.setModel(model);
                                                    for (int ii = 0; ii < arrayBackupForInnerScan.length; ii++) {
                                                        if (arrayBackupForInnerScan[ii].toString()
                                                                .contains(innerText)) {
                                                            model.addElement(arrayBackupForInnerScan[ii]);
                                                        }
                                                        if (innerScanStop) {
                                                            System.out.println(toString() + " ... over!! ==> "
                                                                    + innerScanStop);
                                                            break;
                                                        }
                                                    }
                                                    System.out.println(toString() + " ... run over!! ==> "
                                                            + innerScanStop);
                                                }
                                            }, "innerScanner_" + System.currentTimeMillis());
                                    innerScanThread.setDaemon(true);
                                    innerScanThread.start();
                                }
                            }
                        });
                    }
                }
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel8.add(jScrollPane4, BorderLayout.CENTER);
                    {
                        DefaultListModel scanListModel = new DefaultListModel();
                        scanList = new JList();
                        jScrollPane4.setViewportView(scanList);
                        scanList.setModel(scanListModel);
                        scanList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("scanList.mouseClicked", evt);
                            }
                        });
                        scanList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("scanList.keyPressed", evt);
                            }
                        });
                    }
                }
                {
                    scannerStatus = new JLabel();
                    jPanel8.add(scannerStatus, BorderLayout.SOUTH);
                    scannerStatus.setPreferredSize(new java.awt.Dimension(741, 27));
                }
            }
        }

        swingUtil.addAction("moveFiles.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                if (model.getSize() == 0 || execList.getSelectedValues().length == 0) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("no selected file can move!", "ERROR");
                    return;
                }
                File exportListTo = FileUtil.getDefaultExportDir(ExecuteOpener.class, true);
                File file = null;
                List<File> list = new ArrayList<File>();
                for (Object obj : execList.getSelectedValues()) {
                    file = new File((String) obj);
                    if (file.exists() && file.isFile()) {
                        list.add(file);
                    }
                }
                File fromBaseDir = FileUtil.exportReceiveBaseDir(list);
                System.out.println("fromBaseDir = " + fromBaseDir);
                int cutLen = 0;
                if (fromBaseDir != null) {
                    cutLen = fromBaseDir.getAbsolutePath().length();
                }
                StringBuilder err = new StringBuilder();
                File newFile = null;
                for (Object obj : execList.getSelectedValues()) {
                    file = new File((String) obj);
                    if (file.exists() && file.isFile()) {
                        newFile = new File(exportListTo + "/" + file.getParent().substring(cutLen),
                                file.getName());
                        newFile.getParentFile().mkdirs();
                        System.out.println("move to : " + newFile);
                        file.renameTo(newFile);
                        if (!newFile.exists()) {
                            err.append(file + "\n");
                        }
                    }
                }
                if (err.length() > 0) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("move file error : \n" + err, "ERROR");
                } else {
                    JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                            "move file success : " + execList.getSelectedValues().length, "SUCCESS");
                }
            }
        });
        swingUtil.addAction("deleteSelected.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                StringBuilder sb = new StringBuilder();
                for (Object obj : execList.getSelectedValues()) {
                    sb.append(new File((String) obj).getName() + "\n");
                }
                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil.newInstance()
                        .confirmButtonYesNo().iconWaringMessage()
                        .showConfirmDialog("are you sure delete file : \n" + sb, "DELETE")) {
                    return;
                }
                File file = null;
                sb = new StringBuilder();
                for (Object obj : execList.getSelectedValues()) {
                    file = new File((String) obj);
                    if (!file.exists()) {
                        continue;
                    }
                    if (file.isDirectory() && file.list().length == 0) {
                        if (!file.delete()) {
                            sb.append(file.getName() + "\n");
                        }
                        continue;
                    }
                    if (!file.delete()) {
                        sb.append(file.getName() + "\n");
                    }
                }
                if (sb.length() != 0) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("delete error list :\n" + sb, "ERROR");
                } else {
                    JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog("delete completed!",
                            "SUCCESS");
                }
            }
        });
        swingUtil.addAction("loadClipboardPath.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = new File(ClipboardUtil.getInstance().getContents());
                if (!file.exists()) {
                    return;
                }
                List<File> list = new ArrayList<File>();
                FileUtil.searchFileMatchs(file, ".*", list);
                prop.clear();
                for (File f : list) {
                    if (f.isFile()) {
                        prop.setProperty(f.getAbsolutePath(), "");
                    }
                }
                DefaultListModel model = new DefaultListModel();
                for (Object key : prop.keySet()) {
                    model.addElement(key);
                }
                execList.setModel(model);
            }
        });
        swingUtil.addAction("deleteEmptyDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (file == null) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file is not correct!",
                            "ERROR");
                    return;
                }
                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil.newInstance()
                        .iconWaringMessage().confirmButtonYesNo()
                        .showConfirmDialog("are you sure delete empty dir in \n" + file, "WARRNING")) {
                    return;
                }
                List<File> delDir = new ArrayList<File>();
                FileUtil.deleteEmptyDir(file, delDir);
                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                        "delete dir list : \n" + delDir.toString().replace(',', '\n'), "DELETE");
            }
        });
        swingUtil.addAction("browser.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectFileAndDirectory().showOpenDialog()
                        .getApproveSelectedFile();
                if (file != null) {
                    DefaultListModel model = (DefaultListModel) execList.getModel();
                    model.addElement(file.getAbsolutePath());
                }
            }
        });
        swingUtil.addAction("addArea.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                if (StringUtils.isBlank(exeArea.getText())) {
                    return;
                }
                DefaultListModel model = (DefaultListModel) execList.getModel();
                StringTokenizer token = new StringTokenizer(exeArea.getText(), "\t\n\r\f");
                while (token.hasMoreElements()) {
                    String val = ((String) token.nextElement()).trim();
                    model.addElement(val);
                    prop.put(val, "");
                }
            }
        });
        swingUtil.addAction("execute.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                    String val = (String) enu.nextElement();
                    exec(val);
                }
            }
        });
        swingUtil.addAction("execList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(execList).defaultJListKeyPressed(evt);
            }
        });
        //DEFAULT PROP SAVE
        swingUtil.addAction("saveList.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                String orignName = JOptionPaneUtil.newInstance().iconPlainMessage()
                        .showInputDialog("input properties file name", "SAVE");
                File saveFile = null;
                if (StringUtils.isNotBlank(orignName)) {
                    String fileName = orignName;
                    if (!fileName.toLowerCase().endsWith(".properties")) {
                        fileName += ".properties";
                    }
                    fileName = ExecuteOpener.class.getSimpleName() + "_" + fileName;
                    prop.clear();
                    DefaultListModel model = (DefaultListModel) execList.getModel();
                    for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                        String val = (String) enu.nextElement();
                        prop.put(val, "");
                    }
                    saveFile = new File(jarPositionDir, fileName);
                } else {
                    saveFile = currentPropFile;
                }
                prop.store(new FileOutputStream(saveFile), orignName);
                JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog(saveFile,
                        "PROPERTIES CREATE");
            }
        });
        swingUtil.addAction("clearExecList.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                //                    prop.clear();
                //                    reloadExecListProperties(prop);
                execList.setModel(new DefaultListModel());
            }
        });
        swingUtil.addAction("execList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                // right button single click event
                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                    JPopupMenuUtil popupUtil = JPopupMenuUtil.newInstance(execList).applyEvent(evt);

                    if (execList.getSelectedValues().length == 1) {
                        popupUtil.addJMenuItem(
                                JFileExecuteUtil.newInstance(new File((String) execList.getSelectedValues()[0]))
                                        .createDefaultJMenuItems());
                        popupUtil.addJMenuItem("----------------", false);
                    }

                    popupUtil.addJMenuItem("eclipse home", new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            DefaultListModel model = (DefaultListModel) execList.getModel();
                            Object[] arry = model.toArray();
                            for (Object obj : arry) {
                                try {
                                    Runtime.getRuntime().exec(String.format("cmd /c call \"%s\" \"%s\"",
                                            "C:/?/eclipse_jee/eclipse.exe", obj));
                                } catch (IOException ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        }
                    });
                    popupUtil.addJMenuItem("eclipse company", new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            DefaultListModel model = (DefaultListModel) execList.getModel();
                            Object[] arry = model.toArray();
                            for (Object obj : arry) {
                                try {
                                    Runtime.getRuntime().exec(String.format("cmd /c call \"%s\" \"%s\"",
                                            "C:/?/iisi_eclipse/eclipse.exe", obj));
                                } catch (IOException ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        }
                    });

                    popupUtil.addJMenuItem("----------------", false);

                    popupUtil//
                            .addJMenuItem("sort list", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    Object[] arry = model.toArray();
                                    Arrays.sort(arry);
                                    DefaultListModel model2 = new DefaultListModel();
                                    for (Object obj : arry) {
                                        model2.addElement(obj);
                                    }
                                    execList.setModel(model2);
                                }
                            }).addJMenuItem("keep exists", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    DefaultListModel model2 = new DefaultListModel();
                                    for (Object obj : model.toArray()) {
                                        if (new File((String) obj).exists()) {
                                            model2.addElement(obj);
                                        }
                                    }
                                    execList.setModel(model2);
                                }
                            }).addJMenuItem("remove duplicate", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    DefaultListModel model2 = new DefaultListModel();
                                    Set<String> set = new HashSet<String>();
                                    for (Object obj : model.toArray()) {
                                        set.add((String) obj);
                                    }
                                    for (String val : set) {
                                        model2.addElement(val);
                                    }
                                    execList.setModel(model2);
                                }
                            }).addJMenuItem("remove folder", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    for (int ii = 0; ii < model.getSize(); ii++) {
                                        if (new File((String) model.getElementAt(ii)).isDirectory()) {
                                            model.removeElementAt(ii);
                                            ii--;
                                        }
                                    }
                                }
                            }).addJMenuItem("remove empty folder", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    DefaultListModel model = (DefaultListModel) execList.getModel();
                                    File dir = null;
                                    for (int ii = 0; ii < model.getSize(); ii++) {
                                        dir = new File((String) model.getElementAt(ii));
                                        if (dir.isDirectory() && dir.list().length == 0) {
                                            model.removeElementAt(ii);
                                            ii--;
                                        }
                                    }
                                }
                            }).addJMenuItem("----------------", false)
                            .addJMenuItem("diff left : " + (diffLeft != null ? diffLeft.getName() : ""), true,
                                    new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            File value = new File(
                                                    (String) JListUtil.getLeadSelectionObject(execList));
                                            if (value != null && value.isFile() && value.exists()) {
                                                diffLeft = value;
                                            }
                                        }
                                    })
                            .addJMenuItem("diff right : " + (diffRight != null ? diffRight.getName() : ""),
                                    true, new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            File value = new File(
                                                    (String) JListUtil.getLeadSelectionObject(execList));
                                            if (value != null && value.isFile() && value.exists()) {
                                                diffRight = value;
                                            }
                                        }
                                    })
                            .addJMenuItem((diffLeft != null && diffRight != null) ? "diff compare" : "",
                                    (diffLeft != null && diffRight != null), new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            try {
                                                Runtime.getRuntime().exec(String.format(
                                                        "cmd /c call TortoiseMerge.exe /base:\"%s\" /theirs:\"%s\"",
                                                        diffLeft, diffRight));
                                            } catch (IOException ex) {
                                                JCommonUtil.handleException(ex);
                                            }
                                        }
                                    })
                            .addJMenuItem((execList.getSelectedValues().length == 2) ? "diff compare" : "",
                                    (execList.getSelectedValues().length == 2), new ActionListener() {
                                        public void actionPerformed(ActionEvent arg0) {
                                            try {
                                                Runtime.getRuntime().exec(String.format(
                                                        "cmd /c call TortoiseMerge.exe /base:\"%s\" /theirs:\"%s\"",
                                                        execList.getSelectedValues()[0],
                                                        execList.getSelectedValues()[1]));
                                            } catch (IOException ex) {
                                                JCommonUtil.handleException(ex);
                                            }
                                        }
                                    })
                            .addJMenuItem("----------------", false)//
                            .show();//
                }

                // left button double click event 
                int pos = execList.getLeadSelectionIndex();
                if (pos == -1) {
                    return;
                }
                if (((MouseEvent) evt).getClickCount() < 2) {
                    return;
                }
                DefaultListModel model = (DefaultListModel) execList.getModel();
                String val = (String) model.getElementAt(pos);
                exec(val);
            }
        });
        swingUtil.addAction("loadProp.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (file == null) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file not correct!",
                            "ERROR");
                    return;
                }
                reloadExecListProperties(file);
                setTitle("load prop : " + file.getName());
            }
        });
        swingUtil.addAction("reloadList.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                reloadExecListProperties(prop);
            }
        });
        swingUtil.addAction("exportListHasOrignTree.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                if (model.isEmpty()) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("no file can export!",
                            "ERROR");
                    return;
                }
                List<File> allList = new ArrayList<File>();
                for (int ii = 0; ii < model.getSize(); ii++) {
                    allList.add(new File((String) model.getElementAt(ii)));
                }
                File baseDir = FileUtil.exportReceiveBaseDir(allList);
                System.out.println("common base dir : " + baseDir);
                boolean dynamicBaseDir = baseDir == null;

                File tmp = null;
                File copyTo = null;
                int realCopyCount = 0;

                File exportListTo = FileUtil.getDefaultExportDir(ExecuteOpener.class, true);
                for (int ii = 0; ii < model.getSize(); ii++) {
                    String val = (String) model.getElementAt(ii);
                    if (StringUtils.isBlank(val)) {
                        continue;
                    }
                    tmp = new File(val);
                    if (tmp.isDirectory()) {
                        continue;
                    }
                    File copyFrom = getCorrectFile(tmp);
                    if (dynamicBaseDir) {
                        baseDir = FileUtil.getRoot(copyFrom);
                    }
                    copyTo = FileUtil.exportFileToTargetPath(copyFrom, baseDir, exportListTo);
                    if (!copyTo.getParentFile().exists()) {
                        copyTo.getParentFile().mkdirs();
                    }
                    System.out.println("## file : " + tmp + " -- > " + copyFrom);
                    System.out.println("\t copy to : " + copyTo);
                    FileUtil.copyFile(copyFrom, copyTo);
                    realCopyCount++;
                }
                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                        "copy completed!\ntotal : " + model.getSize() + "\ncopy : " + realCopyCount, "SUCCESS");
            }
        });
        swingUtil.addAction("executeExport.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) execList.getModel();
                if (model.isEmpty()) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("no file can export!",
                            "ERROR");
                    return;
                }
                File tmp = null;
                File copyTo = null;
                int realCopyCount = 0;
                File exportListTo = FileUtil.getDefaultExportDir(ExecuteOpener.class, true);
                BufferedWriter writer = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(exportListTo + "/output_log.txt"), "BIG5"));
                for (int ii = 0; ii < model.getSize(); ii++) {
                    String val = (String) model.getElementAt(ii);
                    if (StringUtils.isBlank(val)) {
                        continue;
                    }
                    tmp = new File(val);
                    if (tmp.isDirectory()) {
                        continue;
                    }
                    if (isNeedToCopy(exportListTo, tmp)) {
                        File copyFrom = getCorrectFile(tmp);
                        System.out.println("## file : " + tmp + " -- > " + copyFrom);
                        copyTo = new File(exportListTo, copyFrom.getName());
                        for (int jj = 0; copyTo.exists(); jj++) {
                            String name = copyFrom.getName();
                            int pos = name.lastIndexOf(".");
                            String prefix = name.substring(0, pos);
                            String rearfix = name.substring(pos);
                            copyTo = new File(exportListTo, prefix + "_R" + jj + rearfix);
                        }
                        FileUtil.copyFile(copyFrom, copyTo);
                        writer.write(tmp.getAbsolutePath()
                                + (!tmp.getName().equals(copyTo.getName()) ? "\t [rename] : " + copyTo.getName()
                                        : ""));
                        realCopyCount++;
                    } else {
                        writer.write(tmp.getAbsolutePath() + "\t [has same file, ommit!]");
                    }
                    writer.newLine();
                }
                writer.flush();
                writer.close();
                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(
                        "copy completed!\ntotal : " + model.getSize() + "\ncopy : " + realCopyCount, "SUCCESS");
            }
        });
        swingUtil.addAction("jTabbedPane1.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                File file = new File(getTitle());
                if (file.exists()) {
                    JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog(file,
                            "current properties");
                }
                ClipboardUtil.getInstance().setContents(file);
            }
        });
        swingUtil.addAction("propertiesList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = (File) propertiesList.getSelectedValue();
                JPopupMenuUtil.newInstance(propertiesList).applyEvent(evt)
                        .addJMenuItem("reload list", new ActionListener() {
                            public void actionPerformed(ActionEvent paramActionEvent) {
                                reloadCurrentDirPropertiesList();
                            }
                        }).addJMenuItem(JFileExecuteUtil.newInstance(file).createDefaultJMenuItems()).show();
                if (file == null) {
                    return;
                }
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                prop.clear();
                prop.load(new FileInputStream(file));
                currentPropFile = file;
                reloadExecListProperties(prop);
                setTitle("properties : " + file.getName());
            }
        });
        swingUtil.addAction("propertiesList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                JListUtil.newInstance(propertiesList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("jTabbedPane1.stateChanged", new Action() {
            public void action(EventObject evt) throws Exception {
                if (jTabbedPane1.getSelectedIndex() == 2) {
                    reloadCurrentDirPropertiesList();
                }
            }
        });
        swingUtil.addAction("scanList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(scanList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("scanList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                System.out.println("index = " + scanList.getLeadSelectionIndex());
                final Object[] vals = scanList.getSelectedValues();
                if (vals == null || vals.length == 0) {
                    return;
                }
                JPopupMenuUtil.newInstance(scanList).applyEvent(evt)
                        .addJMenuItem("add to file list : " + vals.length, new ActionListener() {
                            public void actionPerformed(ActionEvent arg0) {
                                File file = null;
                                DefaultListModel model = (DefaultListModel) execList.getModel();
                                for (Object v : vals) {
                                    file = (File) v;
                                    model.addElement(file.getAbsolutePath());
                                }
                            }
                        }).show();
            }
        });
        swingUtil.addAction("fileScan.actionPerformed", new Action() {

            Thread scanMainThread = null;

            public void action(EventObject evt) throws Exception {
                String scanText_ = scannerText.getText();
                final boolean anyFileMatch = StringUtils.isEmpty(scanText_);
                final String scanText = anyFileMatch ? UUID.randomUUID().toString() : scanText_;
                final FileOrDirType fileOrDirType = (FileOrDirType) fileOrDirTypeCombo.getSelectedItem();

                String scanDir_ = scanDirText.getText();
                final File scanDir = new File(scanDir_);
                if (StringUtils.isEmpty(scanDir_)) {
                    JOptionPaneUtil.newInstance().iconErrorMessage()
                            .showMessageDialog("scan dir text can't empty!", "ERROR");
                    return;
                }
                if (!scanDir.exists()) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("directory is't exists!",
                            "ERROR");
                    return;
                }

                Object[] igArry_ = ((DefaultListModel) ignoreScanList.getModel()).toArray();
                final String[] igArry = new String[igArry_.length];
                for (int ii = 0; ii < igArry.length; ii++) {
                    igArry[ii] = (String) igArry_[ii];
                }
                final boolean ignoreCheck = igArry.length > 0;

                final DefaultListModel model = new DefaultListModel();

                final StringTokenizer tok = new StringTokenizer(scanText);

                if (scanMainThread == null || scanMainThread.getState() == Thread.State.TERMINATED) {
                    scanMainThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {

                        ScanType scanTp;

                        public void run() {
                            currentScannerThreadStop = false;
                            final long startTime = System.currentTimeMillis();
                            scanTp = (ScanType) scanType.getSelectedItem();

                            List<Thread> threadList = new ArrayList<Thread>();
                            final Map<String, Integer> matchCountMap = new HashMap<String, Integer>();
                            for (; tok.hasMoreElements();) {
                                final String scanVal = (String) tok.nextElement();
                                System.out.println("add scan condition = " + scanVal);

                                Pattern ppp = null;
                                try {
                                    ppp = Pattern.compile(scanVal);
                                } catch (Exception ex) {
                                    System.out.println(ex);
                                }

                                final Pattern scanTextPattern = ppp;

                                Thread currentScannerThread = new Thread(
                                        Thread.currentThread().getThreadGroup(), new Runnable() {

                                            int matchCount = 0;

                                            void addElement(File file) {
                                                if (scanTp.filter(anyFileMatch, scanVal, scanTextPattern, file,
                                                        ignoreCheck, igArry)) {
                                                    for (int ii = 0;; ii++) {
                                                        try {
                                                            model.addElement(file);
                                                            matchCount++;
                                                            break;
                                                        } catch (Exception ex) {
                                                            System.err.println(
                                                                    file + ", error occor !!! ==> " + ex);
                                                            if (ii > 10) {
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                            void find(File file) {
                                                if (currentScannerThreadStop) {
                                                    return;
                                                }
                                                if (file == null || !file.exists()) {
                                                    System.out
                                                            .println("file == null || !file.exists()\t" + file);
                                                    return;
                                                }
                                                scannerStatus.setText(
                                                        model.getSize() + " : " + file.getAbsolutePath());
                                                if (file.isDirectory()) {
                                                    if (file.listFiles() != null) {
                                                        for (File f : file.listFiles()) {
                                                            find(f);
                                                        }
                                                    } else {
                                                        System.out
                                                                .println("file.listFiles() == null!!\t" + file);
                                                    }
                                                    switch (fileOrDirType) {
                                                    case DIRECTORY_ONLY:
                                                        addElement(file);
                                                        break;
                                                    case ALL:
                                                        addElement(file);
                                                        break;
                                                    }
                                                }
                                                if (file.isFile()) {
                                                    switch (fileOrDirType) {
                                                    case FILE_ONLY:
                                                        addElement(file);
                                                        break;
                                                    case ALL:
                                                        addElement(file);
                                                        break;
                                                    }
                                                }
                                            }

                                            public void run() {
                                                find(scanDir);
                                                matchCountMap.put(scanVal, matchCount);
                                            }
                                        }, "file_scann_" + System.currentTimeMillis());
                                currentScannerThread.setDaemon(true);
                                currentScannerThread.start();
                                threadList.add(currentScannerThread);
                            }

                            for (;;) {
                                try {
                                    Thread.sleep(1000);
                                    boolean allTerminated = true;
                                    for (int ii = 0; ii < threadList.size(); ii++) {
                                        if (threadList.get(ii).getState() != Thread.State.TERMINATED) {
                                            allTerminated = false;
                                            break;
                                        }
                                    }
                                    if (allTerminated) {
                                        System.out.println("all done...");
                                        break;
                                    }
                                } catch (InterruptedException e) {
                                    JCommonUtil.handleException(e);
                                }
                            }

                            long endTime = System.currentTimeMillis() - startTime;

                            String status = "scan completed \n during :" + endTime + "\n file : "
                                    + model.getSize() + "\n \tResult : \n " + matchCountMap;
                            JOptionPaneUtil.newInstance().iconPlainMessage().showMessageDialog(status,
                                    "COMPLETED");
                            scannerStatus.setText(status);
                            scanList.setModel(model);

                            arrayBackupForInnerScan = ((DefaultListModel) scanList.getModel()).toArray();

                            currentScannerThreadStop = false;
                        }
                    }, "file_scann_main_" + System.currentTimeMillis());
                    scanMainThread.setDaemon(true);
                    scanMainThread.start();
                } else {
                    if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                            "scanner is running \n want to stop??", "WARNING")) {
                        currentScannerThreadStop = true;
                    }
                }
            }
        });
        swingUtil.addAction("scanDirText.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                    return;
                }
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (dir == null) {
                    return;
                }
                scanDirText.setText(dir.getAbsolutePath());
            }
        });
        swingUtil.addAction("addListToExecList.actionPerformed", new Action() {

            Thread moveThread = null;

            public void action(EventObject evt) throws Exception {
                if (moveThread != null && moveThread.getState() != Thread.State.TERMINATED) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("add list process already running!");
                    return;
                }
                moveThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                    public void run() {
                        DefaultListModel model = (DefaultListModel) scanList.getModel();
                        DefaultListModel model2 = (DefaultListModel) execList.getModel();
                        for (int ii = 0; ii < model.getSize(); ii++) {
                            File f = (File) model.getElementAt(ii);
                            model2.addElement(f.getAbsolutePath());
                        }
                        if (model.getSize() > 1000) {
                            JCommonUtil._jOptionPane_showMessageDialog_info(
                                    "add list completed!\n" + model.getSize());
                        }
                    }
                }, "addListToExecList.actionPerformed_" + System.currentTimeMillis());
                moveThread.setDaemon(true);
                moveThread.start();
            }
        });
        swingUtil.addAction("openSvnUpdate.actionPerformed", new Action() {

            Pattern svnPattern = Pattern.compile("^(?:[M|\\?])\\s+\\d*\\s+(.+)$");

            Thread svnThread = null;

            public void action(EventObject evt) throws Exception {
                if (svnThread != null && svnThread.getState() != Thread.State.TERMINATED) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("svn scan process already running!");
                    return;
                }
                final File svnDir = JCommonUtil._jFileChooser_selectDirectoryOnly();
                if (svnDir == null) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("dir is not correct!");
                    return;
                }

                svnThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                    public void run() {
                        try {
                            Process process = Runtime.getRuntime()
                                    .exec(String.format("svn status -u \"%s\"", svnDir));
                            BufferedReader reader = new BufferedReader(
                                    new InputStreamReader(process.getInputStream()));
                            Matcher matcher = null;
                            File file = null;
                            DefaultListModel model = new DefaultListModel();
                            List<File> scanList = new ArrayList<File>();
                            for (String line = null; (line = reader.readLine()) != null;) {
                                matcher = svnPattern.matcher(line);
                                if (matcher.find()) {
                                    file = new File(matcher.group(1));
                                    if (file.isFile()) {
                                        model.addElement(file.getAbsolutePath());
                                    }
                                    if (file.isDirectory()) {
                                        scanList.clear();
                                        FileUtil.searchFileMatchs(file, ".*", scanList);
                                        for (File f : scanList) {
                                            model.addElement(f.getAbsolutePath());
                                        }
                                    }
                                } else {
                                    System.out.println("ignore : [" + line + "]");
                                }
                            }
                            reader.close();
                            execList.setModel(model);
                            setTitle("svn : " + svnDir);

                            JCommonUtil._jOptionPane_showMessageDialog_info("svn scan completed!");
                        } catch (IOException e) {
                            JCommonUtil.handleException(e);
                        }
                    }
                }, "svn_scan" + System.currentTimeMillis());
                svnThread.setDaemon(true);
                svnThread.start();
            }
        });
        swingUtil.addAction("contentFilterBtn.actionPerformed", new Action() {
            Thread thread = null;
            String encode = Charset.defaultCharset().displayName();

            public void action(EventObject evt) throws Exception {
                if (thread != null && thread.getState() != Thread.State.TERMINATED) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("scan process already running!");
                    return;
                }

                final String filter = JCommonUtil._jOptionPane_showInputDialog("input filter content?");
                if (StringUtils.isEmpty(filter)) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("filter is empty!");
                    return;
                }

                Pattern tmpPattern = null;
                try {
                    tmpPattern = Pattern.compile(filter);
                } catch (Exception ex) {
                }
                final Pattern filterPattern = tmpPattern;

                try {
                    encode = JCommonUtil._jOptionPane_showInputDialog("input encode?", encode);
                } catch (Exception ex) {
                    JCommonUtil._jOptionPane_showMessageDialog_error("error encode!");
                    return;
                }

                thread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                    public void run() {
                        DefaultListModel model = (DefaultListModel) execList.getModel();
                        DefaultListModel model_ = new DefaultListModel();
                        File file = null;
                        BufferedReader reader = null;
                        for (int ii = 0; ii < model.getSize(); ii++) {
                            file = new File((String) model.getElementAt(ii));
                            if (!file.exists()) {
                                continue;
                            }
                            try {
                                reader = new BufferedReader(
                                        new InputStreamReader(new FileInputStream(file), encode));
                                for (String line = null; (line = reader.readLine()) != null;) {
                                    if (line.contains(filter)) {
                                        model_.addElement(file.getAbsolutePath());
                                        break;
                                    }
                                    if (filterPattern != null && filterPattern.matcher(line).find()) {
                                        model_.addElement(file.getAbsolutePath());
                                        break;
                                    }
                                }
                                reader.close();
                            } catch (Exception e) {
                                JCommonUtil.handleException(e);
                            }
                        }
                        execList.setModel(model_);
                        JCommonUtil._jOptionPane_showMessageDialog_info("completed!");
                    }
                }, UUID.randomUUID().toString());
                thread.setDaemon(true);
                thread.start();
            }
        });
        swingUtil.addAction("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", new Action() {
            public void action(EventObject evt) throws Exception {
            }
        });

        this.setSize(870, 551);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:canreg.client.gui.analysis.TableBuilderInternalFrame.java

private void refreshTableTypeList() {

    FilenameFilter filter = (File dir, String name1) -> (name1.endsWith(".conf"));

    LinkedList<String> children = new LinkedList<>();

    // get directories of .confs
    File[] dirs = { new File(Globals.TABLES_CONF_PATH), new File(Globals.USER_TABLES_CONF_PATH) };

    for (File dir : dirs) {
        if (dir.exists()) {
            for (String fileName : dir.list(filter)) {
                children.add(dir.getAbsolutePath() + Globals.FILE_SEPARATOR + fileName);
            }//  w  w w  .  j  a  v a  2 s  .  c o  m
        }
    }

    // LinkedList<TableBuilderListElement> tableTypeLinkedList = new LinkedList<TableBuilderListElement>();
    DefaultListModel listModel = new DefaultListModel();
    //open one by one using configreader
    //make list
    children.forEach((configFileName) -> {
        // Get filename of file or directory
        try {
            String[] tempArray;
            FileReader fileReader = new FileReader(configFileName);
            LinkedList<ConfigFields> configFields = ConfigFieldsReader.readFile(fileReader);
            TableBuilderListElement etle = new TableBuilderListElement();
            etle.setConfigFileName(configFileName);
            etle.setConfigFields(configFields);

            tempArray = ConfigFieldsReader.findConfig("table_label", configFields);
            if (tempArray != null && tempArray.length > 0) {
                etle.setName(tempArray[0]);
                // System.out.println(tempArray[0]);
            }

            tempArray = ConfigFieldsReader.findConfig("table_description", configFields);
            if (tempArray != null && tempArray.length > 0) {
                etle.setDescription(tempArray[0]);
                // System.out.println(tempArray[0]);
            }

            tempArray = ConfigFieldsReader.findConfig("table_engine", configFields);
            if (tempArray != null && tempArray.length > 0) {
                etle.setEngineName(tempArray[0]);
                // System.out.println(tempArray[0]);
            }

            String[] engineParameters = ConfigFieldsReader.findConfig("engine_parameters", configFields);
            etle.setEngineParameters(engineParameters);

            tempArray = ConfigFieldsReader.findConfig("preview_image", configFields);
            if (tempArray != null && tempArray.length > 0) {
                etle.setPreviewImageFilename(tempArray[0]);
                // System.out.println(tempArray[0]);
            }

            // tableTypeLinkedList.add(etle);
            listModel.addElement(etle);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    tableTypeList.setModel(listModel);

}

From source file:de.main.sessioncreator.DesktopApplication1View.java

public void getAreasBacgroundW(File f) {
    fileHelper.getAreas(f);//  ww w  .  ja  v  a2 s .  c o m
    Iterator<Map.Entry<String, List>> it = fileHelper.areaMap.entrySet().iterator();
    while (it.hasNext()) {
        DefaultListModel dlm = new DefaultListModel();
        JList list = new JList(dlm);
        list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        JScrollPane scrollPane = new JScrollPane(list);
        scrollPane.getViewport().setView(list);
        Map.Entry en = it.next();
        wizardtabpAreas.addTab(en.getKey().toString().substring(3), scrollPane);
        for (Object o : fileHelper.areaMap.get(en.getKey().toString())) {
            dlm.addElement(o);
        }
        MouseListener mouseListener = new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent mouseEvent) {
                JList tabList = (JList) mouseEvent.getSource();
                if (mouseEvent.getClickCount() == 2) {
                    int index = tabList.locationToIndex(mouseEvent.getPoint());
                    if (index >= 0) {
                        Object o = tabList.getModel().getElementAt(index);
                        wizardtaChoosenAreas.append(o.toString() + "\n");
                    }
                }
            }
        };
        list.addMouseListener(mouseListener);
        ListSelectionListener listListener = new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                JList list = (JList) e.getSource();
                if (e.getValueIsAdjusting() == false) {

                    if (list.getSelectedIndex() == -1) {
                        //No selection, disable add button.
                        wizardbtnAddAreas.setEnabled(false);

                    } else {
                        //Selection, enable the add button.
                        wizardbtnAddAreas.setEnabled(true);
                    }
                }
            }
        };
        list.addListSelectionListener(listListener);
    }
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

/** Builds the parameter list on the gui from the <code>parameters</code> list. */
private void createDefaultParameterList(final List<ParameterInfo> parameters) {
    final DefaultListModel model = new DefaultListModel();
    for (final ParameterInfo parameterInfo : parameters)
        model.addElement(new AvailableParameter(parameterInfo, currentModelHandler.getModelClass()));
    parameterList.setModel(model);/*from  www . j  a v a2  s . co m*/
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * @param catName//from  w  ww.  j a  v a  2 s.co  m
 */
protected void fillUsageItemsList(final String catName) {
    String sql = "SELECT Name, Total FROM (SELECT Name, SUM(CountAmt) as Total FROM trackitem WHERE CountAmt < 100000 AND SUBSTRING(Name, 1, 8) = 'Usage_"
            + catName + "' GROUP BY Name) AS T1 ORDER BY Total";
    System.out.println(sql);
    Vector<Object[]> rows = BasicSQLUtils.query(sql);

    DefaultListModel model = (DefaultListModel) trackItemsList.getModel();
    if (rows != null && rows.size() > 0) {
        boolean isCatOK = catName.length() == 2;
        boolean isDataEntry = catName.equals("DE");
        boolean isDatabase = catName.equals("DB");

        Hashtable<String, Boolean> clsHash = new Hashtable<String, Boolean>();

        Vector<Pair<String, Integer>> values = new Vector<Pair<String, Integer>>();
        int total = 0;
        for (Object[] colData : rows) {
            String name = (String) colData[0];
            int val = ((BigDecimal) colData[1]).intValue();

            if (name.startsWith("Usage_")) {
                name = name.substring(6);
            }

            String str;
            if (isCatOK && name.charAt(2) == '_') {
                str = name.substring(catName.length() + 1);
                /*if (str.startsWith(catName) && str.charAt(2) == '_')
                {
                str = str.substring(catName.length()+1);
                }*/
                if (str.startsWith("VIEW_")) {
                    str = str.substring(5);
                }

                if (isDataEntry) {
                    String clsName = str;
                    if (clsName.endsWith("_RS")) {
                        clsName = clsName.substring(0, clsName.length() - 3);
                    }
                    clsHash.put(clsName, true);

                } else if (isDatabase) {
                    int inx = str.lastIndexOf('_');
                    String clsName = str.substring(inx + 1);
                    clsHash.put(clsName, true);
                }

            } else {
                str = name;
            }
            values.add(new Pair<String, Integer>(str, val));
            total += val;
        }

        Collections.sort(values, countComparator);

        createBarChart(trackDescHash.get(catName), "Actions", values);

        // Fill Model
        model.clear();
        sql = "SELECT DISTINCT(Name) FROM trackitem WHERE SUBSTRING(Name, 1, 8) = 'Usage_" + catName
                + "' ORDER BY Name";
        rows = BasicSQLUtils.query(sql);
        if (rows != null && rows.size() > 0) {
            for (Object[] colData : rows) {
                model.addElement(colData[0]);
            }
        }

        if (clsHash.size() > 0) {
            showClassList(clsHash);

        } else if (classFrame != null && classFrame.isVisible()) {
            classFrame.setVisible(false);
        }

    } else {
        model.clear();
        if (chartFrame != null && chartFrame.isVisible()) {
            chartFrame.setVisible(false);
        }
    }
}

From source file:com.xyphos.vmtgen.GUI.java

private void showTextureFiles() {
    DefaultListModel model = (DefaultListModel) lstFiles.getModel();
    model.clear();/* w  w w.j a va2 s.com*/

    String root = txtRootFolder.getText();
    String work = txtWorkFolder.getText();

    if (root.isEmpty() || work.isEmpty()) {
        return;
    }

    basePath = work.replace(root, "");
    File dir = new File(work);
    String full, name, ext;

    if (chkOnlyMissing.isSelected()) {
        List<String> fileVTF = new ArrayList<>();
        List<String> fileVMT = new ArrayList<>();

        for (File file : dir.listFiles()) {
            if (file.isFile()) {
                full = file.getName();
                //name = FilenameUtils.getBaseName( full );
                ext = FilenameUtils.getExtension(full);

                if (ext.equalsIgnoreCase("vtf")) {
                    fileVTF.add(full);
                } else if (ext.equalsIgnoreCase("vmt")) {
                    fileVMT.add(full);
                }
            }
        }

        String baseName;
        Iterator<String> itr;
        boolean matched;
        for (String file : fileVTF) {
            baseName = FilenameUtils.getBaseName(file);
            itr = fileVMT.iterator();
            matched = false;
            while (itr.hasNext()) {
                if (FilenameUtils.getBaseName(itr.next()).equalsIgnoreCase(baseName)) {
                    matched = true;
                    break;
                }
            }

            if (!matched) {
                model.addElement(file);
            }
        }
    } else {
        for (File file : dir.listFiles()) {
            name = file.getName();
            ext = FilenameUtils.getExtension(name);
            if (file.isFile() && ext.equalsIgnoreCase("vtf")) {
                model.addElement(name);
            }
        }
    }
}