List of usage examples for com.intellij.openapi.ui Messages showErrorDialog
public static void showErrorDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:org.jetbrains.idea.svn.checkout.SvnCheckoutProvider.java
License:Apache License
public static void doExport(final Project project, final File target, final SVNURL url, final SVNDepth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) { try {//from w ww . j av a 2s . c om final VcsException[] exception = new VcsException[1]; final SvnVcs vcs = SvnVcs.getInstance(project); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); ISVNEventHandler handler = new CheckoutEventHandler(vcs, true, progressIndicator); try { progressIndicator .setText(SvnBundle.message("progress.text.export", target.getAbsolutePath())); SvnTarget from = SvnTarget.fromURL(url); ExportClient client = vcs.getFactoryFromSettings().createExportClient(); client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler); } catch (VcsException e) { exception[0] = e; } } }, SvnBundle.message("message.title.export"), true, project); if (exception[0] != null) { throw exception[0]; } } catch (VcsException e1) { Messages.showErrorDialog(SvnBundle.message("message.text.cannot.export", e1.getMessage()), SvnBundle.message("message.title.export")); } }
From source file:org.jetbrains.idea.svn.checkout.SvnCheckoutProvider.java
License:Apache License
public static void doImport(final Project project, final File target, final SVNURL url, final SVNDepth depth, final boolean includeIgnored, final String message) { final Ref<String> errorMessage = new Ref<String>(); final SvnVcs vcs = SvnVcs.getInstance(project); final String targetPath = FileUtil.toSystemIndependentName(target.getAbsolutePath()); ExclusiveBackgroundVcsAction.run(project, new Runnable() { @Override// ww w . ja v a 2 s. co m public void run() { ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { final FileIndexFacade facade = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class); ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); try { progressIndicator .setText(SvnBundle.message("progress.text.import", target.getAbsolutePath())); final VirtualFile targetVf = SvnUtil.getVirtualFile(targetPath); if (targetVf == null) { errorMessage.set("Can not find file: " + targetPath); } else { final boolean isInContent = ApplicationManager.getApplication() .runReadAction(new Computable<Boolean>() { @Override public Boolean compute() { return facade.isInContent(targetVf); } }); CommitEventHandler handler = new IdeaCommitHandler(progressIndicator); boolean useFileFilter = !project.isDefault() && isInContent; ISVNCommitHandler commitHandler = useFileFilter ? new MyFilter(LocalFileSystem.getInstance(), new SvnExcludingIgnoredOperation.Filter(project)) : null; long revision = vcs.getFactoryFromSettings().createImportClient().doImport(target, url, depth, message, includeIgnored, handler, commitHandler); if (revision > 0) { StatusBar.Info.set(SvnBundle.message("status.text.comitted.revision", revision), project); } } } catch (VcsException e) { errorMessage.set(e.getMessage()); } } }, SvnBundle.message("message.title.import"), true, project); } }); if (!errorMessage.isNull()) { Messages.showErrorDialog(SvnBundle.message("message.text.cannot.import", errorMessage.get()), SvnBundle.message("message.title.import")); } }
From source file:org.jetbrains.idea.svn.dialogs.RepositoryBrowserDialog.java
License:Apache License
protected static void doMkdir(final SVNURL url, final String comment, final Project project) { final SVNException[] exception = new SVNException[1]; Runnable command = new Runnable() { public void run() { ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); if (progress != null) { progress.setText(SvnBundle.message("progress.text.browser.creating", url.toString())); }/* ww w . j av a2 s .co m*/ SvnVcs vcs = SvnVcs.getInstance(project); try { SVNCommitClient committer = vcs.createCommitClient(); committer.doMkDir(new SVNURL[] { url }, comment); } catch (SVNException e) { exception[0] = e; } } }; ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.text.create.remote.folder"), false, project); if (exception[0] != null) { Messages.showErrorDialog(exception[0].getMessage(), SvnBundle.message("message.text.error")); } }
From source file:org.jetbrains.idea.svn.dialogs.RepositoryBrowserDialog.java
License:Apache License
private void doCopy(final SVNURL src, final SVNURL dst, final boolean move, final String comment) { final SVNException[] exception = new SVNException[1]; Runnable command = new Runnable() { public void run() { ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); if (progress != null) { progress.setText((move ? SvnBundle.message("progress.text.browser.moving", src) : SvnBundle.message("progress.text.browser.copying", src))); progress.setText2(SvnBundle.message("progress.text.browser.remote.destination", dst)); }/*w w w. j a v a 2 s. c o m*/ SvnVcs vcs = SvnVcs.getInstance(myProject); try { SVNCopyClient committer = vcs.createCopyClient(); final SVNCopySource[] copySource = new SVNCopySource[] { new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, src) }; committer.doCopy(copySource, dst, move, true, true, comment, null); } catch (SVNException e) { exception[0] = e; } } }; String progressTitle = move ? SvnBundle.message("progress.title.browser.move") : SvnBundle.message("progress.title.browser.copy"); ProgressManager.getInstance().runProcessWithProgressSynchronously(command, progressTitle, false, myProject); if (exception[0] != null) { Messages.showErrorDialog(exception[0].getMessage(), SvnBundle.message("message.text.error")); } }
From source file:org.jetbrains.idea.svn.dialogs.RepositoryBrowserDialog.java
License:Apache License
protected void doCheckout(@Nullable final CheckoutProvider.Listener listener, final RepositoryTreeNode selectedNode) { if (selectedNode == null) { return;/*ww w .j a va 2s . c o m*/ } SVNURL url = selectedNode.getURL(); String relativePath = ""; final SVNDirEntry dirEntry = selectedNode.getSVNDirEntry(); if (dirEntry != null) { if (dirEntry.getRepositoryRoot() != null) { if (!dirEntry.getRepositoryRoot().equals(url)) { relativePath = SVNPathUtil.getRelativePath(dirEntry.getRepositoryRoot().toString(), url.toDecodedString()); } } else { relativePath = dirEntry.getRelativePath(); } } else { relativePath = url.getPath(); } File dir = selectFile(SvnBundle.message("svn.checkout.destination.directory.title"), SvnBundle.message("svn.checkout.destination.directory.description")); if (dir == null) { return; } Project p = myProject; CheckoutOptionsDialog dialog = new CheckoutOptionsDialog(p, url, dir, SvnUtil.getVirtualFile(dir.getAbsolutePath()), relativePath); dialog.show(); dir = dialog.getTarget(); if (dialog.isOK() && dir != null) { final SVNRevision revision; try { revision = dialog.getRevision(); } catch (ConfigurationException e) { Messages.showErrorDialog(SvnBundle.message("message.text.cannot.checkout", e.getMessage()), SvnBundle.message("message.title.check.out")); return; } SvnCheckoutProvider.doCheckout(myProject, dir, url.toString(), revision, dialog.getDepth(), dialog.isIgnoreExternals(), listener); } }
From source file:org.jetbrains.idea.svn.integrate.IntegratedSelectedOptionsDialog.java
License:Apache License
@Nullable public static Pair<WorkingCopyInfo, SVNURL> selectWorkingCopy(final Project project, final SVNURL currentBranch, final String targetBranch, final boolean showIntegrationParameters, final String selectedLocalBranchPath, final String dialogTitle) { final IntegratedSelectedOptionsDialog dialog = new IntegratedSelectedOptionsDialog(project, currentBranch, targetBranch);// w ww. ja v a 2 s . c o m if (!showIntegrationParameters) { dialog.selectWcopyRootOnly(); } if (selectedLocalBranchPath != null) { dialog.setSelectedWcPath(selectedLocalBranchPath); } if (dialogTitle != null) { dialog.setTitle(dialogTitle); } dialog.show(); if (dialog.isOK()) { ApplicationManager.getApplication().saveAll(); dialog.saveOptions(); final WorkingCopyInfo info = dialog.getSelectedWc(); if (info != null) { final File file = new File(info.getLocalPath()); if ((!file.exists()) || (!file.isDirectory())) { Messages.showErrorDialog( SvnBundle.message("action.Subversion.integrate.changes.error.target.not.dir.text"), SvnBundle.message("action.Subversion.integrate.changes.messages.title")); return null; } final SVNURL targetUrl = realTargetUrl(SvnVcs.getInstance(project), info, targetBranch); if (targetUrl == null) { Messages.showErrorDialog( SvnBundle.message("action.Subversion.integrate.changes.error.not.versioned.text"), SvnBundle.message("action.Subversion.integrate.changes.messages.title")); return null; } return new Pair<WorkingCopyInfo, SVNURL>(info, targetUrl); } } return null; }
From source file:org.jetbrains.idea.svn.integrate.SvnIntegrateChangesActionPerformer.java
License:Apache License
public void onBranchSelected(final String url, final String selectedLocalBranchPath, final String dialogTitle) { if (myCurrentBranch.toString().equals(url)) { Messages.showErrorDialog( SvnBundle.message("action.Subversion.integrate.changes.error.source.and.target.same.text"), SvnBundle.message("action.Subversion.integrate.changes.messages.title")); return;//from www .j a v a 2 s . c om } // from name final String name = SVNPathUtil.tail(myCurrentBranch.toString()); final Pair<WorkingCopyInfo, SVNURL> pair = IntegratedSelectedOptionsDialog.selectWorkingCopy( myVcs.getProject(), myCurrentBranch, url, true, selectedLocalBranchPath, dialogTitle); if (pair == null) { return; } final WorkingCopyInfo info = pair.first; final SVNURL realTargetUrl = pair.second; final SVNURL sourceUrl = correctSourceUrl(url, realTargetUrl.toString()); if (sourceUrl == null) { // should not occur return; } final SvnIntegrateChangesTask task = new SvnIntegrateChangesTask(myVcs, info, myMergerFactory, sourceUrl, SvnBundle.message("action.Subversion.integrate.changes.messages.title"), SvnConfiguration.getInstance(myVcs.getProject()).isMergeDryRun(), name); ProgressManager.getInstance().run(task); }
From source file:org.jetbrains.idea.svn.integrate.SvnIntegrateChangesTask.java
License:Apache License
private void showAlienCommit() { final AlienDirtyScope dirtyScope = new AlienDirtyScope(); if (myMergeTarget != null) { dirtyScope.addDir(myMergeTarget); } else {//from w w w. ja v a 2 s . c o m UpdateFilesHelper.iterateFileGroupFiles(myAccomulatedFiles.getUpdatedFiles(), new UpdateFilesHelper.Callback() { public void onFile(final String filePath, final String groupId) { final FilePath file = FilePathImpl.create(new File(filePath)); dirtyScope.addFile(file); } }); } final SvnChangeProvider provider = new SvnChangeProvider(myVcs); final GatheringChangelistBuilder clb = new GatheringChangelistBuilder(myVcs, myAccomulatedFiles); try { provider.getChanges(dirtyScope, clb, ProgressManager.getInstance().getProgressIndicator(), null); } catch (VcsException e) { Messages.showErrorDialog( SvnBundle.message("action.Subversion.integrate.changes.error.unable.to.collect.changes.text", e.getMessage()), myTitle); return; } if (!clb.getChanges().isEmpty()) { CommitChangeListDialog.commitAlienChanges(myProject, clb.getChanges(), myVcs, myMerger.getComment(), myMerger.getComment()); } }
From source file:org.jetbrains.idea.svn.update.SvnSelectRevisionUtil.java
License:Apache License
@Nullable public static SvnChangeList chooseCommittedChangeList(final Project project, final SvnRepositoryLocation location, final VirtualFile root) { try {// w ww . j a v a2 s .c om final SvnCommittedChangesTableModel model = new SvnCommittedChangesTableModel(location, project, root, SvnVcs.getInstance(project).getCommittedChangesProvider().getColumns()); final ChangesBrowserDialog dlg = new ChangesBrowserDialog(project, model, ChangesBrowserDialog.Mode.Choose, null); dlg.show(); if (dlg.isOK()) { return (SvnChangeList) dlg.getSelectedChangeList(); } model.onBeforeClose(); } catch (VcsException e) { Messages.showErrorDialog(e.getMessage(), SvnBundle.message("error.cannot.load.revisions")); } return null; }
From source file:org.jetbrains.jet.plugin.framework.ui.FileUIUtils.java
License:Apache License
@Nullable public static Map<File, File> copyWithOverwriteDialog(@NotNull String messagesTitle, @NotNull Map<File, String> filesWithDestinations) { Set<String> fileNames = new HashSet<String>(); Map<File, File> targetFiles = new LinkedHashMap<File, File>(filesWithDestinations.size()); for (Map.Entry<File, String> sourceToDestination : filesWithDestinations.entrySet()) { File file = sourceToDestination.getKey(); String destinationPath = sourceToDestination.getValue(); String fileName = file.getName(); if (!fileNames.add(fileName)) { throw new IllegalArgumentException("There are several files with the same name: " + fileName); }/*from www . j a v a 2 s .c o m*/ targetFiles.put(file, new File(destinationPath, fileName)); } Collection<Map.Entry<File, File>> existentFiles = Collections2.filter(targetFiles.entrySet(), new Predicate<Map.Entry<File, File>>() { @Override public boolean apply(@Nullable Map.Entry<File, File> sourceToTarget) { assert sourceToTarget != null; return sourceToTarget.getValue().exists(); } }); if (!existentFiles.isEmpty()) { String message; if (existentFiles.size() == 1) { File conflictingFile = existentFiles.iterator().next().getValue(); message = String.format("File \"%s\" already exists in %s.\nDo you want to overwrite it?", conflictingFile.getName(), conflictingFile.getParentFile().getAbsolutePath()); } else { Collection<File> conflictFiles = Collections2.transform(existentFiles, new Function<Map.Entry<File, File>, File>() { @Override public File apply(@Nullable Map.Entry<File, File> pair) { assert pair != null; return pair.getValue(); } }); message = String.format("Files already exist:\n%s\nDo you want to overwrite them?", StringUtil.join(conflictFiles, "\n")); } int replaceIfExist = Messages.showYesNoDialog(null, message, messagesTitle + ". Replace File", "Overwrite", "Cancel", Messages.getWarningIcon()); if (replaceIfExist != JOptionPane.YES_OPTION) { return null; } } for (Map.Entry<File, File> sourceToTarget : targetFiles.entrySet()) { try { String destinationPath = sourceToTarget.getValue().getParentFile().getAbsolutePath(); if (!ProjectWizardUtil.createDirectoryIfNotExists("Destination folder", destinationPath, false)) { Messages.showErrorDialog(String.format("Error during folder creating '%s'", destinationPath), messagesTitle + ". Error"); return null; } FileUtil.copy(sourceToTarget.getKey(), sourceToTarget.getValue()); LocalFileSystem.getInstance().refreshAndFindFileByIoFile(sourceToTarget.getValue()); } catch (IOException e) { Messages.showErrorDialog("Error with copy file " + sourceToTarget.getKey().getName(), messagesTitle + ". Error"); return null; } } return targetFiles; }