List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:com.aptana.ide.editors.untitled.BaseTextEditor.java
License:Open Source License
private File doExternalSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell();/*from w ww. java 2 s. c om*/ IDocumentProvider provider = getDocumentProvider(); IEditorInput input = getEditorInput(); FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); String fileName = getDefaultSaveAsFile(); fileDialog.setFileName(getBaseFilename(fileName)); FileDialogFilterInfo filterInfo = getFileDialogFilterInformation(fileName); String[] fileExtensions = filterInfo.getFilterExtensions(); if (fileExtensions != null && fileExtensions.length > 0) { fileDialog.setFilterExtensions(fileExtensions); fileDialog.setFilterNames(filterInfo.getFilterNames()); } // [IM] This appears to have no effect on OSX. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=101948 if (directoryHint != null) { File f = new File(directoryHint); if (f.exists()) { fileDialog.setFilterPath(directoryHint); } } String text = fileDialog.open(); if (text == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return null; } File file = new File(text); final IEditorInput newInput = CoreUIUtils.createJavaFileEditorInput(file); boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = Messages.BaseTextEditor_SaveFileError; String msg = StringUtils.format(Messages.BaseTextEditor_ErrorSaving, new Object[] { x.getMessage() }); if (status != null) { switch (status.getSeverity()) { case IStatus.INFO: MessageDialog.openInformation(shell, title, msg); break; case IStatus.WARNING: MessageDialog.openWarning(shell, title, msg); break; default: MessageDialog.openError(shell, title, msg); } } else { MessageDialog.openError(shell, title, msg); } } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } if (success) { return file; } else { return null; } }
From source file:com.aptana.ide.scripting.Global.java
License:Open Source License
/** * Popup an alert box with the specified message * //from ww w . ja v a 2 s . co m * @param message * The message to display in an alert dialog */ public void alert(final String message) { final Display currentDisplay = Display.getCurrent(); if (currentDisplay != null) { currentDisplay.syncExec(new Runnable() { public void run() { Shell shell = currentDisplay.getActiveShell(); if (shell != null) { MessageDialog.openWarning(shell, "Aptana Studio", message); //$NON-NLS-1$ } } }); } }
From source file:com.aptana.ide.subscription.SubscriptionManager.java
License:Open Source License
private static void showWarning() { CoreUIUtils.getDisplay().asyncExec(new Runnable() { public void run() { MessageDialog.openWarning(CoreUIUtils.getActiveShell(), Messages.SubscriptionManager_WarningTitle, MessageFormat.format(Messages.SubscriptionManager_WarningMessage, ALLOWED_DAY)); }//from w w w. j ava2 s . c om }); }
From source file:com.aptana.ide.syncing.ui.actions.BaseSyncAction.java
License:Open Source License
public void run(IAction action) { if (fSelectedElements.size() == 0) { return;/*from w w w . j av a2 s. c om*/ } if (fSite == null) { // gets the site connection user wants to use ISiteConnection[] sites = getSiteConnections(); if (sites.length == 0) { // the selected elements do not belong to a common source location MessageDialog.openWarning(getShell(), getMessageTitle(), Messages.BaseSyncAction_Warning_NoCommonParent); return; } if (sites.length == 1) { fSite = sites[0]; } else { // multiple connections on the selected source IResource resource = (IResource) fSelectedElements.get(0).getAdapter(IResource.class); if (resource != null) { IContainer container = null; boolean remember = false; if (resource instanceof IContainer) { remember = ResourceSynchronizationUtils.isRememberDecision((IContainer) resource); if (remember) { container = (IContainer) resource; } } if (!remember) { // checks the parent path container = resource.getParent(); while (container != null && !(container instanceof IWorkspaceRoot)) { remember = ResourceSynchronizationUtils.isRememberDecision(container); if (remember) { break; } container = container.getParent(); } } if (remember) { fSite = getLastSyncConnection(container); } } if (fSite == null) { ChooseSiteConnectionDialog dialog = new ChooseSiteConnectionDialog(getShell(), sites); dialog.setShowRememberMyDecision(true); if (dialog.open() == Window.OK) { fSite = dialog.getSelectedSite(); if (fSite != null) { setRememberMyDecision(fSite, dialog.isRememberMyDecision()); } } } } } if (fSite != null) { try { performAction(fSelectedElements.toArray(new IAdaptable[fSelectedElements.size()]), fSite); } catch (CoreException e) { // TODO: Opens an error dialog } } }
From source file:com.aptana.ide.syncing.ui.dialogs.SiteConnectionsEditorDialog.java
License:Open Source License
protected boolean doSelectionChange() { if (sitePropertiesWidget.isChanged()) { MessageDialog dlg = new MessageDialog(getShell(), Messages.SiteConnectionsEditorDialog_SaveConfirm_Title, null, MessageFormat.format(Messages.SiteConnectionsEditorDialog_SaveConfirm_Message, sitePropertiesWidget.getSource().getName()), MessageDialog.QUESTION, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 1);// w w w . j a v a2s .com switch (dlg.open()) { case 1: if (sitePropertiesWidget.applyChanges()) { break; } else { // unresolved error exists in the current selection MessageDialog.openWarning(getShell(), Messages.SiteConnectionsEditorDialog_UnresolvedWarning_Title, Messages.SiteConnectionsEditorDialog_UnresolvedWarning_Message); } case 2: return false; } } return true; }
From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//* w ww . java2 s . c om*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = UIUtils.getActiveShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ return Boolean.TRUE; case 1: return Boolean.TRUE; case 3: WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER); return Boolean.TRUE; default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format( Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5))); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, ((String) source).substring(10))); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } } IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return Boolean.TRUE; } } String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, (String) source); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return Boolean.TRUE; case IDialogConstants.NO_ID: return Boolean.FALSE; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } }
From source file:com.aptana.portal.ui.dispatch.actionControllers.RecentFilesActionController.java
License:Open Source License
private void open(EditorHistoryItem item) { IWorkbenchPage page = PortalUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page != null) { try {/*from www . j a va2 s . co m*/ String itemName = item.getName(); if (!item.isRestored()) { item.restoreState(); } IEditorInput input = item.getInput(); IEditorDescriptor desc = item.getDescriptor(); if (input == null || desc == null) { String title = WorkbenchMessages.OpenRecent_errorTitle; String msg = NLS.bind(WorkbenchMessages.OpenRecent_unableToOpen, itemName); MessageDialog.openWarning(Display.getDefault().getActiveShell(), title, msg); } else { page.openEditor(input, desc.getId()); } } catch (PartInitException e2) { String title = WorkbenchMessages.OpenRecent_errorTitle; MessageDialog.openWarning(Display.getDefault().getActiveShell(), title, e2.getMessage()); } } }
From source file:com.arcbees.gwtp.plugin.core.project.CreateProjectWizard.java
License:Apache License
private void warn(final String message) { Display.getDefault().asyncExec(new Runnable() { @Override//from ww w . ja v a2 s.com public void run() { MessageDialog.openWarning(getShell(), "Warning", message); } }); }
From source file:com.archimatetool.editor.Logger.java
License:Open Source License
/** * Convenience method to open a standard warning dialog * // w ww . j a v a 2 s . co m * @param message * the message */ public static void showWarningDialog(String message) { MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Warning", message); //$NON-NLS-1$ }
From source file:com.archimatetool.editor.model.impl.EditorModelManager.java
License:Open Source License
/** * Ask user for file name to save model//ww w. java 2 s . c o m * @return the file or null */ private File askSaveModel() { // On Mac if the app is minimised in the dock Display.getCurrent().getActiveShell() will return null Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); shell.setActive(); // Get focus on Mac FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setFilterExtensions(new String[] { ARCHIMATE_FILE_WILDCARD, "*.*" }); //$NON-NLS-1$ String path = dialog.open(); if (path == null) { return null; } // Only Windows adds the extension by default if (dialog.getFilterIndex() == 0 && !path.endsWith(ARCHIMATE_FILE_EXTENSION)) { path += ARCHIMATE_FILE_EXTENSION; } File file = new File(path); // Make sure we don't already have it open for (IArchimateModel m : getModels()) { if (file.equals(m.getFile())) { MessageDialog.openWarning(shell, Messages.EditorModelManager_8, NLS.bind(Messages.EditorModelManager_9, file)); return null; } } // Make sure the file does not already exist if (file.exists()) { boolean result = MessageDialog.openQuestion(shell, Messages.EditorModelManager_10, NLS.bind(Messages.EditorModelManager_11, file)); if (!result) { return null; } } return file; }