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();
}
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));
}
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);
}
}
}
}
});
}
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);
}
});
}
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);
}
}
});
}
Aggregations