List of usage examples for com.intellij.openapi.ui Messages showErrorDialog
public static void showErrorDialog(@Nullable Component component, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:com.jetbrains.lang.dart.ide.refactoring.ServerRefactoringDialog.java
License:Apache License
protected final void doRefactoring(@NotNull final Set<String> excludedIds) { // Apply the change. final String error = ApplicationManager.getApplication().runWriteAction(new Computable<String>() { @Override//from w w w . j a va2s . co m public String compute() { final SourceChange change = myRefactoring.getChange(); assert change != null; try { AssistUtils.applySourceChange(myProject, change, false, excludedIds); } catch (DartSourceEditException e) { return e.getMessage(); } return null; } }); if (error == null) { close(DialogWrapper.OK_EXIT_CODE); } else { Messages.showErrorDialog(myProject, error, CommonBundle.getErrorTitle()); } }
From source file:com.jetbrains.unchain.ui.UnchainPanel.java
License:Apache License
private void moveClasses() { Module selectedItem = (Module) myTargetModuleComboBox.getSelectedItem(); CollectionListModel<String> model = (CollectionListModel<String>) myGoodDepsList.getModel(); final UnchainMover mover = new UnchainMover(selectedItem, model.getItems()); final Ref<Boolean> failed = Ref.create(false); new WriteCommandAction.Simple(myProject, "Moving classes to target module") { @Override/*from ww w . jav a2 s .c om*/ protected void run() throws Throwable { try { mover.run(); } catch (UnsupportedOperationException e) { Messages.showErrorDialog(myProject, e.getMessage(), "Move Failed"); failed.set(true); } } }.execute(); if (!failed.get()) { myClassNameField.setText(""); clearList(myBadDepsList); clearList(myCallChainList); showDepsCard(true); } }
From source file:com.maddyhome.idea.copyright.ui.CopyrightConfigurable.java
License:Apache License
public CopyrightConfigurable(final Project project, CopyrightProfile copyrightProfile, Runnable updater) { super(true, updater); myProject = project;// w ww . java 2 s . c o m myCopyrightProfile = copyrightProfile; myDisplayName = myCopyrightProfile.getName(); myWholePanel = new JPanel(new VerticalFlowLayout()); myCopyrightEditorPanel = new JEditorPane(); myCopyrightEditorPanel .setFont(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); DefaultActionGroup group = new DefaultActionGroup(); group.add(new AnAction("Preview", null, AllIcons.Actions.Preview) { @Override public void actionPerformed(AnActionEvent e) { try { String evaluate = VelocityHelper.evaluate(null, project, null, myCopyrightEditorPanel.getText()); new PreviewDialog(project, evaluate, myCopyrightEditorPanel.getSize()).show(); } catch (Exception e1) { Messages.showErrorDialog(myProject, "Template contains error:\n" + e1.getMessage(), "Preview"); } } }); val extensions = PredefinedCopyrightTextEP.EP_NAME.getExtensions(); if (extensions.length > 0) { group.add(new AnAction("Reset To", null, AllIcons.Actions.Reset) { @Override public void actionPerformed(AnActionEvent e) { val actionGroup = new DefaultActionGroup(); for (val extension : extensions) { actionGroup.add(new AnAction(extension.name) { @Override public void actionPerformed(AnActionEvent e) { String text = extension.getText(); myCopyrightEditorPanel.setText(text); } }); } ActionPopupMenu popupMenu = ActionManager.getInstance() .createActionPopupMenu(ActionPlaces.UNKNOWN, actionGroup); popupMenu.getComponent().show(e.getInputEvent().getComponent(), e.getInputEvent().getComponent().getWidth(), 0); } }); } ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); JPanel result = new JPanel(new BorderLayout()); JPanel toolBarPanel = new JPanel(new BorderLayout()); toolBarPanel.add(actionToolbar.getComponent(), BorderLayout.WEST); JLabel label = new JBLabel("Velocity Template"); label.setForeground(JBColor.GRAY); toolBarPanel.add(label, BorderLayout.EAST); result.add(toolBarPanel, BorderLayout.NORTH); result.add(new JBScrollPane(myCopyrightEditorPanel), BorderLayout.CENTER); result.setPreferredSize(new Dimension(-1, 400)); myWholePanel.add(result); myWholePanel.add(LabeledComponent.left(myKeywordField = new JBTextField(), "Keyword to detect copyright in comments")); myWholePanel.add(LabeledComponent.left(myAllowReplaceTextField = new JBTextField(), "Allow replacing copyright if old copyright contains")); }
From source file:com.microsoft.alm.plugin.idea.common.utils.IdeaHelper.java
License:Open Source License
/** * Shows an error dialog// w ww .jav a 2 s. c om * * @param project * @param message */ public static void showErrorDialog(@NotNull final Project project, @NotNull final String message) { if (ApplicationManager.getApplication() == null) { // No application manager means no IntelliJ, we are probably in a test context return; } Messages.showErrorDialog(project, message, TfPluginBundle.message(TfPluginBundle.KEY_TITLE_TEAM_SERVICES_ERROR)); }
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 w w . j a va 2 s . c om 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.alm.plugin.idea.tfvc.actions.SingleItemAction.java
License:Open Source License
public void doActionPerformed(final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final VirtualFile file = VcsUtil.getOneVirtualFile(e); if (project == null || file == null) { // This shouldn't happen, but just in case logger.warn("project or file is null in actionPerformed"); return;//from ww w . jav a 2s . c o m } // checked by isEnabled() final FilePath localPath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); final String actionTitle = StringUtil.trimEnd(e.getPresentation().getText(), "..."); try { final SingleItemActionContext actionContext = new SingleItemActionContext(project, localPath); final List<VcsException> errors = new ArrayList<VcsException>(); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { try { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); final ServerContext context = TFSVcs.getInstance(project).getServerContext(true); final ItemInfo item = CommandUtils.getItemInfo(context, localPath.getPath()); actionContext.setItem(item); actionContext.setServerContext(context); } catch (final Throwable t) { errors.add(TFSVcs.convertToVcsException(t)); } } }, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_UPDATE_STATUS_MSG), false, project); if (!errors.isEmpty()) { AbstractVcsHelper.getInstance(project).showErrors(errors, TFSVcs.TFVC_NAME); return; } execute(actionContext); } catch (TfsException ex) { Messages.showErrorDialog(project, ex.getMessage(), actionTitle); } }
From source file:com.microsoft.alm.plugin.idea.tfvc.ui.checkout.TfvcCheckoutModel.java
License:Open Source License
@Override public void doCheckout(final Project project, final CheckoutProvider.Listener listener, final ServerContext context, final VirtualFile destinationParent, final String directoryName, final String parentDirectory, final boolean isAdvancedChecked) { final String workspaceName = directoryName; final String teamProjectName = getRepositoryName(context); final String localPath = Path.combine(parentDirectory, directoryName); final AtomicBoolean checkoutResult = new AtomicBoolean(); (new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_CREATING_WORKSPACE), true, PerformInBackgroundOption.DEAF) { public void run(@NotNull final ProgressIndicator indicator) { IdeaHelper.setProgress(indicator, 0.10, TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_PROGRESS_CREATING)); try { // Create the workspace with default values final CreateWorkspaceCommand command = new CreateWorkspaceCommand(context, workspaceName, TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_WORKSPACE_COMMENT), null, null); command.runSynchronously(); } catch (final WorkspaceAlreadyExistsException e) { logger.warn("Error creating workspace: " + LocalizationServiceImpl.getInstance().getExceptionMessage(e)); // TODO: allow user to change name in the flow instead of starting over IdeaHelper.runOnUIThread(new Runnable() { @Override//from w w w .java 2 s . com public void run() { Messages.showErrorDialog(project, LocalizationServiceImpl.getInstance().getExceptionMessage(e), TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_FAILED_TITLE)); } }); // returning since the workspace failed to create so we can't proceed with the next steps return; } IdeaHelper.setProgress(indicator, 0.20, TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_PROGRESS_ADD_ROOT)); // Map the project root to the local folder final String serverPath = VcsHelper.TFVC_ROOT + teamProjectName; final UpdateWorkspaceMappingCommand mappingCommand = new UpdateWorkspaceMappingCommand(context, workspaceName, new Workspace.Mapping(serverPath, localPath, false), false); mappingCommand.runSynchronously(); IdeaHelper.setProgress(indicator, 0.30, TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_PROGRESS_CREATE_FOLDER)); // Ensure that the local folder exists final File file = new File(localPath); if (!file.mkdirs()) { //TODO should we throw here? } // if advanced is set, then sync just some of the files (those that we need for IntelliJ) // Otherwise, sync all the files for the team project if (!isAdvancedChecked) { IdeaHelper.setProgress(indicator, 0.50, TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_TFVC_PROGRESS_SYNC)); // Sync all files recursively CommandUtils.syncWorkspace(context, localPath); } IdeaHelper.setProgress(indicator, 1.00, "", true); // No exception means that it was successful checkoutResult.set(true); } public void onSuccess() { if (checkoutResult.get()) { // Check the isAdvanced flag if (isAdvancedChecked) { // The user wants to edit the workspace before syncing... final RepositoryContext repositoryContext = RepositoryContext.createTfvcContext(localPath, workspaceName, teamProjectName, context.getServerUri().toString()); final WorkspaceController controller = new WorkspaceController(project, repositoryContext, workspaceName); if (controller.showModalDialog(false)) { // Save and Sync the workspace (this will be backgrounded) controller.saveWorkspace(localPath, true, new Runnable() { @Override public void run() { // Files are all synchronized, so trigger the VCS update UpdateVersionControlSystem(project, parentDirectory, directoryName, destinationParent, listener); } }); } } else { // We don't have to wait for the workspace to be updated, so just trigger the VCS update UpdateVersionControlSystem(project, parentDirectory, directoryName, destinationParent, listener); } } } }).queue(); }
From source file:com.microsoft.alm.plugin.idea.tfvc.ui.settings.ProjectConfigurableForm.java
License:Open Source License
public ProjectConfigurableForm(final Project project) { myProject = project;/*from w w w.j a va2 s . c o m*/ // TODO: set these visible once we start using them myResetPasswordsButton.setVisible(false); myUseIdeaHttpProxyCheckBox.setVisible(false); myTFSCheckBox.setVisible(false); myStatefulCheckBox.setVisible(false); myReportNotInstalledPoliciesCheckBox.setVisible(false); myResetPasswordsButton.setVisible(false); serverLabel.setVisible(false); passwordLabel.setVisible(false); checkinPolicyLabel.setVisible(false); noteLabel.setVisible(false); pathLabel.setText(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_DESCRIPTION)); tfExeField.addBrowseFolderListener(TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_TITLE), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_DESCRIPTION), project, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); testExeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { PluginServiceProvider.getInstance().getPropertyService().setProperty(PropertyService.PROP_TF_HOME, getCurrentExecutablePath()); try { TfTool.checkVersion(); Messages.showInfoMessage(myContentPane, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_SETTINGS_FOUND_EXE), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_TF_VERSION_WARNING_TITLE)); } catch (ToolVersionException e) { Messages.showWarningDialog(myContentPane, LocalizationServiceImpl.getInstance().getExceptionMessage(e), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_TF_VERSION_WARNING_TITLE)); } catch (ToolException e) { Messages.showErrorDialog(myContentPane, LocalizationServiceImpl.getInstance().getExceptionMessage(e), TfPluginBundle.message(TfPluginBundle.KEY_TFVC_TF_VERSION_WARNING_TITLE)); } } }); // load settings load(); // TODO: comment back in when ready to use // myManageButton.addActionListener(new ActionListener() { // public void actionPerformed(final ActionEvent e) { // ManageWorkspacesDialog d = new ManageWorkspacesDialog(myProject); // d.show(); // } // }); // // myUseIdeaHttpProxyCheckBox.setSelected(TFSConfigurationManager.getInstance().useIdeaHttpProxy()); // // myResetPasswordsButton.addActionListener(new ActionListener() { // public void actionPerformed(final ActionEvent e) { // final String title = "Reset Stored Passwords"; // if (Messages.showYesNoDialog(myProject, "Do you want to reset all stored passwords?", title, Messages.getQuestionIcon()) == Messages.YES) { // TFSConfigurationManager.getInstance().resetStoredPasswords(); // Messages.showInfoMessage(myProject, "Passwords reset successfully.", title); // } // } // }); // // ActionListener l = new ActionListener() { // public void actionPerformed(ActionEvent e) { // updateNonInstalledCheckbox(); // } // }; // myStatefulCheckBox.addActionListener(l); // myTFSCheckBox.addActionListener(l); }
From source file:com.microsoft.alm.plugin.idea.utils.IdeaHelper.java
License:Open Source License
/** * Shows an error dialog// ww w . ja v a 2s .c o m * * @param project * @param throwable */ public static void showErrorDialog(@NotNull final Project project, final Throwable throwable) { if (throwable != null) { Messages.showErrorDialog(project, throwable.getMessage(), TfPluginBundle.message(TfPluginBundle.KEY_TITLE_TEAM_SERVICES_ERROR)); } else { Messages.showErrorDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_MESSAGE_TEAM_SERVICES_UNEXPECTED_ERROR), TfPluginBundle.message(TfPluginBundle.KEY_TITLE_TEAM_SERVICES_ERROR)); } }
From source file:com.perl5.lang.perl.idea.configuration.settings.sdk.Perl5ProjectConfigurable.java
License:Apache License
private void doAddExternalLibrary(AnActionButton button) { FileChooserFactory.getInstance()// w w w. j a va 2 s .c om .createPathChooser(FileChooserDescriptorFactory.createMultipleFoldersDescriptor() .withTreeRootVisible(true).withTitle(PerlBundle.message("perl.settings.select.libs")), myProject, myLibsList) .choose(null, virtualFiles -> { Ref<Boolean> notifyInternals = new Ref<>(false); List<VirtualFile> rootsToAdd = new ArrayList<>(); for (VirtualFile virtualFile : virtualFiles) { if (!virtualFile.isValid()) { continue; } if (!virtualFile.isDirectory()) { virtualFile = virtualFile.getParent(); if (virtualFile == null || !virtualFile.isValid()) { continue; } } if (ModuleUtilCore.findModuleForFile(virtualFile, myProject) != null) { notifyInternals.set(true); continue; } rootsToAdd.add(virtualFile); } myLibsModel.add(rootsToAdd); if (notifyInternals.get()) { Messages.showErrorDialog(myLibsList, PerlBundle.message("perl.settings.external.libs.internal.text"), PerlBundle.message("perl.settings.external.libs.internal.title")); } }); }