List of usage examples for com.intellij.openapi.ui Messages showInfoMessage
public static void showInfoMessage(@Nullable Project project, @Nls String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:org.jetbrains.tfsIntegration.actions.BranchAction.java
License:Apache License
protected void execute(final @NotNull Project project, final @NotNull WorkspaceInfo workspace, final @NotNull FilePath sourceLocalPath, final @NotNull ExtendedItem sourceExtendedItem) { try {//from w ww. ja va 2s .c o m final String sourceServerPath = sourceExtendedItem.getSitem(); CreateBranchDialog d = new CreateBranchDialog(project, workspace, sourceServerPath, sourceExtendedItem.getType() == ItemType.Folder); if (!d.showAndGet()) { return; } VersionSpecBase version = d.getVersionSpec(); if (version == null) { Messages.showErrorDialog(project, "Incorrect version specified", "Create Branch"); return; } final String targetServerPath = d.getTargetPath(); if (d.isCreateWorkingCopies()) { FilePath targetLocalPath = workspace.findLocalPathByServerPath(targetServerPath, true, project); if (targetLocalPath == null) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); descriptor.setTitle("Select Local Folder"); descriptor.setShowFileSystemRoots(true); final String message = MessageFormat.format( "Branch target folder ''{0}'' is not mapped. Select a local folder to create a mapping in workspace ''{1}''", targetServerPath, workspace.getName()); descriptor.setDescription(message); VirtualFile selectedFile = FileChooser.chooseFile(descriptor, project, null); if (selectedFile == null) { return; } workspace.addWorkingFolderInfo(new WorkingFolderInfo(WorkingFolderInfo.Status.Active, TfsFileUtil.getFilePath(selectedFile), targetServerPath)); workspace.saveToServer(project, workspace); } } 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; } if (d.isCreateWorkingCopies()) { final Ref<Collection<VcsException>> downloadErrors = new Ref<Collection<VcsException>>( Collections.<VcsException>emptyList()); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { downloadErrors .set(ApplyGetOperations.execute(project, workspace, createBranchResult.getResult(), new ApplyProgress.ProgressIndicatorWrapper( ProgressManager.getInstance().getProgressIndicator()), null, ApplyGetOperations.DownloadMode.ALLOW)); } }, "Creating target working copies", false, project); if (!downloadErrors.get().isEmpty()) { AbstractVcsHelper.getInstance(project) .showErrors(new ArrayList<VcsException>(downloadErrors.get()), "Create Branch"); } } // TODO checkin requires proper configuration final Collection<PendingChange> pendingChanges = workspace.getServer().getVCS() .queryPendingSetsByServerItems(workspace.getName(), workspace.getOwnerName(), Collections.singletonList(targetServerPath), RecursionType.Full, project, TFSBundle.message("loading.changes")); Collection<String> checkin = new ArrayList<String>(); for (PendingChange change : pendingChanges) { if (new ChangeTypeMask(change.getChg()).contains(ChangeType_type0.Branch)) { checkin.add(change.getItem()); } } final String comment = MessageFormat.format("Branched from {0}", sourceServerPath); final ResultWithFailures<CheckinResult> checkinResult = workspace.getServer().getVCS().checkIn( workspace.getName(), workspace.getOwnerName(), checkin, comment, Collections.<WorkItem, CheckinWorkItemAction>emptyMap(), Collections.<Pair<String, String>>emptyList(), null, project, TFSBundle.message("checking.in")); if (!checkinResult.getFailures().isEmpty()) { final List<VcsException> checkinErrors = TfsUtil.getVcsExceptions(checkinResult.getFailures()); AbstractVcsHelper.getInstance(project).showErrors(checkinErrors, "Create Branch"); } final FilePath targetLocalPath = workspace.findLocalPathByServerPath(targetServerPath, true, project); if (targetLocalPath != null) { TfsFileUtil.markDirtyRecursively(project, targetLocalPath); } String message = MessageFormat.format("''{0}'' branched successfully to ''{1}''.", sourceServerPath, targetServerPath); Messages.showInfoMessage(project, message, "Create Branch"); } catch (TfsException ex) { String message = "Failed to create branch: " + ex.getMessage(); Messages.showErrorDialog(project, message, "Create Branch"); } }
From source file:org.jetbrains.tfsIntegration.actions.ItemInfoAction.java
License:Apache License
protected void execute(final @NotNull Project project, final @NotNull WorkspaceInfo workspace, final @NotNull FilePath localPath, final @NotNull ExtendedItem extendedItem) throws TfsException { //noinspection ConstantConditions if (extendedItem.getLver() == Integer.MIN_VALUE) { final String itemType = localPath.isDirectory() ? "Folder" : "File"; final String message = MessageFormat.format("{0} ''{1}'' is unversioned", itemType, localPath.getPresentableUrl()); Messages.showInfoMessage(project, message, getActionTitle(localPath.isDirectory())); return;/*from ww w. j a v a 2s .com*/ } final String serverPath = extendedItem.getTitem() != null ? extendedItem.getTitem() : extendedItem.getSitem(); final Collection<BranchRelative> branches = workspace.getServer().getVCS().queryBranches(serverPath, new ChangesetVersionSpec(extendedItem.getLver()), project, TFSBundle.message("loading.branches")); ItemInfoDialog d = new ItemInfoDialog(project, workspace, extendedItem, branches, getActionTitle(localPath.isDirectory())); d.show(); }
From source file:org.jetbrains.tfsIntegration.actions.LockAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final VirtualFile[] files = VcsUtil.getVirtualFiles(e); final List<LockItemModel> items = new ArrayList<LockItemModel>(); final List<VcsException> exceptions = new ArrayList<VcsException>(); final Ref<Boolean> mappingFound = new Ref<Boolean>(false); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { try { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); WorkstationHelper.processByWorkspaces(TfsFileUtil.getFilePaths(files), false, project, new WorkstationHelper.VoidProcessDelegate() { public void executeRequest(final WorkspaceInfo workspace, final List<ItemPath> paths) throws TfsException { mappingFound.set(true); final Map<FilePath, ExtendedItem> itemsMap = workspace.getExtendedItems2(paths, project, TFSBundle.message("loading.items")); for (ExtendedItem item : itemsMap.values()) { if (item != null) { items.add(new LockItemModel(item, workspace)); }//from w w w . ja v a 2s . c om } } }); } catch (TfsException e) { exceptions.add(new VcsException(e)); } } }, "Reading existing locks...", false, project); if (!exceptions.isEmpty()) { AbstractVcsHelper.getInstance(project).showErrors(exceptions, TFSVcs.TFS_NAME); return; } if (!mappingFound.get()) { Messages.showInfoMessage(project, "Team Foundation Server mappings not found.", e.getPresentation().getText()); return; } if (items.isEmpty()) { Messages.showInfoMessage(project, "Server item not found.", e.getPresentation().getText()); return; } performInitialSelection(items); final LockItemsDialog d = new LockItemsDialog(project, items); d.show(); int exitCode = d.getExitCode(); if (exitCode != LockItemsDialog.LOCK_EXIT_CODE && exitCode != LockItemsDialog.UNLOCK_EXIT_CODE) { return; } final List<LockItemModel> selectedItems = d.getSelectedItems(); String title = d.getLockLevel() == LockLevel.None ? "Unlocking..." : "Locking..."; ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); exceptions.addAll(lockOrUnlockItems(selectedItems, d.getLockLevel(), project)); } }, title, false, project); if (exceptions.isEmpty()) { String message = MessageFormat.format("{0} {1} {2}", selectedItems.size(), selectedItems.size() == 1 ? "item" : "items", exitCode == LockItemsDialog.LOCK_EXIT_CODE ? "locked" : "unlocked"); TfsUtil.showBalloon(project, MessageType.INFO, message); } else { AbstractVcsHelper.getInstance(project).showErrors(exceptions, TFSVcs.TFS_NAME); } }
From source file:org.jetbrains.tfsIntegration.ui.ProjectConfigurableForm.java
License:Apache License
public ProjectConfigurableForm(final Project project) { myProject = project;// ww w . jav a 2 s.c o m 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:org.jetbrains.tfsIntegration.ui.SelectChangesetForm.java
License:Apache License
private void search() { VersionSpec versionFrom = null;//from w ww . j a v a 2s .c o m VersionSpec versionTo = LatestVersionSpec.INSTANCE; try { if (myChangeNumberRadioButton.isSelected()) { if (myFromChangesetField.getText() != null && myFromChangesetField.getText().length() > 0) { versionFrom = new ChangesetVersionSpec(Integer.parseInt(myFromChangesetField.getText())); } if (myToChangesetField.getText() != null && myToChangesetField.getText().length() > 0) { versionTo = new ChangesetVersionSpec(Integer.parseInt(myToChangesetField.getText())); } } else if (myCreatedDateRadioButton.isSelected()) { if (myFromDateField.getText() != null && myFromDateField.getText().length() > 0) { versionFrom = new DateVersionSpec( SimpleDateFormat.getInstance().parse(myFromDateField.getText())); } if (myToDateField.getText() != null && myToDateField.getText().length() > 0) { versionTo = new DateVersionSpec(SimpleDateFormat.getInstance().parse(myToDateField.getText())); } } List<Changeset> changesets = myWorkspace.getServer().getVCS().queryHistory(myWorkspace, myServerPath, myRecursive, myUserField.getText(), versionFrom, versionTo, getContentPane(), TFSBundle.message("loading.history"), Integer.MAX_VALUE); if (changesets.isEmpty()) { Messages.showInfoMessage(panel, "No matching changesets found", "Find Changeset"); } myChangesetsTableModel.setChangesets(changesets); } catch (TfsException ex) { myChangesetsTableModel.setChangesets(Collections.<Changeset>emptyList()); Messages.showErrorDialog(panel, ex.getMessage(), "Find Changeset"); } catch (NumberFormatException ex) { myChangesetsTableModel.setChangesets(Collections.<Changeset>emptyList()); Messages.showErrorDialog(panel, "Invalid changeset number specified", "Find Changeset"); } catch (ParseException e1) { myChangesetsTableModel.setChangesets(Collections.<Changeset>emptyList()); Messages.showErrorDialog(panel, "Invalid date specified", "Find Changeset"); } }
From source file:org.moe.designer.rendering.HtmlLinkManager.java
License:Apache License
private static void handleDisableSandboxUrl(@NotNull Module module, @Nullable RenderResult result) { RenderSecurityManager.sEnabled = false; if (result != null) { RenderService renderService = result.getRenderService(); if (renderService != null) { RenderContext renderContext = renderService.getRenderContext(); if (renderContext != null) { renderContext.requestRender(); }/*w w w.ja v a2 s.co m*/ } } Messages.showInfoMessage(module.getProject(), "The custom view rendering sandbox was disabled for this session.\n\n" + "You can turn it off permanently by adding\n" + RenderSecurityManager.ENABLED_PROPERTY + "=" + VALUE_FALSE + "\n" + "to {install}/bin/idea.properties.", "Disabled Rendering Sandbox"); }
From source file:org.napile.idea.thermit.config.explorer.SaveMetaTargetDialog.java
License:Apache License
protected void doOKAction() { final ExecuteCompositeTargetEvent eventObject = createEventObject(); if (myAntConfiguration.getTargetForEvent(eventObject) == null) { myAntConfiguration.setTargetForEvent(myBuildFile, eventObject.getMetaTargetName(), eventObject); super.doOKAction(); } else {//ww w . j a va2 s .c om Messages.showInfoMessage(getContentPane(), ThermitBundle.message("save.meta.data.such.sequence.of.targets.already.exists.error.message"), getTitle()); } }
From source file:org.sonarlint.intellij.config.global.SonarQubeServerEditor.java
License:Open Source License
private void generateToken() { CreateTokenDialog dialog = new CreateTokenDialog(urlText.getText()); if (!dialog.showAndGet()) { return;//from w w w . j av a2s . c o m } String login = dialog.getLogin(); char[] password = dialog.getPassword(); CreateTokenTask createTokenTask = new CreateTokenTask(urlText.getText(), nameText.getText(), login, new String(password)); ProgressManager.getInstance().run(createTokenTask); Exception ex = createTokenTask.getException(); String token = createTokenTask.getToken(); String title = "Create authentication token"; if (ex != null) { if (ex instanceof UnsupportedServerException) { Messages.showErrorDialog(rootPanel, "Failed to create token. Tokens are not supported in the SonarQube server. " + ex.getMessage(), title); } else if (ex.getMessage() != null) { Messages.showErrorDialog(rootPanel, "Failed to create token: " + ex.getMessage(), title); } else { Messages.showErrorDialog(rootPanel, "Failed to create token", title); LOGGER.info(ex); } } else { tokenText.setText(token); Messages.showInfoMessage(rootPanel, "Token created successfully", title); } }
From source file:org.zmlx.hg4idea.ui.HgConfigurationProjectPanel.java
License:Apache License
public HgConfigurationProjectPanel(@NotNull HgProjectSettings projectSettings, @NotNull Project project) { myProjectSettings = projectSettings; myVcs = HgVcs.getInstance(project);/* w w w. j a va 2s. c om*/ loadSettings(); myTestButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String executable = getCurrentPath(); HgVersion version; try { version = HgVersion.identifyVersion(executable); } catch (Exception exception) { Messages.showErrorDialog(myMainPanel, exception.getMessage(), HgVcsMessages.message("hg4idea.run.failed.title")); return; } Messages.showInfoMessage(myMainPanel, String.format("Mercurial version is %s", version.toString()), HgVcsMessages.message("hg4idea.run.success.title")); } }); if (!project.isDefault()) { final HgRepositoryManager repositoryManager = ServiceManager.getService(project, HgRepositoryManager.class); mySyncControl.setVisible(repositoryManager != null && repositoryManager.moreThanOneRoot()); } else { mySyncControl.setVisible(true); } mySyncControl.setToolTipText(DvcsBundle.message("sync.setting.description", "Mercurial")); }