List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:com.safi.workshop.util.SafletPersistenceManager.java
public void addOrUpdateSaflets(IProject project, final List<Saflet> saflets, final boolean update, final boolean interactive) throws CoreException { final List<Saflet> safletsCopy = new ArrayList<Saflet>(saflets); // TODO Auto-generated method stub project.accept(new IResourceVisitor() { @Override/* w w w. j a v a2 s .co m*/ public boolean visit(IResource resource) throws CoreException { if (resource.getType() == IResource.FILE && "saflet".equals(resource.getFileExtension())) { boolean skipAll = false, overwriteAll = false; int pid = SafletPersistenceManager.getInstance().getResourceId(resource); String existingName = SafletPersistenceManager.getInstance().getSafletName(resource); for (Saflet saflet : saflets) { final boolean sameName = StringUtils.equals(existingName, saflet.getName()); if ((pid == saflet.getId() && pid != -1) || sameName) { safletsCopy.remove(saflet); if (!update) continue; if (interactive) { if (skipAll) continue; if (!overwriteAll) { String dialogMessage = null; if (sameName) dialogMessage = "A Saflet with name " + saflet.getName() + " already exists in the workspace. Do you wish to skip or overwrite? "; else dialogMessage = "Saflet (" + saflet.getName() + ") exists with the same ID a different name in the workspace (" + existingName + "). Do you wish to skip or overwrite? "; MessageDialog dlg = new MessageDialog(SafiWorkshopEditorUtil.getActiveShell(), "Overwrite Existing Saflet?", null, dialogMessage, MessageDialog.QUESTION, new String[] { "Skip", "Skip all", "Overwrite", "Overwrite All" }, 4); int result = dlg.open(); switch (result) { case 0: // Skip continue; case 1: // Skip all skipAll = true; continue; case 2: // Overwrite break; case 3: // Overwrite All overwriteAll = true; break; } } } IPath fullPath = null; try { fullPath = SafletPersistenceManager.getInstance() .writeSafletToExistingFile((IFile) resource, saflet);// SafletPersistenceManager.getInstance().getSaflet(saflet.getId())); AsteriskDiagramEditor editor = getOpenEditor((IFile) resource); if (editor != null) { AsteriskDiagramEditorPlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow().getActivePage().closeEditor(editor, false); editor = (AsteriskDiagramEditor) SafiWorkshopEditorUtil.openDiagram( URI.createFileURI(fullPath.toPortableString()), false, true); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Update Error", "Couldn't update Saflet: " + e.getLocalizedMessage()); AsteriskDiagramEditorPlugin.getInstance().logError("Couldn't update Saflet", e); break; } } } } return true; } }); for (Saflet saflet : safletsCopy) { String filename = SafiWorkshopEditorUtil.getUniqueFileName(project, saflet.getName(), "saflet"); IFile file = project.getFile(filename); try { byte[] code = saflet.getCode() == null ? DBManager.getInstance().getSafletCode(saflet.getId()) : (saflet.getCode() == null ? null : saflet.getCode()); file.create(new ByteArrayInputStream(code), true, null); Date now = new Date(); file.setPersistentProperty(RES_ID_KEY, String.valueOf(saflet.getId())); file.setPersistentProperty(MODIFIED_KEY, String.valueOf(now.getTime())); file.setPersistentProperty(UPDATED_KEY, String.valueOf(now.getTime())); file.setPersistentProperty(SAFLET_NAME_KEY, saflet.getName()); } catch (DBManagerException e) { // TODO Auto-generated catch block throw new CoreException(new Status(IStatus.ERROR, AsteriskDiagramEditorPlugin.ID, "Couldn't write Saflet to local file", e)); } } updateLocalProject(project, saflets.get(0).getProject()); }
From source file:com.salesforce.ide.ui.dialogs.HyperLinkMessageDialog.java
License:Open Source License
/** * Convenience method to open a simple confirm (OK/Cancel) dialog. * //ww w. ja va 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 * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise */ public static boolean openConfirm(Shell parent, String title, String message) { HyperLinkMessageDialog dialog = new HyperLinkMessageDialog(parent, title, null, // accept // the // default // window // icon message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); // OK is the // default return dialog.open() == 0; }
From source file:com.salesforce.ide.ui.dialogs.HyperLinkMessageDialog.java
License:Open Source License
/** * Convenience method to open a simple Yes/No question dialog. * //from ww w . j av a2s . 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 * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise */ public static boolean openQuestion(Shell parent, String title, String message) { HyperLinkMessageDialog dialog = new HyperLinkMessageDialog(parent, title, null, // accept // the // default // window // icon message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the default return dialog.open() == 0; }
From source file:com.sap.netweaver.porta.ide.eclipse.server.ui.dialogs.LoginDialog.java
License:Open Source License
public LoginDialog(Shell parentShell, String title, String message, String defaultUser) { super(parentShell, title, null, message, MessageDialog.QUESTION, new String[] { "Login", IDialogConstants.CANCEL_LABEL }, 0); this.defaultUser = defaultUser; }
From source file:com.siteview.mde.internal.ui.editor.monitor.MonitorOverviewPage.java
License:Open Source License
private void activateExtensionPages(String activePageId) { MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.OverviewPage_extensionPageMessageTitle, null, MDEUIMessages.OverviewPage_extensionPageMessageBody, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (mdiag.open() != Window.OK) return;/*from w w w .j a va2 s . com*/ try { MonitorEditor manifestEditor = (MonitorEditor) getEditor(); manifestEditor.addExtensionTabs(); manifestEditor.setShowExtensions(true); manifestEditor.setActivePage(activePageId); } catch (PartInitException e) { } catch (BackingStoreException e) { } }
From source file:com.siteview.mde.internal.ui.editor.monitor.OverviewPage.java
License:Open Source License
private void activateExtensionPages(String activePageId) { MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.OverviewPage_extensionPageMessageTitle, null, MDEUIMessages.OverviewPage_extensionPageMessageBody, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (mdiag.open() != Window.OK) return;// w w w. ja v a 2 s . c o m try { MonitorEditor monitorEditor = (MonitorEditor) getEditor(); monitorEditor.addExtensionTabs(); monitorEditor.setShowExtensions(true); monitorEditor.setActivePage(activePageId); } catch (PartInitException e) { } catch (BackingStoreException e) { } }
From source file:com.siteview.mde.internal.ui.editor.product.IntroSection.java
License:Open Source License
private void handleNewIntro() { boolean needNewProduct = false; if (!productDefined()) { needNewProduct = true;// w w w. ja va2s . c o m MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(), MDEUIMessages.IntroSection_undefinedProductId, null, MDEUIMessages.IntroSection_undefinedProductIdMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (mdiag.open() != Window.OK) return; } ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct); WizardDialog dialog = new WizardDialog(MDEPlugin.getActiveWorkbenchShell(), wizard); dialog.create(); if (dialog.open() == Window.OK) { String id = wizard.getIntroId(); fIntroCombo.add(id, 0); fIntroCombo.setText(id); getIntroInfo().setId(id); addDependenciesAndPlugins(); } }
From source file:com.siteview.mde.internal.ui.launcher.LauncherUtilsStatusHandler.java
License:Open Source License
/** * Creates a message dialog using a syncExec in case we are launching in the background. * Dialog will be a question dialog with Yes, No and Cancel buttons. * @param message Message to use in the dialog * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no). */// w w w . j a v a 2s. c o m private static Integer generateDialog(final String message) { final int[] result = new int[1]; getDisplay().syncExec(new Runnable() { public void run() { String title = MDEUIMessages.LauncherUtils_title; MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); result[0] = dialog.open(); } }); return new Integer(result[0]); }
From source file:com.trivadis.loganalysis.ui.internal.dialog.DeleteFileDialog.java
License:Open Source License
public DeleteFileDialog(IFileDescriptor file, Shell shell) { super(shell, getTitle(file), null, getMessage(file), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); setShellStyle(getShellStyle() | SWT.SHEET); }
From source file:com.twinsoft.convertigo.eclipse.dialogs.MultipleDeletionDialog.java
License:Open Source License
private boolean confirmOverwrite(String msg) { if (shell == null) return false; final MessageDialog dialog = new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, buttons, 0); shell.getDisplay().syncExec(new Runnable() { public void run() { dialog.open();//from ww w. j av a 2 s. c o m } }); if (hasMultiple) { switch (dialog.getReturnCode()) { case 0: return true; case 1: confirmation = YES_TO_ALL; return true; case 2: return false; case 3: confirmation = NO_TO_ALL; default: return false; } } else { switch (dialog.getReturnCode()) { case 0: return true; case 1: return false; case 2: default: return false; } } }