List of usage examples for com.intellij.openapi.fileChooser FileChooserDescriptor setTitle
public void setTitle(@Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstalledPluginsManagerMain.java
License:Apache License
private static void chooseAndInstall(@NotNull final InstalledPluginsTableModel model, @NotNull final Consumer<Pair<File, IdeaPluginDescriptor>> callback, @Nullable final Component parent) { final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, true, false, false) { @Override/* ww w. j av a 2s. c o m*/ public boolean isFileSelectable(VirtualFile file) { final String extension = file.getExtension(); return Comparing.strEqual(extension, "jar") || Comparing.strEqual(extension, "zip"); } }; descriptor.setTitle("Choose Plugin File"); descriptor.setDescription("JAR and ZIP archives are accepted"); final String oldPath = PropertiesComponent.getInstance().getValue(PLUGINS_PRESELECTION_PATH); final VirtualFile toSelect = oldPath == null ? null : VfsUtil.findFileByIoFile(new File(FileUtil.toSystemDependentName(oldPath)), false); FileChooser.chooseFile(descriptor, null, parent, toSelect, new Consumer<VirtualFile>() { @Override public void consume(@NotNull VirtualFile virtualFile) { File file = VfsUtilCore.virtualToIoFile(virtualFile); PropertiesComponent.getInstance().setValue(PLUGINS_PRESELECTION_PATH, FileUtil.toSystemIndependentName(file.getParent())); try { IdeaPluginDescriptorImpl pluginDescriptor = PluginDownloader.loadDescriptionFromJar(file); if (pluginDescriptor == null) { MessagesEx.showErrorDialog(parent, "Fail to load plugin descriptor from file " + file.getName(), CommonBundle.getErrorTitle()); return; } if (ourState.wasInstalled(pluginDescriptor.getPluginId())) { String message = "Plugin '" + pluginDescriptor.getName() + "' was already installed"; MessagesEx.showWarningDialog(parent, message, CommonBundle.getWarningTitle()); return; } if (PluginManagerCore.isIncompatible(pluginDescriptor)) { String message = "Plugin '" + pluginDescriptor.getName() + "' is incompatible with this installation"; MessagesEx.showErrorDialog(parent, message, CommonBundle.getErrorTitle()); return; } IdeaPluginDescriptor installedPlugin = PluginManager.getPlugin(pluginDescriptor.getPluginId()); if (installedPlugin != null && !installedPlugin.isBundled()) { File oldFile = installedPlugin.getPath(); if (oldFile != null) { StartupActionScriptManager .addActionCommand(new StartupActionScriptManager.DeleteCommand(oldFile)); } } PluginInstaller.install(file, file.getName(), false); ourState.onPluginInstall(pluginDescriptor); checkInstalledPluginDependencies(model, pluginDescriptor, parent); callback.consume(pair(file, (IdeaPluginDescriptor) pluginDescriptor)); } catch (IOException ex) { MessagesEx.showErrorDialog(parent, ex.getMessage(), CommonBundle.getErrorTitle()); } } }); }
From source file:com.microsoft.alm.plugin.idea.tfvc.actions.BranchAction.java
License:Open Source License
protected void execute(final @NotNull SingleItemActionContext actionContext) { logger.info("executing..."); try {/*from w ww. j a v a 2 s. c o m*/ final ServerContext serverContext = actionContext.getServerContext(); final Project project = actionContext.getProject(); final String sourceServerPath = actionContext.getItem().getServerItem(); final boolean isFolder = actionContext.getItem().isFolder(); final String workingFolder = isFolder ? actionContext.getItem().getLocalItem() : Path.getDirectoryName(actionContext.getItem().getLocalItem()); logger.info("Working folder: " + workingFolder); logger.info("Opening branch dialog for " + sourceServerPath); CreateBranchDialog d = new CreateBranchDialog(project, serverContext, sourceServerPath, isFolder); if (!d.showAndGet()) { return; } // For now we are just branching from the Latest //VersionSpecBase version = d.getVersionSpec(); //if (version == null) { // Messages.showErrorDialog(project, "Incorrect version specified", "Create Branch"); // return; //} // Get the current workspace final Workspace workspace = CommandUtils.getWorkspace(serverContext, actionContext.getProject()); if (workspace == null) { throw new RuntimeException( TfPluginBundle.message(TfPluginBundle.KEY_ERRORS_UNABLE_TO_DETERMINE_WORKSPACE)); } final String targetServerPath = d.getTargetPath(); logger.info("TargetServerPath from dialog: " + targetServerPath); String targetLocalPath = StringUtils.EMPTY; if (d.isCreateWorkingCopies()) { logger.info("User selected to sync the new branched copies"); // See if the target path is already mapped targetLocalPath = CommandUtils.tryGetLocalPath(serverContext, targetServerPath, workspace.getName()); logger.info("targetLocalPath: " + targetLocalPath); if (StringUtils.isEmpty(targetLocalPath)) { logger.info( "Opening the FileChooser dialog for the user to select where the unmapped branch should be mapped to."); final FileChooserDescriptor descriptor = FileChooserDescriptorFactory .createSingleFolderDescriptor(); descriptor.setTitle( TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_FILE_CHOOSE_TITLE)); descriptor.setShowFileSystemRoots(true); final String message = TfPluginBundle.message( TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_FILE_CHOOSE_DESCRIPTION, targetServerPath, workspace.getName()); descriptor.setDescription(message); final VirtualFile selectedFile = FileChooser.chooseFile(descriptor, project, null); if (selectedFile == null) { logger.info("User canceled"); return; } targetLocalPath = TfsFileUtil.getFilePath(selectedFile).getPath(); logger.info("Adding workspace mapping: " + targetServerPath + " -> " + targetLocalPath); CommandUtils.addWorkspaceMapping(serverContext, workspace.getName(), targetServerPath, targetLocalPath); } } // final ResultWithFailures<GetOperation> createBranchResult = workspace.getServer().getVCS() // .createBranch(workspace.getName(), workspace.getOwnerName(), sourceServerPath, version, targetServerPath, project, // TFSBundle.message("creating.branch")); // if (!createBranchResult.getFailures().isEmpty()) { // StringBuilder s = new StringBuilder("Failed to create branch:\n"); // for (Failure failure : createBranchResult.getFailures()) { // s.append(failure.getMessage()).append("\n"); // } // Messages.showErrorDialog(project, s.toString(), "Create Branch"); // return; // } // Create the branch logger.info("Creating branch... isFolder: " + isFolder); final String comment = TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_COMMENT, sourceServerPath); CommandUtils.createBranch(serverContext, workingFolder, true, comment, null, sourceServerPath, targetServerPath); if (d.isCreateWorkingCopies()) { logger.info("Get the latest for the branched folder..."); final String localPath = targetLocalPath; final List<VcsException> errors = new ArrayList<VcsException>(); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { logger.info("Syncing: " + localPath); final SyncResults syncResults = CommandUtils.syncWorkspace(serverContext, localPath); if (syncResults.getExceptions().size() > 0) { for (final SyncException se : syncResults.getExceptions()) { errors.add(TFSVcs.convertToVcsException(se)); } } } }, TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_SYNC_PROGRESS), false, project); if (!errors.isEmpty()) { logger.info("Errors found"); AbstractVcsHelper.getInstance(project).showErrors(errors, TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_TITLE)); } } targetLocalPath = CommandUtils.tryGetLocalPath(serverContext, targetServerPath, workspace.getName()); logger.info("targetLocalPath: " + targetLocalPath); if (StringUtils.isNotEmpty(targetLocalPath)) { logger.info("Marking the target path dirty in the editor."); TfsFileUtil.markDirtyRecursively(project, new LocalFilePath(targetLocalPath, isFolder)); } final String message = TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_SUCCESS, sourceServerPath, targetServerPath); Messages.showInfoMessage(project, message, TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_TITLE)); } catch (final Throwable t) { logger.warn("Branching failed", t); final String message = TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_FAILURE, t.getMessage()); Messages.showErrorDialog(actionContext.getProject(), message, TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_TFVC_BRANCH_MESSAGE_TITLE)); } }
From source file:com.microsoft.azure.hdinsight.projects.SparkLibraryDescription.java
License:Open Source License
private NewLibraryConfiguration getSparkSDKConfigurationFromLocalFile() { FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false); chooserDescriptor.setTitle("Select Spark SDK"); String pluginPath = PluginUtil.getPluginRootDirectory(); VirtualFile pluginVfs = LocalFileSystem.getInstance().findFileByPath(pluginPath); VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, pluginVfs); if (chooseFile == null) { return null; }/*from w ww.java 2 s . c o m*/ this.localPath = chooseFile.getPath(); final List<OrderRoot> roots = RootDetectionUtil.detectRoots(Arrays.asList(chooseFile), null, null, new DefaultLibraryRootsComponentDescriptor()); if (roots.isEmpty()) { return null; } return new NewLibraryConfiguration(LibraryTypeServiceImpl.suggestLibraryName(roots), SparkLibraryType.getInstance(), new SparkLibraryProperties()) { @Override public void addRoots(@NotNull LibraryEditor libraryEditor) { libraryEditor.addRoots(roots); } }; }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionAdvancedConfigDialog.java
License:Open Source License
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,// w w w . ja va2 s. c om 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); }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
License:Open Source License
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/*ww w . j a v a2 s .co m*/ 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)); }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
License:Open Source License
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); }//from ww w .j a va 2s .com } }); 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)); }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionExDialog.java
License:Open Source License
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/*from ww w . j a v a 2 s . c o m*/ 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 hard 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); contentPane.add(artifactSelectLabel, new GridBagConstraints(0, ++row, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0)); contentPane.add(intelliJArtifactRadioButton, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0)); contentPane.add(selectedArtifactComboBox, new GridBagConstraints(1, row, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0)); contentPane.add(errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()], new GridBagConstraints(1, ++row, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0)); contentPane.add(localArtifactRadioButton, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0)); contentPane.add(selectedArtifactTextField, new GridBagConstraints(1, row, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0)); contentPane.add(errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()], new GridBagConstraints(1, ++row, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0)); }
From source file:com.microsoft.intellij.forms.ImportSubscriptionForm.java
License:Open Source License
public ImportSubscriptionForm(Project project) { super(project, true); myProject = project;// w ww .ja va 2 s. c om lblPolicy.addMouseListener(new LinkListener("http://msdn.microsoft.com/en-us/vstudio/dn425032.aspx")); lblDownload.addMouseListener(new LinkListener("http://go.microsoft.com/fwlink/?LinkID=301775")); this.setModal(true); this.setTitle("Import Microsoft Azure Subscriptions"); final ImportSubscriptionForm form = this; this.setOKActionEnabled(false); this.setOKButtonText("Import"); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { try { return file.isDirectory() || (file.getExtension() != null && file.getExtension().equals("publishsettings")); } catch (Throwable t) { return super.isFileVisible(file, showHiddenFiles); } } @Override public boolean isFileSelectable(VirtualFile file) { return (file.getExtension() != null && file.getExtension().equals("publishsettings")); } }; fileChooserDescriptor.setTitle("Choose Subscriptions File"); FileChooser.chooseFile(fileChooserDescriptor, null, null, new Consumer<VirtualFile>() { @Override public void consume(VirtualFile virtualFile) { if (virtualFile != null) { form.setOKActionEnabled(true); txtFile.setText(virtualFile.getPath()); } } }); } }); DocumentListener documentListener = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { setOKActionEnabled(txtFile.getText() != null && !txtFile.getText().trim().isEmpty()); } @Override public void removeUpdate(DocumentEvent e) { setOKActionEnabled(txtFile.getText() != null && !txtFile.getText().trim().isEmpty()); } @Override public void changedUpdate(DocumentEvent e) { setOKActionEnabled(txtFile.getText() != null && !txtFile.getText().trim().isEmpty()); } }; txtFile.getDocument().addDocumentListener(documentListener); init(); }
From source file:com.microsoft.intellij.forms.OpenSSLFinderForm.java
License:Open Source License
public OpenSSLFinderForm(Project project) { super(project, true); setModal(true);/*from w w w .ja va 2 s . com*/ btnBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { try { return file.isDirectory() || file.getNameWithoutExtension().toLowerCase().equals("openssl"); } catch (Throwable t) { return super.isFileVisible(file, showHiddenFiles); } } @Override public boolean isFileSelectable(VirtualFile file) { return file.getNameWithoutExtension().toLowerCase().equals("openssl"); } }; fileChooserDescriptor.setTitle("Choose OpenSSL executable"); FileChooser.chooseFile(fileChooserDescriptor, null, null, new Consumer<VirtualFile>() { @Override public void consume(VirtualFile virtualFile) { if (virtualFile != null) { txtFile.setText(virtualFile.getParent().getPath()); } } }); } }); init(); }
From source file:com.microsoft.intellij.ui.azureroles.CertificateDialog.java
License:Open Source License
private void importBtnListner() { FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {/* w w w .ja va2s. c o m*/ @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return file.isDirectory() || (file.getExtension() != null && (file.getExtension().equals("pfx") || file.getExtension().equals("pfx") || file.getExtension().equals("cer") || file.getExtension().equals(".CER"))); } @Override public boolean isFileSelectable(VirtualFile file) { return (file.getExtension() != null && (file.getExtension().equals("pfx") || file.getExtension().equals("pfx") || file.getExtension().equals("cer") || file.getExtension().equals(".CER"))); } }; fileChooserDescriptor.setTitle("Select Certificate"); FileChooser.chooseFile(fileChooserDescriptor, null, null, new Consumer<VirtualFile>() { @Override public void consume(VirtualFile virtualFile) { if (virtualFile != null) { String path = virtualFile.getPath(); String password = null; boolean proceed = true; if (path.endsWith(".pfx") || path.endsWith(".PFX")) { SimplePfxPwdDlg dlg = new SimplePfxPwdDlg(path); dlg.show(); if (dlg.isOK()) { password = dlg.getPwd(); } else { proceed = false; } } if (proceed) { X509Certificate cert = CerPfxUtil.getCert(path, password); if (cert != null) { if (txtName.getText().isEmpty()) { populateCertName(CertificateDialogUtilMethods .removeSpaceFromCN(cert.getSubjectDN().getName())); } String thumbprint = ""; try { thumbprint = CerPfxUtil.getThumbPrint(cert); } catch (Exception e) { PluginUtil.displayErrorDialog(message("certErrTtl"), message("certImpEr")); } txtThumb.setText(thumbprint); } } } } }); }