Example usage for javax.swing DefaultListModel DefaultListModel

List of usage examples for javax.swing DefaultListModel DefaultListModel

Introduction

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

Prototype

DefaultListModel

Source Link

Usage

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

private void initGUI() {
    try {/*from w ww  .j  a  v a2s.c om*/
        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:de.tor.tribes.ui.components.GroupSelectionList.java

private void resetModel() {
    HashMap<Tag, ListItem.RELATION_TYPE> storedState = new HashMap<>();
    for (int i = 0; i < getModel().getSize(); i++) {
        ListItem item = getItemAt(i);/*from  w ww  . j a v a 2s. c om*/
        storedState.put(item.getTag(), item.getState());
    }
    DefaultListModel model = new DefaultListModel();

    for (Tag tag : TagUtils.getTags(Tag.CASE_INSENSITIVE_ORDER)) {
        ListItem item = new ListItem(tag);
        if (storedState.get(tag) != null) {
            item.setState(storedState.get(tag));
        }
        model.addElement(item);
    }
    setModel(model);
    checkStateAndRepaint();
}

From source file:au.org.ala.delta.intkey.ui.CharacterSelectionDialog.java

private void init(List<Character> characters, boolean displayNumbering) {
    ResourceMap resourceMap = Application.getInstance().getContext()
            .getResourceMap(CharacterSelectionDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(CharacterSelectionDialog.class,
            this);

    setTitle(MessageFormat.format(title, _directiveName));

    _panelButtons.setBorder(new EmptyBorder(0, 20, 10, 20));
    _panelButtons.setLayout(new GridLayout(0, 5, 5, 5));

    _btnOk = new JButton();
    _btnOk.setAction(actionMap.get("characterSelectionDialog_OK"));
    _panelButtons.add(_btnOk);/*from  w ww. ja  va2  s. c  om*/

    _btnSelectAll = new JButton();
    _btnSelectAll.setAction(actionMap.get("characterSelectionDialog_SelectAll"));
    _panelButtons.add(_btnSelectAll);

    _btnKeywords = new JButton();
    _btnKeywords.setAction(actionMap.get("characterSelectionDialog_Keywords"));
    _panelButtons.add(_btnKeywords);

    _btnImages = new JButton();
    _btnImages.setAction(actionMap.get("characterSelectionDialog_Images"));
    _btnImages.setEnabled(false);
    _panelButtons.add(_btnImages);

    _btnSearch = new JButton();
    _btnSearch.setAction(actionMap.get("characterSelectionDialog_Search"));
    _panelButtons.add(_btnSearch);

    _btnCancel = new JButton();
    _btnCancel.setAction(actionMap.get("characterSelectionDialog_Cancel"));
    _panelButtons.add(_btnCancel);

    _btnDeselectAll = new JButton();
    _btnDeselectAll.setAction(actionMap.get("characterSelectionDialog_DeselectAll"));
    _panelButtons.add(_btnDeselectAll);

    _btnFullText = new JButton();
    _btnFullText.setAction(actionMap.get("characterSelectionDialog_FullText"));
    _panelButtons.add(_btnFullText);

    _btnNotes = new JButton();
    _btnNotes.setAction(actionMap.get("characterSelectionDialog_Notes"));
    _btnNotes.setEnabled(false);
    _panelButtons.add(_btnNotes);

    _btnHelp = new JButton();
    _btnHelp.setAction(actionMap.get("characterSelectionDialog_Help"));
    _panelButtons.add(_btnHelp);

    // Some of the buttons should not be displayed if not in advanced mode
    if (_context.getUI().isAdvancedMode()) {
        _panelButtons.add(_btnOk);
        _panelButtons.add(_btnSelectAll);
        _panelButtons.add(_btnKeywords);
        _panelButtons.add(_btnImages);
        _panelButtons.add(_btnSearch);
        _panelButtons.add(_btnCancel);
        _panelButtons.add(_btnDeselectAll);
        _panelButtons.add(_btnFullText);
        _panelButtons.add(_btnNotes);
        _panelButtons.add(_btnHelp);
    } else {
        _panelButtons.setLayout(new GridLayout(0, 4, 5, 0));
        _panelButtons.add(_btnOk);
        _panelButtons.add(_btnCancel);
        _panelButtons.add(_btnSelectAll);
        _panelButtons.add(_btnDeselectAll);
    }

    _selectedCharacters = null;

    if (characters != null) {
        _listModel = new DefaultListModel();
        for (Character ch : characters) {
            _listModel.addElement(ch);
        }
        _list.setCellRenderer(new CharacterCellRenderer(displayNumbering));
        _list.setModel(_listModel);
    }

    _list.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (_list.getSelectedIndices().length == 1) {
                Character ch = (Character) _list.getSelectedValue();
                _btnImages.setEnabled(ch.getImages().size() > 0);
                _btnFullText.setEnabled(true);
                _btnNotes.setEnabled(StringUtils.isNotBlank(ch.getNotes()));
            } else {
                _btnImages.setEnabled(false);
                _btnFullText.setEnabled(false);
                _btnNotes.setEnabled(false);
            }
        }
    });

    _list.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                // Treat double click on a list item as the ok button being
                // pressed.
                characterSelectionDialog_OK();
            }
        }

    });

    _selectedKeywords = new ArrayList<String>();
}

From source file:FontChooser.java

/** This method is called from within the constructor to
* initialize the form./*from   w  w  w . ja va 2  s .  c  o m*/
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents() {
    jPanel3 = new javax.swing.JPanel();
    jFont = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    jFontList = new javax.swing.JList();
    jPanel4 = new javax.swing.JPanel();
    jStyle = new javax.swing.JTextField();
    jScrollPane2 = new javax.swing.JScrollPane();
    jStyleList = new javax.swing.JList();
    jPanel5 = new javax.swing.JPanel();
    jSize = new javax.swing.JTextField();
    jScrollPane3 = new javax.swing.JScrollPane();
    jSizeList = new javax.swing.JList();
    jPanel1 = new javax.swing.JPanel();
    jScrollPane4 = new javax.swing.JScrollPane();
    jSample = new javax.swing.JTextArea();
    jButtons = new javax.swing.JPanel();
    jOk = new javax.swing.JButton();
    jCancel = new javax.swing.JButton();
    jLabel6 = new javax.swing.JLabel();
    getContentPane().setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints1;
    setTitle("Font Chooser");
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
        }
    });

    jPanel3.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints2;
    jPanel3.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Font "));

    jFont.setColumns(24);
    jFont.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jFontActionPerformed(evt);
        }
    });
    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.gridwidth = 0;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints2.insets = new java.awt.Insets(0, 3, 0, 3);
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints2.weightx = 1.0;
    jPanel3.add(jFont, gridBagConstraints2);

    jFontList.setModel(new DefaultListModel());
    jFontList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jFontList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jFontListValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(jFontList);

    gridBagConstraints2 = new java.awt.GridBagConstraints();
    gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3);
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.weighty = 1.0;
    jPanel3.add(jScrollPane1, gridBagConstraints2);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);
    gridBagConstraints1.weightx = 0.5;
    gridBagConstraints1.weighty = 1.0;
    getContentPane().add(jPanel3, gridBagConstraints1);

    jPanel4.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints3;
    jPanel4.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Style "));

    jStyle.setColumns(18);
    jStyle.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jStyleActionPerformed(evt);
        }
    });
    gridBagConstraints3 = new java.awt.GridBagConstraints();
    gridBagConstraints3.gridwidth = 0;
    gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints3.insets = new java.awt.Insets(0, 3, 0, 3);
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints3.weightx = 1.0;
    jPanel4.add(jStyle, gridBagConstraints3);

    jStyleList.setModel(new DefaultListModel());
    jStyleList.setVisibleRowCount(4);
    jStyleList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jStyleListValueChanged(evt);
        }
    });
    jScrollPane2.setViewportView(jStyleList);

    gridBagConstraints3 = new java.awt.GridBagConstraints();
    gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints3.insets = new java.awt.Insets(3, 3, 3, 3);
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints3.weightx = 0.5;
    gridBagConstraints3.weighty = 1.0;
    jPanel4.add(jScrollPane2, gridBagConstraints3);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);
    gridBagConstraints1.weightx = 0.375;
    gridBagConstraints1.weighty = 1.0;
    getContentPane().add(jPanel4, gridBagConstraints1);

    jPanel5.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints4;
    jPanel5.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Size "));

    jSize.setColumns(6);
    jSize.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jSizeActionPerformed(evt);
        }
    });
    gridBagConstraints4 = new java.awt.GridBagConstraints();
    gridBagConstraints4.gridwidth = 0;
    gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints4.insets = new java.awt.Insets(0, 3, 0, 3);
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints4.weightx = 1.0;
    jPanel5.add(jSize, gridBagConstraints4);

    jSizeList.setModel(new DefaultListModel());
    jSizeList.setVisibleRowCount(4);
    jSizeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jSizeList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jSizeListValueChanged(evt);
        }
    });
    jScrollPane3.setViewportView(jSizeList);

    gridBagConstraints4 = new java.awt.GridBagConstraints();
    gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints4.insets = new java.awt.Insets(3, 3, 3, 3);
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints4.weightx = 0.25;
    gridBagConstraints4.weighty = 1.0;
    jPanel5.add(jScrollPane3, gridBagConstraints4);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.gridwidth = 0;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 5);
    gridBagConstraints1.weightx = 0.125;
    gridBagConstraints1.weighty = 1.0;
    getContentPane().add(jPanel5, gridBagConstraints1);

    jPanel1.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints5;
    jPanel1.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), " Sample "));

    jSample.setWrapStyleWord(true);
    jSample.setLineWrap(true);
    jSample.setColumns(20);
    jSample.setRows(3);
    jSample.setText("The quick brown fox jumped over the lazy dog.");
    jScrollPane4.setViewportView(jSample);

    gridBagConstraints5 = new java.awt.GridBagConstraints();
    gridBagConstraints5.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints5.insets = new java.awt.Insets(0, 3, 3, 3);
    gridBagConstraints5.weightx = 1.0;
    gridBagConstraints5.weighty = 1.0;
    jPanel1.add(jScrollPane4, gridBagConstraints5);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.gridwidth = 0;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.insets = new java.awt.Insets(0, 5, 0, 5);
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints1.weightx = 1.0;
    getContentPane().add(jPanel1, gridBagConstraints1);

    jButtons.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints6;

    jOk.setMnemonic(KeyEvent.VK_O);
    jOk.setText("OK");
    jOk.setRequestFocusEnabled(false);
    jOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jOkActionPerformed(evt);
        }
    });
    gridBagConstraints6 = new java.awt.GridBagConstraints();
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 0);
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;
    jButtons.add(jOk, gridBagConstraints6);

    jCancel.setMnemonic(KeyEvent.VK_C);
    jCancel.setText("Cancel");
    jCancel.setRequestFocusEnabled(false);
    jCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCancelActionPerformed(evt);
        }
    });
    gridBagConstraints6 = new java.awt.GridBagConstraints();
    gridBagConstraints6.gridwidth = 0;
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 5);
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints6.weightx = 1.0;
    jButtons.add(jCancel, gridBagConstraints6);

    gridBagConstraints6 = new java.awt.GridBagConstraints();
    gridBagConstraints6.weightx = 1.0;
    jButtons.add(jLabel6, gridBagConstraints6);

    gridBagConstraints1 = new java.awt.GridBagConstraints();
    gridBagConstraints1.gridwidth = 0;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints1.weightx = 1.0;
    getContentPane().add(jButtons, gridBagConstraints1);
}

From source file:au.org.ala.delta.intkey.ui.TaxonSelectionDialog.java

private void init(List<Item> taxa, boolean displayNumbering, boolean singleSelect,
        boolean includeSpecimenAsOption) {
    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(TaxonSelectionDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(TaxonSelectionDialog.class, this);

    setTitle(MessageFormat.format(title, _directiveName));

    _fullTextTaxonFormatter = new ItemFormatter(true, CommentStrippingMode.RETAIN,
            AngleBracketHandlingMode.REPLACE, true, false, false);

    _panelButtons.setBorder(new EmptyBorder(0, 20, 10, 20));
    _panelButtons.setLayout(new GridLayout(0, 5, 5, 5));

    _btnOk = new JButton();
    _btnOk.setAction(actionMap.get("taxonSelectionDialog_OK"));

    _btnSelectAll = new JButton();
    _btnSelectAll.setAction(actionMap.get("taxonSelectionDialog_SelectAll"));

    _btnKeywords = new JButton();
    _btnKeywords.setAction(actionMap.get("taxonSelectionDialog_Keywords"));

    _btnImages = new JButton();
    _btnImages.setAction(actionMap.get("taxonSelectionDialog_Images"));
    _btnImages.setEnabled(false);/* ww w  .j a  va2  s  .c  om*/

    _btnSearch = new JButton();
    _btnSearch.setAction(actionMap.get("taxonSelectionDialog_Search"));

    _btnCancel = new JButton();
    _btnCancel.setAction(actionMap.get("taxonSelectionDialog_Cancel"));

    _btnDeselectAll = new JButton();
    _btnDeselectAll.setAction(actionMap.get("taxonSelectionDialog_DeselectAll"));

    _btnFullText = new JButton();
    _btnFullText.setAction(actionMap.get("taxonSelectionDialog_FullText"));
    _btnFullText.setEnabled(false);

    _btnHelp = new JButton();
    _btnHelp.setAction(actionMap.get("taxonSelectionDialog_Help"));

    // Some of the buttons should not be displayed if not in advanced mode
    if (_context.getUI().isAdvancedMode()) {
        _panelButtons.add(_btnOk);
        _panelButtons.add(_btnSelectAll);
        _panelButtons.add(_btnKeywords);
        _panelButtons.add(_btnImages);
        _panelButtons.add(_btnSearch);
        _panelButtons.add(_btnCancel);
        _panelButtons.add(_btnDeselectAll);
        _panelButtons.add(_btnFullText);
        _panelButtons.add(_btnHelp);
    } else {
        _panelButtons.setLayout(new GridLayout(0, 4, 5, 0));
        _panelButtons.add(_btnOk);
        _panelButtons.add(_btnCancel);
        _panelButtons.add(_btnSelectAll);
        _panelButtons.add(_btnDeselectAll);
    }

    _selectedTaxa = null;

    _includeSpecimenAsOption = includeSpecimenAsOption;

    if (taxa != null) {
        _listModel = new DefaultListModel();

        if (_includeSpecimenAsOption) {
            _listModel.addElement(IntkeyContext.SPECIMEN_KEYWORD);
        }

        for (Item taxon : taxa) {
            _listModel.addElement(taxon);
        }
        _list.setCellRenderer(new TaxonCellRenderer(displayNumbering, false));
        _list.setModel(_listModel);
    }

    if (singleSelect) {
        _list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    _list.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (_list.getSelectedIndices().length == 1
                    && !_list.getSelectedValue().equals(IntkeyContext.SPECIMEN_KEYWORD)) {
                Item taxon = (Item) _list.getSelectedValue();
                _btnImages.setEnabled(taxon.getImages().size() > 0);
                _btnFullText.setEnabled(true);
            } else {
                _btnImages.setEnabled(false);
                _btnFullText.setEnabled(false);
            }
        }
    });

    _list.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                // Treat double click on a list item as the ok button being
                // pressed.
                taxonSelectionDialog_OK();
            }
        }

    });

    _selectedKeywords = new ArrayList<String>();
}

From source file:edu.ku.brc.specify.tasks.subpane.VisualQueryPanel.java

/**
 * Creates the UI./*from www  .  j a  v a2  s  .  c  om*/
 */
protected void createUI() {
    CellConstraints cc = new CellConstraints();

    lineLayer = new RenderableLayer();

    upBtn = UIHelper.createIconBtn("Green Arrow Up", "", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            moveItems(recSetList, botIdHash, dbObjList, topIdHash);
        }
    });

    dwnBtn = UIHelper.createIconBtn("Green Arrow Down", "", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            moveItems(dbObjList, topIdHash, recSetList, botIdHash);

            boolean hasItems = recSetList.getModel().getSize() > 0;
            rsBtn.setEnabled(hasItems);
            fmBtn.setEnabled(hasItems);

        }
    });

    selectAllBtn = UIHelper.createI18NButton("SELECTALL");
    selectAllBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dbObjList.clearSelection();
            dbObjList.getSelectionModel().setSelectionInterval(0, dbObjList.getModel().getSize());
        }
    });
    deselectAllBtn = UIHelper.createI18NButton("DESELECTALL");
    deselectAllBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dbObjList.clearSelection();
        }
    });

    PanelBuilder upDwnPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,10px,p,f:p:g,p,f:p:g", "p"));
    //upDwnPB.add(selectAllBtn,   cc.xy(2,1));
    upDwnPB.add(dwnBtn, cc.xy(4, 1));
    upDwnPB.add(upBtn, cc.xy(6, 1));
    //upDwnPB.add(deselectAllBtn, cc.xy(7,1));

    dbObjList = new JList(new DefaultListModel());
    dbObjList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //wpList.setCellRenderer(new WPListCellRenderer());
    dbObjList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            upBtn.setEnabled(false);
            dwnBtn.setEnabled(dbObjList.getSelectedIndex() != -1);
        }
    });

    recSetList = new JList(new DefaultListModel());
    recSetList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //trkList.setCellRenderer(new TrkListCellRenderer());
    recSetList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            boolean isSel = recSetList.getSelectedIndex() != -1;
            dwnBtn.setEnabled(false);
            upBtn.setEnabled(isSel);
        }
    });

    rsBtn = UIHelper.createIconBtn("Record_Set", IconManager.IconSize.Std24, "", null);
    fmBtn = UIHelper.createIconBtn("FormEdit", IconManager.IconSize.Std24, "", null);
    PanelBuilder toolsBtnPB = new PanelBuilder(new FormLayout("f:p:g,2px,p,2px,p", "p"));
    toolsBtnPB.add(fmBtn, cc.xy(3, 1));
    toolsBtnPB.add(rsBtn, cc.xy(5, 1));

    PanelBuilder leftPB = new PanelBuilder(
            new FormLayout("min(p;250px),10px,f:p:g", "p,2px,f:p:g, 4px,p,4px, p,2px,f:p:g, 2px,p"));

    int y = 1;
    leftPB.add(topLbl = UIHelper.createLabel("Available Points"), cc.xy(1, y));
    y += 2; // I18N
    leftPB.add(UIHelper.createScrollPane(dbObjList, true), cc.xy(1, y));
    y += 2;

    leftPB.add(upDwnPB.getPanel(), cc.xy(1, y));
    y += 2;

    leftPB.add(UIHelper.createLabel("Selected Objects"), cc.xy(1, y));
    y += 2;
    leftPB.add(UIHelper.createScrollPane(recSetList, true), cc.xy(1, y));
    y += 2;

    leftPB.add(toolsBtnPB.getPanel(), cc.xy(1, y));
    y += 2;

    wwPanel = new WorldWindPanel();
    wwPanel.setPreferredSize(new Dimension(MAP_WIDTH, MAP_HEIGHT));
    wwPanel.getWorld().addSelectListener(new ClickAndGoSelectListener(wwPanel.getWorld(), MarkerLayer.class));
    //wwPanel.getWorld().addSelectListener(getWWSelectListener());
    //wwPanel.getWorld().getInputHandler().addMouseListener(getWWMouseAdapter());

    PanelBuilder rightPB = new PanelBuilder(new FormLayout("f:p:g", "f:p:g"));

    // ZZZ lineBuilder = new LineBuilder(wwPanel.getWorld(), lineLayer, polyline);
    rightPB.add(wwPanel, cc.xy(1, 1));
    y += 2;

    polyline.setAntiAliasHint(Polyline.ANTIALIAS_NICEST);
    polyline.setLineWidth(1.5);
    polyline.setFollowTerrain(true);

    startBtn = UIHelper.createI18NButton("Start");
    endBtn = UIHelper.createI18NButton("End");
    searchBtn = UIHelper.createI18NButton("SEARCH");
    clearAllBtn = UIHelper.createI18NButton("Clear All");
    clearSearchBtn = UIHelper.createI18NButton("Clear Search");

    typeCBX = UIHelper.createComboBox(TABLE_INFO);

    PanelBuilder btnPB = new PanelBuilder(
            new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p"));
    btnPB.add(typeCBX, cc.xy(2, 1));
    btnPB.add(startBtn, cc.xy(4, 1));
    btnPB.add(endBtn, cc.xy(6, 1));
    btnPB.add(searchBtn, cc.xy(8, 1));
    btnPB.add(clearSearchBtn, cc.xy(10, 1));
    btnPB.add(clearAllBtn, cc.xy(12, 1));

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,10px,f:p:g", "f:p:g, 4px, p"), this);

    pb.add(leftPB.getPanel(), cc.xy(1, 1));
    pb.add(rightPB.getPanel(), cc.xy(3, 1));
    pb.add(btnPB.getPanel(), cc.xyw(1, 3, 3));
    pb.setDefaultDialogBorder();

    startBtn.setEnabled(true);
    endBtn.setEnabled(false);
    searchBtn.setEnabled(false);
    clearAllBtn.setEnabled(false);
    clearSearchBtn.setEnabled(false);

    rsBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            RecordSetIFace rs = createRecordSet();
            if (rs != null) {
                CommandDispatcher.dispatch(new CommandAction(RecordSetTask.RECORD_SET, "Save", null, null, rs));
            }
        }
    });

    fmBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            RecordSetIFace rs = createRecordSet();
            if (rs != null) {
                CommandDispatcher
                        .dispatch(new CommandAction(DataEntryTask.DATA_ENTRY, DataEntryTask.EDIT_DATA, rs));
            }
        }
    });

    searchBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                doSearch();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    });

    startBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (true) {
                //doSearch();
                //return;
            }
            /*
            double lat = 37.24517;
            double lon = -100.99083;
                    
            double[] p = new double[] {-100.90805562872109,37.24714676134192,
                                    -101.1442623355922,37.15441022126542,
                                    -100.78757107464702,37.1712467680786,
                                    -100.90570697458969,37.24401619379327,
                                    -100.90805562872109,37.24714676134192};
            ArrayList<Position> list = new ArrayList<Position>();
            for (int i=0;i<p.length;i++)
            {
            Position pos = Position.fromDegrees(p[i+1], p[i], 0);
            list.add(pos);
            i++;
            }
            polygon = new Polyline(list);
            polygon.setClosed(true);
                    
            Position pos = Position.fromDegrees(lat, lon, 0.0);
            System.out.println("isLocationInside: "+GeometryMath.isLocationInside(pos, polygon.getPositions()));
            */

            //polygonWWPoints.clear();
            isCreatingPolygon = true;
            searchBtn.setEnabled(false);
            endBtn.setEnabled(true);
            startBtn.setEnabled(false);
            // ZZZ lineBuilder.setArmed(true);
        }
    });

    endBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            polyline.setClosed(true);
            isCreatingPolygon = false;
            searchBtn.setEnabled(true);
            endBtn.setEnabled(false);
            startBtn.setEnabled(false);
            searchBtn.setEnabled(true);
            clearAllBtn.setEnabled(true);
            clearSearchBtn.setEnabled(true);

            //polygonWWPoints.add(polygonWWPoints.get(0));
            //createPolyline();

            // ZZZ lineBuilder.setArmed(false);

        }
    });

    clearAllBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doClearAll(true);
        }
    });

    clearSearchBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doClearAll(false);
        }
    });

    typeCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doPickedNewObjType();
        }
    });

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            typeCBX.setSelectedIndex(0);
        }
    });
}

From source file:iaws_desktop.VelibDispoDialogFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    DefaultListModel<VelibStation> listResultat = new DefaultListModel();
    if (textStation.getText().equals("")) {
        listVelib.setModel(listModel);//from  w w w.j a  v a  2  s . c o  m
    } else {
        for (int i = 0; i < listModel.size(); i++) {
            if (listModel.getElementAt(i).getName().contains(textStation.getText())) {
                listResultat.addElement(listModel.getElementAt(i));
            }
        }
        listVelib.setModel(listResultat);
    }
}

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

/**
 * //from w  w w. j  a  va  2 s  .co  m
 */
protected void createUI() {
    JTabbedPane tabbedPane = new JTabbedPane();

    rp = new RegProcessor();
    rp.processSQL();

    tree = new JTree(rp.getRoot(INCL_ANON));
    propsTable = new JTable();

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            fillPropsTable();
        }
    });
    tree.setCellRenderer(new MyTreeCellRenderer());

    Component topComp = UIHelper.createScrollPane(tree);
    Component botComp = UIHelper.createScrollPane(propsTable);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);

    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    splitPane.setLastDividerLocation(300);
    Dimension minimumSize = new Dimension(200, 400);
    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    tabbedPane.add("Registration", splitPane);

    final List<Pair<String, String>> trackDescPairs = rp.getTrackKeyDescPairs();
    Vector<String> trkItems = new Vector<String>();
    for (Pair<String, String> p : trackDescPairs) {
        trkItems.add(p.second);
    }

    //Collections.sort(trkItems);
    final JList list = new JList(trkItems);
    //pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1));
    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int inx = list.getSelectedIndex();
                if (inx > -1) {
                    fillUsageItemsList(trackDescPairs.get(inx).first);
                }
            }
        }
    });

    tabbedPane.add("Reg Stats", getStatsPane("Registration", rp.getRegNumHash().values(), "register"));

    DefaultListModel model = new DefaultListModel();
    trackItemsList = new JList(model);

    topComp = UIHelper.createScrollPane(list);
    botComp = UIHelper.createScrollPane(trackItemsList);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);
    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    splitPane.setDividerLocation(0.5);
    trackUsageHash = rp.getTrackCatsHash();
    tabbedPane.add("Usage Tracking", splitPane);

    tabbedPane.add("User Stats", getStatsPane("Tracking", rp.getTrackIdHash().values(), "track"));

    add(tabbedPane, BorderLayout.CENTER);
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @param key//from   w  ww.  ja  va 2  s.co m
 * @param arguments
 */
public ColorSchemeDialog(Component actionComp, String key, PlotConfiguration plotConfig, Object... arguments) {
    super(actionComp != null ? SwingUtilities.getWindowAncestor(actionComp) : null, key,
            ModalityType.APPLICATION_MODAL, arguments);
    this.plotConfig = plotConfig;

    initializing = true;

    nominalColorListModel = new DefaultListModel<Color>();
    gradientStartColorComboBoxModel = new DefaultComboBoxModel<Color>();
    gradientEndColorComboBoxModel = new DefaultComboBoxModel<Color>();
    colorSchemeComboBoxModel = new DefaultComboBoxModel<Object>();

    this.setResizable(false);

    createPreviewPlotBackend(new JPanel().getBackground(),
            plotConfig.getActiveColorScheme().getColors().size());

    createComponents();
    save(plotConfig.getColorSchemes(), plotConfig.getActiveColorScheme().getName());

    initializing = false;

    adaptPreviewPlots();

    setLocationRelativeTo(actionComp);

}

From source file:de.tor.tribes.ui.algo.AttackTimePanel.java

/**
 * Set the timespans manually e.g. while loading a stored state
 *
 * @param pSpans//  www . j a v a 2s  .  com
 */
public void setTimeSpans(List<TimeSpan> pSpans) {
    DefaultListModel model = new DefaultListModel();
    model.addElement(new TimeSpanDivider());
    jTimeFrameList.setModel(model);
    for (TimeSpan span : pSpans) {
        addTimeSpan(span);
    }
}