use of java.awt.event.ItemListener in project intellij-community by JetBrains.
the class DebuggerDataViewsConfigurable method createComponent.
@Override
public JComponent createComponent() {
if (myProject == null) {
myProject = JavaDebuggerSupport.getContextProjectForEditorFieldsInDebuggerConfigurables();
}
final JPanel panel = new JPanel(new GridBagLayout());
myCbAutoscroll = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.autoscroll"));
myCbShowSyntheticFields = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.synthetic.fields"));
myCbShowValFieldsAsLocalVariables = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.val.fields.as.locals"));
myCbHideNullArrayElements = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.hide.null.array.elements"));
myCbShowStatic = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.fields"));
myCbShowStaticFinalFields = new StateRestoringCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.static.final.fields"));
myCbEnableAlternateViews = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.alternate.view"));
myCbShowStatic.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (myCbShowStatic.isSelected()) {
myCbShowStaticFinalFields.makeSelectable();
} else {
myCbShowStaticFinalFields.makeUnselectable(false);
}
}
});
myCbShowSyntheticFields.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (myCbShowSyntheticFields.isSelected()) {
myCbShowValFieldsAsLocalVariables.makeSelectable();
} else {
myCbShowValFieldsAsLocalVariables.makeUnselectable(false);
}
}
});
myCbShowDeclaredType = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.declared.type"));
myCbShowFQNames = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.fq.names"));
myCbShowObjectId = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.object.id"));
myCbHexValue = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.hex.value"));
myCbShowStringsType = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.show.strings.type"));
myCbEnableToString = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.enable.toString"));
myRbAllThatOverride = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.all.overriding"));
myRbFromList = new JRadioButton(DebuggerBundle.message("label.base.renderer.configurable.classes.from.list"));
ButtonGroup group = new ButtonGroup();
group.add(myRbAllThatOverride);
group.add(myRbFromList);
myToStringFilterEditor = new ClassFilterEditor(myProject, null, "reference.viewBreakpoints.classFilters.newPattern");
myCbEnableToString.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
final boolean enabled = myCbEnableToString.isSelected();
myRbAllThatOverride.setEnabled(enabled);
myRbFromList.setEnabled(enabled);
myToStringFilterEditor.setEnabled(enabled && myRbFromList.isSelected());
}
});
myRbFromList.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
myToStringFilterEditor.setEnabled(myCbEnableToString.isSelected() && myRbFromList.isSelected());
}
});
panel.add(myCbAutoscroll, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insetsTop(4), 0, 0));
final JPanel showPanel = new JPanel(new GridBagLayout());
showPanel.setBorder(IdeBorderFactory.createTitledBorder("Show", true));
showPanel.add(myCbShowDeclaredType, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.emptyInsets(), 0, 0));
showPanel.add(myCbShowObjectId, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insetsTop(4), 0, 0));
showPanel.add(myCbShowSyntheticFields, new GridBagConstraints(1, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insetsLeft(10), 0, 0));
showPanel.add(myCbShowStatic, new GridBagConstraints(1, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 10, 0, 0), 0, 0));
showPanel.add(myCbShowValFieldsAsLocalVariables, new GridBagConstraints(2, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 10, 0, 0), 0, 0));
showPanel.add(myCbShowStaticFinalFields, new GridBagConstraints(2, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 10, 0, 0), 0, 0));
showPanel.add(myCbShowFQNames, new GridBagConstraints(3, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsLeft(10), 0, 0));
panel.add(showPanel, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, HORIZONTAL, JBUI.insetsTop(4), 0, 0));
//final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
//final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
//assert arraysComponent != null;
//arraysPanel.add(arraysComponent, BorderLayout.CENTER);
//arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
//arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
//panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
panel.add(myCbShowStringsType, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, NORTH, HORIZONTAL, JBUI.emptyInsets(), 0, 0));
panel.add(myCbHexValue, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, NORTH, HORIZONTAL, JBUI.insetsTop(4), 0, 0));
panel.add(myCbHideNullArrayElements, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, NORTH, HORIZONTAL, JBUI.insetsTop(4), 0, 0));
panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, RELATIVE, 1, 1, 0.0, 0.0, WEST, NONE, JBUI.insets(4, 0, 0, 10), 0, 0));
// starting 4-th row
panel.add(myCbEnableToString, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsTop(4), 0, 0));
panel.add(myRbAllThatOverride, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsLeft(12), 0, 0));
panel.add(myRbFromList, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsLeft(12), 0, 0));
myToStringFilterEditor.setMinimumSize(JBUI.size(50, 100));
panel.add(myToStringFilterEditor, new GridBagConstraints(0, RELATIVE, 3, 1, 1.0, 1.0, CENTER, BOTH, JBUI.insetsLeft(12), 0, 0));
return panel;
}
use of java.awt.event.ItemListener in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method fillFields.
public void fillFields(final SubscriptionDetail subscription, Location region) {
if (subscription == null) {
// loadRegions();
accoountKindCombo.setModel(new DefaultComboBoxModel(Kind.values()));
accoountKindCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
fillPerformanceComboBox();
fillReplicationTypes();
boolean isBlobKind = e.getItem().equals(Kind.BLOB_STORAGE);
accessTeirComboBox.setVisible(isBlobKind);
accessTierLabel.setVisible(isBlobKind);
}
}
});
accessTeirComboBox.setModel(new DefaultComboBoxModel(AccessTier.values()));
subscriptionComboBox.setEnabled(true);
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
List<SubscriptionDetail> selectedSubscriptions = subscriptionDetails.stream().filter(SubscriptionDetail::isSelected).collect(Collectors.toList());
subscriptionComboBox.setModel(new DefaultComboBoxModel<>(selectedSubscriptions.toArray(new SubscriptionDetail[selectedSubscriptions.size()])));
if (selectedSubscriptions.size() > 0) {
loadRegions();
}
} catch (Exception ex) {
DefaultLoader.getUIHelper().logError("An error occurred when trying to load Subscriptions\n\n" + ex.getMessage(), ex);
}
subscriptionComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent itemEvent) {
loadRegions();
}
});
} else {
// if you create SA while creating VM
this.subscription = subscription;
subscriptionComboBox.addItem(subscription);
// only General purpose accounts supported for VMs
accoountKindCombo.addItem(Kind.STORAGE);
accoountKindCombo.setEnabled(false);
// Access tier is not available for General purpose accounts
accessTeirComboBox.setVisible(false);
accessTierLabel.setVisible(false);
regionComboBox.addItem(region);
regionComboBox.setEnabled(false);
loadGroups();
}
//performanceComboBox.setModel(new DefaultComboBoxModel(SkuTier.values()));
fillPerformanceComboBox();
performanceComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
fillReplicationTypes();
}
}
});
replicationComboBox.setRenderer(new ListCellRendererWrapper<ReplicationTypes>() {
@Override
public void customize(JList jList, ReplicationTypes replicationTypes, int i, boolean b, boolean b1) {
if (replicationTypes != null) {
setText(replicationTypes.getDescription());
}
}
});
fillReplicationTypes();
}
use of java.awt.event.ItemListener in project jdk8u_jdk by JetBrains.
the class Test8015300 method main.
public static void main(String[] args) throws Exception {
UIManager.LookAndFeelInfo[] array = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo info : array) {
UIManager.setLookAndFeel(info.getClassName());
System.err.println("L&F: " + info.getName());
invokeAndWait(new Runnable() {
@Override
public void run() {
combo = new JComboBox<>(ITEMS);
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent event) {
if (ItemEvent.SELECTED == event.getStateChange() && combo.isEditable()) {
ComboBoxEditor editor = combo.getEditor();
Object component = editor.getEditorComponent();
if (component instanceof JTextField) {
JTextField text = (JTextField) component;
boolean selected = null != text.getSelectedText();
StringBuilder sb = new StringBuilder();
sb.append(" - ").append(combo.getSelectedIndex());
sb.append(": ").append(event.getItem());
if (selected) {
sb.append("; selected");
}
System.err.println(sb);
if ((editor instanceof WindowsComboBoxEditor) == (null == text.getSelectedText())) {
throw new Error("unexpected state of text selection");
}
}
}
}
});
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(combo);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
});
for (int i = 0; i < ITEMS.length; ++i) {
select(i, true);
select(1, false);
}
invokeAndWait(new Runnable() {
@Override
public void run() {
windowForComponent(combo).dispose();
}
});
}
}
use of java.awt.event.ItemListener in project azure-tools-for-java by Microsoft.
the class SparkSubmissionAdvancedConfigDialog method addRemoteDebugLineItem.
private void addRemoteDebugLineItem() {
enableRemoteDebugCheckBox = new JCheckBox("Enable Spark remote debug", true);
enableRemoteDebugCheckBox.setToolTipText("Enable Spark remote debug, use with caution since this might override data previously generated");
add(enableRemoteDebugCheckBox, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin / 6, 0, 0, 0), 0, 0));
String sshUserNameToolTipText = "Secure shell (SSH) user name used in Spark remote debugging, by default using sshuser";
JLabel sshUserNameLabel = new JLabel("Secure Shell (SSH) User Name:");
sshUserNameLabel.setToolTipText(sshUserNameToolTipText);
add(sshUserNameLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));
sshUserNameTextField = new JTextField("sshuser");
sshUserNameTextField.setToolTipText(sshUserNameToolTipText);
add(sshUserNameTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));
JLabel sshAuthTypeLabel = new JLabel("Secure Shell (SSH) Auth Type");
sshAuthTypeLabel.setToolTipText("Secure shell (SSH) authentication type used in Spark remote debugging, by default using the password");
sshPasswordUsePasswordRadioButton = new JRadioButton("Use secure shell (SSH) password:", false);
String sshPasswordUsePasswordToolTip = "For secure shell (SSH) password, use the password specified here";
sshPasswordUsePasswordRadioButton.setToolTipText(sshPasswordUsePasswordToolTip);
sshPasswordUsePasswordField = new JPasswordField();
sshPasswordUsePasswordField.setToolTipText(sshPasswordUsePasswordToolTip);
sshPasswordUseKeyFileRadioButton = new JRadioButton("Use private key file:", false);
String sshPasswordUseKeyFileToolTip = "For secure shell (SSH) password, use the key file specified here";
sshPasswordUseKeyFileRadioButton.setToolTipText(sshPasswordUseKeyFileToolTip);
sshPasswordUseKeyFileTextField = new TextFieldWithBrowseButton();
sshPasswordUseKeyFileTextField.setToolTipText(sshPasswordUseKeyFileToolTip);
sshPasswordUseKeyFileTextField.getButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
fileChooserDescriptor.setTitle("Select SSH key file");
VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null);
if (chooseFile != null) {
String path = chooseFile.getPath();
sshPasswordUseKeyFileTextField.setText(path);
}
}
});
sshPasswordButtonGroup = new ButtonGroup();
sshPasswordButtonGroup.add(sshPasswordUsePasswordRadioButton);
sshPasswordButtonGroup.add(sshPasswordUseKeyFileRadioButton);
sshPasswordUsePasswordRadioButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
sshPasswordUsePasswordField.setEnabled(true);
sshPasswordUseKeyFileTextField.setEnabled(false);
}
}
});
sshPasswordUseKeyFileRadioButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
sshPasswordUsePasswordField.setEnabled(false);
sshPasswordUseKeyFileTextField.setEnabled(true);
}
}
});
enableRemoteDebugCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (enableRemoteDebugCheckBox.isSelected()) {
sshUserNameTextField.setEnabled(true);
sshUserNameLabel.setEnabled(true);
sshAuthTypeLabel.setEnabled(true);
sshPasswordUsePasswordRadioButton.setEnabled(true);
sshPasswordUseKeyFileRadioButton.setEnabled(true);
sshPasswordUsePasswordField.setEnabled(true);
sshPasswordUseKeyFileTextField.setEnabled(true);
ButtonModel currentSelection = sshPasswordButtonGroup.getSelection();
sshPasswordUsePasswordRadioButton.setSelected(true);
sshPasswordUseKeyFileRadioButton.setSelected(true);
currentSelection.setSelected(true);
} else {
sshUserNameTextField.setEnabled(false);
sshUserNameLabel.setEnabled(false);
sshAuthTypeLabel.setEnabled(false);
sshPasswordUsePasswordRadioButton.setEnabled(false);
sshPasswordUseKeyFileRadioButton.setEnabled(false);
sshPasswordUsePasswordField.setEnabled(false);
sshPasswordUseKeyFileTextField.setEnabled(false);
}
}
});
add(sshAuthTypeLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
add(sshPasswordUsePasswordRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
add(sshPasswordUsePasswordField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
add(sshPasswordUseKeyFileRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
add(sshPasswordUseKeyFileTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
sshPasswordUsePasswordRadioButton.setSelected(true);
enableRemoteDebugCheckBox.setSelected(false);
}
use of java.awt.event.ItemListener in project azure-tools-for-java by Microsoft.
the class SparkSubmissionContentPanel method addSparkClustersLineItem.
private void addSparkClustersLineItem() {
JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)");
sparkClusterLabel.setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
GridBagConstraints c11 = new GridBagConstraints();
c11.gridx = 0;
c11.gridy = 0;
c11.insets = new Insets(margin, margin, 0, margin);
add(sparkClusterLabel, new GridBagConstraints(0, displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
clustersListComboBox = new ComboboxWithBrowseButton();
clustersListComboBox.setButtonIcon(StreamUtil.getImageResourceFile(REFRESH_BUTTON_PATH));
clustersListComboBox.getButton().setToolTipText("Refresh");
clustersListComboBox.getButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Cursor cursor = getCursor();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
List<IClusterDetail> clusterDetails = ClusterManagerEx.getInstance().getClusterDetails(submitModel.getProject());
setCursor(cursor);
submitModel.setClusterComboBoxModel(clusterDetails);
}
});
clustersListComboBox.getComboBox().setToolTipText("The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
clustersListComboBox.getComboBox().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName() == "model" && evt.getNewValue() instanceof DefaultComboBoxModel) {
int size = ((DefaultComboBoxModel) evt.getNewValue()).getSize();
setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.ClusterName.ordinal(), size <= 0);
}
}
});
add(clustersListComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));
errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] = new JLabel("Cluster Name Should not be null");
errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
clustersListComboBox.getComboBox().addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setVisibleForFixedErrorMessageLabel(0, clustersListComboBox.getComboBox().getItemCount() == 0);
}
});
add(errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}
Aggregations