use of java.awt.event.ItemListener in project gephi by gephi.
the class WelcomeTopComponent method loadPrefs.
private void loadPrefs() {
Boolean openStartup = NbPreferences.forModule(WelcomeTopComponent.class).getBoolean(STARTUP_PREF, Boolean.TRUE);
openOnStartupCheckbox.setSelected(openStartup);
openOnStartupCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
NbPreferences.forModule(WelcomeTopComponent.class).putBoolean(STARTUP_PREF, openOnStartupCheckbox.isSelected());
}
});
}
use of java.awt.event.ItemListener in project gitblit by gitblit.
the class EditRepositoryDialog method initialize.
private void initialize(int protocolVersion, RepositoryModel anRepository) {
nameField = new JTextField(anRepository.name == null ? "" : anRepository.name, 35);
descriptionField = new JTextField(anRepository.description == null ? "" : anRepository.description, 35);
JTextField originField = new JTextField(anRepository.origin == null ? "" : anRepository.origin, 40);
originField.setEditable(false);
if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
headRefField = new JComboBox();
headRefField.setEnabled(false);
} else {
headRefField = new JComboBox(anRepository.availableRefs.toArray());
headRefField.setSelectedItem(anRepository.HEAD);
}
Integer[] gcPeriods = { 1, 2, 3, 4, 5, 7, 10, 14 };
gcPeriod = new JComboBox(gcPeriods);
gcPeriod.setSelectedItem(anRepository.gcPeriod);
gcThreshold = new JTextField(8);
gcThreshold.setText(anRepository.gcThreshold);
ownersPalette = new JPalette<String>(true);
acceptNewTickets = new JCheckBox(Translation.get("gb.acceptsNewTicketsDescription"), anRepository.acceptNewTickets);
acceptNewPatchsets = new JCheckBox(Translation.get("gb.acceptsNewPatchsetsDescription"), anRepository.acceptNewPatchsets);
requireApproval = new JCheckBox(Translation.get("gb.requireApprovalDescription"), anRepository.requireApproval);
if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
mergeToField = new JComboBox();
mergeToField.setEnabled(false);
} else {
mergeToField = new JComboBox(anRepository.availableRefs.toArray());
mergeToField.setSelectedItem(anRepository.mergeTo);
}
useIncrementalPushTags = new JCheckBox(Translation.get("gb.useIncrementalPushTagsDescription"), anRepository.useIncrementalPushTags);
showRemoteBranches = new JCheckBox(Translation.get("gb.showRemoteBranchesDescription"), anRepository.showRemoteBranches);
skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"), anRepository.skipSizeCalculation);
skipSummaryMetrics = new JCheckBox(Translation.get("gb.skipSummaryMetricsDescription"), anRepository.skipSummaryMetrics);
isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);
maxActivityCommits = new JComboBox(new Integer[] { -1, 0, 25, 50, 75, 100, 150, 250, 500 });
maxActivityCommits.setSelectedItem(anRepository.maxActivityCommits);
mailingListsField = new JTextField(ArrayUtils.isEmpty(anRepository.mailingLists) ? "" : StringUtils.flattenStrings(anRepository.mailingLists, " "), 50);
accessRestriction = new JComboBox(AccessRestrictionType.values());
accessRestriction.setRenderer(new AccessRestrictionRenderer());
accessRestriction.setSelectedItem(anRepository.accessRestriction);
accessRestriction.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
AccessRestrictionType art = (AccessRestrictionType) accessRestriction.getSelectedItem();
EditRepositoryDialog.this.setupAccessPermissions(art);
}
}
});
boolean authenticated = anRepository.authorizationControl != null && AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);
allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));
allowAuthenticated.setSelected(authenticated);
allowAuthenticated.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
usersPalette.setEnabled(false);
teamsPalette.setEnabled(false);
}
}
});
allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));
allowNamed.setSelected(!authenticated);
allowNamed.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
usersPalette.setEnabled(true);
teamsPalette.setEnabled(true);
}
}
});
ButtonGroup group = new ButtonGroup();
group.add(allowAuthenticated);
group.add(allowNamed);
JPanel authorizationPanel = new JPanel(new GridLayout(0, 1));
authorizationPanel.add(allowAuthenticated);
authorizationPanel.add(allowNamed);
allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks);
verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter);
// federation strategies - remove ORIGIN choice if this repository has
// no origin.
List<FederationStrategy> federationStrategies = new ArrayList<FederationStrategy>(Arrays.asList(FederationStrategy.values()));
if (StringUtils.isEmpty(anRepository.origin)) {
federationStrategies.remove(FederationStrategy.FEDERATE_ORIGIN);
}
federationStrategy = new JComboBox(federationStrategies.toArray());
federationStrategy.setRenderer(new FederationStrategyRenderer());
federationStrategy.setSelectedItem(anRepository.federationStrategy);
JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
fieldsPanel.add(newFieldPanel(Translation.get("gb.name"), nameField));
fieldsPanel.add(newFieldPanel(Translation.get("gb.description"), descriptionField));
fieldsPanel.add(newFieldPanel(Translation.get("gb.origin"), originField));
fieldsPanel.add(newFieldPanel(Translation.get("gb.headRef"), headRefField));
fieldsPanel.add(newFieldPanel(Translation.get("gb.gcPeriod"), gcPeriod));
fieldsPanel.add(newFieldPanel(Translation.get("gb.gcThreshold"), gcThreshold));
fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewTickets"), acceptNewTickets));
fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewPatchsets"), acceptNewPatchsets));
fieldsPanel.add(newFieldPanel(Translation.get("gb.requireApproval"), requireApproval));
fieldsPanel.add(newFieldPanel(Translation.get("gb.mergeTo"), mergeToField));
fieldsPanel.add(newFieldPanel(Translation.get("gb.enableIncrementalPushTags"), useIncrementalPushTags));
fieldsPanel.add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches));
fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation));
fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics));
fieldsPanel.add(newFieldPanel(Translation.get("gb.maxActivityCommits"), maxActivityCommits));
fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField));
JPanel clonePushPanel = new JPanel(new GridLayout(0, 1));
clonePushPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
clonePushPanel.add(newFieldPanel(Translation.get("gb.allowForks"), allowForks));
clonePushPanel.add(newFieldPanel(Translation.get("gb.verifyCommitter"), verifyCommitter));
usersPalette = new RegistrantPermissionsPanel(RegistrantType.USER);
JPanel northFieldsPanel = new JPanel(new BorderLayout(0, 5));
northFieldsPanel.add(newFieldPanel(Translation.get("gb.owners"), ownersPalette), BorderLayout.NORTH);
northFieldsPanel.add(newFieldPanel(Translation.get("gb.accessRestriction"), accessRestriction), BorderLayout.CENTER);
JPanel northAccessPanel = new JPanel(new BorderLayout(5, 5));
northAccessPanel.add(northFieldsPanel, BorderLayout.NORTH);
northAccessPanel.add(newFieldPanel(Translation.get("gb.authorizationControl"), authorizationPanel), BorderLayout.CENTER);
northAccessPanel.add(clonePushPanel, BorderLayout.SOUTH);
JPanel accessPanel = new JPanel(new BorderLayout(5, 5));
accessPanel.add(northAccessPanel, BorderLayout.NORTH);
accessPanel.add(newFieldPanel(Translation.get("gb.userPermissions"), usersPalette), BorderLayout.CENTER);
teamsPalette = new RegistrantPermissionsPanel(RegistrantType.TEAM);
JPanel teamsPanel = new JPanel(new BorderLayout(5, 5));
teamsPanel.add(newFieldPanel(Translation.get("gb.teamPermissions"), teamsPalette), BorderLayout.CENTER);
setsPalette = new JPalette<String>();
JPanel federationPanel = new JPanel(new BorderLayout(5, 5));
federationPanel.add(newFieldPanel(Translation.get("gb.federationStrategy"), federationStrategy), BorderLayout.NORTH);
federationPanel.add(newFieldPanel(Translation.get("gb.federationSets"), setsPalette), BorderLayout.CENTER);
indexedBranchesPalette = new JPalette<String>();
JPanel indexedBranchesPanel = new JPanel(new BorderLayout(5, 5));
indexedBranchesPanel.add(newFieldPanel(Translation.get("gb.indexedBranches"), indexedBranchesPalette), BorderLayout.CENTER);
preReceivePalette = new JPalette<String>(true);
preReceiveInherited = new JLabel();
JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
preReceivePanel.add(preReceivePalette, BorderLayout.CENTER);
preReceivePanel.add(preReceiveInherited, BorderLayout.WEST);
postReceivePalette = new JPalette<String>(true);
postReceiveInherited = new JLabel();
JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
customFieldsPanel = new JPanel();
customFieldsPanel.setLayout(new BoxLayout(customFieldsPanel, BoxLayout.Y_AXIS));
JScrollPane customFieldsScrollPane = new JScrollPane(customFieldsPanel);
customFieldsScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
customFieldsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
panel.addTab(Translation.get("gb.general"), fieldsPanel);
panel.addTab(Translation.get("gb.accessRestriction"), accessPanel);
if (protocolVersion >= 2) {
panel.addTab(Translation.get("gb.teams"), teamsPanel);
}
panel.addTab(Translation.get("gb.federation"), federationPanel);
if (protocolVersion >= 3) {
panel.addTab(Translation.get("gb.indexedBranches"), indexedBranchesPanel);
}
panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
panel.addTab(Translation.get("gb.customFields"), customFieldsScrollPane);
setupAccessPermissions(anRepository.accessRestriction);
JButton createButton = new JButton(Translation.get("gb.save"));
createButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (validateFields()) {
canceled = false;
setVisible(false);
}
}
});
JButton cancelButton = new JButton(Translation.get("gb.cancel"));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
canceled = true;
setVisible(false);
}
});
JPanel controls = new JPanel();
controls.add(cancelButton);
controls.add(createButton);
final Insets _insets = new Insets(5, 5, 5, 5);
JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {
private static final long serialVersionUID = 1L;
@Override
public Insets getInsets() {
return _insets;
}
};
centerPanel.add(panel, BorderLayout.CENTER);
centerPanel.add(controls, BorderLayout.SOUTH);
getContentPane().setLayout(new BorderLayout(5, 5));
getContentPane().add(centerPanel, BorderLayout.CENTER);
pack();
nameField.requestFocus();
}
use of java.awt.event.ItemListener in project gephi by gephi.
the class AppearanceTopComponent method refreshCombo.
private void refreshCombo() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
if (model != null) {
TransformerUI ui = model.getSelectedTransformerUI();
if (ui != null && model.isAttributeTransformerUI(ui)) {
//Ranking
Function selectedColumn = model.getSelectedFunction();
attibuteBox.removeItemListener(attributeListener);
comboBoxModel.addElement(NO_SELECTION);
comboBoxModel.setSelectedItem(NO_SELECTION);
List<Function> rows = new ArrayList<>();
rows.addAll(model.getFunctions());
Collections.sort(rows, new Comparator<Function>() {
@Override
public int compare(Function o1, Function o2) {
if (o1.isAttribute() && !o2.isAttribute()) {
return 1;
} else if (!o1.isAttribute() && o2.isAttribute()) {
return -1;
}
return o1.toString().compareTo(o2.toString());
}
});
for (Function r : rows) {
comboBoxModel.addElement(r);
if (selectedColumn != null && selectedColumn.equals(r)) {
comboBoxModel.setSelectedItem(r);
}
}
attributeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (model != null) {
if (!attibuteBox.getSelectedItem().equals(NO_SELECTION)) {
Function selectedItem = (Function) attibuteBox.getSelectedItem();
Function selectedFunction = model.getSelectedFunction();
if (selectedFunction != selectedItem) {
controller.setSelectedFunction(selectedItem);
}
} else {
controller.setSelectedFunction(null);
}
}
}
};
attibuteBox.addItemListener(attributeListener);
}
}
attibuteBox.setModel(comboBoxModel);
}
});
}
use of java.awt.event.ItemListener in project gephi by gephi.
the class GlobalSettingsPanel 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("backgroundColor")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("autoSelectNeighbor")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("lightenNonSelectedAuto")) {
refreshSharedConfig();
} else if (evt.getPropertyName().equals("use3d")) {
refreshSharedConfig();
}
}
});
refreshSharedConfig();
hightlightCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.setLightenNonSelectedAuto(hightlightCheckBox.isSelected());
}
});
((JColorButton) backgroundColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.setBackgroundColor(((JColorButton) backgroundColorButton).getColor());
}
});
autoSelectNeigborCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
VizModel vizModel = VizController.getInstance().getVizModel();
vizModel.setAutoSelectNeighbor(autoSelectNeigborCheckbox.isSelected());
}
});
zoomSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int cam = (int) VizController.getInstance().getVizModel().getCameraDistance();
if (zoomSlider.getValue() != cam && cam < zoomSlider.getMaximum()) {
GraphIO io = VizController.getInstance().getGraphIO();
io.setCameraDistance(zoomSlider.getValue());
}
}
});
}
use of java.awt.event.ItemListener in project gephi by gephi.
the class LabelSettingsPanel method setup.
public void setup() {
VizModel vizModel = VizController.getInstance().getVizModel();
TextModelImpl model = vizModel.getTextModel();
vizModel.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("init")) {
refreshSharedConfig();
}
}
});
//NodePanel
showNodeLabelsCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean value = showNodeLabelsCheckbox.isSelected();
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (value != model.isShowNodeLabels()) {
model.setShowNodeLabels(value);
setEnable(true);
}
}
});
nodeFontButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
Font font = JFontChooser.showDialog(WindowManager.getDefault().getMainWindow(), model.getNodeFont());
if (font != null && font != model.getNodeFont()) {
model.setNodeFont(font);
}
}
});
((JColorButton) nodeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (!model.getNodeColor().equals(((JColorButton) nodeColorButton).getColor())) {
model.setNodeColor(((JColorButton) nodeColorButton).getColor());
}
}
});
nodeSizeSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getNodeSizeFactor() != nodeSizeSlider.getValue() / 100f) {
model.setNodeSizeFactor(nodeSizeSlider.getValue() / 100f);
}
}
});
//EdgePanel
showEdgeLabelsCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean value = showEdgeLabelsCheckbox.isSelected();
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (value != model.isShowEdgeLabels()) {
model.setShowEdgeLabels(value);
setEnable(true);
}
}
});
edgeFontButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
Font font = JFontChooser.showDialog(WindowManager.getDefault().getMainWindow(), model.getEdgeFont());
if (font != null && font != model.getEdgeFont()) {
model.setEdgeFont(font);
}
}
});
((JColorButton) edgeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (!model.getEdgeColor().equals(((JColorButton) edgeColorButton).getColor())) {
model.setEdgeColor(((JColorButton) edgeColorButton).getColor());
}
}
});
edgeSizeSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
model.setEdgeSizeFactor(edgeSizeSlider.getValue() / 100f);
}
});
//General
final TextManager textManager = VizController.getInstance().getTextManager();
final DefaultComboBoxModel sizeModeModel = new DefaultComboBoxModel(textManager.getSizeModes());
sizeModeCombo.setModel(sizeModeModel);
final DefaultComboBoxModel colorModeModel = new DefaultComboBoxModel(textManager.getColorModes());
colorModeCombo.setModel(colorModeModel);
sizeModeCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getSizeMode() != sizeModeModel.getSelectedItem()) {
model.setSizeMode((SizeMode) sizeModeModel.getSelectedItem());
}
}
});
colorModeCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.getColorMode() != colorModeModel.getSelectedItem()) {
model.setColorMode((ColorMode) colorModeModel.getSelectedItem());
}
}
});
hideNonSelectedCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
if (model.isSelectedOnly() != hideNonSelectedCheckbox.isSelected()) {
model.setSelectedOnly(hideNonSelectedCheckbox.isSelected());
}
}
});
//Attributes
configureLabelsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
LabelAttributesPanel panel = new LabelAttributesPanel();
panel.setup(model);
DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(VizBarController.class, "LabelAttributesPanel.title"), true, NotifyDescriptor.OK_CANCEL_OPTION, null, null);
if (DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) {
panel.unsetup();
return;
}
}
});
//Evt
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
refreshSharedConfig();
}
});
refreshSharedConfig();
}
Aggregations