use of java.awt.event.ItemEvent 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));
}
use of java.awt.event.ItemEvent in project azure-tools-for-java by Microsoft.
the class SparkSubmissionContentPanel method addSelectedArtifactLineItem.
private void addSelectedArtifactLineItem() {
final String tipInfo = "The Artifact you want to use.";
JLabel artifactSelectLabel = new JLabel("Select an Artifact to submit");
artifactSelectLabel.setToolTipText(tipInfo);
selectedArtifactComboBox = new ComboBox();
selectedArtifactComboBox.setToolTipText(tipInfo);
errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()] = new JLabel("Artifact should not be null!");
errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setVisible(false);
errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()] = new JLabel("Could not find the local jar package for Artifact");
errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setVisible(false);
selectedArtifactTextField = new TextFieldWithBrowseButton();
selectedArtifactTextField.setToolTipText("Artifact from local jar package.");
selectedArtifactTextField.setEditable(true);
selectedArtifactTextField.setEnabled(false);
selectedArtifactTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
}
@Override
public void removeUpdate(DocumentEvent e) {
setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
}
@Override
public void changedUpdate(DocumentEvent e) {
setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
}
});
selectedArtifactTextField.getButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
chooserDescriptor.setTitle("Select Local Artifact File");
VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, null);
if (chooseFile != null) {
String path = chooseFile.getPath();
if (path.endsWith("!/")) {
path = path.substring(0, path.length() - 2);
}
selectedArtifactTextField.setText(path);
}
}
});
intelliJArtifactRadioButton = new JRadioButton("Artifact from IntelliJ project:", true);
localArtifactRadioButton = new JRadioButton("Artifact from local disk:", false);
intelliJArtifactRadioButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
selectedArtifactComboBox.setEnabled(true);
selectedArtifactTextField.setEnabled(false);
mainClassTextField.setButtonEnabled(true);
setVisibleForFixedErrorMessageLabel(2, false);
if (selectedArtifactComboBox.getItemCount() == 0) {
setVisibleForFixedErrorMessageLabel(2, true);
}
}
}
});
localArtifactRadioButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
selectedArtifactComboBox.setEnabled(false);
selectedArtifactTextField.setEnabled(true);
mainClassTextField.setButtonEnabled(false);
setVisibleForFixedErrorMessageLabel(1, false);
if (StringHelper.isNullOrWhiteSpace(selectedArtifactTextField.getText())) {
setVisibleForFixedErrorMessageLabel(2, true);
}
}
}
});
ButtonGroup group = new ButtonGroup();
group.add(intelliJArtifactRadioButton);
group.add(localArtifactRadioButton);
intelliJArtifactRadioButton.setSelected(true);
add(artifactSelectLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
add(intelliJArtifactRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
add(selectedArtifactComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
add(errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
add(localArtifactRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
add(selectedArtifactTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
add(errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class AbstractCustomizeWizardStep method createBigButtonPanel.
protected static JPanel createBigButtonPanel(LayoutManager layout, final JToggleButton anchorButton, final Runnable action) {
final JPanel panel = new JPanel(layout) {
@Override
public Color getBackground() {
return anchorButton.isSelected() ? getSelectionBackground() : super.getBackground();
}
};
panel.setOpaque(anchorButton.isSelected());
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
anchorButton.setSelected(true);
return true;
}
}.installOn(panel);
anchorButton.addItemListener(new ItemListener() {
boolean curState = anchorButton.isSelected();
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED && curState != anchorButton.isSelected()) {
action.run();
}
curState = anchorButton.isSelected();
panel.setOpaque(curState);
panel.repaint();
}
});
return panel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class SearchDialog method buildOptions.
protected void buildOptions(JPanel searchOptions) {
recursiveMatching = new JCheckBox(SSRBundle.message("recursive.matching.checkbox"), true);
if (isRecursiveSearchEnabled()) {
searchOptions.add(UIUtil.createOptionLine(recursiveMatching));
}
caseSensitiveMatch = new JCheckBox(FindBundle.message("find.options.case.sensitive"), true);
searchOptions.add(UIUtil.createOptionLine(caseSensitiveMatch));
final List<FileType> types = new ArrayList<>();
for (FileType fileType : StructuralSearchUtil.getSuitableFileTypes()) {
if (StructuralSearchUtil.getProfileByFileType(fileType) != null) {
types.add(fileType);
}
}
Collections.sort(types, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
final DefaultComboBoxModel<FileType> comboBoxModel = new DefaultComboBoxModel<>(types.toArray(new FileType[types.size()]));
fileTypes = new ComboBox<>(comboBoxModel);
fileTypes.setRenderer(new FileTypeRenderer());
new ComboboxSpeedSearch(fileTypes) {
@Override
protected String getElementText(Object element) {
return ((FileType) element).getName();
}
};
contexts = new ComboBox<>();
contexts.setPreferredSize(new Dimension(60, -1));
dialects = new ComboBox<>();
dialects.setRenderer(new ListCellRendererWrapper<Language>() {
@Override
public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
if (value == null) {
setText("None");
} else {
setText(value.getDisplayName());
}
}
});
dialects.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updateEditor();
}
});
new ComboboxSpeedSearch(dialects);
dialects.setPreferredSize(new Dimension(120, -1));
final JLabel jLabel = new JLabel(SSRBundle.message("search.dialog.file.type.label"));
final JLabel jLabel2 = new JLabel(SSRBundle.message("search.dialog.context.label"));
final JLabel jLabel3 = new JLabel(SSRBundle.message("search.dialog.file.dialect.label"));
searchOptions.add(UIUtil.createOptionLine(new JComponent[] { jLabel, fileTypes, (JComponent) Box.createHorizontalStrut(8), jLabel2, contexts, (JComponent) Box.createHorizontalStrut(8), jLabel3, dialects }));
jLabel.setLabelFor(fileTypes);
jLabel2.setLabelFor(contexts);
jLabel3.setLabelFor(dialects);
detectFileTypeAndDialect();
fileTypes.setSelectedItem(ourFtSearchVariant);
fileTypes.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
updateDialectsAndContexts();
updateEditor();
initiateValidation();
}
}
});
dialects.setSelectedItem(ourDialect);
contexts.setSelectedItem(ourContext);
updateDialectsAndContexts();
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class XSuspendPolicyPanel method init.
@Override
public void init(Project project, final XBreakpointManager breakpointManager, @NotNull XBreakpointBase breakpoint) {
super.init(project, breakpointManager, breakpoint);
mySuspendCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
boolean selected = mySuspendCheckBox.isSelected();
if (myBreakpoint.getType().isSuspendThreadSupported()) {
changeEnableState(selected);
}
if (myDelegate != null && !selected) {
myDelegate.showMoreOptionsIfNeeded();
}
}
});
if (!myBreakpoint.getType().isSuspendThreadSupported()) {
return;
}
updateSuspendPolicyFont();
ItemListener suspendPolicyChangeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updateMakeDefaultEnableState();
}
};
updateMakeDefaultEnableState();
mySuspendAll.addItemListener(suspendPolicyChangeListener);
mySuspendThread.addItemListener(suspendPolicyChangeListener);
myMakeDefaultButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SuspendPolicy suspendPolicy = getSelectedSuspendPolicy();
((XBreakpointManagerImpl) myBreakpointManager).getBreakpointDefaults(myBreakpointType).setSuspendPolicy(suspendPolicy);
updateSuspendPolicyFont();
if (SuspendPolicy.THREAD == suspendPolicy) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(mySuspendThread, true);
});
} else {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(mySuspendAll, true);
});
}
myMakeDefaultButton.setEnabled(false);
}
});
}
Aggregations