List of usage examples for com.intellij.openapi.ui Messages showChooseDialog
@Deprecated public static int showChooseDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, String[] values, String initialValue, @Nullable Icon icon)
From source file:git4idea.actions.GitMerge.java
License:Apache License
@Override protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();/*w ww. ja v a2 s . c om*/ final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs); List<GitBranch> branches; for (VirtualFile root : roots) { GitCommand command = new GitCommand(project, vcs.getSettings(), root); String currBranch = command.currentBranch(); branches = command.branchList(); String[] branchesList = new String[branches.size()]; GitBranch selectedBranch = null; int i = 0; for (GitBranch b : branches) { branchesList[i++] = b.getName(); if (!b.isActive() && selectedBranch == null) selectedBranch = b; } if (selectedBranch == null) return; int branchNum = Messages.showChooseDialog("Select branch to merge into this one (" + currBranch + ")", "Merge Branch", branchesList, selectedBranch.getName(), Messages.getQuestionIcon()); if (branchNum < 0) return; selectedBranch = branches.get(branchNum); GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.MERGE_CMD); cmdr.setArgs(new String[] { selectedBranch.getName() }); ProgressManager manager = ProgressManager.getInstance(); //TODO: make this async so the git command output can be seen in the version control window as it happens... manager.runProcessWithProgressSynchronously(cmdr, "Merging branch " + selectedBranch.getName(), false, project); VcsException ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git merge'"); return; } } }
From source file:git4idea.actions.GitPull.java
License:Apache License
@Override protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();/*from w w w .ja v a 2 s .c o m*/ final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs); for (VirtualFile root : roots) { GitCommand command = new GitCommand(project, vcs.getSettings(), root); String initialValue = null; List<GitBranch> rbranches = command.branchList(true); if (rbranches != null && rbranches.size() > 0) { initialValue = command.remoteRepoURL(rbranches.get(0)); } String repoURL = Messages.showInputDialog(project, "Enter remote repository URL to pull/merge (empty for default):", "Pull URL", Messages.getQuestionIcon(), initialValue, null); GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.FETCH_CMD); cmdr.setArgs(new String[] { repoURL }); ProgressManager manager = ProgressManager.getInstance(); manager.runProcessWithProgressSynchronously(cmdr, "Fetching from " + repoURL, false, project); VcsException ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git fetch'"); return; } cmdr.setArgs(new String[] { "--tags", repoURL }); manager.runProcessWithProgressSynchronously(cmdr, "Updating tags from " + repoURL, false, project); ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git fetch --tags'"); return; } List<GitBranch> branches = command.branchList(); String[] branchesList = new String[branches.size()]; GitBranch selectedBranch = null; int i = 0; for (GitBranch b : branches) { if (!b.isActive() && selectedBranch == null) selectedBranch = b; branchesList[i++] = b.getName(); } if (selectedBranch == null) selectedBranch = branches.get(0); int branchNum = Messages.showChooseDialog( "Select branch to merge into this one(" + command.currentBranch() + ")", "Merge Branch", branchesList, selectedBranch.getName(), Messages.getQuestionIcon()); if (branchNum < 0) { return; } selectedBranch = branches.get(branchNum); cmdr.setCommand(GitCommand.MERGE_CMD); cmdr.setArgs(new String[] { selectedBranch.getName() }); //TODO: make this async so the git command output can be seen in the version control window as it happens... manager.runProcessWithProgressSynchronously(cmdr, "Merging branch " + selectedBranch.getName(), false, project); ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git merge'"); } } }
From source file:git4idea.actions.GitUnstash.java
License:Apache License
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();//from ww w . ja va 2s. c o m if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(GitVcs.getInstance(project), affectedFiles)) return; final Map<VirtualFile, List<VirtualFile>> roots = GitUtil.sortFilesByVcsRoot(project, affectedFiles); for (VirtualFile root : roots.keySet()) { GitCommand command = new GitCommand(project, vcs.getSettings(), root); String[] stashList = command.stashList(); if (stashList == null || stashList.length == 0) continue; int stashIndex = Messages.showChooseDialog("Select stash to restore: ", "UnStash Changes", stashList, stashList[0], Messages.getQuestionIcon()); if (stashIndex < 0) continue; GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.STASH_CMD); String stashName = stashList[stashIndex].split(":")[0]; cmdr.setArgs(new String[] { "apply", stashName }); ProgressManager manager = ProgressManager.getInstance(); //TODO: make this async so the git command output can be seen in the version control window as it happens... manager.runProcessWithProgressSynchronously(cmdr, "UnStashing changes... ", false, project); VcsException ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git stash apply'"); break; } } }
From source file:org.metaborg.intellij.idea.sdks.MetaborgSdkType.java
License:Apache License
/** * {@inheritDoc}/* w w w .j a v a 2 s . c om*/ */ @Override public boolean setupSdkPaths(final Sdk metaborgSdk, final SdkModel sdkModel) { final SdkModificator sdkModificator = metaborgSdk.getSdkModificator(); boolean success = setupSdkPaths(metaborgSdk, sdkModificator, sdkModel); if (success && sdkModificator.getSdkAdditionalData() == null) { @Nullable final JavaSdkVersion minimumJdkVersion = getMinimumJdkVersion(metaborgSdk); final List<String> jdkCandidates = new ArrayList<>(); for (final Sdk sdk : sdkModel.getSdks()) { if (isAcceptableJdk(sdk, minimumJdkVersion)) { jdkCandidates.add(sdk.getName()); } } if (jdkCandidates.isEmpty()) { Messages.showErrorDialog("No JDK found" + (minimumJdkVersion != null ? " of at least version " + minimumJdkVersion.getDescription() : "") + ". Please configure one.", "JDK Not Found"); return false; } String jdkName = jdkCandidates.get(0); if (jdkCandidates.size() > 1) { @SuppressWarnings("deprecation") final int choice = Messages.showChooseDialog("Select the JDK to use with Metaborg.", "Select JDK", ArrayUtil.toStringArray(jdkCandidates), jdkName, Messages.getQuestionIcon()); if (choice == -1) { // User cancelled. success = false; } jdkName = jdkCandidates.get(choice); } @Nullable final Sdk jdk = sdkModel.findSdk(jdkName); assert jdk != null; setJdk(metaborgSdk, sdkModificator, jdk); } sdkModificator.commitChanges(); return success; }