Example usage for javax.swing.event ChangeEvent getSource

List of usage examples for javax.swing.event ChangeEvent getSource

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*from  www  .  j  a  v  a  2  s . c o  m*/
 *
 * @return _more_
 *
 * @throws RemoteException _more_
 * @throws VisADException _more_
 */
public JComponent doMakeViewpointPanel() throws VisADException, RemoteException {

    JSlider speedSlider = new JSlider(1, 200, 200 - animationSpeed);
    speedSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider slider = (JSlider) e.getSource();
            if (!slider.getValueIsAdjusting()) {
                animationSpeed = 200 - slider.getValue() + 1;
            }
        }
    });

    showTimesCbx = new JCheckBox("Set Animation Time", showTimes);
    showTimesCbx.setEnabled(hasTimes);
    animateCbx = new JCheckBox("Animated", animate);
    changeViewpointCbx = new JCheckBox("Change Viewpoint", changeViewpoint);

    orients = new Vector<TwoFacedObject>();
    orients.add(new TwoFacedObject("Towards Next Point", ORIENT_POINT));
    orients.add(new TwoFacedObject("Forward", ORIENT_FORWARD));
    orients.add(new TwoFacedObject("Up", ORIENT_UP));
    orients.add(new TwoFacedObject("Down", ORIENT_DOWN));
    orients.add(new TwoFacedObject("Left", ORIENT_LEFT));
    orients.add(new TwoFacedObject("Right", ORIENT_RIGHT));
    orientBox = new JComboBox(orients);
    orientBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            orientation = TwoFacedObject.getIdString(orientBox.getSelectedItem());
            goToCurrent();
        }
    });

    if (animationInfo == null) {
        animationInfo = new AnimationInfo();
        animationInfo.setShareIndex(true);
    }

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            Misc.run(Flythrough.this, "goToCurrent");
        }
    };

    //xxxxx

    animationWidget = new AnimationWidget(null, null, animationInfo);

    if ((getShareGroup() == null) || getShareGroup().equals(SharableManager.GROUP_ALL)) {
        setShareGroup("flythrough");
    }
    animationWidget.setShareGroup(getShareGroup());
    animationWidget.setSharing(getSharing());

    animation = new Animation();
    animation.setAnimationInfo(animationInfo);
    animation.addPropertyChangeListener(this);
    animationWidget.setAnimation(animation);

    locationMarker = new SelectorPoint("flythrough.point",
            ShapeUtility.setSize(ShapeUtility.createShape(ShapeUtility.AIRPLANE3D)[0], .1f),
            new RealTuple(RealTupleType.SpatialCartesian3DTuple, new double[] { 0, 0, 0 }));

    locationMarker.setAutoSize(true);
    locationMarker.setManipulable(false);
    locationMarker.setColor(Color.green);
    locationMarker.setVisible(false);

    locationLine = new LineDrawing("flythroughpoint.line");
    locationLine.setVisible(false);
    locationLine.setLineWidth(2);
    locationLine.setColor(Color.green);

    //        locationLine2 = new LineDrawing("flythroughpoint.line2");
    //        locationLine2.setVisible(false);
    //        locationLine2.setLineWidth(2);
    //        locationLine2.setColor(Color.red);
    //        viewManager.getMaster().addDisplayable(locationLine2);

    Misc.runInABit(2000, this, "setScaleOnMarkers", null);

    viewManager.getMaster().addDisplayable(locationMarker);
    viewManager.getMaster().addDisplayable(locationLine);

    readout = new CursorReadoutWindow(viewManager, false);

    //zoomFld = new JTextField(zoom + "", 5);
    zoomFld = new JTextField(Misc.format(zoom), 5);

    for (int i = 0; i < tilt.length; i++) {
        final int theIndex = i;
        tiltSliders[i] = new JSlider(-90, 90, (int) tilt[i]);
        tiltSliders[i].setToolTipText("Control-R: reset");
        tiltSliders[i].addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) {
                    tilt[theIndex] = 0;
                    tiltLabels[theIndex].setText("" + (int) tilt[theIndex]);
                    tiltSliders[theIndex].setValue(0);
                    goToCurrent();
                }
            }
        });

        tiltLabels[i] = new JLabel("" + (int) tilt[i]);
        tiltSliders[i].addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                JSlider slider = (JSlider) e.getSource();
                tiltLabels[theIndex].setText("" + slider.getValue());
                if (!slider.getValueIsAdjusting()) {
                    tilt[theIndex] = slider.getValue();
                    goToCurrent();
                }
            }
        });
    }

    zoomFld.addActionListener(listener);

    fixedZCbx = GuiUtils.makeCheckbox("Use fixed Z", this, "useFixedZ");
    GuiUtils.tmpInsets = GuiUtils.INSETS_5;
    JComponent orientationComp = GuiUtils.formLayout(new Component[] { GuiUtils.filler(),
            GuiUtils.left(changeViewpointCbx), GuiUtils.rLabel("Tilt Down/Up:"),
            GuiUtils.centerRight(tiltSliders[0], tiltLabels[0]), GuiUtils.rLabel("Tilt Left/Right:"),
            GuiUtils.centerRight(tiltSliders[1], tiltLabels[1]), GuiUtils.rLabel("Zoom:"),
            GuiUtils.left(zoomFld), GuiUtils.rLabel("Orientation:"),
            GuiUtils.left(GuiUtils.hbox(orientBox, (doGlobe() ? GuiUtils.filler() : (JComponent) fixedZCbx))),
            //            GuiUtils.rLabel("Tilt Down/Up:"), GuiUtils.centerRight(tiltSliders[2],tiltLabels[2]),

            GuiUtils.rLabel("Transitions:"),
            GuiUtils.vbox(GuiUtils.left(animateCbx), GuiUtils.leftCenter(new JLabel("Speed"), speedSlider)),
            GuiUtils.filler(), GuiUtils.left(showTimesCbx), });

    return GuiUtils.top(orientationComp);

}

From source file:com.mirth.connect.client.ui.ChannelPanel.java

public void initPanelPlugins() {
    loadPanelPlugins();// www  .  j a va2s.c o m
    switchBottomPane();

    ChangeListener changeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
            int index = sourceTabbedPane.getSelectedIndex();
            loadPanelPlugin(sourceTabbedPane.getTitleAt(index));
        }
    };
    tabPane.addChangeListener(changeListener);
}

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

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

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

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

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

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

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

    select.addChangeListener(new ChangeListener() {

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

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

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

    showNumberOfElements.addChangeListener(new ChangeListener() {

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

    autoAssignGroup.addChangeListener(new ChangeListener() {

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

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

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

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

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

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

    editModeCb.addActionListener(new ActionListener() {

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

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

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

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

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

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

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

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

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

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

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

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

From source file:course_generator.frmMain.java

/**
 * This method is called to initialize the form.
 *///from ww  w . ja  va 2s  . c o m
private void initComponents() {
    // -- Main windows
    // ------------------------------------------------------
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // java.util.ResourceBundle bundle =
    // java.util.ResourceBundle.getBundle("course_generator/Bundle");
    setTitle(bundle.getString("frmMain.title"));
    setIconImages(null);
    // setName("FrameMain");
    // setPreferredSize(new java.awt.Dimension(812, 800));
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    // paneGlobal.setLayout(new GridBagLayout());
    paneGlobal.setLayout(new BorderLayout());

    // -- Menu bar
    // ----------------------------------------------------------
    Create_MenuBarMain();

    // -- Main toolbar
    // ------------------------------------------------------
    Create_MainToolbar();
    paneGlobal.add(ToolBarMain, BorderLayout.NORTH);

    // -- Status bar
    // ------------------------------------------------------
    Create_Statusbar();
    paneGlobal.add(StatusBar, BorderLayout.SOUTH);

    // -- Main split bar (vertical)
    // -----------------------------------------
    SplitPaneMain = new javax.swing.JSplitPane();
    paneGlobal.add(SplitPaneMain, BorderLayout.CENTER);

    // -- Left side of the split bar
    // ----------------------------------------
    jPanelLeft = new javax.swing.JPanel();
    jPanelLeft.setLayout(new java.awt.BorderLayout());

    // -- Add the left panel to the main split panel
    // ------------------------
    SplitPaneMain.setLeftComponent(jPanelLeft);

    // -- Content of the tree
    javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode(
            "Course Generator");
    javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Parcours");
    javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode(
            "Utmb 2011");
    javax.swing.tree.DefaultMutableTreeNode treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Montagnard");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2008");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2009");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2010");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2011");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2012");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2013");
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu");
    treeNode3.add(treeNode4);
    treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait");
    treeNode3.add(treeNode4);
    treeNode2.add(treeNode3);
    treeNode1.add(treeNode2);
    treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Configuration");
    treeNode1.add(treeNode2);

    // -- Tree
    // --------------------------------------------------------------
    jTreeMain = new javax.swing.JTree();
    jTreeMain.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    jTreeMain.setPreferredSize(new java.awt.Dimension(109, 25));

    // -- Add the tree to a scroll panel
    // ------------------------------------
    jScrollPaneTree = new javax.swing.JScrollPane();
    jScrollPaneTree.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jScrollPaneTree.setViewportView(jTreeMain);

    // -- Add the scroll panel to the left panel
    // ----------------------------
    jPanelLeft.add(jScrollPaneTree, java.awt.BorderLayout.CENTER);

    // -- Right split pane
    // --------------------------------------------------
    SplitPaneMainRight = new javax.swing.JSplitPane();
    SplitPaneMainRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    SplitPaneMain.setRightComponent(SplitPaneMainRight);

    // -- Tabbed panel
    // ------------------------------------------------------
    TabbedPaneMain = new javax.swing.JTabbedPane();
    // -- Create the listener
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
            int index = sourceTabbedPane.getSelectedIndex();
            if (index == 4) // Tab Resume
                RefreshResume();
        }
    };
    TabbedPaneMain.addChangeListener(changeListener);

    SplitPaneMainRight.setTopComponent(TabbedPaneMain);

    // -- Tab - data (grid)
    // -------------------------------------------------
    TableMain = new javax.swing.JTable();
    TableMain.setModel(ModelTableMain);
    TableMain.getTableHeader()
            .setDefaultRenderer(new MainHeaderRenderer(TableMain.getTableHeader().getDefaultRenderer()));
    TableMain.getTableHeader().setReorderingAllowed(false);

    TableMain.setDefaultRenderer(ElevationClass.class, new ElevationRenderer());
    TableMain.setDefaultRenderer(DistClass.class, new DistRenderer());
    TableMain.setDefaultRenderer(TotalClass.class, new TotalRenderer());
    TableMain.setDefaultRenderer(DiffClass.class, new DiffRenderer());
    TableMain.setDefaultRenderer(CoeffClass.class, new CoeffRenderer());
    TableMain.setDefaultRenderer(LatClass.class, new LatRenderer());
    TableMain.setDefaultRenderer(LonClass.class, new LonRenderer());
    TableMain.setDefaultRenderer(RecupClass.class, new RecupRenderer());
    TableMain.setDefaultRenderer(TimeClass.class, new TimeRenderer());
    TableMain.setDefaultRenderer(TimelimitClass.class, new TimelimitRenderer());
    TableMain.setDefaultRenderer(HourClass.class, new HourRenderer());
    TableMain.setDefaultRenderer(StationClass.class, new StationRenderer());
    TableMain.setDefaultRenderer(TagClass.class, new TagRenderer());

    TableMain.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    TableMain.setRowHeight(20);
    TableMain.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() >= 2 && !evt.isConsumed()) {
                evt.consume();
                int row = TableMain.rowAtPoint(evt.getPoint());
                int col = TableMain.columnAtPoint(evt.getPoint());
                frmEditPosition frm = new frmEditPosition();
                if (frm.showDialog(Settings, Track, row, col)) {
                    Track.isModified = true;
                    RefreshTableMain();
                    RefreshProfil();
                    RefreshStatusbar(Track);
                }
            } else
                TableMainMouseClicked(evt);
        }
    });
    TableMain.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            TableMainKeyReleased(evt);
        }
    });

    // -- Add the grid to a scroll panel
    // ------------------------------------
    jScrollPaneData = new javax.swing.JScrollPane();
    jScrollPaneData.setViewportView(TableMain);

    // -- Add the scroll panel to the tabbed panel
    // --------------------------
    addTab(TabbedPaneMain, jScrollPaneData, bundle.getString("frmMain.TabData.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/satellite16.png")));

    // -- Tab - Profil
    // ------------------------------------------------------
    jPanelProfil = new javax.swing.JPanel();
    jPanelProfil.setPreferredSize(new java.awt.Dimension(677, 150));
    jPanelProfil.setLayout(new java.awt.BorderLayout());

    // -- Profil tool bar
    // ---------------------------------------------------
    // Create_Profil_Toolbar();
    // jPanelProfil.add(ToolBarProfil, java.awt.BorderLayout.WEST);

    // -- Profil chart
    // ------------------------------------------------------
    jPanelProfilChart = new ChartPanel(chart);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    // xCrosshair.setLabelVisible(true);
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);

    yCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    // yCrosshair.setLabelVisible(true);
    yCrosshair.setLabelBackgroundPaint(Color.WHITE);

    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);

    jPanelProfilChart.addOverlay(crosshairOverlay);
    jPanelProfilChart.setBackground(new java.awt.Color(255, 0, 51));
    jPanelProfilChart.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent event) {

            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                yCrosshair.setValue(y);
                RefreshProfilInfo(i);
                //Refresh the position on the data grid
                TableMain.setRowSelectionInterval(i, i);
                Rectangle rect = TableMain.getCellRect(i, 0, true);
                TableMain.scrollRectToVisible(rect);
                //Refresh the marker position on the map
                RefreshCurrentPosMarker(Track.data.get(i).getLatitude(), Track.data.get(i).getLongitude());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });

    jPanelProfil.add(jPanelProfilChart, java.awt.BorderLayout.CENTER);

    // -- Profil info bar
    // ---------------------------------------------------
    jPanelProfilInfo = new javax.swing.JPanel();
    jPanelProfilInfo.setLayout(new GridBagLayout());
    jPanelProfil.add(jPanelProfilInfo, java.awt.BorderLayout.SOUTH);

    // -- Line 0
    // -- Distance
    // ----------------------------------------------------------
    lbProfilDistance = new javax.swing.JLabel();
    lbProfilDistance.setText(" " + bundle.getString("frmMain.lbProfilDistance.text") + "=0.000km ");
    lbProfilDistance.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilDistance, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.BOTH);

    // -- Time
    // --------------------------------------------------------------
    lbProfilTime = new javax.swing.JLabel();
    lbProfilTime.setText(" " + bundle.getString("frmMain.lbProfilTime.text") + "=00:00:00 ");
    lbProfilTime.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilTime, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Slope
    // -------------------------------------------------------------
    lbProfilSlope = new javax.swing.JLabel();
    lbProfilSlope.setText(" " + bundle.getString("frmMain.lbProfilSlope.text") + "=0.0% ");
    lbProfilSlope.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilSlope, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Name
    // --------------------------------------------------------------
    lbProfilName = new javax.swing.JLabel();
    lbProfilName.setText(" " + bundle.getString("frmMain.lbProfilName.text") + "= ");
    lbProfilName.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilName, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Line 1
    // -- Elevation
    // ---------------------------------------------------------
    lbProfilElevation = new javax.swing.JLabel();
    lbProfilElevation.setText(" " + bundle.getString("frmMain.lbProfilElevation.text") + "=0m ");
    lbProfilElevation.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilElevation, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.BOTH);

    // -- Hour
    // --------------------------------------------------------------
    lbProfilHour = new javax.swing.JLabel();
    lbProfilHour.setText(" " + bundle.getString("frmMain.lbProfilHour.text") + "=00:00:00 ");
    lbProfilHour.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilHour, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Speed
    // -------------------------------------------------------------
    lbProfilSpeed = new javax.swing.JLabel();
    lbProfilSpeed.setText(" " + bundle.getString("frmMain.lbProfilSpeed.text") + "=0.0km/h ");
    lbProfilSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilSpeed, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);

    // -- Comment
    // -----------------------------------------------------------
    lbProfilComment = new javax.swing.JLabel();
    lbProfilComment.setText(" " + bundle.getString("frmMain.lbProfilComment.text") + "= ");
    lbProfilComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilComment, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH);
    // -- Distance / Temps / Pente / Nom
    // -- Altitude / Heure / Vitesse / Commentaire

    // -- Add the panel to the tabbed panel
    // ---------------------------------
    addTab(TabbedPaneMain, jPanelProfil, bundle.getString("frmMain.TabProfil.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/profil.png")));

    // -- Tab - Statistic
    // ---------------------------------------------------
    jPanelStatistic = new javax.swing.JPanel();
    jPanelStatistic.setLayout(new java.awt.BorderLayout());

    // -- Statistic tool bar
    // ---------------------------------------------------
    Create_Statistic_Toolbar();
    jPanelStatistic.add(ToolBarStatistic, java.awt.BorderLayout.NORTH);

    // TODO Add the component to display the statistics

    addTab(TabbedPaneMain, jPanelStatistic, bundle.getString("frmMain.TabStatistic.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/stat.png")));

    // -- Tab - Analysis
    // ----------------------------------------------------
    jPanelAnalyze = new javax.swing.JPanel();

    // TODO Define this panel

    addTab(TabbedPaneMain, jPanelAnalyze, bundle.getString("frmMain.TabAnalyze.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/search.png")));

    // -- Tab - Resume
    // ------------------------------------------------------
    jPanelResume = new javax.swing.JPanel();
    jPanelResume.setLayout(new java.awt.BorderLayout());

    // -- Resume tool bar
    // ---------------------------------------------------
    Create_Resume_Toolbar();
    jPanelResume.add(ToolBarResume, java.awt.BorderLayout.NORTH);

    TableResume = new javax.swing.JTable();
    TableResume.setModel(ModelTableResume);
    TableResume.setRowHeight(20);
    TableResume.getTableHeader().setReorderingAllowed(false);

    TableResume.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);

    TableResume.getTableHeader()
            .setDefaultRenderer(new ResumeHeaderRenderer(TableResume.getTableHeader().getDefaultRenderer()));

    // TODO Change the Renderer name. Add Resume...
    TableResume.setDefaultRenderer(ResumeNumClass.class, new ResumeNumRenderer());
    TableResume.setDefaultRenderer(ResumeNameClass.class, new ResumeNameRenderer());
    TableResume.setDefaultRenderer(ResumeLineClass.class, new ResumeLineRenderer());
    TableResume.setDefaultRenderer(ResumeElevationClass.class, new ResumeElevationRenderer());
    TableResume.setDefaultRenderer(ResumeClimbPClass.class, new ResumeClimbPRenderer());
    TableResume.setDefaultRenderer(ResumeClimbNClass.class, new ResumeClimbNRenderer());
    TableResume.setDefaultRenderer(ResumeDistanceClass.class, new ResumeDistanceRenderer());
    TableResume.setDefaultRenderer(ResumeTimeClass.class, new ResumeTimeRenderer());
    TableResume.setDefaultRenderer(ResumeHourClass.class, new ResumeHourRenderer());
    TableResume.setDefaultRenderer(ResumedtTimeClass.class, new ResumedtTimeRenderer());
    TableResume.setDefaultRenderer(ResumeTimeLimitClass.class, new ResumeTimeLimitRenderer());
    TableResume.setDefaultRenderer(ResumeStationTimeClass.class, new ResumeStationTimeRenderer());
    TableResume.setDefaultRenderer(ResumedtDistanceClass.class, new ResumedtDistanceRenderer());
    TableResume.setDefaultRenderer(ResumedtClimbPClass.class, new ResumedtClimbPRenderer());
    TableResume.setDefaultRenderer(ResumedtClimbNClass.class, new ResumedtClimbNRenderer());
    TableResume.setDefaultRenderer(ResumeSpeedPClass.class, new ResumeSpeedPRenderer());
    TableResume.setDefaultRenderer(ResumeSpeedNClass.class, new ResumeSpeedNRenderer());
    TableResume.setDefaultRenderer(ResumeAvgSlopePClass.class, new ResumeAvgSlopePRenderer());
    TableResume.setDefaultRenderer(ResumeAvgSlopeNClass.class, new ResumeAvgSlopeNRenderer());
    TableResume.setDefaultRenderer(ResumeAvgSpeedClass.class, new ResumeAvgSpeedRenderer());
    TableResume.setDefaultRenderer(ResumeCommentClass.class, new ResumeCommentRenderer());

    // TableResume.addMouseListener(new java.awt.event.MouseAdapter() {
    // public void mouseClicked(java.awt.event.MouseEvent evt) {
    // TableMainMouseClicked(evt);
    // }
    // });
    // TableResume.addKeyListener(new java.awt.event.KeyAdapter() {
    // public void keyReleased(java.awt.event.KeyEvent evt) {
    // TableMainKeyReleased(evt);
    // }
    // });

    // -- Add the grid to a scroll panel
    // ------------------------------------
    jScrollPaneResume = new javax.swing.JScrollPane();
    jScrollPaneResume.setViewportView(TableResume);
    jPanelResume.add(jScrollPaneResume, java.awt.BorderLayout.CENTER);

    addTab(TabbedPaneMain, jPanelResume, bundle.getString("frmMain.TabResume.tabTitle"),
            new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/grid.png")));

    // -- Map panel
    // ---------------------------------------------------------
    jPanelMap = new javax.swing.JPanel();
    jPanelMap.setLayout(new java.awt.BorderLayout());

    Create_Map_Toolbar();
    jPanelMap.add(jToolBarMapViewer, java.awt.BorderLayout.WEST);

    MapViewer = new org.openstreetmap.gui.jmapviewer.JMapViewer();
    MapViewer.setMapMarkerVisible(true);
    MapViewer.setScrollWrapEnabled(true);
    MapViewer.setZoomButtonStyle(org.openstreetmap.gui.jmapviewer.JMapViewer.ZOOM_BUTTON_STYLE.VERTICAL);
    MapViewer.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            MapViewerMouseClicked(evt);
        }
    });
    jPanelMap.add(MapViewer, java.awt.BorderLayout.CENTER);

    jScrollPanelMap = new javax.swing.JScrollPane();
    jScrollPanelMap.setViewportView(jPanelMap);

    SplitPaneMainRight.setRightComponent(jScrollPanelMap);

    // -- Finished - Pack
    // ---------------------------------------------------
    pack();
}

From source file:org.nuclos.client.ui.collect.Chart.java

/**
 * @param entityName/*  w  w  w.  j  a  v a  2s  .com*/
 * @param toolBarOrientation @see JToolbar#setOrientation
 * @param foreignKeyFieldToParent Needs only be specified if not unique. @see #getForeignKeyFieldToParent()
 * @precondition entityName != null
 * @postcondition this.getForeignKeyFieldToParent() == foreignKeyFieldToParent
 */
public Chart(String entityName, int iScrollPane, int toolBarOrientation, String foreignKeyFieldToParent,
        boolean bFromProperties, boolean bSearchable) {
    super(new GridLayout(1, 1));

    this.bFromProperties = bFromProperties;
    this.bSearchable = bSearchable;

    this.subform = new SubForm(entityName, -1, foreignKeyFieldToParent, bFromProperties) {
        private TableModelListener tblmdllistener;

        public void setupTableModelListener() {
            // set all columns visble.
            if (!(getSubformTable().getModel() instanceof CollectableTableModel<?>))
                return;

            CollectableEntity colEntity = DefaultCollectableEntityProvider.getInstance()
                    .getCollectableEntity(subform.getEntityName());
            List<CollectableEntityField> lstclctefColumns = new ArrayList<CollectableEntityField>();
            for (String sFieldName : colEntity.getFieldNames()) {
                if (!sFieldName.equalsIgnoreCase("genericObject"))
                    lstclctefColumns.add(colEntity.getEntityField(sFieldName));
            }
            ((CollectableTableModel<?>) getSubformTable().getModel()).setColumns(lstclctefColumns);

            this.tblmdllistener = new TableModelListener() {
                boolean enabled = Chart.this.isEnabled();

                @Override
                public void tableChanged(TableModelEvent ev) {
                    Chart.this.setEnabled(
                            (subform.getJTable().getModel() instanceof SearchConditionTableModelImpl) ? false
                                    : enabled);

                    String type = getProperty(PROPERTY_TYPE, String.class);
                    if (type != null) {
                        JFreeChart chart = ChartFunction.valueOf(type).createChart(Chart.this);
                        panel.setChart(chart);
                        panel.repaint();
                    }
                }
            };

            getSubformTable().getModel().addTableModelListener(this.tblmdllistener);
        }

        public void removeTableModelListener() {
            getSubformTable().getModel().removeTableModelListener(this.tblmdllistener);
            this.tblmdllistener = null;
        }
    };

    if (iScrollPane != -1) {
        this.scrollPane = new JScrollPane();
    } else
        this.scrollPane = new JPanel(new BorderLayout());

    this.toolbar = UIUtils.createNonFloatableToolBar(toolBarOrientation);

    this.listeners = new ArrayList<ChartToolListener>();

    if (entityName == null) {
        throw new NullArgumentException("entityName");
    }
    this.entityName = entityName;

    String sDataSource = entityName.substring(MasterDataMetaVO.CHART_ENTITY_PREFIX.length()).toLowerCase();

    try {
        DatasourceVO datasourceVO = DatasourceDelegate.getInstance().getChartByName(sDataSource);
        if (datasourceVO != null) {
            final List<DatasourceParameterVO> lstParams = DatasourceDelegate.getInstance()
                    .getParametersFromXML(datasourceVO.getSource());
            for (Iterator iterator = lstParams.iterator(); iterator.hasNext();) {
                DatasourceParameterVO datasourceParameterVO = (DatasourceParameterVO) iterator.next();
                if (datasourceParameterVO.getParameter().equals("genericObject"))
                    iterator.remove();
            }
            if (!lstParams.isEmpty() && !bSearchable && !bFromProperties) {
                JPanel pnl = new JPanel(new BorderLayout());
                ParameterPanel pnlParameters = new ParameterPanel(lstParams, new ChangeListener() {
                    @Override
                    public void stateChanged(ChangeEvent e) {
                        if (e != null && e.getSource() instanceof ParameterPanel) {
                            try {
                                Map<String, Object> mpParams = new HashMap<String, Object>();
                                ((ParameterPanel) e.getSource()).fillParameterMap(lstParams, mpParams);
                                subform.setMapParams(mpParams);
                            } catch (Exception e2) {
                                //ignore.
                            }
                        }
                    }
                });
                pnl.add(pnlParameters, BorderLayout.NORTH);

                JSplitPane splitPane = new JSplitPane(
                        toolBarOrientation == -1 ? JSplitPane.VERTICAL_SPLIT : toolBarOrientation, pnl,
                        scrollPane);
                contentPane.add(splitPane, BorderLayout.CENTER);
            } else
                contentPane.add(scrollPane, BorderLayout.CENTER);
        } else {
            contentPane.add(scrollPane, BorderLayout.CENTER);
        }
    } catch (Exception e) {
        throw new NuclosFatalException("init failed for datasource " + sDataSource, e);
    }

    if (toolBarOrientation == -1) {
        this.toolbar.setVisible(false);
    } else {
        this.toolbar.setOrientation(toolBarOrientation);
    }
    this.foreignKeyFieldToParent = foreignKeyFieldToParent;

    layer = new JXLayer<JComponent>(contentPane, new TranslucentLockableUI());
    layer.setName("JXLayerGlasspane");
    add(layer);

    this.init(iScrollPane);

    toolbarButtons = new HashMap<String, AbstractButton>();
    toolbarMenuItems = new HashMap<String, JMenuItem>();
    toolbarOrder = new ArrayList<String>();
    for (ToolbarFunction func : ToolbarFunction.values()) {
        AbstractButton button = func.createButton();
        JMenuItem mi = func.createMenuItem();
        toolbarButtons.put(func.name(), button);
        toolbarMenuItems.put(func.name(), mi);
        toolbar.add(button);
        if (func.equals(ToolbarFunction.PRINT)) {
            button.addActionListener(panel);
            mi.addActionListener(panel);
        } else {
            button.addActionListener(this);
            mi.addActionListener(this);
        }
        toolbarOrder.add(func.name());
    }

    subform.setReadOnly(true);
    setEnabled(!bFromProperties && !bSearchable);

    addChartToolListener(new ChartToolListener() {

        @Override
        public void toolbarAction(String actionCommand) {
            if (actionCommand.equals(ToolbarFunction.SHOW.name())) {
                actionCommandShow();
            } else if (actionCommand.equals(ToolbarFunction.SAVE.name())) {
                actionCommandSave();
            }
        }
    });

    assert this.getForeignKeyFieldToParent() == foreignKeyFieldToParent;
}

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyAssignISOs.java

/**
 * @return/*from   www.  ja  v a2  s  .  c  om*/
 */
@SuppressWarnings("rawtypes")
public boolean buildAsyncOrig(final int earthId) {
    String sql = adjustSQL(
            "SELECT COUNT(*) FROM geography WHERE GeographyCode IS NOT NULL AND RankID = 100 AND GeographyTreeDefID = GEOTREEDEFID");
    int numContinentsWithNames = BasicSQLUtils.getCountAsInt(sql);

    continentsCBX = createCheckBox("All Continents"); // I18N

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb1 = new PanelBuilder(new FormLayout("f:p:g", "p,4px,p,4px,p,8px"));
    countriesCBX = createCheckBox("All Countries");
    stateCBX = createCheckBox("All States");
    countiesCBX = createCheckBox("All Counties");
    pb1.add(countriesCBX, cc.xy(1, 1));
    pb1.add(stateCBX, cc.xy(1, 3));
    //pb1.add(countiesCBX,   cc.xy(1, 5));

    allCountriesRB = new JRadioButton("Choose the Geography level to be processed"); //L18N
    singleCountryRB = new JRadioButton("Choose an individual Country");
    btnGroup = new ButtonGroup();
    btnGroup.add(this.allCountriesRB);
    btnGroup.add(this.singleCountryRB);

    if (numContinentsWithNames == 0) {
        continentsCBX.setEnabled(false);
        continentsCBX.setSelected(true);
    }

    countriesCBX.setEnabled(true);
    stateCBX.setEnabled(false);
    countiesCBX.setEnabled(false);

    countryIds.clear();
    sql = "SELECT g.GeographyID, g.Name, g2.Name FROM geography g LEFT JOIN geography g2 ON g.ParentID = g2.GeographyID "
            + "WHERE g.Name IS NOT NULL && LENGTH(g.Name) > 0 AND g.RankID = 200 AND g.GeographyTreeDefID = GEOTREEDEFID ORDER BY g.Name";
    sql = adjustSQL(sql);

    Vector<Object[]> rows = query(sql);
    Object[] titles = new Object[rows.size() + 1];
    int i = 0;
    titles[i++] = "None"; // I18N
    countryIds.add(-1);
    for (Object[] r : rows) {
        countryIds.add((Integer) r[0]);
        String countryStr = (String) r[1];
        String contStr = (String) r[2];
        titles[i++] = countryStr != null ? (countryStr + " (" + contStr + ")") : countryStr;
    }

    PanelBuilder pb2 = new PanelBuilder(new FormLayout("8px,p,2px,f:p:g", "p,4px,p,8px"));
    spCountriesLbl = createFormLabel("Country"); // I18N
    spCountriesCmbx = createComboBox(titles);
    spStatesCBX = createCheckBox("States (Required)"); // I18N
    spCountiesCBX = createCheckBox("Counties"); // I18N

    pb2.add(spCountriesLbl, cc.xy(2, 1));
    pb2.add(spCountriesCmbx, cc.xy(4, 1));
    pb2.add(spStatesCBX, cc.xyw(1, 3, 4));
    //pb2.add(spCountiesCBX,   cc.xyw(1, 5, 4));

    spCountriesCmbx.setSelectedIndex(0);

    spStatesCBX.setSelected(true);
    spStatesCBX.setEnabled(false);
    spCountiesCBX.setEnabled(false);

    String rowDef = createDuplicateJGoodiesDef("p", "4px", 8);
    PanelBuilder pb = new PanelBuilder(new FormLayout("16px,f:p:g", rowDef));

    pb.addSeparator("Continents to be processed", cc.xyw(1, 1, 2));
    pb.add(continentsCBX, cc.xyw(1, 3, 2));

    pb.addSeparator("Countries to be processed", cc.xyw(1, 5, 2));
    pb.add(allCountriesRB, cc.xyw(1, 7, 2));
    pb.add(pb1.getPanel(), cc.xyw(2, 9, 1));

    pb.add(singleCountryRB, cc.xyw(1, 11, 2));
    pb.add(pb2.getPanel(), cc.xyw(2, 13, 1));

    pb.add(createGeoStatsPanel(), cc.xyw(1, 15, 2));

    pb.setDefaultDialogBorder();
    final CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), "ISO Code Processing", true,
            CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N
    dlg.setHelpContext("GeoCleanUpLevelChooser");

    // Setup actions
    ChangeListener rbChangeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            radioSelected(dlg);
        }
    };
    allCountriesRB.addChangeListener(rbChangeListener);
    singleCountryRB.addChangeListener(null);

    countriesCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean isSel = countriesCBX.isSelected();
            stateCBX.setEnabled(isSel);
            countiesCBX.setEnabled(false);
            if (!isSel) {
                stateCBX.setSelected(false);
                countiesCBX.setSelected(false);
            }
            calcGeoStats();
            dlg.getOkBtn().setEnabled(isSel || spCountriesCmbx.getSelectedIndex() > 0);
        }
    });

    stateCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            countiesCBX.setEnabled(stateCBX.isSelected());
            if (!stateCBX.isSelected()) {
                countiesCBX.setSelected(false);
            }
            calcGeoStats();
        }
    });

    // Special
    spCountriesCmbx.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSel = spCountriesCmbx.getSelectedIndex() > 0;
            spStatesCBX.setSelected(isSel);
            spCountiesCBX.setEnabled(isSel);
            if (!isSel) {
                spStatesCBX.setSelected(false);
                spCountiesCBX.setSelected(false);
            }
            calcGeoStats();
            dlg.getOkBtn().setEnabled(isSel || countriesCBX.isSelected());

        }
    });

    spStatesCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            spCountiesCBX.setEnabled(stateCBX.isSelected());
            calcGeoStats();
        }
    });

    allCountriesRB.setSelected(true);

    dlg.createUI();
    dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called after 'createUI'
    dlg.getOkBtn().setEnabled(false);

    // AUTO Don't show Dialog because it is automatically setting what to do 
    centerAndShow(dlg);

    if (dlg.isCancelled()) {
        return false;
    }

    connectToDB();

    if (true) // AUTO 
    {
        doAllCountries = new boolean[] { countriesCBX.isSelected(), stateCBX.isSelected(),
                countiesCBX.isSelected(), false };
        doInvCountry = new boolean[] { spCountriesCmbx.getSelectedIndex() > 0, spStatesCBX.isSelected(),
                spCountiesCBX.isSelected(), false };
        doIndvCountryId = doInvCountry[0] ? countryIds.get(spCountriesCmbx.getSelectedIndex()) : null;
    } else {
        int indexOfUSA = getUnitedStatesIndex(titles);
        if (indexOfUSA == -1) {
            Vector<Object> nameList = new Vector<Object>();
            Collections.addAll(nameList, titles);
            JList list = createList(nameList);

            JScrollPane sp = createScrollPane(list);
            pb = new PanelBuilder(new FormLayout("f:p:g", "p,8px,f:p:g"));
            pb.add(createLabel("Select the United States"), cc.xy(1, 1));
            pb.add(sp, cc.xy(1, 3));
            pb.setDefaultDialogBorder();
            final CustomDialog askDlg = new CustomDialog((Frame) getTopWindow(), "Choose", true,
                    CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N
            dlg.setHelpContext("GeoCleanUpLevelChooser");
            centerAndShow(askDlg);
            if (!askDlg.isCancelled()) {
                indexOfUSA = list.getSelectedIndex();
            }
        }

        doAllCountries = new boolean[] { true, false, false, false };
        doInvCountry = new boolean[] { indexOfUSA > -1, true, false, false };
        doIndvCountryId = doInvCountry[0] ? countryIds.get(indexOfUSA) : null;
    }

    // Check to see if it needs indexing.
    boolean shouldIndex = luceneSearch.shouldIndex();

    if (shouldIndex) {
        frame = new ProgressFrame("Building Geography Authority..."); // I18N
        frame.getCloseBtn().setVisible(false);
        frame.turnOffOverAll();
        frame.setDesc("Loading Geonames data..."); // I18N
        frame.pack();
        frame.setSize(450, frame.getBounds().height + 10);
        UIHelper.centerAndShow(frame, 450, frame.getBounds().height + 10);

        luceneSearch.startIndexingProcessAsync(earthId, frame, new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                frame.setVisible(false);
                frame = null;
                if (((Boolean) e.getSource())) {
                    GeographyAssignISOs.this.startTraversal();
                }
            }
        });

    } else {
        sql = "SELECT Name, geonameId, iso_alpha2 FROM countryinfo";
        for (Object[] row : query(sql)) {
            countryInfo.add(new GeoSearchResultsItem((String) row[0], (Integer) row[1], (String) row[2]));
        }
        startTraversal();
    }

    return true;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jTabbedPane1StateChanged(ChangeEvent evt) {
    JTabbedPane pane = (JTabbedPane) evt.getSource();
    int sel = pane.getSelectedIndex();
    if (sel == 2) {
        bochsCommandTextField.requestFocus();
    }//  w w w .j ava2 s. c  om
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGui.java

@Override
public void stateChanged(ChangeEvent e) {
    if (e.getSource() == autoRedirects) {
        if (autoRedirects.isSelected()) {
            followRedirects.setSelected(false);
        }//from w  ww .java 2s.  c om
    } else if (e.getSource() == followRedirects) {
        if (followRedirects.isSelected()) {
            autoRedirects.setSelected(false);
        }
    }
    // disable the multi-part if not a post request
    else if (e.getSource() == method) {
        boolean isPostMethod = HTTPConstants.POST.equals(method.getText());
        useMultipartForPost.setEnabled(isPostMethod);
    }
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java

public void stateChanged(ChangeEvent e) {
    if (e.getSource() == autoRedirects) {
        if (autoRedirects.isSelected()) {
            followRedirects.setSelected(false);
        }//from   ww w .ja  v  a 2 s.c om
    }
    if (e.getSource() == followRedirects) {
        if (followRedirects.isSelected()) {
            autoRedirects.setSelected(false);
        }
    }
}

From source file:org.apache.jmeter.visualizers.RespTimeGraphVisualizer.java

/**
 * Initialize the GUI./*from w  ww. ja  v a 2s.c  om*/
 */
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());

    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    Border margin2 = new EmptyBorder(10, 10, 5, 10);

    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());

    JPanel settingsPane = new VerticalPanel();
    settingsPane.setBorder(margin2);

    graphPanel = new RespTimeGraphChart();
    graphPanel.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGTH));

    settingsPane.add(createGraphActionsPane());
    settingsPane.add(createGraphSettingsPane());
    settingsPane.add(createGraphTitlePane());
    settingsPane.add(createLinePane());
    settingsPane.add(createGraphDimensionPane());
    JPanel axisPane = new JPanel(new BorderLayout());
    axisPane.add(createGraphXAxisPane(), BorderLayout.WEST);
    axisPane.add(createGraphYAxisPane(), BorderLayout.CENTER);
    settingsPane.add(axisPane);
    settingsPane.add(createLegendPane());

    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane); //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel); //$NON-NLS-1$

    // If clic on the Graph tab, make the graph (without apply interval or filter)
    ChangeListener changeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
            int index = srcTab.getSelectedIndex();
            if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) { //$NON-NLS-1$
                actionMakeGraph();
            }
        }
    };
    tabbedGraph.addChangeListener(changeListener);

    this.add(mainPanel, BorderLayout.NORTH);
    this.add(tabbedGraph, BorderLayout.CENTER);

}