Search in sources :

Example 31 with ItemListener

use of java.awt.event.ItemListener in project intellij-community by JetBrains.

the class MoveInnerDialog method init.

protected void init() {
    myClassNameField.setText(myInnerClass.getName());
    myClassNameField.selectAll();
    if (!myInnerClass.hasModifierProperty(PsiModifier.STATIC)) {
        myCbPassOuterClass.setSelected(true);
        myCbPassOuterClass.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                myParameterField.setEnabled(myCbPassOuterClass.isSelected());
            }
        });
    } else {
        myCbPassOuterClass.setSelected(false);
        myCbPassOuterClass.setEnabled(false);
        myParameterField.setEnabled(false);
    }
    if (myCbPassOuterClass.isEnabled()) {
        boolean thisNeeded = isThisNeeded(myInnerClass, myOuterClass);
        myCbPassOuterClass.setSelected(thisNeeded);
        myParameterField.setEnabled(thisNeeded);
    }
    myCbPassOuterClass.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            boolean selected = myCbPassOuterClass.isSelected();
            myParameterField.getComponent().setEnabled(selected);
        }
    });
    if (!(myTargetContainer instanceof PsiDirectory)) {
        myPackageNameField.setVisible(false);
        myPackageNameLabel.setVisible(false);
    }
    super.init();
}
Also used : ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener)

Example 32 with ItemListener

use of java.awt.event.ItemListener in project joda-time by JodaOrg.

the class AgeCalculator method addBottomArea.

private void addBottomArea(Container container) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    ItemListener listener = new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateResults();
        }
    };
    iFieldSets = new FieldSet[] { new FieldSet("Month Based", new FieldGroup[] { new FieldGroup(listener, "Years", YEARS), new FieldGroup(listener, "Months", MONTHS), new FieldGroup(listener, "Days", DAYS), new FieldGroup(listener, "Hours", HOURS), new FieldGroup(listener, "Minutes", MINUTES), new FieldGroup(listener, "Seconds", SECONDS) }), new FieldSet("Week Based", new FieldGroup[] { new FieldGroup(listener, "Weekyears", WEEKYEARS), new FieldGroup(listener, "Weeks", WEEKS), new FieldGroup(listener, "Days", DAYS), new FieldGroup(listener, "Hours", HOURS), new FieldGroup(listener, "Minutes", MINUTES), new FieldGroup(listener, "Seconds", SECONDS) }) };
    for (int i = 0; i < iFieldSets.length; i++) {
        if (i > 0) {
            panel.add(Box.createHorizontalStrut(10));
        }
        iFieldSets[i].addTo(panel);
    }
    panel.add(Box.createVerticalGlue());
    container.add(fixedHeight(panel));
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) BoxLayout(javax.swing.BoxLayout) ItemListener(java.awt.event.ItemListener)

Example 33 with ItemListener

use of java.awt.event.ItemListener in project gephi by gephi.

the class ReportPanel method initGraphTypeCombo.

private void initGraphTypeCombo(final Container[] containers) {
    final String directedStr = NbBundle.getMessage(ReportPanel.class, "ReportPanel.graphType.directed");
    final String undirectedStr = NbBundle.getMessage(ReportPanel.class, "ReportPanel.graphType.undirected");
    final String mixedStr = NbBundle.getMessage(ReportPanel.class, "ReportPanel.graphType.mixed");
    EdgeDirectionDefault edd = null;
    for (Container container : containers) {
        EdgeDirectionDefault d = container.getUnloader().getEdgeDefault();
        if (edd == null) {
            edd = d;
        } else if (d.equals(EdgeDirectionDefault.UNDIRECTED) && !edd.equals(EdgeDirectionDefault.UNDIRECTED)) {
            edd = EdgeDirectionDefault.MIXED;
        } else if (d.equals(EdgeDirectionDefault.DIRECTED) && !edd.equals(EdgeDirectionDefault.DIRECTED)) {
            edd = EdgeDirectionDefault.MIXED;
        }
    }
    final EdgeDirectionDefault dir = edd;
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            DefaultComboBoxModel comboModel = new DefaultComboBoxModel();
            switch(dir) {
                case DIRECTED:
                    comboModel.addElement(directedStr);
                    comboModel.addElement(undirectedStr);
                    comboModel.addElement(mixedStr);
                    comboModel.setSelectedItem(directedStr);
                    break;
                case UNDIRECTED:
                    comboModel.addElement(undirectedStr);
                    comboModel.addElement(mixedStr);
                    comboModel.setSelectedItem(undirectedStr);
                    break;
                case MIXED:
                    comboModel.addElement(directedStr);
                    comboModel.addElement(undirectedStr);
                    comboModel.addElement(mixedStr);
                    comboModel.setSelectedItem(mixedStr);
                    break;
            }
            graphTypeCombo.setModel(comboModel);
        }
    });
    graphTypeCombo.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                Object g = e.getItem();
                if (g.equals(directedStr)) {
                    for (Container container : containers) {
                        container.getLoader().setEdgeDefault(EdgeDirectionDefault.DIRECTED);
                    }
                } else if (g.equals(undirectedStr)) {
                    for (Container container : containers) {
                        container.getLoader().setEdgeDefault(EdgeDirectionDefault.UNDIRECTED);
                    }
                } else if (g.equals(mixedStr)) {
                    for (Container container : containers) {
                        container.getLoader().setEdgeDefault(EdgeDirectionDefault.MIXED);
                    }
                }
            }
        }
    });
}
Also used : Container(org.gephi.io.importer.api.Container) ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) EdgeDirectionDefault(org.gephi.io.importer.api.EdgeDirectionDefault)

Example 34 with ItemListener

use of java.awt.event.ItemListener in project gephi by gephi.

the class LayoutPanel method initEvents.

private void initEvents() {
    layoutCombobox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (layoutCombobox.getSelectedItem().equals(NO_SELECTION) && model.getSelectedLayout() != null) {
                setSelectedLayout(null);
            } else if (layoutCombobox.getSelectedItem() instanceof LayoutBuilderWrapper) {
                LayoutBuilder builder = ((LayoutBuilderWrapper) layoutCombobox.getSelectedItem()).getLayoutBuilder();
                if (model.getSelectedLayout() == null || model.getSelectedBuilder() != builder) {
                    setSelectedLayout(builder);
                }
            }
        }
    });
    infoLabel.addMouseListener(new MouseAdapter() {

        RichTooltip richTooltip;

        @Override
        public void mouseEntered(MouseEvent e) {
            if (infoLabel.isEnabled() && model != null && model.getSelectedLayout() != null) {
                richTooltip = buildTooltip(model.getSelectedBuilder());
                richTooltip.showTooltip(infoLabel, e.getLocationOnScreen());
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (richTooltip != null) {
                richTooltip.hideTooltip();
                richTooltip = null;
            }
        }
    });
    presetsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JPopupMenu menu = new JPopupMenu();
            List<Preset> presets = layoutPresetPersistence.getPresets(model.getSelectedLayout());
            if (presets != null && !presets.isEmpty()) {
                for (final Preset p : presets) {
                    JMenuItem item = new JMenuItem(p.toString());
                    item.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            layoutPresetPersistence.loadPreset(p, model.getSelectedLayout());
                            refreshProperties();
                            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.loadPreset", model.getSelectedBuilder().getName(), p.toString()));
                        }
                    });
                    menu.add(item);
                }
            } else {
                menu.add("<html><i>" + NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.nopreset") + "</i></html>");
            }
            JMenuItem saveItem = new JMenuItem(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset"));
            saveItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String lastPresetName = NbPreferences.forModule(LayoutPanel.class).get("LayoutPanel.lastPresetName", "");
                    NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input"), NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input.name"));
                    question.setInputText(lastPresetName);
                    if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
                        String input = question.getInputText();
                        if (input != null && !input.isEmpty()) {
                            layoutPresetPersistence.savePreset(input, model.getSelectedLayout());
                            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.savePreset", model.getSelectedBuilder().getName(), input));
                            NbPreferences.forModule(LayoutPanel.class).put("LayoutPanel.lastPresetName", input);
                        }
                    }
                }
            });
            menu.add(new JSeparator());
            menu.add(saveItem);
            menu.show(layoutToolbar, 0, -menu.getPreferredSize().height);
        }
    });
}
Also used : LayoutBuilder(org.gephi.layout.spi.LayoutBuilder) ItemEvent(java.awt.event.ItemEvent) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) Preset(org.gephi.desktop.layout.LayoutPresetPersistence.Preset) MouseAdapter(java.awt.event.MouseAdapter) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) NotifyDescriptor(org.openide.NotifyDescriptor) RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener) ArrayList(java.util.ArrayList) List(java.util.List) JMenuItem(javax.swing.JMenuItem)

Example 35 with ItemListener

use of java.awt.event.ItemListener in project gephi by gephi.

the class EdgeSettingsPanel method setup.

public void setup() {
    VizModel vizModel = VizController.getInstance().getVizModel();
    vizModel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("init")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeHasUniColor")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("showEdges")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeUniColor")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeSelectionColor")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeInSelectionColor")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeOutSelectionColor")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeBothSelectionColor")) {
                refreshSharedConfig();
            } else if (evt.getPropertyName().equals("edgeScale")) {
                refreshSharedConfig();
            }
        }
    });
    refreshSharedConfig();
    showEdgesCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setShowEdges(showEdgesCheckbox.isSelected());
            setEnable(true);
        }
    });
    ((JColorButton) edgeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setEdgeUniColor(((JColorButton) edgeColorButton).getColorArray());
        }
    });
    sourceNodeColorCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setEdgeHasUniColor(!sourceNodeColorCheckbox.isSelected());
        }
    });
    selectionColorCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setEdgeSelectionColor(selectionColorCheckbox.isSelected());
        }
    });
    edgeInSelectionColorChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setEdgeInSelectionColor(edgeInSelectionColorChooser.getColor().getComponents(null));
        }
    });
    edgeBothSelectionColorChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setEdgeBothSelectionColor(edgeBothSelectionColorChooser.getColor().getComponents(null));
        }
    });
    edgeOutSelectionColorChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            vizModel.setEdgeOutSelectionColor(edgeOutSelectionColorChooser.getColor().getComponents(null));
        }
    });
    scaleSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            VizModel vizModel = VizController.getInstance().getVizModel();
            if (vizModel.getEdgeScale() != (scaleSlider.getValue() / 10f + 0.1f)) {
                vizModel.setEdgeScale(scaleSlider.getValue() / 10f + 0.1f);
            }
        }
    });
}
Also used : JColorButton(org.gephi.ui.components.JColorButton) VizModel(org.gephi.visualization.VizModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) ItemEvent(java.awt.event.ItemEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) ActionEvent(java.awt.event.ActionEvent) ItemListener(java.awt.event.ItemListener) PropertyChangeListener(java.beans.PropertyChangeListener) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ItemListener (java.awt.event.ItemListener)331 ItemEvent (java.awt.event.ItemEvent)314 ActionEvent (java.awt.event.ActionEvent)111 ActionListener (java.awt.event.ActionListener)108 JPanel (javax.swing.JPanel)93 JLabel (javax.swing.JLabel)81 JCheckBox (javax.swing.JCheckBox)65 JComboBox (javax.swing.JComboBox)64 JButton (javax.swing.JButton)51 Dimension (java.awt.Dimension)50 BorderLayout (java.awt.BorderLayout)47 JTextField (javax.swing.JTextField)46 ButtonGroup (javax.swing.ButtonGroup)34 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)33 GridBagConstraints (java.awt.GridBagConstraints)29 JMenu (javax.swing.JMenu)29 ChangeEvent (javax.swing.event.ChangeEvent)29 GridBagLayout (java.awt.GridBagLayout)28 JMenuItem (javax.swing.JMenuItem)28 ChangeListener (javax.swing.event.ChangeListener)28