use of com.intellij.openapi.fileChooser.FileChooserDescriptor 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 com.intellij.openapi.fileChooser.FileChooserDescriptor 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 com.intellij.openapi.fileChooser.FileChooserDescriptor in project azure-tools-for-java by Microsoft.
the class SparkSubmissionContentPanel method addConfigurationLineItem.
private void addConfigurationLineItem() {
JLabel jobConfigurationLabel = new JLabel("Job configurations");
add(jobConfigurationLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));
String[] columns = { "Key", "Value", "" };
jobConfigurationTable = new JBTable();
Dimension jobConfigurationTableSize = new Dimension(320, 100);
jobConfigurationTable.setPreferredScrollableViewportSize(jobConfigurationTableSize);
jobConfigurationTable.setSurrendersFocusOnKeystroke(true);
jobConfigurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jobConfigurationTable.setColumnSelectionAllowed(true);
JBScrollPane scrollPane = new JBScrollPane(jobConfigurationTable);
jobConfigurationTable.setFillsViewportHeight(true);
scrollPane.setMinimumSize(jobConfigurationTableSize);
jobConfigurationTable.addPropertyChangeListener((evt) -> {
if ((evt.getPropertyName().equals("tableCellEditor") || evt.getPropertyName().equals("model")) && jobConfigurationTable.getModel() instanceof SubmissionTableModel) {
SubmissionTableModel model = (SubmissionTableModel) jobConfigurationTable.getModel();
setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), false);
SparkSubmissionJobConfigCheckResult result = model.getFirstCheckResults();
if (result != null) {
setStatusForMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), true, result.getMessaqge(), result.getStatus() == SparkSubmissionJobConfigCheckStatus.Warning);
}
}
});
add(scrollPane, new GridBagConstraints(1, displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, 0), 0, 0));
JButton loadJobConfigurationButton = new JButton("...");
loadJobConfigurationButton.setPreferredSize(selectedArtifactTextField.getButton().getPreferredSize());
FixedSizeButton loadJobConfigurationFixedSizeButton = new FixedSizeButton(loadJobConfigurationButton);
add(loadJobConfigurationFixedSizeButton, new GridBagConstraints(2, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(margin, margin / 2, 0, margin), 0, 0));
loadJobConfigurationFixedSizeButton.setToolTipText("Load Spark config from property file");
loadJobConfigurationFixedSizeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
fileChooserDescriptor.setTitle("Select Spark property file");
VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null);
if (chooseFile != null) {
submitModel.loadJobConfigMapFromPropertyFile(chooseFile.getCanonicalPath());
}
}
});
errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] = new JLabel();
errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setVisible(false);
add(errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0));
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class CustomizableActionsPanel method createBrowseField.
private static TextFieldWithBrowseButton createBrowseField() {
TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
//noinspection HardCodedStringLiteral
return file.getName().endsWith(".png");
}
};
textField.addBrowseFolderListener(IdeBundle.message("title.browse.icon"), IdeBundle.message("prompt.browse.icon.for.selected.action"), null, fileChooserDescriptor);
InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
return textField;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class ImportIntoShelfAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return;
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true);
FileChooser.chooseFiles(descriptor, project, null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(final List<VirtualFile> files) {
//gatherPatchFiles
final ProgressManager pm = ProgressManager.getInstance();
final ShelveChangesManager shelveChangesManager = ShelveChangesManager.getInstance(project);
final List<VirtualFile> patchTypeFiles = new ArrayList<>();
final boolean filesFound = pm.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
patchTypeFiles.addAll(shelveChangesManager.gatherPatchFiles(files));
}
}, "Looking for patch files...", true, project);
if (!filesFound || patchTypeFiles.isEmpty())
return;
if (!patchTypeFiles.equals(files)) {
final String message = "Found " + (patchTypeFiles.size() == 1 ? "one patch file (" + patchTypeFiles.get(0).getPath() + ")." : (patchTypeFiles.size() + " patch files.")) + "\nContinue with import?";
final int toImport = Messages.showYesNoDialog(project, message, "Import Patches", Messages.getQuestionIcon());
if (Messages.NO == toImport)
return;
}
pm.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
final List<VcsException> exceptions = new ArrayList<>();
final List<ShelvedChangeList> lists = shelveChangesManager.importChangeLists(patchTypeFiles, new Consumer<VcsException>() {
@Override
public void consume(VcsException e) {
exceptions.add(e);
}
});
if (!lists.isEmpty()) {
ShelvedChangesViewManager.getInstance(project).activateView(lists.get(lists.size() - 1));
}
if (!exceptions.isEmpty()) {
AbstractVcsHelper.getInstance(project).showErrors(exceptions, "Import patches into shelf");
}
if (lists.isEmpty() && exceptions.isEmpty()) {
VcsBalloonProblemNotifier.showOverChangesView(project, "No patches found", MessageType.WARNING);
}
}
}, "Import patches into shelf", true, project);
}
});
}
Aggregations