List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:de.mprengemann.intellij.plugin.androidicons.util.RefactorHelper.java
License:Apache License
public static boolean checkFileExist(@Nullable PsiDirectory targetDirectory, int[] choice, PsiFile file, String name, String title) { if (targetDirectory == null) { return false; }//from ww w . jav a2 s. co m final PsiFile existing = targetDirectory.findFile(name); if (existing != null && !existing.equals(file)) { int selection; if (choice == null || choice[0] == -1) { String message = String.format("File '%s' already exists in directory '%s'", name, targetDirectory.getVirtualFile().getPath()); String[] options = choice == null ? new String[] { "Overwrite", "Skip" } : new String[] { "Overwrite", "Skip", "Overwrite for all", "Skip for all" }; selection = Messages.showDialog(message, title, options, 0, Messages.getQuestionIcon()); if (selection == 2 || selection == 3) { RefactorHelper.selection = selection; } } else { selection = choice[0]; } if (choice != null && selection > 1) { choice[0] = selection % 2; selection = choice[0]; } if (selection == 0 && file != existing) { existing.delete(); } else { return true; } } return false; }
From source file:generate.tostring.view.MethodExistsDialog.java
License:Apache License
/** * Shows this dialog.//from w w w . j a v a 2 s . co m * <p/> * The user now has the choices to either: * <ul> * <li/>Replace existing method * <li/>Create a duplicate method * <li/>Cancel * </ul> * * @param targetMethodName the name of the target method (toString) * @return the chosen conflict resolution policy (never null) */ public static ConflictResolutionPolicy showDialog(String targetMethodName) { int exit = Messages.showYesNoCancelDialog("Replace existing " + targetMethodName + " method", "Method Already Exists", Messages.getQuestionIcon()); if (exit == JOptionPane.CLOSED_OPTION || exit == JOptionPane.CANCEL_OPTION) { return CancelPolicy.getInstance(); } else if (exit == JOptionPane.YES_OPTION) { return ReplacePolicy.getInstance(); } else if (exit == JOptionPane.NO_OPTION) { return DuplicatePolicy.getInstance(); } throw new IllegalArgumentException("exit code [" + exit + "] from YesNoCancelDialog not supported"); }
From source file:git4idea.actions.GitCheckout.java
License:Apache License
@Override protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();/*from ww w . j a va 2 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); branches = command.branchList(); String[] branchesList = new String[branches.size()]; String selectedBranch = null; int i = 0; for (GitBranch b : branches) { branchesList[i++] = b.getName(); if (selectedBranch == null || b.isActive()) selectedBranch = b.getName(); } String branchName = Messages.showEditableChooseDialog("Select branch to checkout", "Checkout Branch", Messages.getQuestionIcon(), branchesList, selectedBranch, new GitBranchNameValidator()); if (branchName == null) return; selectedBranch = null; for (GitBranch b : branches) { if (branchName.equals(b.getName())) { selectedBranch = branchName; } } String[] args = new String[1]; if (selectedBranch != null) { args[0] = selectedBranch; } else { args[0] = branchName; } GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.CHECKOUT_CMD); cmdr.setArgs(args); 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, "Checkout " + args[0], false, project); VcsException ex = cmdr.getException(); if (ex != null) Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git checkout'"); } }
From source file:git4idea.actions.GitClone.java
License:Apache License
@Override public void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();//from ww w. jav a 2 s . c om // TODO: implement remote repository login/password - setup remote repos in Git config, // TODO: then just reference repo name here final String src_repo = Messages.showInputDialog(project, "Specify source repository URL", "clone", Messages.getQuestionIcon()); if (src_repo == null) return; FileChooserDescriptor fcd = new FileChooserDescriptor(false, true, false, false, false, false); fcd.setShowFileSystemRoots(true); fcd.setTitle("Destination Directory"); fcd.setDescription("Select destination directory for clone."); fcd.setHideIgnored(false); VirtualFile[] files = FileChooser.chooseFiles(project, fcd, null); if (files.length != 1 || files[0] == null) { return; } final Map<VirtualFile, List<VirtualFile>> roots = GitUtil.sortFilesByVcsRoot(project, affectedFiles); for (VirtualFile root : roots.keySet()) { GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.CLONE_CMD); cmdr.setArgs(new String[] { src_repo, files[0].getPath() }); 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, "Cloning source repo " + src_repo, false, project); VcsException ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git clone'"); break; } } VcsDirtyScopeManager mgr = VcsDirtyScopeManager.getInstance(project); for (VirtualFile file : affectedFiles) { mgr.fileDirty(file); file.refresh(true, true); } }
From source file:git4idea.actions.GitFetch.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 . j a v a 2 s. co 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 fetch (empty for default):", "Fetch 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; } } }
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();//from ww w .ja v a2 s .co m 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 ww w .j ava 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.GitStash.java
License:Apache License
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();// www. ja v a 2 s .c om if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(GitVcs.getInstance(project), affectedFiles)) return; final Map<VirtualFile, List<VirtualFile>> roots = GitUtil.sortFilesByVcsRoot(project, affectedFiles); String stashName = Messages.showInputDialog(project, "Enter new stash name/description: ", "Stash", Messages.getQuestionIcon(), "", null); if (stashName == null || stashName.length() == 0) return; for (VirtualFile root : roots.keySet()) { GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.STASH_CMD); cmdr.setArgs(new String[] { "save", 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, "Stashing changes... ", false, project); VcsException ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git stash'"); break; } } }
From source file:git4idea.actions.GitTag.java
License:Apache License
@Override public void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();//from w w w . j a v a2 s .c om if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, affectedFiles)) { Messages.showErrorDialog(project, "ERROR: Files not tagged, not all are under VCS root!", "Tag Result"); return; } final String tagName = Messages.showInputDialog(project, "Specify tag name: ", "Tag", Messages.getQuestionIcon()); if (tagName == null || tagName.length() == 0) return; final Map<VirtualFile, List<VirtualFile>> roots = GitUtil.sortFilesByVcsRoot(project, affectedFiles); for (VirtualFile root : roots.keySet()) { GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root); cmdr.setCommand(GitCommand.TAG_CMD); cmdr.setArgs(new String[] { tagName }); 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, "Tagging files... ", false, project); VcsException ex = cmdr.getException(); if (ex != null) { Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git tag'"); break; } } }
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();// ww w. ja v a 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; } } }