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:biomine.bmvis2.pipeline.RepresentiveHighlightOperation.java

public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) {
    final JSlider slider = new JSlider(0, graph.getRootNode().getDescendants().size(), 0);
    slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            numberOfNodes = slider.getValue();
            v.settingsChanged(false);//from   w w w .ja  v  a2 s .co m
        }
    });
    return slider;
}

From source file:brainflow.app.presentation.controls.FileObjectGroupSelector.java

public FileObjectGroupSelector(FileObject root) throws FileSystemException {
    if (root.getType() != FileType.FOLDER) {
        throw new IllegalArgumentException("root file must be a directory");
    }//from   w  w w. j a v a  2 s. c om

    rootFolder = root;
    explorer = new FileExplorer(rootFolder);
    explorer.getJTree().setRootVisible(false);
    explorer.getJTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    setLayout(new BorderLayout());

    Box topPanel = new Box(BoxLayout.X_AXIS);
    topPanel.setBorder(BorderFactory.createEmptyBorder(8, 12, 8, 8));
    topPanel.add(regexLabel);
    topPanel.add(regexField);
    topPanel.add(Box.createHorizontalStrut(4));
    topPanel.add(searchType);
    add(topPanel, BorderLayout.NORTH);

    //JPanel mainPanel = new JPanel();
    //MigLayout layout = new MigLayout("");
    // mainPanel.setLayout(layout);

    //add(regexLabel);
    //add(regexField, "gap left 0, growx");
    //add(findButton, "align right, wrap");

    //add(searchType, "wrap");

    //add(createSplitPane(), "span 3, grow, wrap");
    add(createSplitPane(), BorderLayout.CENTER);

    depthSpinner.setMaximumSize(new Dimension(50, 200));
    depthSpinner.setModel(new SpinnerNumberModel(recursiveDepth, 0, 5, 1));

    JPanel bottomPanel = new JPanel();
    MigLayout layout = new MigLayout("", "[][grow]", "[][]");
    bottomPanel.setLayout(layout);

    //bottomPanel.setBorder(BorderFactory.createEmptyBorder(4,12,8,8));
    bottomPanel.add(new JLabel("Root Folder: "));
    rootField.setEditable(false);
    rootField.setText(root.getName().getBaseName());
    bottomPanel.add(rootField, "wrap, width 150:150:150");
    bottomPanel.add(new JLabel("Search Depth: "), "gap top 8");

    bottomPanel.add(depthSpinner, "width 35:45:55, wrap");
    add(bottomPanel, BorderLayout.SOUTH);

    explorer.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getPath();
            Object[] obj = path.getPath();
            Object lastNode = obj[obj.length - 1];
            if (lastNode instanceof FileExplorer.FileObjectNode) {
                FileExplorer.FileObjectNode fnode = (FileExplorer.FileObjectNode) lastNode;
                try {
                    if (fnode.getFileObject().getType() == FileType.FOLDER) {
                        rootField.setText(fnode.getFileObject().getName().getBaseName());
                        rootFolder = fnode.getFileObject();
                        updateFileList();
                    }
                } catch (FileSystemException ex) {
                    throw new RuntimeException(ex);
                }

            }
        }
    });

    depthSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            recursiveDepth = ((Number) depthSpinner.getValue()).intValue();

            updateFileList();
        }
    });

    regexField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateFileList();
            System.out.println(Arrays.toString(explorer.getSelectedNodes().toArray()));
        }
    });

}

From source file:de.tor.tribes.ui.views.DSWorkbenchNotepad.java

/** Creates new form DSWorkbenchNotepad */
DSWorkbenchNotepad() {//w  w w  . ja v a 2 s .  com
    initComponents();
    centerPanel = new GenericTestPanel();
    jNotesPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jXNotePanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);

    jNoteTabbedPane.getModel().addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            NoteTableTab activeTab = getActiveTab();
            if (activeTab != null) {
                activeTab.updateSet();
            }
        }
    });

    setGlassPane(jxSearchPane);

    //<editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.notes_view",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    //</editor-fold>

}

From source file:au.org.ala.delta.editor.ui.ActionSetsDialog.java

private void addEventHandlers() {
    runButton.setAction(_actions.get("runDirectiveFile"));
    addButton.setAction(_actions.get("addDirectiveFile"));
    editButton.setAction(_actions.get("editDirectiveFile"));
    deleteButton.setAction(_actions.get("deleteDirectiveFile"));
    doneButton.setAction(_actions.get("doneWithActionSets"));

    JTable[] tables = { conforTable, intkeyTable, distTable, keyTable };
    for (final JTable table : tables) {
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override/*from   w ww . j  a  va2s  . c  o m*/
            public void valueChanged(ListSelectionEvent e) {
                updateAction();
            }
        });

        table.getTableHeader().setReorderingAllowed(false);

    }
    tabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            updateAction();
        }
    });
}

From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatDlg.java

@Override
public void createUI() {
    super.createUI();

    JLabel titleLbl = createLabel(getResourceString("DOF_TITLE") + ":");
    titleText = createTextField(32);/*  ww  w .j a  v a 2  s .  co m*/

    JLabel nameLbl = createLabel(getResourceString("DOF_NAME") + ":");
    nameText = createTextField(32);

    // radio buttons (single/multiple/external object display formats
    JLabel typeLbl = createLabel(getResourceString("DOF_TYPE") + ":");
    singleDisplayBtn = createRadioButton(getResourceString("DOF_SINGLE"));
    multipleDisplayBtn = createRadioButton(getResourceString("DOF_MULTIPLE") + ":");
    singleDisplayBtn.setSelected(true);

    CellConstraints cc = new CellConstraints();

    if (dataObjFormatter.getFormatters().size() == 1) {
        DataObjDataFieldFormatIFace dof = dataObjFormatter.getFormatters().iterator().next();
        if (dof.isCustom()) {
            if (dof.hasEditor()) {
                customEditor = dof.getCustomEditor(new ChangeListener() {
                    @Override
                    public void stateChanged(ChangeEvent e) {
                        setHasChanged(true);
                    }
                });
            } else {
                isEditable = false;
                UIRegistry.showLocalizedMsg("DOF_NO_CST_EDT");
                return;
            }
        }
    }

    if (customEditor == null) {
        ButtonGroup displayTypeGrp = new ButtonGroup();
        displayTypeGrp.add(singleDisplayBtn);
        displayTypeGrp.add(multipleDisplayBtn);
        addDisplayTypeRadioButtonListeners();

        // combo box that lists fields that can be selected when multiple
        // display radio button is selected
        DefaultComboBoxModel cboModel = new DefaultComboBoxModel();
        valueFieldCbo = createComboBox(cboModel);
        addValueFieldsToCombo(null);
        addValueFieldCboAL();

        // little panel to hold multiple display radio button and its combo box
        PanelBuilder multipleDisplayPB = new PanelBuilder(new FormLayout("l:p,f:p:g", "p"));
        multipleDisplayPB.add(multipleDisplayBtn, cc.xy(1, 1));
        multipleDisplayPB.add(valueFieldCbo, cc.xy(2, 1));

        // format editing panels (dependent on the type for format: single/multiple)
        DataObjSwitchFormatterContainerIface formatterContainer = new DataObjSwitchFormatterSingleContainer(
                dataObjFormatter);
        fmtSingleEditingPanel = new DataObjFieldFormatSinglePanel(tableInfo, formatterContainer,
                dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, this, getOkBtn());
        fmtMultipleEditingPanel = new DataObjFieldFormatMultiplePanel(tableInfo, formatterContainer,
                dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, this, getOkBtn());

        // Panel for radio buttons and display formatting editing panel
        PanelBuilder pb = new PanelBuilder(new FormLayout("r:p,4px,f:p:g", "p,2px,p,10px,p,p,10px,f:p:g"));

        int y = 1;
        pb.add(nameLbl, cc.xy(1, y));
        pb.add(nameText, cc.xy(3, y));
        y += 2;

        pb.add(titleLbl, cc.xy(1, y));
        pb.add(titleText, cc.xy(3, y));
        y += 2;

        pb.add(typeLbl, cc.xy(1, y));
        pb.add(singleDisplayBtn, cc.xy(3, y));
        y += 1;
        pb.add(multipleDisplayPB.getPanel(), cc.xy(3, y));
        y += 2;

        // both panels occupy the same space
        pb.add(fmtSingleEditingPanel, cc.xyw(1, y, 3));
        pb.add(fmtMultipleEditingPanel, cc.xyw(1, y, 3));

        pb.setDefaultDialogBorder();

        contentPanel = pb.getPanel();

    } else {
        PanelBuilder pb = new PanelBuilder(new FormLayout("r:p,4px,f:p:g", "p,6px,p,2px,p,4px,p,10px"));

        int y = 1;
        pb.addSeparator(getResourceString("DOF_CST_ED"), cc.xyw(1, y, 3));
        y += 2;

        pb.add(nameLbl, cc.xy(1, y));
        pb.add(nameText, cc.xy(3, y));
        y += 2;

        pb.add(titleLbl, cc.xy(1, y));
        pb.add(titleText, cc.xy(3, y));
        y += 2;

        String labelStr = dataObjFormatter.getFormatters().iterator().next().getLabel();
        if (StringUtils.isNotEmpty(labelStr)) {
            pb.add(UIHelper.createFormLabel(labelStr), cc.xy(1, y));
            pb.add(customEditor, cc.xy(3, y));
            y += 2;

        } else {
            pb.add(customEditor, cc.xyw(1, y, 3));
            y += 2;
        }

        pb.setDefaultDialogBorder();

        contentPanel = pb.getPanel();
    }

    mainPanel.add(contentPanel, BorderLayout.CENTER);

    // after all is created, set initial selection on format list
    fillWithObjFormatter(dataObjFormatter, true);

    // title text field
    DocumentAdaptor nameChangedDL = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent ev) {
            String name = nameText.getText();
            String title = titleText.getText();

            isInError = (StringUtils.isEmpty(name)
                    || dataObjFieldFormatMgrCache.getDataFormatter(name) != null);

            dataObjFormatter.setName(name);
            dataObjFormatter.setTitle(title);

            setHasChanged(true);
        }
    };

    titleText.getDocument().addDocumentListener(nameChangedDL);
    nameText.getDocument().addDocumentListener(nameChangedDL);

    updateUIEnabled();

    packWithLargestPanel();
}

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

private void initGUI() {
    try {/*from w  ww .  j a v  a 2 s  .c o  m*/
        final SwingActionUtil swingUtil = SwingActionUtil.newInstance(this);

        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        this.setTitle("SVN BACKUP");
        this.setPreferredSize(new java.awt.Dimension(734, 442));
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent evt) {
                    swingUtil.invokeAction("jTabbedPane1_changeEvent", evt);
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("src text", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        srcArea = new JTextArea();
                        jScrollPane1.setViewportView(srcArea);
                    }
                }
                {
                    loadSrcTextarea = new JButton();
                    jPanel1.add(loadSrcTextarea, BorderLayout.SOUTH);
                    loadSrcTextarea.setText("load src textarea");
                    loadSrcTextarea.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("loadSrcTextarea.actionPerformed", evt);
                        }
                    });
                }
                {
                    srcBaseDir = new JButton();
                    jPanel1.add(srcBaseDir, BorderLayout.NORTH);
                    srcBaseDir.setText("set src base dir");
                    srcBaseDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("srcBaseDir.actionPerformed", evt);
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("src list", null, jPanel2, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(531, 317));
                    {
                        ListModel srcListModel = new DefaultListModel();
                        srcList = new JList();
                        jScrollPane2.setViewportView(srcList);
                        srcList.setModel(srcListModel);
                        srcList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("srcList.mouseClicked", evt);
                            }
                        });
                        srcList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("srcList.keyPressed", evt);
                            }
                        });
                    }
                }
                {
                    srcListQuery = new JTextField();
                    srcListQuery.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                public void process(DocumentEvent event) {
                                    String scan = JCommonUtil.getDocumentText(event);
                                    DefaultListModel model = new DefaultListModel();
                                    Pattern pat = Pattern.compile(scan);
                                    for (LineParser line : copySrcListForQuerySet) {
                                        if (!line.file.exists()) {
                                            continue;
                                        }
                                        if (line.file.getAbsolutePath().contains(scan)) {
                                            model.addElement(line);
                                            continue;
                                        }
                                        try {
                                            if (pat.matcher(line.file.getAbsolutePath()).find()) {
                                                model.addElement(line);
                                                continue;
                                            }
                                        } catch (Exception ex) {
                                        }
                                    }
                                    srcList.setModel(model);
                                }
                            }));
                    jPanel2.add(srcListQuery, BorderLayout.NORTH);
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("out list", null, jPanel3, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel3.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        ListModel outPutListModel = new DefaultListModel();
                        outPutList = new JList();
                        jScrollPane3.setViewportView(outPutList);
                        outPutList.setModel(outPutListModel);
                        outPutList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("outPutList.mouseClicked", evt);
                            }
                        });
                        outPutList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                swingUtil.invokeAction("outPutList.keyPressed", evt);
                            }
                        });
                    }
                }
                {
                    outPutDir = new JButton();
                    jPanel3.add(outPutDir, BorderLayout.NORTH);
                    outPutDir.setText("set output dir");
                    outPutDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("outPutDir.actionPerformed", evt);
                        }
                    });
                }
                {
                    execute = new JButton();
                    jPanel3.add(execute, BorderLayout.SOUTH);
                    execute.setText("execute backup");
                    execute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            swingUtil.invokeAction("execute.actionPerformed", evt);
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("compre", null, jPanel4, null);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel4.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(713, 339));
                    {
                        TableModel compareTableModel = new DefaultTableModel();
                        compareTable = new JTable();
                        jScrollPane4.setViewportView(compareTable);
                        compareTable.setModel(compareTableModel);
                        JTableUtil.defaultSetting(compareTable);
                        compareTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                swingUtil.invokeAction("compareTable.mouseClicked", evt);
                            }
                        });
                    }
                }
                {
                    jPanel5 = new JPanel();
                    jPanel4.add(jPanel5, BorderLayout.NORTH);
                    jPanel5.setPreferredSize(new java.awt.Dimension(713, 42));
                    {
                        openExternalSrcFolder = new JButton();
                        jPanel5.add(openExternalSrcFolder);
                        openExternalSrcFolder.setText("open external src folder");
                        openExternalSrcFolder.setPreferredSize(new java.awt.Dimension(280, 29));
                        openExternalSrcFolder.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("openExternalSrcFolder.actionPerformed", evt);
                            }
                        });
                    }
                    {
                        startCompareMatch = new JButton();
                        jPanel5.add(startCompareMatch);
                        startCompareMatch.setText("start compare source");
                        startCompareMatch.setPreferredSize(new java.awt.Dimension(280, 29));
                        startCompareMatch.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                swingUtil.invokeAction("startCompareMatch.actionPerformed", evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel6 = new JPanel();
                GroupLayout jPanel6Layout = new GroupLayout((JComponent) jPanel6);
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("configuration", null, jPanel6, null);
                {
                    DefaultComboBoxModel exportModeComboModel = new DefaultComboBoxModel();
                    for (ParseMode mode : ParseMode.values()) {
                        exportModeComboModel.addElement(mode);
                    }
                    exportModeCombo = new JComboBox();
                    exportModeCombo.setModel(exportModeComboModel);
                }
                jPanel6Layout.setHorizontalGroup(jPanel6Layout
                        .createSequentialGroup().addContainerGap(41, 41).addComponent(exportModeCombo,
                                GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(505, Short.MAX_VALUE));
                jPanel6Layout
                        .setVerticalGroup(jPanel6Layout.createSequentialGroup().addContainerGap(30, 30)
                                .addComponent(exportModeCombo, GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(321, Short.MAX_VALUE));
            }
            {
                jPanel7 = new JPanel();
                BorderLayout jPanel7Layout = new BorderLayout();
                jPanel7.setLayout(jPanel7Layout);
                jTabbedPane1.addTab("error log", null, jPanel7, null);
                {
                    jScrollPane5 = new JScrollPane();
                    jPanel7.add(jScrollPane5, BorderLayout.CENTER);
                    {
                        DefaultListModel errorLogListModel = new DefaultListModel();
                        errorLogList = new JList();
                        jScrollPane5.setViewportView(errorLogList);
                        errorLogList.setModel(errorLogListModel);
                    }
                }
            }
        }
        this.setSize(734, 442);

        swingUtil.addAction("openExternalSrcFolder.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (dir == null) {
                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("file is not correct!",
                            "ERROR");
                    return;
                }
                externalDir = dir;
            }
        });
        swingUtil.addAction("startCompareMatch.actionPerformed", new Action() {

            public void action(EventObject evt) throws Exception {
                Validate.notNull(manualBaseDir, "source folder not set!!");
                Validate.notNull(externalDir, "external folder not set!!");
                Validate.isTrue(!manualBaseDir.equals(externalDir), "source dir : " + manualBaseDir
                        + "\nexternal dir : " + externalDir + "\n cant be the same!!");

                List<File> externalSrcFolderList = new ArrayList<File>();
                FileUtil.searchFileMatchs(externalDir, ".*", externalSrcFolderList);
                System.out.println("externalSrcFolderList = " + externalSrcFolderList.size());

                List<File> manualBaseSourceList = new ArrayList<File>();
                FileUtil.searchFileMatchs(manualBaseDir, ".*", manualBaseSourceList);
                System.out.println("manualBaseSourceList = " + manualBaseSourceList.size());

                String cutExternalPath = FileUtil.exportReceiveBaseDir(externalSrcFolderList).getAbsolutePath();
                System.out.println("cutExternalPath = " + cutExternalPath);
                int cutExternalLength = cutExternalPath.length();

                List<CompareFile> _compareList = new ArrayList<CompareFile>();
                CompareFile compare = null;
                File mostCloseFile = null;
                List<File> searchMatchSrcList = new ArrayList<File>();
                for (File external : externalSrcFolderList) {
                    compare = new CompareFile();
                    compare.external = external;

                    searchMatchSrcList.clear();
                    mostCloseFile = new File(manualBaseDir,
                            external.getAbsolutePath().substring(cutExternalLength));
                    System.out.println(mostCloseFile.exists() + " == close file : " + mostCloseFile);
                    if (mostCloseFile.exists()) {
                        searchMatchSrcList.add(mostCloseFile);
                    } else {
                        for (File src : manualBaseSourceList) {
                            if (src.getName().equalsIgnoreCase(external.getName())) {
                                searchMatchSrcList.add(src);
                            }
                        }
                    }

                    System.out.println(external.getName() + " => match source : " + searchMatchSrcList.size());
                    compare.srcSet = new HashSet<File>(searchMatchSrcList);
                    _compareList.add(compare);
                }
                compareList = _compareList;
                reloadCompareTable();
            }
        });
        swingUtil.addAction("compareTable.mouseClicked", new Action() {
            String tortoiseMergeFormat = "cmd /c call TortoiseMerge /base:\"%s\" /theirs:\"%s\"";
            String openFileFormat = "cmd /c call \"%s\"";

            void openFile(File file) {
                String command = String.format(openFileFormat, file);
                System.out.println(command);
                try {
                    ProcessWatcher.newInstance(Runtime.getRuntime().exec(command)).getStreamSync();
                    System.out.println("do reload...");
                    reloadCompareTable();
                } catch (IOException e1) {
                    JCommonUtil.handleException(e1);
                }
            }

            public void action(EventObject evt) throws Exception {
                MouseEvent event = (MouseEvent) evt;

                int rowPos = JTableUtil.newInstance(compareTable).getSelectedRow();
                final File external = (File) JTableUtil.newInstance(compareTable).getModel().getValueAt(rowPos,
                        CompareTableIndex.EXTERNAL_FILE.pos);
                final File srcFile = (File) JTableUtil.newInstance(compareTable).getModel().getValueAt(rowPos,
                        CompareTableIndex.SOURCE_FILE.pos);

                System.out.println("external : " + external);
                System.out.println("srcFile : " + srcFile);

                if (JMouseEventUtil.buttonLeftClick(2, event)) {
                    String command = String.format(tortoiseMergeFormat, external, srcFile);
                    System.out.println(command);
                    Runtime.getRuntime().exec(command);
                }
                if (JMouseEventUtil.buttonRightClick(1, event)) {
                    JMenuItem showInfoMenu = new JMenuItem();
                    showInfoMenu.setText("information");
                    showInfoMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(//
                                    "source file : \n" + srcFile + "\n"
                                            + DateFormatUtils.format(srcFile.lastModified(),
                                                    "yyyy/MM/dd HH:mm:ss")
                                            + "\n" + "size : " + srcFile.length() / 1024 + "\n\n"
                                            + "external file : \n" + external + "\n"
                                            + DateFormatUtils.format(external.lastModified(),
                                                    "yyyy/MM/dd HH:mm:ss")
                                            + "\n" + "size : " + external.length() / 1024,
                                    "INFORMATION");
                        }
                    });
                    JMenuItem openFileMenu = new JMenuItem();
                    openFileMenu.setText("OPEN : source");
                    openFileMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            openFile(srcFile);
                        }
                    });
                    JMenuItem openExternalMenu = new JMenuItem();
                    openExternalMenu.setText("OPEN : external");
                    openExternalMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            openFile(external);
                        }
                    });
                    JMenuItem openPairlMenu = new JMenuItem();
                    openPairlMenu.setText("OPEN : all");
                    openPairlMenu.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            openFile(srcFile);
                            openFile(external);
                        }
                    });

                    JPopupMenuUtil.newInstance(compareTable).applyEvent(event)
                            .addJMenuItem(showInfoMenu, openFileMenu, openExternalMenu, openPairlMenu).show();
                }
            }
        });
        swingUtil.addAction("loadSrcTextarea.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                loadSrcTextarea();
            }
        });
        swingUtil.addAction("srcList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                    JPopupMenuUtil.newInstance(srcList).applyEvent(evt)
                            .addJMenuItem("mark svn delete", new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil
                                            .newInstance().confirmButtonYesNo().showConfirmDialog(
                                                    "are you sure, mark delete file : "
                                                            + srcList.getSelectedValues().length,
                                                    "SVN DELETE")) {
                                        return;
                                    }
                                    StringBuilder sb = new StringBuilder();
                                    Process process = null;
                                    InputStream in = null;
                                    for (Object obj : srcList.getSelectedValues()) {
                                        LineParser l = (LineParser) obj;
                                        String command = String.format("svn delete \"%s\"", l.file);
                                        System.out.println(command);
                                        try {
                                            process = Runtime.getRuntime().exec(command);
                                            in = process.getInputStream();
                                            for (; in.read() != -1;)
                                                ;
                                            if (l.file.exists()) {
                                                sb.append(l.file.getName() + "\n");
                                            }
                                        } catch (IOException e1) {
                                            e1.printStackTrace();
                                            sb.append(l.file.getName() + "\n");
                                        }
                                    }
                                    if (sb.length() > 0) {
                                        JOptionPaneUtil.newInstance().iconErrorMessage()
                                                .showMessageDialog("error : \n" + sb, "ERROR");
                                    } else {
                                        JOptionPaneUtil.newInstance().iconInformationMessage()
                                                .showMessageDialog("mark delete completed!!", "SUCCESS");
                                    }
                                    DefaultListModel model = (DefaultListModel) srcList.getModel();
                                    for (int ii = 0; ii < model.getSize(); ii++) {
                                        LineParser l = (LineParser) model.getElementAt(ii);
                                        if (!l.file.exists()) {
                                            model.remove(ii);
                                            ii--;
                                        }
                                    }
                                }
                            }).show();
                }

                if (!JListUtil.newInstance(srcList).isCorrectMouseClick(evt)) {
                    return;
                }
                LineParser lineParser = (LineParser) JListUtil.getLeadSelectionObject(srcList);
                if (lineParser == null) {
                    return;
                }
                Runtime.getRuntime().exec("cmd /c call \"" + lineParser.file + "\"");
            }
        });
        swingUtil.addAction("srcList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(srcList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("outPutList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                if (!JListUtil.newInstance(outPutList).isCorrectMouseClick(evt)) {
                    return;
                }
            }
        });
        swingUtil.addAction("outPutList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                JListUtil.newInstance(outPutList).defaultJListKeyPressed(evt);
            }
        });
        swingUtil.addAction("outPutDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (dir == null) {
                    outputDir = DEFAULT_OUTPUT_DIR;
                } else {
                    outputDir = dir;
                }
                reflushOutputList();
            }
        });
        swingUtil.addAction("srcBaseDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File dir = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                Validate.notNull(dir, "src base directory is not correct!");
                manualBaseDir = dir;
            }
        });
        swingUtil.addAction("execute.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) outPutList.getModel();
                for (int ii = 0; ii < model.size(); ii++) {
                    OutputFile file = (OutputFile) model.getElementAt(ii);
                    if (!file.destFile.getParentFile().exists()) {
                        file.destFile.getParentFile().mkdirs();
                    }
                    FileUtil.copyFile(file.srcFile, file.destFile);
                }
                JOptionPaneUtil.newInstance().iconInformationMessage()
                        .showMessageDialog("copy success!!\nsize = " + model.getSize(), getTitle());
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.owasp.webscarab.plugin.sessionid.swing.SessionIDPanel.java

/** Creates new form SessionIDPanel */
public SessionIDPanel(SessionIDAnalysis sa) {
    _sa = sa;//from w  ww.j a v  a 2  s.  c  o m
    _model = _sa.getModel();

    initComponents();

    mainTabbedPane.getModel().addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            mainTabbedPaneStateChanged(e);
        }
    });
    _requestPanel = new RequestPanel();
    _requestPanel.setBorder(new TitledBorder("Request"));
    _requestPanel.setEditable(true);
    _requestPanel.setRequest(null);

    _responsePanel = new ResponsePanel();
    _responsePanel.setBorder(new TitledBorder("Response"));

    conversationSplitPane.setTopComponent(_requestPanel);
    conversationSplitPane.setBottomComponent(_responsePanel);

    _sessionIDNames.clear();
    for (int i = 0; i < _model.getSessionIDNameCount(); i++) {
        _sessionIDNames.addElement(_model.getSessionIDName(i));
    }

    requestComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object o = requestComboBox.getSelectedItem();
            if (o instanceof ConversationID) {
                ConversationID id = (ConversationID) o;
                Request r = _model.getRequest(id);
                _requestPanel.setEditable(true);
                _requestPanel.setRequest(r);
                _responsePanel.setEditable(false);
                _responsePanel.setResponse(null);
            }
        }
    });

    _tableModel = new SessionIDTableModel();
    _sidd = new SessionIDDataset();

    _sidd.fireDatasetChanged();
    _tableModel.fireTableDataChanged();

    nameComboBox.setModel(new ListComboBoxModel(_sessionIDNames));
    _model.addModelListener(this);

    idTable.setModel(new TableSorter(_tableModel, idTable.getTableHeader()));
    idTable.setDefaultRenderer(Date.class, new DateRenderer());

    _conversationList = new ConversationListModel(_model.getConversationModel());
    requestComboBox.setModel(new ListComboBoxModel(_conversationList));
    requestComboBox.setRenderer(new ConversationRenderer(_model.getConversationModel()));
    createColumns();
}

From source file:Transfer.java

public Transfer() {

    // Establish the GUI
    Container cp = new Box(BoxLayout.X_AXIS);
    setContentPane(cp);/* ww  w  .j av  a 2s. c o m*/
    JPanel firstPanel = new JPanel();
    propertyComboBox = new JComboBox();
    propertyComboBox.addItem("text");
    propertyComboBox.addItem("font");
    propertyComboBox.addItem("background");
    propertyComboBox.addItem("foreground");
    firstPanel.add(propertyComboBox);
    cp.add(firstPanel);
    cp.add(Box.createGlue());

    tf = new JTextField("Hello");
    tf.setForeground(Color.RED);
    tf.setDragEnabled(true);
    cp.add(tf);

    cp.add(Box.createGlue());

    l = new JLabel("Hello");
    l.setBackground(Color.YELLOW);
    cp.add(l);

    cp.add(Box.createGlue());

    JSlider stryder = new JSlider(SwingConstants.VERTICAL);
    stryder.setMinimum(10);
    stryder.setValue(14);
    stryder.setMaximum(72);
    stryder.setMajorTickSpacing(10);
    stryder.setPaintTicks(true);

    cp.add(stryder);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500, 300);

    // Add Listeners and Converters
    setMyTransferHandlers((String) propertyComboBox.getSelectedItem());

    // Mousing in the Label starts a Drag.
    MouseListener myDragListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);
        }
    };
    l.addMouseListener(myDragListener);

    // Selecting in the ComboBox makes that the property that is xfered.
    propertyComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ce) {
            JComboBox bx = (JComboBox) ce.getSource();
            String prop = (String) bx.getSelectedItem();
            setMyTransferHandlers(prop);
        }
    });

    // Typing a word and pressing enter in the TextField tries
    // to set that as the font name.
    tf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            JTextField jtf = (JTextField) evt.getSource();
            String fontName = jtf.getText();
            Font font = new Font(fontName, Font.BOLD, 18);
            tf.setFont(font);
        }
    });

    // Setting the Slider sets that font into the textfield.
    stryder.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JSlider sl = (JSlider) evt.getSource();
            Font oldf = tf.getFont();
            Font newf = oldf.deriveFont((float) sl.getValue());
            tf.setFont(newf);
        }
    });

}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.ClusteringControl.java

public void init() {

    maxCluster = state.growingLayer.getXSize() * state.growingLayer.getYSize();

    spinnerNoCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1));
    spinnerNoCluster.addChangeListener(new ChangeListener() {
        @Override/*  ww w  . ja  v a 2s.c  o m*/
        public void stateChanged(ChangeEvent e) {
            numClusters = (Integer) ((JSpinner) e.getSource()).getValue();
            SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree()
                    .getAllClusteringElements();
            if (m.containsKey(numClusters)) {
                st = m.get(numClusters).sticky;
            } else {
                st = false;
            }
            sticky.setSelected(st);
            redrawClustering();
        }
    });

    JPanel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters");

    sticky.setToolTipText(
            "Marks this number of clusters as sticky for a certain leve; the next set of clusters will have a smaller boundary");
    sticky.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            st = sticky.isSelected();
            SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree()
                    .getAllClusteringElements();
            if (m.containsKey(numClusters)) {
                ClusterElementsStorage c = m.get(numClusters);
                c.sticky = st;
                // System.out.println("test");
                // ((ClusterElementsStorageNode)m.get(numClusters)).sticky = st;
                redrawClustering();
            }
        }
    });

    colorCluster = new JCheckBox("colour", state.colorClusters);
    colorCluster.setToolTipText("Fill the clusters in colours");
    colorCluster.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            state.colorClusters = colorCluster.isSelected();
            // TODO: Palette anzeigen (?)
            redrawClustering();
        }
    });

    UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerNoCluster, sticky, colorCluster);
    getContentPane().add(clusterPanel, c.nextRow());

    dendogramPanel = UiUtils.makeBorderedPanel(new GridLayout(0, 1), "Dendogram");
    getContentPane().add(dendogramPanel, c.nextRow());

    JPanel numLabelPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Labels");
    GridBagConstraintsIFS gcLabels = new GridBagConstraintsIFS();

    labelSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
    labelSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            numLabels = (Integer) ((JSpinner) e.getSource()).getValue();
            state.clusterWithLabels = numLabels;
            redrawClustering();
        }
    });

    this.showValues = new JCheckBox("values", state.labelsWithValues);
    this.showValues.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            state.labelsWithValues = showValues.isSelected();
            redrawClustering();
        }
    });

    int start = new Double((1 - state.clusterByValue) * 100).intValue();
    valueQe = new JSlider(0, 100, start);
    valueQe.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int byValue = ((JSlider) e.getSource()).getValue();
            state.clusterByValue = 1 - byValue / 100;
            redrawClustering();
        }
    });

    numLabelPanel.add(new JLabel("# Labels"), gcLabels);
    numLabelPanel.add(labelSpinner, gcLabels.nextCol());
    numLabelPanel.add(showValues, gcLabels.nextCol());
    numLabelPanel.add(valueQe, gcLabels.nextRow().setGridWidth(3).setFill(GridBagConstraints.HORIZONTAL));
    getContentPane().add(numLabelPanel, c.nextRow());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
    labelTable.put(0, new JLabel("by Value"));
    labelTable.put(100, new JLabel("by Qe"));
    valueQe.setToolTipText("Method how to select representative labels - by QE, or the attribute values");
    valueQe.setLabelTable(labelTable);
    valueQe.setPaintLabels(true);

    final JComboBox initialisationBox = new JComboBox(KMeans.InitType.values());
    initialisationBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object o = mapPane.getMap().getClusteringTreeBuilder();
            if (o instanceof KMeansTreeBuilder) {
                ((KMeansTreeBuilder) o).reInit((KMeans.InitType) initialisationBox.getSelectedItem());
                // FIXME: is this call needed?
                mapPane.getMap().getCurrentClusteringTree().getAllClusteringElements();
                redrawClustering();
            }
        }
    });

    getContentPane().add(UiUtils.fillPanel(kmeansInitialisationPanel, new JLabel("k-Means initialisation"),
            initialisationBox), c.nextRow());

    JPanel borderPanel = new TitledCollapsiblePanel("Border", new GridLayout(1, 4), true);

    JSpinner borderSpinner = new JSpinner(
            new SpinnerNumberModel(ClusteringTree.INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR, 0.1, 5, 0.1));
    borderSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            state.clusterBorderWidthMagnificationFactor = ((Double) ((JSpinner) e.getSource()).getValue())
                    .floatValue();
            redrawClustering();
        }
    });

    borderPanel.add(new JLabel("width"));
    borderPanel.add(borderSpinner);

    borderPanel.add(new JLabel("colour"));
    buttonColour = new JButton("");
    buttonColour.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new ClusterBoderColorChooser(state.parentFrame, state.clusterBorderColour, ClusteringControl.this);
        }
    });
    buttonColour.setBackground(state.clusterBorderColour);
    borderPanel.add(buttonColour);

    getContentPane().add(borderPanel, c.nextRow());

    JPanel evaluationPanel = new TitledCollapsiblePanel("Cluster Evaluation", new GridLayout(3, 2), true);

    evaluationPanel.add(new JLabel("quality measure"));
    qualityMeasureButton = new JButton();
    qualityMeasureButton.setText("ent/pur calc");
    qualityMeasureButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("doing entropy here");
            ClusteringTree clusteringTree = state.mapPNode.getClusteringTree();
            if (clusteringTree == null) {
                // we have not clustered yet
                return;
            }
            // System.out.println(clusteringTree.getChildrenCount());

            // FIXME put this in a method and call it on numcluster.change()
            SOMLibClassInformation classInfo = state.inputDataObjects.getClassInfo();
            ArrayList<ClusterNode> clusters = clusteringTree.getNodesAtLevel(numClusters);
            System.out.println(clusters.size());
            // EntropyMeasure.computeEntropy(clusters, classInfo);
            EntropyAndPurityCalculator eapc = new EntropyAndPurityCalculator(clusters, classInfo);
            // FIXME round first
            entropyLabel.setText(String.valueOf(eapc.getEntropy()));
            purityLabel.setText(String.valueOf(eapc.getPurity()));

        }
    });
    evaluationPanel.add(qualityMeasureButton);
    GridBagConstraintsIFS gcEval = new GridBagConstraintsIFS();

    evaluationPanel.add(new JLabel("entropy"), gcEval);
    evaluationPanel.add(new JLabel("purity"), gcEval.nextCol());

    entropyLabel = new JLabel("n/a");
    purityLabel = new JLabel("n/a");

    evaluationPanel.add(entropyLabel, gcEval.nextRow());
    evaluationPanel.add(purityLabel, gcEval.nextCol());

    getContentPane().add(evaluationPanel, c.nextRow());

    JPanel panelButtons = new JPanel(new GridLayout(1, 4));

    JButton saveButton = new JButton("Save");
    saveButton.setFont(smallFont);
    saveButton.setMargin(SMALL_INSETS);
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser;
            if (state.fileChooser.getSelectedFile() != null) {
                fileChooser = new JFileChooser(state.fileChooser.getSelectedFile().getPath());
            } else {
                fileChooser = new JFileChooser();
            }
            fileChooser.addChoosableFileFilter(clusteringFilter);
            fileChooser.addChoosableFileFilter(xmlFilter);

            File filePath = ExportUtils.getFilePath(ClusteringControl.this, fileChooser,
                    "Save Clustering and Labels");

            if (filePath != null) {
                if (xmlFilter.accept(filePath)) {
                    LabelXmlUtils.saveLabelsToFile(state.mapPNode, filePath);
                } else {
                    try {
                        FileOutputStream fos = new FileOutputStream(filePath);
                        GZIPOutputStream gzipOs = new GZIPOutputStream(fos);
                        PObjectOutputStream oos = new PObjectOutputStream(gzipOs);

                        oos.writeObjectTree(mapPane.getMap().getCurrentClusteringTree());
                        oos.writeObjectTree(mapPane.getMap().getManualLabels());
                        oos.writeInt(state.clusterWithLabels);
                        oos.writeBoolean(state.labelsWithValues);
                        oos.writeDouble(state.clusterByValue);
                        oos.writeObject(spinnerNoCluster.getValue());

                        oos.close();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                // keep the selected path for future references
                state.fileChooser.setSelectedFile(filePath.getParentFile());
            }
        }
    });
    panelButtons.add(saveButton);

    JButton loadButton = new JButton("Load");
    loadButton.setFont(smallFont);
    loadButton.setMargin(SMALL_INSETS);
    loadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = getFileChooser();
            fileChooser.setName("Open Clustering");
            fileChooser.addChoosableFileFilter(xmlFilter);
            fileChooser.addChoosableFileFilter(clusteringFilter);

            int returnVal = fileChooser.showDialog(ClusteringControl.this, "Open");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File filePath = fileChooser.getSelectedFile();
                if (xmlFilter.accept(filePath)) {
                    PNode restoredLabels = null;
                    try {
                        restoredLabels = LabelXmlUtils.restoreLabelsFromFile(fileChooser.getSelectedFile());
                        PNode manual = state.mapPNode.getManualLabels();

                        ArrayList<PNode> tmp = new ArrayList<PNode>();
                        for (ListIterator<?> iter = restoredLabels.getChildrenIterator(); iter.hasNext();) {
                            PNode element = (PNode) iter.next();
                            tmp.add(element);
                        }
                        manual.addChildren(tmp);
                        Logger.getLogger("at.tuwien.ifs.somtoolbox")
                                .info("Successfully loaded cluster labels.");
                    } catch (Exception e1) {
                        e1.printStackTrace();
                        Logger.getLogger("at.tuwien.ifs.somtoolbox")
                                .info("Error loading cluster labels: " + e1.getMessage());
                    }

                } else {

                    try {
                        FileInputStream fis = new FileInputStream(filePath);
                        GZIPInputStream gzipIs = new GZIPInputStream(fis);
                        ObjectInputStream ois = new ObjectInputStream(gzipIs);
                        ClusteringTree tree = (ClusteringTree) ois.readObject();

                        PNode manual = (PNode) ois.readObject();
                        PNode all = mapPane.getMap().getManualLabels();
                        ArrayList<PNode> tmp = new ArrayList<PNode>();
                        for (ListIterator<?> iter = manual.getChildrenIterator(); iter.hasNext();) {
                            PNode element = (PNode) iter.next();
                            tmp.add(element);
                        }
                        all.addChildren(tmp);

                        state.clusterWithLabels = ois.readInt();
                        labelSpinner.setValue(state.clusterWithLabels);
                        state.labelsWithValues = ois.readBoolean();
                        showValues.setSelected(state.labelsWithValues);
                        state.clusterByValue = ois.readDouble();
                        valueQe.setValue(new Double((1 - state.clusterByValue) * 100).intValue());

                        mapPane.getMap().buildTree(tree);
                        spinnerNoCluster.setValue(ois.readObject());

                        ois.close();
                        Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Successfully loaded clustering.");
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        Logger.getLogger("at.tuwien.ifs.somtoolbox")
                                .info("Error loading clustering: " + ex.getMessage());
                    }

                }
                // keep the selected path for future references
                state.fileChooser.setSelectedFile(filePath.getParentFile());
            }
        }

    });
    panelButtons.add(loadButton);

    JButton exportImages = new JButton("Export");
    exportImages.setFont(smallFont);
    exportImages.setMargin(SMALL_INSETS);
    exportImages.setToolTipText("Export labels as images (not yet working)");
    exportImages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            if (CommonSOMViewerStateData.fileNamePrefix != null
                    && !CommonSOMViewerStateData.fileNamePrefix.equals("")) {
                fileChooser.setCurrentDirectory(new File(CommonSOMViewerStateData.fileNamePrefix));
            } else {
                fileChooser.setCurrentDirectory(state.getFileChooser().getCurrentDirectory());
            }
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (fileChooser.getSelectedFile() != null) { // reusing the dialog
                fileChooser.setSelectedFile(null);
            }
            fileChooser.setName("Choose path");
            int returnVal = fileChooser.showDialog(ClusteringControl.this, "Choose path");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                // save images
                String path = fileChooser.getSelectedFile().getAbsolutePath();
                Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Writing label images to " + path);
            }
        }
    });
    panelButtons.add(exportImages);

    JButton deleteManual = new JButton("Delete");
    deleteManual.setFont(smallFont);
    deleteManual.setMargin(SMALL_INSETS);
    deleteManual.setToolTipText("Delete manually added labels.");
    deleteManual.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            state.mapPNode.getManualLabels().removeAllChildren();
            Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Manual Labels deleted.");
        }
    });
    panelButtons.add(deleteManual);
    c.anchor = GridBagConstraints.NORTH;
    this.getContentPane().add(panelButtons, c.nextRow());

    this.setVisible(true);
}

From source file:com.diversityarrays.kdxplore.field.PlotIdTrialLayoutPane.java

public PlotIdTrialLayoutPane() {
    super(new BorderLayout());

    /*//from  ww w.  j  av  a  2 s  .  c o  m
     *  *  .--->           <---.
     *  |    (o)      (o)   |
     *  v                   v
     *   (o)             (o)
     *   
     *                            
     *   (o)             (o)
     *  ^                   ^ 
     *  |    (o)      (o)   |
     *  `--->           <---'
     *  
     *  Traversal: (o) 1-w  (o) 2-w
     *  
     *  (above is in odtPanel)
     *  ---------------------------
     *  
     *  Run Length:     [         ]
     *  Origin Plot Id: [         ]
     */

    JPanel top = new JPanel();

    GBH gbh = new GBH(top);
    int y = 0;

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Plot Ids:");
    gbh.add(1, y, 3, 1, GBH.HORZ, 1, 1, GBH.WEST, plotIdentInfo);
    ++y;

    // - - - - - - -

    JPanel bottom = new JPanel();
    GBH rgbh = new GBH(bottom);
    y = 0;

    rgbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Run Length:");
    rgbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, runLengthSpinner);
    ++y;
    rgbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Origin Plot Id:");
    rgbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, plotSpinner);
    ++y;

    // - - - - - - -
    Box main = Box.createVerticalBox();
    main.add(top);
    main.add(withInsets(new JSeparator(JSeparator.HORIZONTAL), new Insets(0, 20, 0, 20)));
    main.add(odtPanel);
    main.add(withInsets(new JSeparator(JSeparator.HORIZONTAL), new Insets(0, 20, 0, 20)));

    main.add(bottom);

    add(main, BorderLayout.CENTER);

    //         crb_ll_right.doClick();

    ChangeListener changeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            if (initialised) {
                firePropertyChange(PROP_LAYOUT_CHANGED, false, true);
            }
        }
    };
    runLengthModel.addChangeListener(changeListener);
    plotIdModel.addChangeListener(changeListener);

    initialised = true;
}