Example usage for javax.swing DefaultComboBoxModel DefaultComboBoxModel

List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel

Introduction

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

Prototype

public DefaultComboBoxModel() 

Source Link

Document

Constructs an empty DefaultComboBoxModel object.

Usage

From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java

/**
 * /*from   w w w. ja va  2 s  .  co  m*/
 */
public void buildUI() {
    setIgnoreChanges(true);

    fieldsList = createList(fieldsModel);

    fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                getAllDataFromUI();
                fieldSelected();
            }
        }
    });

    fieldsList.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            super.focusLost(e);
            //lastIndex = fieldsList.getSelectedIndex();
        }
    });

    fieldDescText.addKeyListener(new LengthWatcher(255));
    // setting min and pref sizes to some bogus values so that textarea shrinks with dialog
    fieldNameText.addKeyListener(new LengthWatcher(64));

    CellConstraints cc = new CellConstraints();

    int y = 1;

    JScrollPane fldsp = UIHelper.createScrollPane(fieldsList);

    // LocalizableNameDescIFace
    PanelBuilder pb = new PanelBuilder(new FormLayout("max(200px;p),4px,p,2px,p,10px,p,2px,p,f:p:g",
            (includeHiddenUI ? "p,2px," : "") + (isDBSchema ? "p,2px,p,2px," : "")
                    + (includeFormatAndAutoNumUI ? "p,2px,p,2px," : "")
                    + "p,2px,p,2px,p,2px,p,2px,p,2px,p,2px,f:p:g"),
            this);

    pb.add(fldsp, cc.xywh(1, y, 1, 7 + (isDBSchema ? 4 : 0)));
    pb.add(fieldNameLbl = createI18NFormLabel("SL_LABEL", SwingConstants.RIGHT), cc.xy(3, y));
    pb.add(fieldNameText, cc.xywh(5, y, 6, 1));
    y += 2;

    if (includeHiddenUI) {
        pb.add(fieldHideChk, cc.xy(5, y));
        y += 2;
    }

    pb.add(fieldDescLbl = createI18NFormLabel("SL_DESC", SwingConstants.RIGHT), cc.xy(3, y));
    JScrollPane sp = new JScrollPane(fieldDescText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pb.add(sp, cc.xywh(5, y, 6, 1));
    y += 2;
    fieldDescText.setLineWrap(true);
    fieldDescText.setWrapStyleWord(true);

    if (isDBSchema) {
        fieldTypeTxt = createLabel("");
        fieldLengthTxt = createLabel("");

        pb.add(fieldTypeLbl = createI18NFormLabel("SL_TYPE", SwingConstants.RIGHT), cc.xy(3, y));
        pb.add(fieldTypeTxt, cc.xy(5, y));

        pb.add(fieldReqChk = createCheckBox(getResourceString("SL_REQ")), cc.xy(9, y));
        y += 2;

        pb.add(fieldLengthLbl = createI18NFormLabel("SL_LENGTH", SwingConstants.RIGHT), cc.xy(3, y));
        pb.add(fieldLengthTxt, cc.xy(5, y));
        y += 2;

        fieldTypeTxt.setBackground(Color.WHITE);
        fieldLengthTxt.setBackground(Color.WHITE);
        fieldTypeTxt.setOpaque(true);
        fieldLengthTxt.setOpaque(true);
    }

    if (includeFormatAndAutoNumUI) {
        PanelBuilder inner = new PanelBuilder(new FormLayout("p,2px,p", "p"));

        formatSwitcherCombo = createComboBox();
        fmtCardLayout = new CardLayout();
        formatterPanel = new JPanel(fmtCardLayout);
        pb.add(formatLbl = createI18NFormLabel("SL_FMTTYPE", SwingConstants.RIGHT), cc.xy(3, y));

        inner.add(formatSwitcherCombo, cc.xy(1, 1));
        inner.add(formatterPanel, cc.xy(3, 1));

        pb.add(inner.getPanel(), cc.xywh(5, y, 6, 1));
        y += 2;

        ActionListener switchAL = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String item = (String) formatSwitcherCombo.getSelectedItem();
                if (item != null) {
                    fmtCardLayout.show(formatterPanel, item);
                    webLinkCombo.setEnabled(item.equals(SL_WEBLINK));

                    if (formatSwitcherCombo.getSelectedIndex() == 0) {
                        if (webLinkCombo.getModel().getSize() > 0) {
                            webLinkCombo.setSelectedIndex(0);
                        }
                        if (formatCombo.getModel().getSize() > 0) {
                            formatCombo.setSelectedIndex(0);
                        }
                        if (pickListCBX.getModel().getSize() > 0) {
                            pickListCBX.setSelectedIndex(0);
                        }
                    }
                }
            }
        };
        formatSwitcherCombo.addActionListener(switchAL);

        formatterPanel.add(SL_NONE, new JPanel());

        //--------------------------
        // UIFieldFormatter
        //--------------------------
        inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p"));

        formatCombo = createComboBox(new DefaultComboBoxModel());
        formatMoreBtn = createButton(ELIPSES);

        inner.add(formatCombo, cc.xy(1, 1));
        inner.add(formatMoreBtn, cc.xy(3, 1));

        formatMoreBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                UIFormatterListEdtDlg dlg = new UIFormatterListEdtDlg((Frame) UIRegistry.getTopWindow(),
                        fieldInfo, true, schemaPanel.getUiFieldFormatterMgrCache());
                dlg.setVisible(true);
                if (!dlg.isCancelled() && dlg.hasChanged()) {
                    //schemaPanel.setHasChanged(true);
                    formHasChanged();

                    //fillFormatBox(dlg.getSelectedFormat());
                    setSelectedFieldFormatter(dlg.getSelectedFormat());
                }
            }
        });

        formatterPanel.add(SL_FORMAT, inner.getPanel());

        ActionListener changed = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                formHasChanged();

                boolean hasFormat = formatCombo.getSelectedIndex() > 0;
                webLinkCombo.setEnabled(!hasFormat);
                if (hasFormat) {
                    webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1);
                    pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1);
                }
            }
        };
        formatCombo.addActionListener(changed);

        //--------------------------
        // WebLinks
        //--------------------------
        webLinkMoreBtn = createButton(ELIPSES);
        webLinkMoreBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                WebLinkDef selectedWL = (WebLinkDef) webLinkCombo.getSelectedItem();
                WebLinkConfigDlg dlg = webLinkMgrCache.editWebLinks(tableInfo, false);
                if (dlg.getBtnPressed() == CustomDialog.OK_BTN) {
                    fillWebLinkBox();

                    formHasChanged();

                    if (selectedWL != null && !selectedWL.getName().equals(SL_WEBLINK)) {
                        dlg.setWebLink(selectedWL.getName());
                    }
                    if (dlg.getBtnPressed() == CustomDialog.OK_BTN) {
                        setSelectedWebLink(dlg.getSelectedItem());
                    }
                }
            }
        });

        inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p"));
        webLinkCombo = createComboBox();
        DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel();
        model.addElement(webLinkDefNone);
        webLinkCombo.setSelectedIndex(0);

        inner.add(webLinkCombo, cc.xy(1, 1));
        inner.add(webLinkMoreBtn, cc.xy(3, 1));

        ActionListener wlchanged = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                formHasChanged();

                boolean hasWL = webLinkCombo.getSelectedIndex() > 0;
                webLinkCombo.setEnabled(hasWL);
                if (hasWL) {
                    formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1);
                    pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1);
                }
            }
        };
        webLinkCombo.addActionListener(wlchanged);

        formatterPanel.add(SL_WEBLINK, inner.getPanel());
    }

    //--------------------------
    // PickList
    //--------------------------

    pickListCBX = createComboBox(new DefaultComboBoxModel());
    pickListCBX.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            formHasChanged();
            if (formatCombo != null && pickListCBX.getSelectedIndex() > 0) {
                formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1);
                webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1);
            }
        }
    });
    pickListMoreBtn = createButton(ELIPSES);
    pickListMoreBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            LocalizableItemIFace currentField = prevField;
            prevField = getSelectedFieldItem();

            PickList selectedItem = (PickList) pickListCBX.getSelectedItem();

            PickListEditorDlg dlg = new PickListEditorDlg(
                    localizableIO.hasUpdatablePickLists() ? null : localizableIO, true, true);
            dlg.setTableInfo(tableInfo);
            dlg.setFieldInfo(fieldInfo);
            dlg.createUI();
            dlg.setSize(400, 500);
            dlg.setVisible(true);
            if (!dlg.isCancelled()) {
                if (dlg.hasChanged()) {
                    hasChanged = true;
                    Vector<PickList> list = dlg.getNewPickLists();
                    DefaultComboBoxModel plCbxModel = (DefaultComboBoxModel) pickListCBX.getModel();
                    for (int i = 0; i < plCbxModel.getSize(); i++) {
                        list.add((PickList) plCbxModel.getElementAt(i));
                    }
                    Collections.sort(list);
                    plCbxModel.removeAllElements();
                    plCbxModel.addElement(pickListNone);
                    int inx = -1;
                    int i = 0;
                    for (PickList pl : list) {
                        plCbxModel.addElement(pl);
                        if (inx == -1 && selectedItem != null
                                && ((selectedItem.getId() != null && pl.getId() != null
                                        && selectedItem.getId().equals(pl.getId()))
                                        || (selectedItem.getName() != null && pl.getName() != null
                                                && selectedItem.getName().equals(pl.getName())))) {
                            inx = i;
                        }
                        i++;
                    }
                    pickListCBX.setSelectedIndex(inx + 1);
                }
            }

            prevField = currentField;
        }
    });

    if (includeFormatAndAutoNumUI) {
        PanelBuilder inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p"));
        inner.add(pickListCBX, cc.xy(1, 1));
        inner.add(pickListMoreBtn, cc.xy(3, 1));

        formatterPanel.add(SL_PICKLIST, inner.getPanel());

    } else {
        pb.add(pickListLbl = createI18NFormLabel(SL_PICKLIST, SwingConstants.RIGHT), cc.xy(3, y));
        pb.add(pickListCBX, cc.xy(5, y));
        pb.add(pickListMoreBtn, cc.xy(7, y));
        y += 2;
    }

    nxtBtn = createI18NButton("SL_NEXT");
    nxtEmptyBtn = createI18NButton("SL_NEXT_EMPTY");
    fldSpellChkBtn = createI18NButton("SL_SPELL_CHECK");

    //JPanel bbp = ButtonBarFactory.buildCenteredBar(adjustButtonArray(new JButton[] {nxtEmptyBtn, nxtBtn, fldSpellChkBtn}));
    //bbp.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
    //pb.add(bbp,   cc.xywh(3, y, 8, 1));

    nxtBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            next();
        }
    });
    nxtEmptyBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            nextEmpty();
        }
    });

    fldSpellChkBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (checker != null) {
                checker.spellCheck(fieldDescText);
                checker.spellCheck(fieldNameText);
            }
        }

    });

    fieldHideChk.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            formHasChanged();
        }

    });

    fieldReqChk.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            formHasChanged();
        }

    });

    DocumentListener dl = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            formHasChanged();
        }
    };

    fieldNameText.getDocument().addDocumentListener(dl);
    fieldDescText.getDocument().addDocumentListener(dl);
    /*        
            if (formatTxt != null)
            {
    formatTxt.getDocument().addDocumentListener(dl);
            }
    */
    SchemaI18NService.getInstance().checkCurrentLocaleMenu();

    enableUIControls(false);

    setIgnoreChanges(false);
}

From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java

/**
 * Create the panel.//from  w w  w.  j  a  va 2 s  . co  m
 */
public Hl7V2MessageEditorPanel(final Controller theController) {
    setBorder(null);
    myController = theController;

    ButtonGroup encGrp = new ButtonGroup();
    setLayout(new BorderLayout(0, 0));

    mysplitPane = new JSplitPane();
    mysplitPane.setResizeWeight(0.5);
    mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(mysplitPane);

    mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight();
            ourLog.debug("Resizing split to ratio: {}", ratio);
            Prefs.getInstance().setHl7EditorSplit(ratio);
        }
    });

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit());
        }
    });

    messageEditorContainerPanel = new JPanel();
    messageEditorContainerPanel.setBorder(null);
    mysplitPane.setRightComponent(messageEditorContainerPanel);
    messageEditorContainerPanel.setLayout(new BorderLayout(0, 0));

    myMessageEditor = new JEditorPane();
    Highlighter h = new UnderlineHighlighter();
    myMessageEditor.setHighlighter(h);
    // myMessageEditor.setFont(Prefs.getHl7EditorFont());
    myMessageEditor.setSelectedTextColor(Color.black);

    myMessageEditor.setCaret(new EditorCaret());

    myMessageScrollPane = new JScrollPane(myMessageEditor);
    messageEditorContainerPanel.add(myMessageScrollPane);

    JToolBar toolBar = new JToolBar();
    messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    myFollowToggle = new JToggleButton("Follow");
    myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync");
    myFollowToggle.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            theController.setMessageEditorInFollowMode(myFollowToggle.isSelected());
        }
    });
    myFollowToggle.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png")));
    myFollowToggle.setSelected(theController.isMessageEditorInFollowMode());
    toolBar.add(myFollowToggle);

    myhorizontalStrut = Box.createHorizontalStrut(20);
    toolBar.add(myhorizontalStrut);

    mylabel_4 = new JLabel("Encoding");
    toolBar.add(mylabel_4);

    myRdbtnEr7 = new JRadioButton("ER7");
    myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1));
    toolBar.add(myRdbtnEr7);

    myRdbtnXml = new JRadioButton("XML");
    myRdbtnXml.setMargin(new Insets(1, 5, 0, 1));
    toolBar.add(myRdbtnXml);
    encGrp.add(myRdbtnEr7);
    encGrp.add(myRdbtnXml);

    treeContainerPanel = new JPanel();
    mysplitPane.setLeftComponent(treeContainerPanel);
    treeContainerPanel.setLayout(new BorderLayout(0, 0));

    mySpinnerIconOn = new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif"));
    mySpinnerIconOff = new ImageIcon();

    myTreePanel = new Hl7V2MessageTree(theController);
    myTreePanel.setWorkingListener(new IWorkingListener() {

        public void startedWorking() {
            mySpinner.setText("");
            mySpinner.setIcon(mySpinnerIconOn);
            mySpinnerIconOn.setImageObserver(mySpinner);
        }

        public void finishedWorking(String theStatus) {
            mySpinner.setText(theStatus);

            mySpinner.setIcon(mySpinnerIconOff);
            mySpinnerIconOn.setImageObserver(null);
        }
    });
    myTreeScrollPane = new JScrollPane(myTreePanel);

    myTopTabBar = new JTabbedPane();
    treeContainerPanel.add(myTopTabBar);
    myTopTabBar.setBorder(null);

    JPanel treeContainer = new JPanel();
    treeContainer.setLayout(new BorderLayout(0, 0));
    treeContainer.add(myTreeScrollPane);

    myTopTabBar.add("Message Tree", treeContainer);

    mytoolBar_1 = new JToolBar();
    mytoolBar_1.setFloatable(false);
    treeContainer.add(mytoolBar_1, BorderLayout.NORTH);

    mylabel_3 = new JLabel("Show");
    mytoolBar_1.add(mylabel_3);

    myShowCombo = new JComboBox();
    mytoolBar_1.add(myShowCombo);
    myShowCombo.setPreferredSize(new Dimension(130, 27));
    myShowCombo.setMinimumSize(new Dimension(130, 27));
    myShowCombo.setMaximumSize(new Dimension(130, 32767));

    collapseAllButton = new JButton();
    collapseAllButton.setBorderPainted(false);
    collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton));
    collapseAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.collapseAll();
        }
    });
    collapseAllButton.setToolTipText("Collapse All");
    collapseAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png")));
    mytoolBar_1.add(collapseAllButton);

    expandAllButton = new JButton();
    expandAllButton.setBorderPainted(false);
    expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton));
    expandAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.expandAll();
        }
    });
    expandAllButton.setToolTipText("Expand All");
    expandAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png")));
    mytoolBar_1.add(expandAllButton);

    myhorizontalGlue = Box.createHorizontalGlue();
    mytoolBar_1.add(myhorizontalGlue);

    mySpinner = new JButton("");
    mySpinner.setForeground(Color.DARK_GRAY);
    mySpinner.setHorizontalAlignment(SwingConstants.RIGHT);
    mySpinner.setMaximumSize(new Dimension(200, 15));
    mySpinner.setPreferredSize(new Dimension(200, 15));
    mySpinner.setMinimumSize(new Dimension(200, 15));
    mySpinner.setBorderPainted(false);
    mySpinner.setSize(new Dimension(16, 16));
    mytoolBar_1.add(mySpinner);
    myProfileComboboxModel = new ProfileComboModel();

    myTablesComboModel = new TablesComboModel(myController);

    mytoolBar = new JToolBar();
    mytoolBar.setFloatable(false);
    mytoolBar.setRollover(true);
    treeContainerPanel.add(mytoolBar, BorderLayout.NORTH);

    myOutboundInterfaceCombo = new JComboBox();
    myOutboundInterfaceComboModel = new DefaultComboBoxModel();

    mylabel_1 = new JLabel("Send");
    mytoolBar.add(mylabel_1);
    myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel);
    myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767));
    mytoolBar.add(myOutboundInterfaceCombo);

    mySendButton = new JButton("Send");
    mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton));
    mySendButton.setBorderPainted(false);
    mySendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // int selectedIndex =
            // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem());
            int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex();
            OutboundConnection connection = myController.getOutboundConnectionList().getConnections()
                    .get(selectedIndex);
            activateSendingActivityTabForConnection(connection);
            myController.sendMessages(connection, myMessage,
                    mySendingActivityTable.provideTransmissionCallback());
        }
    });

    myhorizontalStrut_2 = Box.createHorizontalStrut(20);
    myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_2);

    mySendOptionsButton = new JButton("Options");
    mySendOptionsButton.setBorderPainted(false);
    final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton);
    mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor);
    mySendOptionsButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png")));
    mytoolBar.add(mySendOptionsButton);
    mySendOptionsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent theE) {
            if (mySendOptionsPopupDialog != null) {
                mySendOptionsPopupDialog.doHide();
                mySendOptionsPopupDialog = null;
                return;
            }
            mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage,
                    mySendOptionsButton, sendOptionsHoverAdaptor);
            Point los = mySendOptionsButton.getLocationOnScreen();
            mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight());
            mySendOptionsPopupDialog.setVisible(true);
        }
    });

    mySendButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png")));
    mytoolBar.add(mySendButton);

    myhorizontalStrut_1 = Box.createHorizontalStrut(20);
    mytoolBar.add(myhorizontalStrut_1);

    mylabel_2 = new JLabel("Validate");
    mytoolBar.add(mylabel_2);

    myProfileCombobox = new JComboBox();
    mytoolBar.add(myProfileCombobox);
    myProfileCombobox.setPreferredSize(new Dimension(200, 27));
    myProfileCombobox.setMinimumSize(new Dimension(200, 27));
    myProfileCombobox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (myHandlingProfileComboboxChange) {
                return;
            }

            myHandlingProfileComboboxChange = true;
            try {
                if (myProfileCombobox.getSelectedIndex() == 0) {
                    myMessage.setValidationContext(null);
                } else if (myProfileCombobox.getSelectedIndex() == 1) {
                    myMessage.setValidationContext(new DefaultValidation());
                } else if (myProfileCombobox.getSelectedIndex() > 0) {
                    ProfileGroup profile = myProfileComboboxModel.myProfileGroups
                            .get(myProfileCombobox.getSelectedIndex());
                    myMessage.setRuntimeProfile(profile);

                    // } else if (myProfileCombobox.getSelectedItem() ==
                    // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) {
                    // IOkCancelCallback<Void> callback = new
                    // IOkCancelCallback<Void>() {
                    // public void ok(Void theArg) {
                    // myProfileComboboxModel.update();
                    // }
                    //
                    // public void cancel(Void theArg) {
                    // myProfileCombobox.setSelectedIndex(0);
                    // }
                    // };
                    // myController.chooseAndLoadConformanceProfileForMessage(myMessage,
                    // callback);
                }
            } catch (ProfileException e2) {
                ourLog.error("Failed to load profile", e2);
            } finally {
                myHandlingProfileComboboxChange = false;
            }
        }
    });
    myProfileCombobox.setMaximumSize(new Dimension(300, 32767));
    myProfileCombobox.setModel(myProfileComboboxModel);

    myhorizontalStrut_4 = Box.createHorizontalStrut(20);
    myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_4);

    // mySendingPanel = new JPanel();
    // mySendingPanel.setBorder(null);
    // myTopTabBar.addTab("Sending", null, mySendingPanel, null);
    // mySendingPanel.setLayout(new BorderLayout(0, 0));

    mySendingActivityTable = new ActivityTable();
    mySendingActivityTable.setController(myController);
    myTopTabBar.addTab("Sending", null, mySendingActivityTable, null);

    // mySendingPanelScrollPanel = new JScrollPane();
    // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable);
    //
    // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER);

    bottomPanel = new JPanel();
    bottomPanel.setPreferredSize(new Dimension(10, 20));
    bottomPanel.setMinimumSize(new Dimension(10, 20));
    add(bottomPanel, BorderLayout.SOUTH);
    GridBagLayout gbl_bottomPanel = new GridBagLayout();
    gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 };
    gbl_bottomPanel.rowHeights = new int[] { 16, 0 };
    gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    bottomPanel.setLayout(gbl_bottomPanel);

    mylabel = new JLabel("Terser Path:");
    mylabel.setHorizontalTextPosition(SwingConstants.LEFT);
    mylabel.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.fill = GridBagConstraints.VERTICAL;
    gbc_label.weighty = 1.0;
    gbc_label.anchor = GridBagConstraints.NORTHWEST;
    gbc_label.gridx = 0;
    gbc_label.gridy = 0;
    bottomPanel.add(mylabel, gbc_label);

    myTerserPathTextField = new JLabel();
    myTerserPathTextField.setForeground(Color.BLUE);
    myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13));
    myTerserPathTextField.setBorder(null);
    myTerserPathTextField.setBackground(SystemColor.control);
    myTerserPathTextField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) {
                myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0);
            }
        }
    });

    GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints();
    gbc_TerserPathTextField.weightx = 1.0;
    gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL;
    gbc_TerserPathTextField.gridx = 1;
    gbc_TerserPathTextField.gridy = 0;
    bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField);

    initLocal();

}

From source file:main.UIController.java

/************* TO GREGORIAN *************/

public void updateDayComboImladris() {
    UI window = this.getUi();

    JComboBox yen = window.getYen();
    JTextField loa = window.getLoa();
    JComboBox period = window.getPeriod();
    JComboBox day = window.getDayOfLoa();
    JButton convert = window.getToGregorian();
    JTextPane result = window.getResGregorian();
    int yenNum = yen.getSelectedIndex() + 1;
    String value = loa.getText();
    if (!value.isEmpty()) {
        try {//from ww  w  .j a v a2 s . c om
            int loaNum = Integer.parseInt(value);
            if (loaNum > 0 && loaNum <= 144) {
                int periodNum = period.getSelectedIndex() + 1;
                if (periodNum == ImladrisCalendar.YESTARE || periodNum == ImladrisCalendar.METTARE) {
                    day.setEnabled(false);
                    day.setModel(new DefaultComboBoxModel());
                    convert.setEnabled(true);
                    result.setText("");
                } else {
                    int daySel = 0;
                    if (day.isEnabled()) {
                        daySel = day.getSelectedIndex() + 1;
                    }
                    ArrayList<Integer> days = ImladrisInfo.getInstance().getDaysArray(yenNum, loaNum,
                            periodNum);
                    day.setModel(new DefaultComboBoxModel(days.toArray()));
                    if (daySel > 0 && daySel <= days.size()) {
                        day.setSelectedIndex(daySel - 1);
                    }
                    day.setEnabled(true);
                    convert.setEnabled(true);
                    result.setText("");
                }
            } else {
                day.setEnabled(false);
                convert.setEnabled(false);
                day.setModel(new DefaultComboBoxModel());
                result.setText("");
            }
        } catch (NumberFormatException e) {
            day.setEnabled(false);
            convert.setEnabled(false);
            day.setModel(new DefaultComboBoxModel());
            result.setText("");
        }
    } else {
        day.setEnabled(false);
        convert.setEnabled(false);
        day.setModel(new DefaultComboBoxModel());
        result.setText("");
    }
}

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

private void initGUI() {
    try {/*  w w w. ja  va  2s  . 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:com.alvermont.terraj.planet.ui.MainFrame.java

/**
 * Set up our list model from the projection list
 *///from w w w .  j  a v  a 2s  .  c om
protected void setListModel() {
    final DefaultComboBoxModel<Projector> dcm = new DefaultComboBoxModel<>();

    for (Projector p : projManager.getProjections()) {
        dcm.addElement(p);
    }

    projComboBox.setModel(dcm);

    // make the first one selected
    dcm.setSelectedItem(dcm.getElementAt(0));

    // TODO: do this properly
    projComboBoxActionPerformed(new ActionEvent(this, 0, "Hack"));
}

From source file:InterfaceModule.JRobert.java

private ComboBoxModel createParkingMeterList() {
    Controller c = Controller.getInstance();
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    Set<String> set = (Set<String>) c.getParkingMeterList();
    for (String id : set)
        model.addElement(id);/*from   w  w  w  .j a v a2  s  . c o  m*/
    return model;
}

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

private void startCalculation() {
    jideRetimeTabbedPane.setSelectedIndex(0);
    if (parsedAttack == null || parsedAttack.getSource() == null || parsedAttack.getTarget() == null
            || parsedAttack.getUnit() == null || parsedAttack.getArriveTime() == null) {

        JOptionPaneHelper.showInformationBox(this,
                "Bitte fge zuerst einen gltigen Angriff ein und whle eine Einheit", "Information");
        return;/*  ww w  . j  a v  a2  s .com*/
    }

    jCalculationSettingsDialog.pack();
    jCalculationSettingsDialog.setLocationRelativeTo(DSWorkbenchReTimerFrame.this);
    DefaultListModel tagModel = new DefaultListModel();
    tagModel.addElement(NoTag.getSingleton());
    for (ManageableType e : TagManager.getSingleton().getAllElements()) {
        tagModel.addElement((Tag) e);
    }
    jTagList.setModel(tagModel);
    jRelationBox.setSelected(true);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        model.addElement(unit);
    }
    jUnitBox.setModel(model);
    jUnitBox.setRenderer(new UnitListCellRenderer());
    // <editor-fold defaultstate="collapsed" desc="Build attack plan table">
    DefaultTableModel attackPlanTableModel = new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Angriffsplan", "Abgleichen" }) {

        Class[] types = new Class[] { String.class, Boolean.class };

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

        @Override
        public boolean isCellEditable(int row, int col) {
            if (col == 0) {
                return false;
            }
            return true;
        }
    };

    String[] plans = AttackManager.getSingleton().getGroups();
    for (String plan : plans) {
        attackPlanTableModel.addRow(new Object[] { plan, false });
    }

    jAttackPlanTable.setModel(attackPlanTableModel);
    DefaultTableCellRenderer headerRenderer = new SortableTableHeaderRenderer();
    for (int i = 0; i < jAttackPlanTable.getColumnCount(); i++) {
        jAttackPlanTable.getColumn(jAttackPlanTable.getColumnName(i)).setHeaderRenderer(headerRenderer);
    }
    // </editor-fold>
    jCalculationSettingsDialog.setVisible(true);
}

From source file:neg.JRViewer.java

/** This method is called from within the constructor to
 * initialize the form./*from   www.  ja  v  a  2  s  .  c o  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    tlbToolBar = new javax.swing.JPanel();
    btnSave = new javax.swing.JButton();
    btnPrint = new javax.swing.JButton();
    btnReload = new javax.swing.JButton();
    pnlSep01 = new javax.swing.JPanel();
    btnFirst = new javax.swing.JButton();
    btnPrevious = new javax.swing.JButton();
    btnNext = new javax.swing.JButton();
    btnLast = new javax.swing.JButton();
    txtGoTo = new javax.swing.JTextField();
    pnlSep02 = new javax.swing.JPanel();
    btnActualSize = new javax.swing.JToggleButton();
    btnFitPage = new javax.swing.JToggleButton();
    btnFitWidth = new javax.swing.JToggleButton();
    pnlSep03 = new javax.swing.JPanel();
    btnZoomIn = new javax.swing.JButton();
    btnZoomOut = new javax.swing.JButton();
    cmbZoom = new javax.swing.JComboBox();
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (int i = 0; i < zooms.length; i++) {
        model.addElement("" + zooms[i] + "%");
    }
    cmbZoom.setModel(model);
    jButton1 = new javax.swing.JButton();
    pnlMain = new javax.swing.JPanel();
    scrollPane = new javax.swing.JScrollPane();
    scrollPane.getHorizontalScrollBar().setUnitIncrement(5);
    scrollPane.getVerticalScrollBar().setUnitIncrement(5);
    pnlInScroll = new javax.swing.JPanel();
    pnlPage = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    pnlLinks = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    jPanel6 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel9 = new javax.swing.JPanel();
    lblPage = new PageRenderer(this);
    pnlStatus = new javax.swing.JPanel();
    lblStatus = new javax.swing.JLabel();

    setMinimumSize(new java.awt.Dimension(450, 150));
    setPreferredSize(new java.awt.Dimension(450, 150));
    setLayout(new java.awt.BorderLayout());

    tlbToolBar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 2));

    btnSave.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/save.GIF"))); // NOI18N
    btnSave.setToolTipText(getBundleString("save"));
    btnSave.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnSave.setMaximumSize(new java.awt.Dimension(23, 23));
    btnSave.setMinimumSize(new java.awt.Dimension(23, 23));
    btnSave.setPreferredSize(new java.awt.Dimension(23, 23));
    btnSave.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSaveActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnSave);

    btnPrint.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/print.GIF"))); // NOI18N
    btnPrint.setToolTipText(getBundleString("print"));
    btnPrint.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnPrint.setMaximumSize(new java.awt.Dimension(23, 23));
    btnPrint.setMinimumSize(new java.awt.Dimension(23, 23));
    btnPrint.setPreferredSize(new java.awt.Dimension(23, 23));
    btnPrint.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPrintActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnPrint);

    btnReload.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/reload.GIF"))); // NOI18N
    btnReload.setToolTipText(getBundleString("reload"));
    btnReload.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnReload.setMaximumSize(new java.awt.Dimension(23, 23));
    btnReload.setMinimumSize(new java.awt.Dimension(23, 23));
    btnReload.setPreferredSize(new java.awt.Dimension(23, 23));
    btnReload.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnReloadActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnReload);

    pnlSep01.setMaximumSize(new java.awt.Dimension(10, 10));
    tlbToolBar.add(pnlSep01);

    btnFirst.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/first.GIF"))); // NOI18N
    btnFirst.setToolTipText(getBundleString("first.page"));
    btnFirst.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnFirst.setMaximumSize(new java.awt.Dimension(23, 23));
    btnFirst.setMinimumSize(new java.awt.Dimension(23, 23));
    btnFirst.setPreferredSize(new java.awt.Dimension(23, 23));
    btnFirst.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnFirstActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnFirst);

    btnPrevious.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/net/sf/jasperreports/view/images/previous.GIF"))); // NOI18N
    btnPrevious.setToolTipText(getBundleString("previous.page"));
    btnPrevious.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnPrevious.setMaximumSize(new java.awt.Dimension(23, 23));
    btnPrevious.setMinimumSize(new java.awt.Dimension(23, 23));
    btnPrevious.setPreferredSize(new java.awt.Dimension(23, 23));
    btnPrevious.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPreviousActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnPrevious);

    btnNext.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/next.GIF"))); // NOI18N
    btnNext.setToolTipText(getBundleString("next.page"));
    btnNext.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnNext.setMaximumSize(new java.awt.Dimension(23, 23));
    btnNext.setMinimumSize(new java.awt.Dimension(23, 23));
    btnNext.setPreferredSize(new java.awt.Dimension(23, 23));
    btnNext.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNextActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnNext);

    btnLast.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/last.GIF"))); // NOI18N
    btnLast.setToolTipText(getBundleString("last.page"));
    btnLast.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnLast.setMaximumSize(new java.awt.Dimension(23, 23));
    btnLast.setMinimumSize(new java.awt.Dimension(23, 23));
    btnLast.setPreferredSize(new java.awt.Dimension(23, 23));
    btnLast.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnLastActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnLast);

    txtGoTo.setToolTipText(getBundleString("go.to.page"));
    txtGoTo.setMaximumSize(new java.awt.Dimension(40, 23));
    txtGoTo.setMinimumSize(new java.awt.Dimension(40, 23));
    txtGoTo.setPreferredSize(new java.awt.Dimension(40, 23));
    txtGoTo.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            txtGoToActionPerformed(evt);
        }
    });
    tlbToolBar.add(txtGoTo);

    pnlSep02.setMaximumSize(new java.awt.Dimension(10, 10));
    tlbToolBar.add(pnlSep02);

    btnActualSize.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/net/sf/jasperreports/view/images/actualsize.GIF"))); // NOI18N
    btnActualSize.setToolTipText(getBundleString("actual.size"));
    btnActualSize.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnActualSize.setMaximumSize(new java.awt.Dimension(23, 23));
    btnActualSize.setMinimumSize(new java.awt.Dimension(23, 23));
    btnActualSize.setPreferredSize(new java.awt.Dimension(23, 23));
    btnActualSize.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnActualSizeActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnActualSize);

    btnFitPage.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitpage.GIF"))); // NOI18N
    btnFitPage.setToolTipText(getBundleString("fit.page"));
    btnFitPage.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnFitPage.setMaximumSize(new java.awt.Dimension(23, 23));
    btnFitPage.setMinimumSize(new java.awt.Dimension(23, 23));
    btnFitPage.setPreferredSize(new java.awt.Dimension(23, 23));
    btnFitPage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnFitPageActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnFitPage);

    btnFitWidth.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/net/sf/jasperreports/view/images/fitwidth.GIF"))); // NOI18N
    btnFitWidth.setToolTipText(getBundleString("fit.width"));
    btnFitWidth.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnFitWidth.setMaximumSize(new java.awt.Dimension(23, 23));
    btnFitWidth.setMinimumSize(new java.awt.Dimension(23, 23));
    btnFitWidth.setPreferredSize(new java.awt.Dimension(23, 23));
    btnFitWidth.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnFitWidthActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnFitWidth);

    pnlSep03.setMaximumSize(new java.awt.Dimension(10, 10));
    tlbToolBar.add(pnlSep03);

    btnZoomIn.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/zoomin.GIF"))); // NOI18N
    btnZoomIn.setToolTipText(getBundleString("zoom.in"));
    btnZoomIn.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnZoomIn.setMaximumSize(new java.awt.Dimension(23, 23));
    btnZoomIn.setMinimumSize(new java.awt.Dimension(23, 23));
    btnZoomIn.setPreferredSize(new java.awt.Dimension(23, 23));
    btnZoomIn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnZoomInActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnZoomIn);

    btnZoomOut.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/zoomout.GIF"))); // NOI18N
    btnZoomOut.setToolTipText(getBundleString("zoom.out"));
    btnZoomOut.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnZoomOut.setMaximumSize(new java.awt.Dimension(23, 23));
    btnZoomOut.setMinimumSize(new java.awt.Dimension(23, 23));
    btnZoomOut.setPreferredSize(new java.awt.Dimension(23, 23));
    btnZoomOut.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnZoomOutActionPerformed(evt);
        }
    });
    tlbToolBar.add(btnZoomOut);

    cmbZoom.setEditable(true);
    cmbZoom.setToolTipText(getBundleString("zoom.ratio"));
    cmbZoom.setMaximumSize(new java.awt.Dimension(80, 23));
    cmbZoom.setMinimumSize(new java.awt.Dimension(80, 23));
    cmbZoom.setPreferredSize(new java.awt.Dimension(80, 23));
    cmbZoom.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cmbZoomActionPerformed(evt);
        }
    });
    cmbZoom.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            cmbZoomItemStateChanged(evt);
        }
    });
    tlbToolBar.add(cmbZoom);

    jButton1.setForeground(new java.awt.Color(255, 0, 0));
    jButton1.setText("Cancelar");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    tlbToolBar.add(jButton1);

    add(tlbToolBar, java.awt.BorderLayout.NORTH);

    pnlMain.addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentResized(java.awt.event.ComponentEvent evt) {
            pnlMainComponentResized(evt);
        }
    });
    pnlMain.setLayout(new java.awt.BorderLayout());

    scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    pnlInScroll.setLayout(new java.awt.GridBagLayout());

    pnlPage.setMinimumSize(new java.awt.Dimension(100, 100));
    pnlPage.setPreferredSize(new java.awt.Dimension(100, 100));
    pnlPage.setLayout(new java.awt.BorderLayout());

    jPanel4.setMinimumSize(new java.awt.Dimension(100, 120));
    jPanel4.setPreferredSize(new java.awt.Dimension(100, 120));
    jPanel4.setLayout(new java.awt.GridBagLayout());

    pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5));
    pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5));
    pnlLinks.setOpaque(false);
    pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            pnlLinksMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            pnlLinksMouseReleased(evt);
        }
    });
    pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseDragged(java.awt.event.MouseEvent evt) {
            pnlLinksMouseDragged(evt);
        }
    });
    pnlLinks.setLayout(null);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    jPanel4.add(pnlLinks, gridBagConstraints);

    jPanel5.setBackground(java.awt.Color.gray);
    jPanel5.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel5.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
    jPanel4.add(jPanel5, gridBagConstraints);

    jPanel6.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel6.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    jPanel4.add(jPanel6, gridBagConstraints);

    jPanel7.setBackground(java.awt.Color.gray);
    jPanel7.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel7.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel4.add(jPanel7, gridBagConstraints);

    jPanel8.setBackground(java.awt.Color.gray);
    jPanel8.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel8.setPreferredSize(new java.awt.Dimension(5, 5));

    jLabel1.setText("jLabel1");
    jPanel8.add(jLabel1);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    jPanel4.add(jPanel8, gridBagConstraints);

    jPanel9.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel9.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    jPanel4.add(jPanel9, gridBagConstraints);

    lblPage.setBackground(java.awt.Color.white);
    lblPage.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblPage.setOpaque(true);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    jPanel4.add(lblPage, gridBagConstraints);

    pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    pnlInScroll.add(pnlPage, gridBagConstraints);

    scrollPane.setViewportView(pnlInScroll);

    pnlMain.add(scrollPane, java.awt.BorderLayout.CENTER);

    add(pnlMain, java.awt.BorderLayout.CENTER);

    pnlStatus.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));

    lblStatus.setFont(new java.awt.Font("Dialog", 1, 10));
    lblStatus.setText("Page i of n");
    pnlStatus.add(lblStatus);

    add(pnlStatus, java.awt.BorderLayout.SOUTH);
}

From source file:com.declarativa.interprolog.gui.ListenerWindow.java

private void UpdategraphComponents() throws IOException {
    jLayeredPane1.removeAll();/* ww  w.  j  a  v  a2 s  .  co m*/

    List<String> heads = new ArrayList<>();
    List<String> subgrph = new ArrayList<>();
    ArgBuildManager manag = new ArgBuildManager();
    Forest<String, Integer> graphGUI = new DelegateForest<>();
    graphGUI = manag.getGraphJung();

    System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount());

    Forest<String, Integer> forest = new DelegateForest<>();
    //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));
    ObservableGraph g = new ObservableGraph(graphGUI);

    //Layout layout = new BalloonLayout(forest);
    Layout layout = new BalloonLayout(graphGUI);
    //Layout layout = new TreeLayout(forest, 70, 70);

    final BaseJungScene scene2 = new SceneImpl(g, layout);

    //  jLayeredPane1.setLayout(new BorderLayout());     
    //jf.setLayout(new BorderLayout());
    jLayeredPane1.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);
    //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER);

    JToolBar bar = new JToolBar();
    bar.setMargin(new Insets(5, 5, 5, 5));
    bar.setLayout(new FlowLayout(5));
    DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>();
    mdl.addElement(new KKLayout(g));
    mdl.addElement(layout);
    mdl.addElement(new BalloonLayout(forest));
    mdl.addElement(new RadialTreeLayout(forest));
    mdl.addElement(new CircleLayout(g));
    mdl.addElement(new FRLayout(g));
    mdl.addElement(new FRLayout2(g));
    mdl.addElement(new ISOMLayout(g));
    mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g));
    mdl.addElement(new SpringLayout2(g));
    mdl.addElement(new DAGLayout(g));
    mdl.addElement(new XLayout(g));
    mdl.setSelectedItem(layout);
    final JCheckBox checkbox = new JCheckBox("Animate iterative layouts");

    scene2.setLayoutAnimationFramesPerSecond(48);

    final JComboBox<Layout> layouts = new JComboBox(mdl);
    layouts.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    bar.add(new JLabel(" Layout Type"));
    bar.add(layouts);
    layouts.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            Layout layout = (Layout) layouts.getSelectedItem();
            // These two layouts implement IterativeContext, but they do
            // not evolve toward anything, they just randomly rearrange
            // themselves.  So disable animation for these.
            if (layout instanceof ISOMLayout || layout instanceof DAGLayout) {
                checkbox.setSelected(false);
            }
            scene2.setGraphLayout(layout, true);
        }
    });

    bar.add(new JLabel(" Connection Shape"));
    DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>();
    shapes.addElement(new EdgeShape.QuadCurve<String, Number>());
    shapes.addElement(new EdgeShape.BentLine<String, Number>());
    shapes.addElement(new EdgeShape.CubicCurve<String, Number>());
    shapes.addElement(new EdgeShape.Line<String, Number>());
    shapes.addElement(new EdgeShape.Box<String, Number>());
    shapes.addElement(new EdgeShape.Orthogonal<String, Number>());
    shapes.addElement(new EdgeShape.Wedge<String, Number>(10));

    final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(
            shapes);
    shapesBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox
                    .getSelectedItem();
            scene2.setConnectionEdgeShape(xform);
        }
    });
    shapesBox.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln,
                boolean bln1) {
            o = o.getClass().getSimpleName();
            return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates.
        }
    });
    shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>());
    bar.add(shapesBox);

    //jf.add(bar, BorderLayout.NORTH);
    bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView()));
    bar.setFloatable(false);
    bar.setRollover(true);

    final JLabel selectionLabel = new JLabel("<html>&nbsp;</html>");
    System.out.println("LOOKUP IS " + scene2.getLookup());
    Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class);
    LookupListener listener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
            System.out.println("RES CHANGED");
            Lookup.Result<String> res = (Lookup.Result<String>) le.getSource();
            StringBuilder sb = new StringBuilder("<html>");
            List<String> l = new ArrayList<>(res.allInstances());
            Collections.sort(l);
            for (String s : l) {
                if (sb.length() != 0) {
                    sb.append(", ");
                }
                sb.append(s);
            }
            sb.append("</html>");
            selectionLabel.setText(sb.toString());
            System.out.println("LOOKUP EVENT " + sb);
        }
    };
    selectedNodes.addLookupListener(listener);
    selectedNodes.allInstances();

    bar.add(selectionLabel);

    checkbox.setSelected(true);
    checkbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            scene2.setAnimateIterativeLayouts(checkbox.isSelected());
        }
    });
    bar.add(checkbox);
    jLayeredPane3.setLayout(new BorderLayout());

    jLayeredPane3.add(bar);
    //        jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700);
    //        jf.setSize(new Dimension(1280, 720));
    //        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    this.repaint();
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent we) {
            scene2.relayout(true);
            scene2.validate();
        }
    });

}

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

private void buildMenu() {
    clickAccount = new ClickAccountPanel();
    JXTaskPane farmSourcePane = new JXTaskPane();
    farmSourcePane.setTitle("Farmen suchen");
    JXButton searchBarbs = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/search_barbs.png")));
    searchBarbs.setToolTipText("Barbarendrfer im Umkreis suchen");
    searchBarbs.addActionListener(new ActionListener() {

        @Override//  www .  j  a v  a2  s.c  o m
        public void actionPerformed(ActionEvent e) {
            Tribe yourTribe = GlobalOptions.getSelectedProfile().getTribe();
            coordSpinner
                    .setValue(DSCalculator.calculateCenterOfMass(Arrays.asList(yourTribe.getVillageList())));
            jFarmFromBarbarianSelectionDialog.pack();
            jFarmFromBarbarianSelectionDialog.setLocationRelativeTo(DSWorkbenchFarmManager.getSingleton());
            jFarmFromBarbarianSelectionDialog.setVisible(true);
        }
    });

    farmSourcePane.getContentPane().add(searchBarbs);

    JXButton searchBarbsFromClipboard = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/farms_from_clipboard.png")));
    searchBarbsFromClipboard.setToolTipText("Barbarendrfer in der Zwischenablage suchen");
    searchBarbsFromClipboard.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FarmManager.getSingleton().findFarmsInClipboard();
        }
    });

    farmSourcePane.getContentPane().add(searchBarbsFromClipboard);

    JXButton searchReports = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/search_reports.png")));

    searchReports.setToolTipText("Farmen in Berichtdatenbank suchen");
    searchReports.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
            model.addElement("Alle");
            for (String set : ReportManager.getSingleton().getGroups()) {
                if (!set.equals(ReportManager.FARM_SET)) {
                    model.addElement(set);
                }
            }
            jReportSetBox.setModel(model);
            jFarmFromReportSelectionDialog.pack();
            jFarmFromReportSelectionDialog.setLocationRelativeTo(DSWorkbenchFarmManager.getSingleton());
            jFarmFromReportSelectionDialog.setVisible(true);
        }
    });

    farmSourcePane.getContentPane().add(searchReports);

    JXButton centerFarm = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/center_ingame.png")));

    centerFarm.setToolTipText("ffnet die Dorfbersicht der gewhlten Farm im Spiel");
    centerFarm.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            openVillageInfo();
        }
    });
    farmSourcePane.getContentPane().add(centerFarm);

    JXButton markLastFarm = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/last_report.png")));

    markLastFarm.setToolTipText("Whlt die letzte Farm aus, fr die ein Bericht eingelesen wurde");
    markLastFarm.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            selectLastFarm();
        }
    });
    farmSourcePane.getContentPane().add(markLastFarm);
    JXTaskPane farmPane = new JXTaskPane();
    farmPane.setTitle("Farmaktionen");

    JXButton farmA = new JXButton(new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/farmA.png")));

    farmA.setToolTipText("Farmtruppen vom Typ A zur gewhlten Farm schicken");
    farmA.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            farmA();
        }
    });

    farmPane.getContentPane().add(farmA);

    JXButton farmB = new JXButton(new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/farmB.png")));

    farmB.setToolTipText("Farmtruppen vom Typ B zur gewhlten Farm schicken");
    farmB.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            farmB();
        }
    });

    farmPane.getContentPane().add(farmB);

    JXButton farmK = new JXButton(new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/farmK.png")));

    farmK.setToolTipText("Farmtruppen vom Typ K zur gewhlten Farm schicken");
    farmK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            farmK();
        }
    });

    farmPane.getContentPane().add(farmK);

    JXButton farmC = new JXButton(new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/farmC.png")));

    farmC.setToolTipText("Farmtruppen entsprechend der in der Farm vorhandenen Ressourcen schicken");
    farmC.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            farmC();
        }
    });

    farmPane.getContentPane().add(farmC);

    JXTaskPane miscPane = new JXTaskPane();
    miscPane.setTitle("Sonstiges");

    JXButton clearStatus = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/clear_fs.png")));

    clearStatus.setToolTipText("Laufenden Farmangriff fr die gewhlte Farmen zurcksetzen");
    clearStatus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            resetStatus();
        }
    });

    miscPane.getContentPane().add(clearStatus);

    JXButton clearSiegeStatus = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/clear_fs.png")));

    clearSiegeStatus.setToolTipText("Laufenden Katapultangriff fr die gewhlte Farmen zurcksetzen");
    clearSiegeStatus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            resetSiegeStatus();
        }
    });

    miscPane.getContentPane().add(clearSiegeStatus);
    JXButton revalidateFarms = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/check_farms.png")));

    revalidateFarms.setToolTipText("Farmen auf Adelungen und sonstige Vernderungen prfen");
    revalidateFarms.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showInfo("Prfung abgeschlossen");
        }
    });

    miscPane.getContentPane().add(revalidateFarms);
    JXButton showFarmInfo = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/farm_info.png")));

    showFarmInfo.setToolTipText("Informationen ber die gewhlte Farm anzeigen");
    showFarmInfo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new FarmInformationDetailsDialog(DSWorkbenchFarmManager.this, false)
                    .setupAndShow(getSelectedInformation());
        }
    });

    miscPane.getContentPane().add(showFarmInfo);

    JXButton resetLockedStatus = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/lock_open.png")));

    resetLockedStatus.setToolTipText(
            "Gewhlte Farmen entsperren und wieder fr Farmangriffe freigeben oder fr Farmangriffe sperren");
    resetLockedStatus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            lockUnlockSelection();
        }
    });

    miscPane.getContentPane().add(resetLockedStatus);
    // Work in progress: implement farming by groups
    JXButton farmByGroups = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/Advanced_options.png")));

    farmByGroups.setToolTipText("Gruppe zum farmen auswhlen");
    farmByGroups.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
            model.addElement("Alle");
            for (String g : TagManager.getSingleton().getAllTagNames()) {
                model.addElement(g);
            }

            jFarmGroup.setModel(model);
            jFarmGroup.setSelectedItem(DSWorkbenchFarmManager.SelectedFarmGroup);

            jAdvancedSettingsDialog.pack();
            jAdvancedSettingsDialog.setLocationRelativeTo(DSWorkbenchFarmManager.getSingleton());
            jAdvancedSettingsDialog.setVisible(true);
        }

    });

    miscPane.getContentPane().add(farmByGroups);

    JXButton showOverallStatus = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/chart.png")));

    showOverallStatus.setToolTipText("Zeigt Informationen ber alle eingetragenen Farmen");
    showOverallStatus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showOverallStatus();
        }
    });

    miscPane.getContentPane().add(showOverallStatus);

    JXButton resortButton = new JXButton(
            new ImageIcon(DSWorkbenchFarmManager.class.getResource("/res/ui/replace2.png")));

    resortButton.setToolTipText("Aktualisiert die Sortierung der Tabelle");
    resortButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ((TableSortController) jFarmTable.getRowSorter()).sort();
        }
    });

    miscPane.getContentPane().add(resortButton);

    centerPanel.setupTaskPane(clickAccount, farmSourcePane, farmPane, miscPane);
}