List of usage examples for org.eclipse.jface.dialogs MessageDialog MessageDialog
public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, int defaultIndex, String... dialogButtonLabels)
From source file:com.javapathfinder.vjp.config.LaunchDialog.java
License:Open Source License
private void handleDeleteFile() { Object selection = ((TreeSelection) fileTree.getSelection()).getFirstElement(); if (!(selection instanceof IFile)) return;/*from w w w. j a v a2 s . co m*/ IFile file = (IFile) selection; int option = new MessageDialog(getShell(), "Delete " + file.getName() + "?", null, "Are you sure you want to delete " + "the configuration file: " + file.getName() + "?", MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1).open(); if (option != 0) return; try { file.delete(true, true, null); } catch (CoreException e) { VJP.logError("Could not delete file.", e); } updateTree(); }
From source file:com.liferay.ide.portlet.ui.action.BuildLanguagesAction.java
License:Open Source License
protected boolean checkLanguageFileEncoding(IFile langFile) throws CoreException { IProgressMonitor monitor = new NullProgressMonitor(); try {//from w w w. j ava 2 s. c o m langFile.refreshLocal(IResource.DEPTH_INFINITE, monitor); } catch (Exception e) { PortletUIPlugin.logError(e); } String charset = langFile.getCharset(true); if (!"UTF-8".equals(charset)) //$NON-NLS-1$ { String dialogMessage = NLS.bind(Msgs.languageFileCharacterSet, charset); MessageDialog dialog = new MessageDialog(getDisplay().getActiveShell(), Msgs.incompatibleCharacterSet, getDisplay().getSystemImage(SWT.ICON_WARNING), dialogMessage, MessageDialog.WARNING, new String[] { Msgs.yes, Msgs.no, Msgs.cancel }, 0); int retval = dialog.open(); if (retval == 0) { langFile.setCharset("UTF-8", monitor); //$NON-NLS-1$ String question = NLS.bind(Msgs.forcedEditFile, langFile.getName()); if (MessageDialog.openQuestion(getDisplay().getActiveShell(), Msgs.previewFile, question)) { IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), langFile); } return false; } else if (retval == 2) { return false; } } return true; }
From source file:com.liferay.ide.portlet.ui.handlers.BuildLangHandler.java
License:Open Source License
protected boolean checkLanguageFileEncoding(IFile langFile) throws CoreException { IProgressMonitor monitor = new NullProgressMonitor(); try {//from www . j ava 2 s . c om langFile.refreshLocal(IResource.DEPTH_INFINITE, monitor); } catch (Exception e) { PortletUIPlugin.logError(e); } String charset = langFile.getCharset(true); if (!"UTF-8".equals(charset)) { String dialogMessage = NLS.bind(Msgs.languageFileCharacterSet, charset); MessageDialog dialog = new MessageDialog(UIUtil.getActiveShell(), Msgs.incompatibleCharacterSet, UIUtil.getActiveShell().getDisplay().getSystemImage(SWT.ICON_WARNING), dialogMessage, MessageDialog.WARNING, new String[] { Msgs.yes, Msgs.no, Msgs.cancel }, 0); int retval = dialog.open(); if (retval == 0) { langFile.setCharset("UTF-8", monitor); //$NON-NLS-1$ String question = NLS.bind(Msgs.forcedEditFile, langFile.getName()); if (MessageDialog.openQuestion(UIUtil.getActiveShell(), Msgs.previewFile, question)) { IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), langFile); } return false; } else if (retval == 2) { return false; } } return true; }
From source file:com.liferay.ide.server.tomcat.ui.CleanAppServerAction.java
License:Open Source License
protected void cleanAppServer(IProject project, String bundleZipLocation) throws CoreException { String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog dialog = new MessageDialog(getDisplay().getActiveShell(), getTitle(), null, Msgs.deleteEntireTomcatDirectory, MessageDialog.WARNING, labels, 1); int retval = dialog.open(); if (retval == MessageDialog.OK) { new CleanAppServerJob(project, bundleZipLocation).schedule(); }//from ww w . java2 s. c o m }
From source file:com.mentor.nucleus.bp.core.util.UIUtil.java
License:Open Source License
/** * Note this "MessageDialog" currently only supports an array of 2 dialog button * labels. This is why the result is a boolean. It simply behaves in * a similar manner as if a yes/no question had been asked (offset 0 is * yes and offset 1 is no). If additional buttons are ever needed this * will need to be modified to handle it. *//*from w w w .ja v a2s . c o m*/ public static boolean openMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, BPMessageTypes dialogType, String[] dialogButtonLabels, int defaultIndex) { int standardDialogType = MessageDialog.WARNING; if (dialogType == BPMessageTypes.ERROR) { standardDialogType = MessageDialog.ERROR; } else if ((dialogType == BPMessageTypes.INFORMATION)) { standardDialogType = MessageDialog.INFORMATION; } boolean result = (defaultIndex == MessageDialog.OK); if (CoreUtil.IsRunningHeadless) { outputTextForheadlessRun(dialogType, dialogTitle, dialogMessage, ""); } else { MessageDialog dialog = new MessageDialog(parentShell, dialogTitle, dialogTitleImage, dialogMessage, standardDialogType, dialogButtonLabels, defaultIndex); dialog.setBlockOnOpen(true); int actualResult = dialog.open(); result = MessageDialog.OK == actualResult; } return result; }
From source file:com.mentor.nucleus.bp.core.util.UIUtil.java
License:Open Source License
/** * //from ww w .java 2s . c o m * @param msg * @return true if the user responds yes and false if the user responds no */ public static boolean displayYesNoQuestion(final String msg) { displayYesNoQuestion_isYes = true; if (CoreUtil.IsRunningHeadless) { displayYesNoQuestion_isYes = UIUtil.openMessageDialog(null, "BridgePoint UML Suite", null, msg, UIUtil.BPMessageTypes.QUESTION, new String[] { "Yes", "No" }, 0); // yes is he default } else { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { org.eclipse.swt.widgets.Shell sh = PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, "BridgePoint UML Suite", null, msg, MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0); // yes is the default displayYesNoQuestion_isYes = (dialog.open() == 0); } }); } return displayYesNoQuestion_isYes; }
From source file:com.mercatis.lighthouse3.base.ui.handlers.AbstractDeleteHandler.java
License:Apache License
protected boolean showDialog(Object[] elements) { String message = ""; if (elements.length == 1) { message = "Do you really want to delete " + LabelConverter.getLabel(elements[0]) + "?"; } else if (elements.length > 1) { message = "Do you really want to delete these " + elements.length + " elements?"; } else {//from www. j a v a 2s .co m throw new RuntimeException("No elements in selection!"); } MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Delete", null, message, MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1); int button = md.open(); return button == 0; }
From source file:com.mercatis.lighthouse3.security.ui.wizards.NewGroupWizard.java
License:Apache License
@Override public boolean performFinish() { try {/*from www .j a v a2s . com*/ group = new Group(); group.setCode(propertiesPage.getCode()); group.setLongName(propertiesPage.getLongName()); group.setContact(propertiesPage.getContact()); group.setContactEmail(propertiesPage.getContactEmail()); group.setDescription(propertiesPage.getDescription()); Security.getService().persistGroup(lighthouseDomain.getProject(), group); } catch (Exception e) { new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Create Group", null, e.getMessage(), MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return false; } return true; }
From source file:com.mercatis.lighthouse3.security.ui.wizards.NewUserWizard.java
License:Apache License
@Override public boolean performFinish() { try {/* w w w .j av a 2 s. c o m*/ user = new User(); user.setCode(propertiesPage.getCode()); user.setGivenName(propertiesPage.getGivenName()); user.setSurName(propertiesPage.getSurName()); user.setContactEmail(propertiesPage.getContactEmail()); user.setAndHashPassword(propertiesPage.getPassword()); Security.getService().persistUser(lighthouseDomain.getProject(), user); } catch (Exception e) { new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Create User", null, e.getMessage(), MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return false; } return true; }
From source file:com.mercatis.lighthouse3.status.ui.editors.pages.StatusOverviewEditorPage.java
License:Apache License
@Override public void doSave(IProgressMonitor monitor) { if (isDirty()) { if (statuusToDelete != null && !statuusToDelete.isEmpty()) { for (StatusEditingObject std : statuusToDelete) { CommonBaseActivator.getPlugin().getStatusService().deleteStatus(std.getStatus()); }/*from w w w . j av a2s .c o m*/ PlatformUI.getWorkbench().getDecoratorManager().update(LighthouseStatusDecorator.id); statuusToDelete.clear(); } if (getCurrentStatus() != null) updateStatusEditingObject(); for (StatusEditingObject status : statuus) { try { status.updateModel(); CommonBaseActivator.getPlugin().getStatusService().updateStatus(status.getStatus()); } catch (Exception ex) { new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Save Status", null, ex.getMessage(), MessageDialog.ERROR, new String[] { "OK" }, 0).open(); } } } getEditor().editorDirtyStateChanged(); }