List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:com.puppetlabs.geppetto.pp.dsl.ui.linked.ExtLinkedXtextEditor.java
License:Open Source License
@Override protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell();/*from ww w . j a v a 2 s. co m*/ final IEditorInput input = getEditorInput(); // Customize save as if the file is linked, and it is in the special external link project // if (input instanceof IFileEditorInput && ((IFileEditorInput) input).getFile().isLinked() && ((IFileEditorInput) input).getFile().getProject().getName() .equals(ExtLinkedFileHelper.AUTOLINK_PROJECT_NAME)) { final IEditorInput newInput; IDocumentProvider provider = getDocumentProvider(); // 1. If file is "untitled" suggest last save location // 2. ...otherwise use the file's location (i.e. likely to be a rename in same folder) // 3. If a "last save location" is unknown, use user's home // String suggestedName = null; String suggestedPath = null; { // is it "untitled" java.net.URI uri = ((IURIEditorInput) input).getURI(); String tmpProperty = null; try { tmpProperty = ((IFileEditorInput) input).getFile() .getPersistentProperty(TmpFileStoreEditorInput.UNTITLED_PROPERTY); } catch (CoreException e) { // ignore - tmpProperty will be null } boolean isUntitled = tmpProperty != null && "true".equals(tmpProperty); // suggested name IPath oldPath = URIUtil.toPath(uri); // TODO: input.getName() is probably always correct suggestedName = isUntitled ? input.getName() : oldPath.lastSegment(); // suggested path try { suggestedPath = isUntitled ? ((IFileEditorInput) input).getFile().getWorkspace().getRoot() .getPersistentProperty(LAST_SAVEAS_LOCATION) : oldPath.toOSString(); } catch (CoreException e) { // ignore, suggestedPath will be null } if (suggestedPath == null) { // get user.home suggestedPath = System.getProperty("user.home"); } } FileDialog dialog = new FileDialog(shell, SWT.SAVE); if (suggestedName != null) dialog.setFileName(suggestedName); if (suggestedPath != null) dialog.setFilterPath(suggestedPath); dialog.setFilterExtensions(new String[] { "*.pp", "*.*" }); String path = dialog.open(); if (path == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, "Save As", null, path + " already exists.\nDo you want to replace it?", MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException ex) { EditorsPlugin.log(ex.getStatus()); String title = "Problems During Save As..."; String msg = "Save could not be completed. " + ex.getMessage(); MessageDialog.openError(shell, title, msg); return; } IFile file = getWorkspaceFile(fileStore); if (file != null) newInput = new FileEditorInput(file); else { IURIEditorInput uriInput = new FileStoreEditorInput(fileStore); java.net.URI uri = uriInput.getURI(); IFile linkedFile = ExtLinkedFileHelper.obtainLink(uri, false); newInput = new FileEditorInput(linkedFile); } if (provider == null) { // editor has been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = "Problems During Save As..."; String msg = "Save could not be completed. " + x.getMessage(); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) setInput(newInput); // the linked file must be removed (esp. if it is an "untitled" link). ExtLinkedFileHelper.unlinkInput(((IFileEditorInput) input)); // remember last saveAs location String lastLocation = URIUtil.toPath(((FileEditorInput) newInput).getURI()).toOSString(); try { ((FileEditorInput) newInput).getFile().getWorkspace().getRoot() .setPersistentProperty(LAST_SAVEAS_LOCATION, lastLocation); } catch (CoreException e) { // ignore } } if (progressMonitor != null) progressMonitor.setCanceled(!success); return; } super.performSaveAs(progressMonitor); }
From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java
License:Open Source License
public void presentInsufficientPermissionsDialog(InsufficientPermissionsException ex) { logger.warn("Insufficient permissions encountered for user '" + ex.getConnection().getUsername() + "'"); okMessage("Insufficient Permissions", ex.getExceptionMessage(), MessageDialog.WARNING); }
From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java
License:Open Source License
public boolean presentCycleLimitExceptionDialog(ServiceTimeoutException ex, IProgressMonitor monitor) { String exceptionMessage = ForceExceptionUtils.getExceptionMessage(ex); final StringBuffer strBuff = new StringBuffer(Messages.getString("General.FetchCycleLimitReached.message")); strBuff.append(":\n\n").append(exceptionMessage).append("\n\n") .append(Messages.getString("General.FetchTimeoutRetry.message")); // must execute in separate ui thread as operation may be executed outside of a ui thread (invalid thread access) int action = (new Runnable() { int action = -1; @Override/*ww w .j av a2 s.co m*/ public void run() { action = abortContinueMessage("Fetch Cycle Limit Reached", strBuff.toString(), MessageDialog.WARNING); } public int getAction() { Display.getDefault().syncExec(this); return action; } }).getAction(); //int action = abortContinueMessage("Fetch Cycle Limit Reached", strBuff.toString(), MessageDialog.WARNING); if (action == FIRST_BUTTON) { logger.warn("Abort remote component fetching"); return false; } if (logger.isInfoEnabled()) { logger.info("Continuing remote component fetching"); } return true; }
From source file:com.salesforce.ide.core.model.ProjectPackageList.java
License:Open Source License
private boolean handleReadOnlyException(CoreException coreException, Component component) { boolean skipAllReadOnlyExceptions = false; if (ForceExceptionUtils.isReadOnlyException(coreException) && !skipAllReadOnlyExceptions) { String message = ForceExceptionUtils.getStrippedExceptionMessage(coreException.getMessage()); logger.warn("Unable to save " + component.getFullDisplayName() + " to file - " + message); StringBuffer strBuff = new StringBuffer(Messages.getString("Components.SaveResourceError.message")); strBuff.append(":\n\n").append(message).append("\n\n") .append(Messages.getString("Components.SaveResourceError.SkipAllReadOnly.message")); MessageDialogRunnable messageDialogRunnable = new MessageDialogRunnable("Cannot Write to File", null, strBuff.toString(), MessageDialog.WARNING, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL }, 0); Display.getDefault().syncExec(messageDialogRunnable); if (messageDialogRunnable.getAction() == 1) { skipAllReadOnlyExceptions = true; logger.warn("Skipping all further read-only exceptions"); }/*from w w w . j a va 2 s .c o m*/ } return skipAllReadOnlyExceptions; }
From source file:com.salesforce.ide.core.model.ProjectPackageList.java
License:Open Source License
private void handleSaveException(Exception exception, Component component) throws InterruptedException { String message = ForceExceptionUtils.getStrippedExceptionMessage(exception.getMessage()); logger.warn("Unable to save " + component.getFullDisplayName() + " to file - " + message); StringBuffer strBuff = new StringBuffer(Messages.getString("Components.SaveResourceError.message")); strBuff.append(":\n\n").append(message).append("\n\n") .append(Messages.getString("Components.SaveResourceError.ContinueWithSaving.message")); MessageDialogRunnable messageDialogRunnable = new MessageDialogRunnable("Cannot Write to File", null, strBuff.toString(), MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); Display.getDefault().syncExec(messageDialogRunnable); if (messageDialogRunnable.getAction() == 1) { throw new InterruptedException("Save components to project canceled"); }/*from www.j a v a 2 s . c o m*/ }
From source file:com.salesforce.ide.core.WorkbenchShutdownListener.java
License:Open Source License
private void promptRemoveIfIsvDebugProject(IWorkbench workbench, IProject proj) { try {/* w w w .ja v a 2 s. co m*/ if (proj.hasNature(DefaultNature.NATURE_ID)) { ForceProject fProj = ContainerDelegate.getInstance().getServiceLocator().getProjectService() .getForceProject(proj); if (!fProj.getSessionId().isEmpty()) { String message = NLS.bind(Messages.RemoveSubscriberCode_Question, fProj.getProject().getName()); MessageDialog md = new MessageDialog(workbench.getDisplay().getActiveShell(), Messages.RemoveSubscriberCode_Title, null, message, MessageDialog.WARNING, new String[] { Messages.RemoveSubscriberCode_Later, Messages.RemoveSubscriberCode_Now }, 1); // If user selected "Delete Now" if (md.open() == 1) { fProj.getProject().delete(true, true, new NullProgressMonitor()); } } } } catch (CoreException e) { e.printStackTrace(); } }
From source file:com.salesforce.ide.ui.actions.ActionController.java
License:Open Source License
protected boolean syncCheck(boolean cancel) { // proactively sync check against org to avoid overwriting updated content try {/* w ww. j a v a2 s. com*/ syncCheckWork(); } catch (InvocationTargetException e) { Throwable cause = e.getTargetException(); // any insuff-org perms will cancel, but if not treat as a warning message if (cancel && cause instanceof InsufficientPermissionsException) { DialogUtils.getInstance() .presentInsufficientPermissionsDialog((InsufficientPermissionsException) cause); return false; } else if (cancel && cause instanceof InvalidLoginException) { // log failure logger.warn("Unable to perform sync check: " + ForceExceptionUtils.getRootCauseMessage(cause)); // choose further project create direction DialogUtils.getInstance().invalidLoginDialog(ForceExceptionUtils.getRootCauseMessage(cause)); return false; } else { // if cancel and non-insuff org perms, treat as a wanring and cancel further ops, vs. a warning and continue if (cancel) { logger.warn("Unable to perform sync check", ForceExceptionUtils.getRootCause(e)); DialogUtils.getInstance().cancelMessage( UIMessages.getString("DeploymentAction.SyncCheckError.title"), UIMessages.getString("DeploymentAction.SyncCheckError.message", new String[] { ForceExceptionUtils.getStrippedRootCauseMessage(cause) }), MessageDialog.WARNING); } else { logger.warn("Unable to perform sync check: " + ForceExceptionUtils.getRootCauseMessage(e)); DialogUtils.getInstance().continueMessage( UIMessages.getString("DeploymentAction.SyncCheckError.title"), UIMessages.getString("DeploymentAction.SyncCheckError.message", new String[] { ForceExceptionUtils.getStrippedRootCauseMessage(cause) }), MessageDialog.WARNING); } } } catch (InterruptedException e) { logger.warn("Pre-save sync operation cancelled: " + e.getMessage()); } return presentSyncPerspectiveDialog(); }
From source file:com.salesforce.ide.ui.actions.AddNatureAction.java
License:Open Source License
@Override public void execute(IAction action) { try {// www.j a va 2 s .c o m if (project.hasNature(DefaultNature.NATURE_ID)) { Utils.openInfo("Force.com Default Nature Exists", "Force.com Default Nature already exists on project '" + project.getName() + "'."); return; } } catch (CoreException e) { String logMessage = Utils.generateCoreExceptionLog(e); logger.error( "Unable to apply Force.com Online Nature to project '" + project.getName() + "': " + logMessage, e); Utils.openError(e, "Force.com Online Nature Error", "Problems adding Force.com Online Nature to project '" + project.getName() + "': " + e.getMessage()); return; } applyNature(); updateDecorators(); DialogUtils.getInstance().okMessage("Force.com Project Properties", UIMessages.getString("AddForceNature.Properties.message"), MessageDialog.WARNING); try { (new OpenForcePerspectiveAction()).run(); } catch (ForceProjectException e) { logger.error("Unable to open Force Perspective", e); } }
From source file:com.salesforce.ide.ui.dialogs.HyperLinkMessageDialog.java
License:Open Source License
/** * Convenience method to open a standard warning dialog. * /*from w ww . jav a 2 s . c om*/ * @param parent * the parent shell of the dialog, or <code>null</code> if none * @param title * the dialog's title, or <code>null</code> if none * @param message * the message */ public static void openWarning(Shell parent, String title, String message, IResource resource) { HyperLinkMessageDialog dialog = new HyperLinkMessageDialog(parent, title, null, // accept // the // default // window // icon message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); // ok // is // the // default dialog.open(); return; }
From source file:com.salesforce.ide.ui.dialogs.WebOnlyDeleteMessageDialog.java
License:Open Source License
/** * Convenience method to open a standard warning dialog. * /*from w w w . j a v a 2s . c o m*/ * @param parent * the parent shell of the dialog, or <code>null</code> if none * @param title * the dialog's title, or <code>null</code> if none * @param message * the message */ public static void openWarning(Shell parent, String title, String message, List<IResource> resources) { WebOnlyDeleteMessageDialog dialog = new WebOnlyDeleteMessageDialog(parent, title, null, // accept // the // default // window // icon message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); // ok // is // the // default dialog.resources = resources; dialog.open(); return; }