List of usage examples for com.intellij.openapi.ui Messages getWarningIcon
@NotNull public static Icon getWarningIcon()
From source file:org.jetbrains.idea.svn.dialogs.ChangeFormatDialog.java
License:Apache License
@Nullable @Override//from w w w . ja v a2s . c o m protected JPanel getBottomAuxiliaryPanel() { if (!myWcRootIsAbove) { return null; } final JPanel result = new JPanel(new GridBagLayout()); GridBagConstraints gb = new GridBagConstraints(); gb.insets = new Insets(2, 2, 2, 2); gb.weightx = 1; gb.weighty = 0; gb.gridwidth = 2; gb.gridheight = 1; gb.gridx = 0; gb.gridy = 0; gb.anchor = GridBagConstraints.WEST; gb.fill = GridBagConstraints.HORIZONTAL; final JLabel iconLabel = new JLabel(Messages.getWarningIcon()); result.add(iconLabel, gb); ++gb.gridx; JLabel warningLabel = new JLabel(SvnBundle.message("label.working.copy.root.outside.text")); warningLabel.setFont(warningLabel.getFont().deriveFont(Font.BOLD)); warningLabel.setUI(new MultiLineLabelUI()); result.add(warningLabel); return result; }
From source file:org.jetbrains.idea.svn.dialogs.CopiesPanel.java
License:Apache License
private void updateList(@NotNull final List<WCInfo> infoList, @NotNull final List<WorkingCopyFormat> supportedFormats) { myPanel.removeAll();/*from ww w . j ava2 s . c o m*/ final Insets nullIndent = new Insets(1, 3, 1, 0); final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 0, 0), 0, 0); gb.insets.left = 4; myPanel.add(myRefreshLabel, gb); gb.insets.left = 1; final LocalFileSystem lfs = LocalFileSystem.getInstance(); final Insets topIndent = new Insets(10, 3, 0, 0); for (final WCInfo wcInfo : infoList) { final Collection<WorkingCopyFormat> upgradeFormats = getUpgradeFormats(wcInfo, supportedFormats); final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath())); final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf; final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, ""); editorPane.setEditable(false); editorPane.setFocusable(true); editorPane.setBackground(UIUtil.getPanelBackground()); editorPane.setOpaque(false); editorPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (CONFIGURE_BRANCHES.equals(e.getDescription())) { if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches")) return; BranchConfigurationDialog.configureBranches(myProject, root, true); } else if (FIX_DEPTH.equals(e.getDescription())) { final int result = Messages.showOkCancelDialog(myVcs.getProject(), "You are going to checkout into '" + wcInfo.getPath() + "' with 'infinity' depth.\n" + "This will update your working copy to HEAD revision as well.", "Set Working Copy Infinity Depth", Messages.getWarningIcon()); if (result == Messages.OK) { // update of view will be triggered by roots changed event SvnCheckoutProvider.checkout(myVcs.getProject(), new File(wcInfo.getPath()), wcInfo.getRootUrl(), SVNRevision.HEAD, SVNDepth.INFINITY, false, null, wcInfo.getFormat()); } } else if (CHANGE_FORMAT.equals(e.getDescription())) { changeFormat(wcInfo, upgradeFormats); } else if (MERGE_FROM.equals(e.getDescription())) { if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From")) return; mergeFrom(wcInfo, root, editorPane); } else if (CLEANUP.equals(e.getDescription())) { if (!checkRoot(root, wcInfo.getPath(), " invoke Cleanup")) return; new CleanupWorker(new VirtualFile[] { root }, myVcs.getProject(), "action.Subversion.cleanup.progress.title").execute(); } } } private boolean checkRoot(VirtualFile root, final String path, final String actionName) { if (root == null) { Messages.showWarningDialog(myProject, "Invalid working copy root: " + path, "Can not " + actionName); return false; } return true; } }); editorPane.setBorder(null); editorPane.setText(formatWc(wcInfo, upgradeFormats)); final JPanel copyPanel = new JPanel(new GridBagLayout()); final GridBagConstraints gb1 = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, nullIndent, 0, 0); gb1.insets.top = 1; gb1.gridwidth = 3; gb.insets = topIndent; gb.fill = GridBagConstraints.HORIZONTAL; ++gb.gridy; final JPanel contForCopy = new JPanel(new BorderLayout()); contForCopy.add(copyPanel, BorderLayout.WEST); myPanel.add(contForCopy, gb); copyPanel.add(editorPane, gb1); gb1.insets = nullIndent; } myPanel.revalidate(); myPanel.repaint(); }
From source file:org.jetbrains.idea.svn.SvnAuthenticationNotifier.java
License:Apache License
public static void clearAuthenticationCache(@NotNull final Project project, final Component component, final String configDirPath) { if (configDirPath != null) { int result; if (component == null) { result = Messages.showYesNoDialog(project, SvnBundle.message("confirmation.text.delete.stored.authentication.information"), SvnBundle.message("confirmation.title.clear.authentication.cache"), Messages.getWarningIcon()); } else {/*from w w w.j av a 2s .co m*/ result = Messages.showYesNoDialog(component, SvnBundle.message("confirmation.text.delete.stored.authentication.information"), SvnBundle.message("confirmation.title.clear.authentication.cache"), Messages.getWarningIcon()); } if (result == Messages.YES) { SvnConfiguration.RUNTIME_AUTH_CACHE.clear(); clearAuthenticationDirectory(SvnConfiguration.getInstance(project)); } } }
From source file:org.jetbrains.idea.svn.update.SvnUpdateEnvironment.java
License:Apache License
private boolean checkAncestry(final File sourceFile, final SVNURL targetUrl, final SVNRevision targetRevision) throws SVNException { final SVNInfo sourceSvnInfo = myVcs.getInfo(sourceFile); final SVNInfo targetSvnInfo = myVcs.getInfo(targetUrl, targetRevision); if (sourceSvnInfo == null || targetSvnInfo == null) { // cannot check return true; }/*from w w w .j a va 2 s. c om*/ final SVNURL copyFromTarget = targetSvnInfo.getCopyFromURL(); final SVNURL copyFromSource = sourceSvnInfo.getCopyFromURL(); if ((copyFromSource != null) || (copyFromTarget != null)) { if (sourceSvnInfo.getURL().equals(copyFromTarget) || targetUrl.equals(copyFromSource)) { return true; } } final int result = Messages.showYesNoDialog(myVcs.getProject(), SvnBundle.message("switch.target.not.copy.current"), SvnBundle.message("switch.target.problem.title"), Messages.getWarningIcon()); return (Messages.YES == result); }
From source file:org.jetbrains.jet.plugin.framework.FrameworksCompatibilityUtils.java
License:Apache License
private static void removeWithConfirm(ModifiableRootModel rootModel, List<OrderEntry> orderEntries, String message, String title) { if (!orderEntries.isEmpty()) { int result = Messages.showYesNoDialog(message, title, Messages.getWarningIcon()); if (result == 0) { for (OrderEntry entry : orderEntries) { rootModel.removeOrderEntry(entry); }// w w w. j ava2 s . c o m } } }
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); }/* w ww . ja va 2 s .c om*/ 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; }
From source file:org.jetbrains.plugins.groovy.doc.GenerateGroovyDocDialog.java
License:Apache License
private boolean checkDir(String dirName, String dirPrefix) { if (dirName == null || dirName.trim().length() == 0) { Messages.showMessageDialog(myProject, GroovyDocBundle.message("groovydoc.generate.0.directory.not.specified", dirPrefix), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return false; }/*from w w w . j a va 2 s . co m*/ File dir = new File(dirName); if (dir.exists()) { if (!dir.isDirectory()) { showError(GroovyDocBundle.message("groovydoc.generate.not.a.directory", dirName)); return false; } } else { int choice = Messages.showOkCancelDialog(myProject, GroovyDocBundle.message("groovydoc.generate.directory.not.exists", dirName), GroovyDocBundle.message("groovydoc.generate.message.title"), Messages.getWarningIcon()); if (choice != 0) return false; if (!dir.mkdirs()) { showError(GroovyDocBundle.message("groovydoc.generate.directory.creation.failed", dirName)); return false; } } return true; }
From source file:org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantProcessor.java
License:Apache License
protected boolean checkErrors(@NotNull PsiClass targetClass) { String fieldName = settings.getName(); String errorString = check(targetClass, fieldName); if (errorString != null) { String message = RefactoringBundle.getCannotRefactorMessage(errorString); CommonRefactoringUtil.showErrorMessage(GrIntroduceConstantHandler.REFACTORING_NAME, message, HelpID.INTRODUCE_CONSTANT, context.getProject()); return true; }/* w w w . j ava 2 s . com*/ PsiField oldField = targetClass.findFieldByName(fieldName, true); if (oldField != null) { String message = RefactoringBundle.message("field.exists", fieldName, oldField.getContainingClass().getQualifiedName()); int answer = Messages.showYesNoDialog(context.getProject(), message, GrIntroduceConstantHandler.REFACTORING_NAME, Messages.getWarningIcon()); if (answer != 0) { return true; } } return false; }
From source file:org.jetbrains.plugins.ruby.ruby.module.wizard.ui.RubySdkSelectStep.java
License:Apache License
@Override public boolean validate() { Sdk jdk = myPanel.getChosenJdk();/*w ww. ja va 2 s. c o m*/ if (jdk == null) { int result = Messages.showYesNoDialog( RBundle.message("sdk.error.no.sdk.prompt.messge.confirm.without.sdk"), RBundle.message("sdk.select.prompt.title"), Messages.getWarningIcon()); return result == DialogWrapper.OK_EXIT_CODE; } if (!RubySdkUtil.isKindOfRubySDK(jdk)) { Messages.showErrorDialog(RBundle.message("sdk.error.prompt.message.sdk.not.valid"), RBundle.message("sdk.select.prompt.title")); return false; } /* try to set selected SDK as Project default SDK final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject); if (!jdk.equals(projectRootManager.getSdk())) { int result = Messages.showYesNoDialog( RBundle.message("prompt.confirm.default.sdk.change"), RBundle.message("title.default.sdk.change"), Messages.getQuestionIcon() ); if (result == 1) { projectRootManager.setSdk(jdk); } }*/ return true; }
From source file:org.jetbrains.tfsIntegration.ui.ManageWorkspacesForm.java
License:Apache License
private void removeServer(final @NotNull ServerInfo server) { String warning = TFSBundle.message("remove.server.prompt", server.getPresentableUri()); if (Messages.showYesNoDialog(myContentPane, warning, TFSBundle.message("remove.server.title"), Messages.getWarningIcon()) == Messages.YES) { Workstation.getInstance().removeServer(server); updateControls(null);// w ww.ja v a2s . c o m } }