Example usage for javax.swing.event ChangeListener ChangeListener

List of usage examples for javax.swing.event ChangeListener ChangeListener

Introduction

In this page you can find the example usage for javax.swing.event ChangeListener ChangeListener.

Prototype

ChangeListener

Source Link

Usage

From source file:com.qspin.qtaste.ui.MainPanel.java

public void genUI() {
    try {//from  www.  ja  v  a  2s.  c  o  m
        getContentPane().setLayout(new BorderLayout());
        // prepare the top panel that contains the following panes:
        //   - logo
        //   - ConfigInfopanel
        //   - Current Date/time
        JPanel topanel = new JPanel(new BorderLayout());
        JPanel center = new JPanel(new GridBagLayout());
        ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin");
        JLabel iconlabel = new JLabel(topLeftLogo);

        mHeaderPanel = new ConfigInfoPanel(this);
        mTestCasePanel = new TestCasePane(this);
        mTestCampaignPanel = new TestCampaignMainPanel(this);

        mHeaderPanel.init();

        GridBagLineAdder centeradder = new GridBagLineAdder(center);
        JLabel sep = new JLabel("  ");
        sep.setFont(ResourceManager.getInstance().getSmallFont());
        sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor()));
        centeradder.setWeight(1.0f, 0.0f);
        centeradder.add(mHeaderPanel);

        // prepare the right panels containg the main information:
        // the right pane is selected through the tabbed pane:
        //    - Test cases: management of test cases and test suites
        //    - Test campaign: management of test campaigns
        //    - Interactive: ability to invoke QTaste verbs one by one

        mRightPanels = new JPanel(new CardLayout());

        mRightPanels.add(mTestCasePanel, "Test Cases");
        mRightPanels.add(mTestCampaignPanel, "Test Campaign");

        final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel();
        mRightPanels.add(testInterractivePanel, "Interactive");

        mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM);
        mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT));

        TestCaseTree tct = new TestCaseTree(mTestCasePanel);
        JScrollPane sp2 = new JScrollPane(tct);
        mTreeTabsPanel.addTab("Test Cases", sp2);

        // add tree view for test campaign definition
        com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree(
                mTestCampaignPanel.getTreeTable());
        JScrollPane sp3 = new JScrollPane(mtct);
        mTreeTabsPanel.addTab("Test Campaign", sp3);

        genMenu(tct);

        // add another tab contain used for Interactive mode
        TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel);
        JScrollPane spInter = new JScrollPane(jInteractive);
        mTreeTabsPanel.addTab("Interactive", spInter);

        // init will do the link between the tree view and the pane
        testInterractivePanel.init();

        // Define the listener to display the pane depending on the selected tab
        mTreeTabsPanel.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex());
                CardLayout rcl = (CardLayout) mRightPanels.getLayout();
                rcl.show(mRightPanels, componentName);
            }
        });
        mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (e.getID() == TestCampaignMainPanel.RUN_ID) {
                    if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) {
                        // open the tab test cases
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                mTreeTabsPanel.setSelectedIndex(0);
                                mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX);
                            }
                        });

                        // update the buttons
                        mTestCasePanel.setExecutingTestCampaign(true,
                                ((TestCampaignMainPanel) e.getSource()).getExecutionThread());
                        mTestCasePanel.updateButtons(true);
                    } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) {
                        mTestCasePanel.setExecutingTestCampaign(false, null);
                        mTestCasePanel.updateButtons();
                    }
                }
            }
        });

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels);
        splitPane.setDividerSize(4);
        GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
        int mainHorizontalSplitDividerLocation = guiConfiguration
                .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285);
        splitPane.setDividerLocation(mainHorizontalSplitDividerLocation);

        splitPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("dividerLocation")) {
                    GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
                    if (evt.getSource() instanceof JSplitPane) {
                        JSplitPane splitPane = (JSplitPane) evt.getSource();
                        guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY,
                                splitPane.getDividerLocation());
                        try {
                            guiConfiguration.save();
                        } catch (ConfigurationException ex) {
                            logger.error("Error while saving GUI configuration: " + ex.getMessage());
                        }
                    }
                }
            }
        });

        topanel.add(iconlabel, BorderLayout.WEST);
        topanel.add(center);

        getContentPane().add(topanel, BorderLayout.NORTH);
        getContentPane().add(splitPane);
        this.pack();

        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        if (mTestSuiteDir != null) {
            DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir);
            if (testSuite != null) {
                testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour);
                setTestSuite(testSuite.getName());
                mTestCasePanel.runTestSuite(testSuite, false);
            }
        }
        setVisible(true);
        //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT));

    } catch (Exception e) {
        logger.fatal(e);
        e.printStackTrace();
        TestEngine.shutdown();
        System.exit(1);
    }

}

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

private void initGUI() {
    final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this);
    ToolTipManager.sharedInstance().setInitialDelay(0);
    try {/*from w  ww  .j  ava  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:fr.free.hd.servers.gui.FaceView.java

private JPanel createPosition() {
    JPanel panel = new JPanel(new GridLayout(5, 0));
    final JSlider slider = new JSlider();
    final JSlider sliderDegree = new JSlider();
    final JSlider sliderX = new JSlider();
    final JSlider sliderY = new JSlider();
    slider.setMinimum(0);//  ww w .  j a  va 2 s.  c o  m
    slider.setMaximum(1000);
    sliderX.setMinimum(-1000);
    sliderX.setMaximum(1000);
    sliderX.setMajorTickSpacing(100);
    sliderX.setPaintLabels(true);
    sliderX.setPaintTicks(true);
    sliderX.setPaintTrack(true);
    sliderY.setMinimum(-1000);
    sliderY.setMaximum(1000);
    sliderY.setMajorTickSpacing(100);
    sliderY.setPaintLabels(true);
    sliderY.setPaintTicks(true);
    sliderY.setPaintTrack(true);
    sliderDegree.setMinimum(0);
    sliderDegree.setMaximum(360);
    sliderDegree.setMajorTickSpacing(20);
    sliderDegree.setPaintLabels(true);
    sliderDegree.setPaintTicks(true);
    sliderDegree.setPaintTrack(true);

    final JComboBox box = new JComboBox(HandPositionEnum.values());
    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            position = (HandPositionEnum) e.getItem();
            updateLabel();
        }
    });
    panel.add(box);

    slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheRatio(slider.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteRatio(slider.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouRatio(slider.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonRatio(slider.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteRatio(slider.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderDegree.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonDegree(sliderDegree.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteDegree(sliderDegree.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderX.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheX(sliderX.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteX(sliderX.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouX(sliderX.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonX(sliderX.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteX(sliderX.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderY.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (position) {
            case HAND_POSITION_BOUCHE:
                face.setBoucheY(sliderY.getValue());
                break;
            case HAND_POSITION_COTE:
                face.setCoteY(sliderY.getValue());
                break;
            case HAND_POSITION_COU:
                face.setCouY(sliderY.getValue());
                break;
            case HAND_POSITION_MENTON:
                face.setMentonY(sliderY.getValue());
                break;
            case HAND_POSITION_PAUMETTE:
                face.setPaumetteY(sliderY.getValue());
                break;
            }
            updateLabel();
        }
    });
    panel.add(slider);
    panel.add(sliderX);
    panel.add(sliderY);
    panel.add(sliderDegree);
    return panel;
}

From source file:com.floreantpos.config.ui.TerminalConfigurationView.java

private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel(new MigLayout("gap 5px 10px", "[][][grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel lblTerminalNumber = new JLabel(Messages.getString("TerminalConfigurationView.TERMINAL_NUMBER")); //$NON-NLS-1$
    contentPanel.add(lblTerminalNumber, "alignx left,aligny center"); //$NON-NLS-1$

    tfTerminalNumber = new IntegerTextField();
    tfTerminalNumber.setColumns(10);/* w w  w  . j  a  v  a 2  s.  c  o m*/
    contentPanel.add(tfTerminalNumber, "aligny top,wrap"); //$NON-NLS-1$

    JLabel lblTerminalLocation = new JLabel(Messages.getString("TerminalConfigurationView.24")); //$NON-NLS-1$
    taTerminalLocation = new JTextArea();
    taTerminalLocation.setLineWrap(true);
    taTerminalLocation.setPreferredSize(PosUIManager.getSize(350, 40));

    JScrollPane taScrollPane = new JScrollPane(taTerminalLocation);

    contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.9"))); //$NON-NLS-1$
    tfSecretKeyLength = new IntegerTextField(3);
    contentPanel.add(tfSecretKeyLength, "wrap"); //$NON-NLS-1$

    contentPanel.add(cbShowDbConfiguration, "spanx 3"); //$NON-NLS-1$

    cbAutoLogoff.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (cbAutoLogoff.isSelected()) {
                tfLogoffTime.setEnabled(true);
            } else {
                tfLogoffTime.setEnabled(false);
            }
        }
    });
    contentPanel.add(cbAutoLogoff, "newline"); //$NON-NLS-1$
    contentPanel.add(tfLogoffTime, "wrap"); //$NON-NLS-1$

    contentPanel.add(cbTranslatedName, "span 2"); //$NON-NLS-1$
    contentPanel.add(cbFullscreenMode, "newline, span"); //$NON-NLS-1$
    contentPanel.add(cbUseSettlementPrompt, "newline, span"); //$NON-NLS-1$
    contentPanel.add(cbShowBarCodeOnReceipt, "newline,span"); //$NON-NLS-1$
    contentPanel.add(cbGroupKitchenReceiptItems, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkEnabledMultiCurrency, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkAllowToDelPrintedItem, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkAllowQuickMaintenance, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkModifierCannotExceedMaxLimit, "newline,span"); //$NON-NLS-1$

    contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.17")), "newline"); //$NON-NLS-1$//$NON-NLS-2$
    contentPanel.add(cbFonts, "span 2, wrap"); //$NON-NLS-1$

    Vector<String> defaultViewList = new Vector<String>();

    List<OrderType> orderTypes = Application.getInstance().getOrderTypes();
    if (orderTypes != null) {
        for (OrderType orderType : orderTypes) {
            defaultViewList.add(orderType.getName());
        }
    }
    defaultViewList.add(SwitchboardOtherFunctionsView.VIEW_NAME);
    defaultViewList.add(KitchenDisplayView.VIEW_NAME);
    defaultViewList.add(SwitchboardView.VIEW_NAME);

    cbDefaultView = new JComboBox<String>(defaultViewList);

    contentPanel.add(new JLabel("Default View"), "newline"); //$NON-NLS-1$//$NON-NLS-2$
    contentPanel.add(cbDefaultView, "span 2, wrap"); //$NON-NLS-1$

    contentPanel.add(lblTerminalLocation, "alignx left,aligny top"); //$NON-NLS-1$
    contentPanel.add(taScrollPane, "aligny top, spanx 2,wrap"); //$NON-NLS-1$

    JPanel touchConfigurationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 10));
    touchConfigurationPanel.setBorder(BorderFactory.createTitledBorder("-")); //$NON-NLS-1$
    touchConfigurationPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.18"))); //$NON-NLS-1$
    tfButtonHeight = new IntegerTextField(5);
    //touchConfigPanel.add(tfButtonHeight);

    int FPS_MIN = 10;
    int FPS_MAX = 50;
    int FPS_INIT = 10;
    jsResize = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT);
    jsResize.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                double fps = (int) source.getValue();
                fps = fps / 10;
                tfScaleFactor.setText(String.valueOf(fps));
            }
        }
    });
    touchConfigurationPanel.add(jsResize);

    //touchConfigPanel.add(new JLabel("Menu item button height"));
    tfScaleFactor = new DoubleTextField(5);
    touchConfigurationPanel.add(tfScaleFactor);

    //touchConfigPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.20"))); //$NON-NLS-1$
    tfFontSize = new IntegerTextField(5);
    //touchConfigPanel.add(tfFontSize);

    contentPanel.add(touchConfigurationPanel, "span 3, wrap"); //$NON-NLS-1$

    addCashDrawerConfig();

    JScrollPane scrollPane = new JScrollPane(contentPanel);
    scrollPane.setBorder(null);
    add(scrollPane);
}

From source file:net.sf.jabref.gui.groups.GroupSelector.java

/**
 * The first element for each group defines which field to use for the quicksearch. The next two define the name and
 * regexp for the group./*  w  w  w . j a  va  2s .c  o m*/
 */
public GroupSelector(JabRefFrame frame, SidePaneManager manager) {
    super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups"));

    this.frame = frame;
    hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"),
            !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"),
            Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    ButtonGroup nonHits = new ButtonGroup();
    nonHits.add(hideNonHits);
    nonHits.add(grayOut);
    floatCb.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected()));
    andCb.addChangeListener(event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS,
            andCb.isSelected()));
    invCb.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected()));
    showOverlappingGroups.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING,
                    showOverlappingGroups.isSelected());
            if (!showOverlappingGroups.isSelected()) {
                groupsTree.setOverlappingGroups(Collections.emptyList());
            }
        }
    });

    grayOut.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected()));

    JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) {

        floatCb.setSelected(true);
        highlCb.setSelected(false);
    } else {
        highlCb.setSelected(true);
        floatCb.setSelected(false);
    }
    JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) {
        andCb.setSelected(true);
        orCb.setSelected(false);
    } else {
        orCb.setSelected(true);
        andCb.setSelected(false);
    }

    showNumberOfElements.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS,
                    showNumberOfElements.isSelected());
            if (groupsTree != null) {
                groupsTree.invalidate();
                groupsTree.repaint();
            }
        }
    });

    autoAssignGroup.addChangeListener(event -> Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP,
            autoAssignGroup.isSelected()));

    invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS));
    showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING));
    editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE);
    editModeCb.setSelected(editModeIndicator);
    showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
    autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));

    JButton openSettings = new JButton(IconTheme.JabRefIcon.PREFERENCES.getSmallIcon());
    settings.add(andCb);
    settings.add(orCb);
    settings.addSeparator();
    settings.add(invCb);
    settings.addSeparator();
    settings.add(editModeCb);
    settings.addSeparator();
    settings.add(grayOut);
    settings.add(hideNonHits);
    settings.addSeparator();
    settings.add(showOverlappingGroups);
    settings.addSeparator();
    settings.add(showNumberOfElements);
    settings.add(autoAssignGroup);
    openSettings.addActionListener(e -> {
        if (!settings.isVisible()) {
            JButton src = (JButton) e.getSource();
            showNumberOfElements
                    .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
            autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
            settings.show(src, 0, openSettings.getHeight());
        }
    });

    editModeCb.addActionListener(e -> setEditMode(editModeCb.getState()));

    JButton newButton = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon());
    int butSize = newButton.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);

    newButton.setPreferredSize(butDim);
    newButton.setMinimumSize(butDim);
    JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFile.GROUP).getHelpButton();
    helpButton.setPreferredSize(butDim);
    helpButton.setMinimumSize(butDim);
    JButton autoGroup = new JButton(IconTheme.JabRefIcon.AUTO_GROUP.getSmallIcon());
    autoGroup.setPreferredSize(butDim);
    autoGroup.setMinimumSize(butDim);
    openSettings.setPreferredSize(butDim);
    openSettings.setMinimumSize(butDim);
    Insets butIns = new Insets(0, 0, 0, 0);
    helpButton.setMargin(butIns);
    openSettings.setMargin(butIns);
    newButton.addActionListener(e -> {
        GroupDialog gd = new GroupDialog(frame, panel, null);
        gd.setVisible(true);
        if (gd.okPressed()) {
            AbstractGroup newGroup = gd.getResultingGroup();
            groupsRoot.addNewGroup(newGroup, panel.getUndoManager());
            panel.markBaseChanged();
            frame.output(Localization.lang("Created group \"%0\".", newGroup.getName()));
        }
    });
    andCb.addActionListener(e -> valueChanged(null));
    orCb.addActionListener(e -> valueChanged(null));
    invCb.addActionListener(e -> valueChanged(null));
    showOverlappingGroups.addActionListener(e -> valueChanged(null));
    autoGroup.addActionListener(e -> {
        AutoGroupDialog gd = new AutoGroupDialog(frame, panel, groupsRoot,
                Globals.prefs.get(JabRefPreferences.GROUPS_DEFAULT_FIELD), " .,",
                Globals.prefs.get(JabRefPreferences.KEYWORD_SEPARATOR));
        gd.setVisible(true);
        // gd does the operation itself
    });
    floatCb.addActionListener(e -> valueChanged(null));
    highlCb.addActionListener(e -> valueChanged(null));
    hideNonHits.addActionListener(e -> valueChanged(null));
    grayOut.addActionListener(e -> valueChanged(null));
    newButton.setToolTipText(Localization.lang("New group"));
    andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups."));
    orCb.setToolTipText(
            Localization.lang("Display all entries belonging to one or more of the selected groups."));
    autoGroup.setToolTipText(Localization.lang("Automatically create groups for database."));
    openSettings.setToolTipText(Localization.lang("Settings"));
    invCb.setToolTipText(
            "<html>" + Localization.lang("Show entries <b>not</b> in group selection") + "</html>");
    showOverlappingGroups.setToolTipText(Localization
            .lang("Highlight groups that contain entries contained in any currently selected group"));
    floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top"));
    highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection"));
    editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries"));
    ButtonGroup bgr = new ButtonGroup();
    bgr.add(andCb);
    bgr.add(orCb);
    ButtonGroup visMode = new ButtonGroup();
    visMode.add(floatCb);
    visMode.add(highlCb);

    JPanel rootPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    rootPanel.setLayout(gbl);

    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.BOTH;
    con.weightx = 1;
    con.gridwidth = 1;
    con.gridy = 0;

    con.gridx = 0;
    gbl.setConstraints(newButton, con);
    rootPanel.add(newButton);

    con.gridx = 1;
    gbl.setConstraints(autoGroup, con);
    rootPanel.add(autoGroup);

    con.gridx = 2;
    gbl.setConstraints(openSettings, con);
    rootPanel.add(openSettings);

    con.gridx = 3;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(helpButton, con);
    rootPanel.add(helpButton);

    groupsTree = new GroupsTree(this);
    groupsTree.addTreeSelectionListener(this);

    JScrollPane groupsTreePane = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    groupsTreePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weighty = 1;
    con.gridx = 0;
    con.gridwidth = 4;
    con.gridy = 1;
    gbl.setConstraints(groupsTreePane, con);
    rootPanel.add(groupsTreePane);

    add(rootPanel, BorderLayout.CENTER);
    setEditMode(editModeIndicator);
    definePopup();
    NodeAction moveNodeUpAction = new MoveNodeUpAction();
    moveNodeUpAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK));
    NodeAction moveNodeDownAction = new MoveNodeDownAction();
    moveNodeDownAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK));
    NodeAction moveNodeLeftAction = new MoveNodeLeftAction();
    moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK));
    NodeAction moveNodeRightAction = new MoveNodeRightAction();
    moveNodeRightAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK));

    setGroups(GroupTreeNode.fromGroup(new AllEntriesGroup()));
}

From source file:com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.java

public AbstractPieChartPlotter(final PlotterConfigurationModel settings) {
    super(settings);
    setBackground(Color.white);//from  ww  w .  j a  va 2 s  .  c  om
    useDistinct = new ListeningJCheckBox("_" + PARAMETERS_USE_DISTINCT, "Use Only Distinct", false);
    useDistinct.setToolTipText("Indicates if only distinct values should be used for aggregation functions.");
    useDistinct.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            settings.setParameterAsBoolean(PARAMETERS_USE_DISTINCT, useDistinct.isSelected());
        }
    });

    String[] allFunctions = new String[AbstractAggregationFunction.KNOWN_AGGREGATION_FUNCTION_NAMES.length + 1];
    allFunctions[0] = "none";
    System.arraycopy(AbstractAggregationFunction.KNOWN_AGGREGATION_FUNCTION_NAMES, 0, allFunctions, 1,
            AbstractAggregationFunction.KNOWN_AGGREGATION_FUNCTION_NAMES.length);
    aggregationFunction = new ListeningJComboBox(settings, "_" + PARAMETERS_AGGREGATION, allFunctions);
    aggregationFunction.setToolTipText(
            "Select the type of the aggregation function which should be used for grouped values.");
    aggregationFunction.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            settings.setParameterAsString(PARAMETERS_AGGREGATION,
                    aggregationFunction.getSelectedItem().toString());
        }
    });

    for (int i = 0; i < allFunctions.length; i++) {
        if (allFunctions[i].equals("count")) {
            aggregationFunction.setSelectedIndex(i);
        }
    }

    explodingGroupList = new ExtendedJList(new ExtendedListModel(), 200);
    explodingGroupListSelectionModel = new ListeningListSelectionModel("_" + PARAMETERS_EXPLOSION_GROUPS,
            explodingGroupList);
    explodingGroupList.setSelectionModel(explodingGroupListSelectionModel);
    explodingGroupList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                Object[] values = explodingGroupList.getSelectedValues();
                List<String> list = new LinkedList<String>();
                for (Object object : values) {
                    list.add((String) object);
                }
                String result = ParameterTypeEnumeration.transformEnumeration2String(list);
                settings.setParameterAsString(PARAMETERS_EXPLOSION_GROUPS, result);
            }
        }
    });
    explodingGroupList.setForeground(Color.BLACK);
    explodingGroupList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    explodingGroupList.setBorder(BorderFactory.createLoweredBevelBorder());
    explodingGroupList.setCellRenderer(new PlotterPanel.LineStyleCellRenderer(this));

    updateGroups();

    explodingSlider = new ListeningJSlider("_" + PARAMETERS_EXPLOSION_AMOUNT, 0, 100, 0);
    explodingSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            settings.setParameterAsInt(PARAMETERS_EXPLOSION_AMOUNT, explodingSlider.getValue());
        }
    });
}

From source file:cimat.tesis.sna.visualization.ClusteringDemo.java

private void setUpView(BufferedReader br) throws IOException {

    Factory<Number> vertexFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }/*  www.j a v a  2s.  com*/
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }
    };

    PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>(
            vertexFactory, edgeFactory);

    final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>();

    pnr.load(br, graph);

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>(
            new FRLayout<Number, Number>(graph));

    vv = new VisualizationViewer<Number, Number>(layout);
    vv.setBackground(Color.white);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() {
        public Paint transform(Number v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:net.sf.jabref.groups.GroupSelector.java

/**
 * The first element for each group defines which field to use for the quicksearch. The next two define the name and
 * regexp for the group.//  w ww .  j  a  v  a 2 s  .c o m
 */
public GroupSelector(JabRefFrame frame, SidePaneManager manager) {
    super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups"));
    this.groupsRoot = new GroupTreeNode(new AllEntriesGroup());

    this.frame = frame;
    hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"),
            !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"),
            Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    ButtonGroup nonHits = new ButtonGroup();
    nonHits.add(hideNonHits);
    nonHits.add(grayOut);
    floatCb.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected());
        }
    });
    andCb.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, andCb.isSelected());
        }
    });
    invCb.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected());
        }
    });
    showOverlappingGroups.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING,
                    showOverlappingGroups.isSelected());
            if (!showOverlappingGroups.isSelected()) {
                groupsTree.setHighlight2Cells(null);
            }
        }
    });

    select.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SELECT_MATCHES, select.isSelected());
        }
    });
    grayOut.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected()));

    JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) {

        floatCb.setSelected(true);
        highlCb.setSelected(false);
    } else {
        highlCb.setSelected(true);
        floatCb.setSelected(false);
    }
    JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) {
        andCb.setSelected(true);
        orCb.setSelected(false);
    } else {
        orCb.setSelected(true);
        andCb.setSelected(false);
    }

    showNumberOfElements.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS,
                    showNumberOfElements.isSelected());
            if (groupsTree != null) {
                groupsTree.invalidate();
                groupsTree.validate();
                groupsTree.repaint();
            }
        }
    });

    autoAssignGroup.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP, autoAssignGroup.isSelected());
        }
    });

    invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS));
    showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING));
    select.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SELECT_MATCHES));
    editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE);
    editModeCb.setSelected(editModeIndicator);
    showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
    autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));

    openset.setMargin(new Insets(0, 0, 0, 0));
    settings.add(andCb);
    settings.add(orCb);
    settings.addSeparator();
    settings.add(invCb);
    settings.addSeparator();
    settings.add(select);
    settings.addSeparator();
    settings.add(editModeCb);
    settings.addSeparator();
    settings.add(grayOut);
    settings.add(hideNonHits);
    settings.addSeparator();
    settings.add(showOverlappingGroups);
    settings.addSeparator();
    settings.add(showNumberOfElements);
    settings.add(autoAssignGroup);
    // settings.add(moreRow);
    // settings.add(lessRow);
    openset.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!settings.isVisible()) {
                JButton src = (JButton) e.getSource();
                showNumberOfElements
                        .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
                autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
                settings.show(src, 0, openset.getHeight());
            }
        }
    });
    JButton expand = new JButton(IconTheme.JabRefIcon.ADD_ROW.getSmallIcon());
    expand.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) + 1;
            groupsTree.setVisibleRowCount(i);
            groupsTree.revalidate();
            groupsTree.repaint();
            GroupSelector.this.revalidate();
            GroupSelector.this.repaint();
            Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i);
            LOGGER.info("Height: " + GroupSelector.this.getHeight() + "; Preferred height: "
                    + GroupSelector.this.getPreferredSize().getHeight());
        }
    });
    JButton reduce = new JButton(IconTheme.JabRefIcon.REMOVE_ROW.getSmallIcon());
    reduce.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) - 1;
            if (i < 1) {
                i = 1;
            }
            groupsTree.setVisibleRowCount(i);
            groupsTree.revalidate();
            groupsTree.repaint();
            GroupSelector.this.revalidate();
            // _panel.sidePaneManager.revalidate();
            GroupSelector.this.repaint();
            Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i);
        }
    });

    editModeCb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            editModeIndicator = editModeCb.getState();
            updateBorder(editModeIndicator);
            Globals.prefs.putBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, editModeIndicator);
        }
    });

    int butSize = newButton.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);
    //Dimension butDimSmall = new Dimension(20, 20);

    newButton.setPreferredSize(butDim);
    newButton.setMinimumSize(butDim);
    refresh.setPreferredSize(butDim);
    refresh.setMinimumSize(butDim);
    JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFiles.groupsHelp)
            .getHelpButton();
    helpButton.setPreferredSize(butDim);
    helpButton.setMinimumSize(butDim);
    autoGroup.setPreferredSize(butDim);
    autoGroup.setMinimumSize(butDim);
    openset.setPreferredSize(butDim);
    openset.setMinimumSize(butDim);
    expand.setPreferredSize(butDim);
    expand.setMinimumSize(butDim);
    reduce.setPreferredSize(butDim);
    reduce.setMinimumSize(butDim);
    Insets butIns = new Insets(0, 0, 0, 0);
    helpButton.setMargin(butIns);
    reduce.setMargin(butIns);
    expand.setMargin(butIns);
    openset.setMargin(butIns);
    newButton.addActionListener(this);
    refresh.addActionListener(this);
    andCb.addActionListener(this);
    orCb.addActionListener(this);
    invCb.addActionListener(this);
    showOverlappingGroups.addActionListener(this);
    autoGroup.addActionListener(this);
    floatCb.addActionListener(this);
    highlCb.addActionListener(this);
    select.addActionListener(this);
    hideNonHits.addActionListener(this);
    grayOut.addActionListener(this);
    newButton.setToolTipText(Localization.lang("New group"));
    refresh.setToolTipText(Localization.lang("Refresh view"));
    andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups."));
    orCb.setToolTipText(
            Localization.lang("Display all entries belonging to one or more of the selected groups."));
    autoGroup.setToolTipText(Localization.lang("Automatically create groups for database."));
    invCb.setToolTipText(Localization.lang("Show entries *not* in group selection"));
    showOverlappingGroups.setToolTipText(Localization
            .lang("Highlight groups that contain entries contained in any currently selected group"));
    floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top"));
    highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection"));
    select.setToolTipText(Localization.lang("Select entries in group selection"));
    expand.setToolTipText(Localization.lang("Show one more row"));
    reduce.setToolTipText(Localization.lang("Show one less rows"));
    editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries"));
    ButtonGroup bgr = new ButtonGroup();
    bgr.add(andCb);
    bgr.add(orCb);
    ButtonGroup visMode = new ButtonGroup();
    visMode.add(floatCb);
    visMode.add(highlCb);

    JPanel main = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    main.setLayout(gbl);

    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.BOTH;
    //con.insets = new Insets(0, 0, 2, 0);
    con.weightx = 1;
    con.gridwidth = 1;
    con.gridx = 0;
    con.gridy = 0;
    //con.insets = new Insets(1, 1, 1, 1);
    gbl.setConstraints(newButton, con);
    main.add(newButton);
    con.gridx = 1;
    gbl.setConstraints(refresh, con);
    main.add(refresh);
    con.gridx = 2;
    gbl.setConstraints(autoGroup, con);
    main.add(autoGroup);
    con.gridx = 3;
    con.gridwidth = GridBagConstraints.REMAINDER;

    gbl.setConstraints(helpButton, con);
    main.add(helpButton);

    // header.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    // helpButton.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    groupsTree = new GroupsTree(this);
    groupsTree.addTreeSelectionListener(this);
    groupsTree.setModel(groupsTreeModel = new DefaultTreeModel(groupsRoot));
    JScrollPane sp = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    revalidateGroups();
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weighty = 1;
    con.gridx = 0;
    con.gridwidth = 4;
    con.gridy = 1;
    gbl.setConstraints(sp, con);
    main.add(sp);

    JPanel pan = new JPanel();
    GridBagLayout gb = new GridBagLayout();
    con.weighty = 0;
    gbl.setConstraints(pan, con);
    pan.setLayout(gb);
    con.insets = new Insets(0, 0, 0, 0);
    con.gridx = 0;
    con.gridy = 0;
    con.weightx = 1;
    con.gridwidth = 4;
    con.fill = GridBagConstraints.HORIZONTAL;
    gb.setConstraints(openset, con);
    pan.add(openset);

    con.gridwidth = 1;
    con.gridx = 4;
    con.gridy = 0;
    gb.setConstraints(expand, con);
    pan.add(expand);

    con.gridx = 5;
    gb.setConstraints(reduce, con);
    pan.add(reduce);

    con.gridwidth = 6;
    con.gridy = 1;
    con.gridx = 0;
    con.fill = GridBagConstraints.HORIZONTAL;

    con.gridy = 2;
    con.gridx = 0;
    con.gridwidth = 4;
    gbl.setConstraints(pan, con);
    main.add(pan);
    main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    add(main, BorderLayout.CENTER);
    updateBorder(editModeIndicator);
    definePopup();
    NodeAction moveNodeUpAction = new MoveNodeUpAction();
    moveNodeUpAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK));
    NodeAction moveNodeDownAction = new MoveNodeDownAction();
    moveNodeDownAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK));
    NodeAction moveNodeLeftAction = new MoveNodeLeftAction();
    moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK));
    NodeAction moveNodeRightAction = new MoveNodeRightAction();
    moveNodeRightAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK));
}

From source file:org.eumetsat.metop.visat.IasiInfoView.java

private ImageInfoEditorModel createImageInfoEditorModel(final IasiLayer layer) {
    final ImageInfo imageInfo = layer.getImageInfo();
    final ImageInfoEditorModel editorModel = new DefaultImageInfoEditorModel(imageInfo);

    final Stx stx = layer.getStx();
    final Scaling scaling = layer.getScaling();

    editorModel.setDisplayProperties("", "", stx, scaling);
    editorModel.addChangeListener(new ChangeListener() {
        @Override/* ww  w . j  a v a 2s  .c  o m*/
        public void stateChanged(ChangeEvent e) {
            layer.regenerate();
        }
    });

    return editorModel;
}

From source file:edu.ku.brc.specify.datamodel.busrules.DeterminationBusRules.java

@Override
public void afterFillForm(final Object dataObj) {
    isBlockingChange = false;/*from w ww.j  av a  2s. com*/
    determination = null;

    if (formViewObj != null && formViewObj.getDataObj() instanceof Determination) {
        determination = (Determination) formViewObj.getDataObj();

        // if determination exists and is new (no key) then set current true if CO has no other dets
        Component currentComp = formViewObj.getControlByName("isCurrent");
        if (determination != null && currentComp != null) {
            if (isNewObject) {
                // It should never be null, but, currently, it does happen.
                // Also, now with Batch ReIdentify is will always be NULL
                if (determination.getCollectionObject() != null) {
                    if (currentComp instanceof ValCheckBox) {
                        if (formViewObj.isCreatingNewObject()) {
                            // Do this instead of setSelected because
                            // this activates the DataChangeListener
                            isBlockingChange = true;
                            ((ValCheckBox) currentComp).doClick();
                            isBlockingChange = false;

                            // Well, if it is already checked then we just checked it to the 'off' state,
                            // so we need to re-check it so it is in the "checked state"
                            // Note: As stated in the comment above the 'doClick' the easiest way to activate
                            // all the change listeners is by simulating a mouse click.
                            // Also keep in mind that the change listener is listening for ActionEvents for the
                            // checkbox instead of ChangeEvents (ChangeEvents cause to many problems).
                            if (!((ValCheckBox) currentComp).isSelected()) {
                                ((ValCheckBox) currentComp).doClick();
                            }

                            Set<Determination> detSet = determination.getCollectionObject().getDeterminations();
                            for (Determination d : detSet) {
                                if (d != determination) {
                                    d.setIsCurrent(false);
                                }
                            }
                        }

                    } else {
                        log.error("IsCurrent not set to true because form control is of unexpected type: "
                                + currentComp.getClass().getName());
                    }
                }
            } else {
                ((ValCheckBox) currentComp).setValue(determination.getIsCurrent(), null);
            }
        }

        Component activeTax = formViewObj.getControlByName("preferredTaxon");
        if (activeTax != null) {
            JTextField activeTaxTF = (JTextField) activeTax;
            activeTaxTF.setFocusable(false);
            if (determination != null && determination.getPreferredTaxon() != null) {
                activeTaxTF.setText(determination.getPreferredTaxon().getFullName());
            } else {
                activeTaxTF.setText("");
            }
        }

        if (formViewObj.getAltView().getMode() != CreationMode.EDIT) {
            // when we're not in edit mode, we don't need to setup any listeners since the user can't change anything
            //log.debug("form is not in edit mode: no special listeners will be attached");
            return;
        }

        Component nameUsageComp = formViewObj.getControlByName("nameUsage");
        if (nameUsageComp instanceof ValComboBox) {
            // XXX this is probably not necessary anymore...
            if (!checkedBlankUsageItem) {
                boolean fnd = false;

                if (nameUsageComp instanceof ValComboBox) {
                    ValComboBox cbx = (ValComboBox) nameUsageComp;
                    if (cbx.getComboBox().getModel() instanceof PickListDBAdapterIFace) {
                        PickListDBAdapterIFace items = (PickListDBAdapterIFace) cbx.getComboBox().getModel();
                        for (PickListItemIFace item : items.getPickList().getItems()) {
                            if (StringUtils.isBlank(item.getValue())) {
                                fnd = true;
                                break;
                            }
                        }
                        if (!fnd) {
                            boolean readOnly = items.getPickList().getReadOnly();
                            if (readOnly) {
                                items.getPickList().setReadOnly(false);
                            }
                            items.addItem("", null);
                            if (readOnly) {
                                items.getPickList().setReadOnly(true);
                            }
                        }
                    }
                }
                checkedBlankUsageItem = true;
            }
            nameUsageComp.setEnabled(true);
        }

        final Component altNameComp = formViewObj.getControlByName("alternateName");
        if (altNameComp != null && determination != null) {
            altNameComp.setEnabled(determination.getTaxon() == null);
        }

        if (currentComp != null && chkbxCL == null) {
            chkbxCL = new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    adjustIsCurrentCheckbox();
                }
            };

            isCurrentCheckbox = (ValCheckBox) currentComp;
            isCurrentCheckbox.addChangeListener(chkbxCL);
        }
    }
    isNewObject = false;
}