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:net.sf.eclipsensis.util.Common.java
License:Open Source License
public static void openWarning(Shell parent, String title, String message, Image icon) { MessageDialog dialog = new MessageDialog(parent, title, icon, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open();//from w w w. j a va 2 s . c o m }
From source file:net.sf.eclipsensis.util.Common.java
License:Open Source License
public static int openMessageDialog(Shell parent, String title, String message, Image icon, int dialogImageType, String[] buttons, int defaultIndex) { MessageDialog dialog = new MessageDialog(parent, title, icon, message, dialogImageType, buttons, defaultIndex);/* ww w . j a va 2 s . co m*/ return dialog.open(); }
From source file:net.sf.eclipsensis.wizard.NSISWizardContentsPage.java
License:Open Source License
/** * @param tv// w w w .j a va2s.c om * @param sel */ private void deleteElements(final TreeViewer tv, ISelection sel) { if (sel instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) sel; if (!ssel.isEmpty()) { try { int buttonId = -1; for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) { INSISInstallElement element = (INSISInstallElement) iter.next(); if (element.hasChildren()) { if (buttonId == IDialogConstants.NO_TO_ALL_ID) { continue; } else if (buttonId != IDialogConstants.YES_TO_ALL_ID) { int index = new MessageDialog(getShell(), cDeleteConfirmTitle, EclipseNSISPlugin.getShellImage(), MessageFormat .format(cDeleteConfirmMessageFormat, new Object[] { element.getDisplayName() }), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL }, 0).open(); if (index >= 0) { buttonId = cDeleteConfirmButtonIds[index]; } else { return; } if (buttonId == IDialogConstants.NO_ID || buttonId == IDialogConstants.NO_TO_ALL_ID) { continue; } } } INSISInstallElement parent = element.getParent(); if (parent != null) { parent.removeChild(element); tv.refresh(parent, true); } } setPageComplete(validatePage(VALIDATE_ALL)); } catch (Exception ex) { delayedValidateAfterError(ex.getLocalizedMessage(), 2000); } finally { tv.refresh(false); } } } }
From source file:net.sf.fjep.fatjar.wizard.FJExportWizardConfigPage.java
License:Open Source License
private void showOneJARHelp() { MessageDialog dialog = new MessageDialog(getShell(), "One-JAR", null, "One-JAR Help", MessageDialog.INFORMATION, new String[] { "OK" }, 0) { protected Font font; public boolean close() { boolean result; try { font.dispose();/* ww w. j ava2 s . com*/ } finally { result = super.close(); } return result; } protected Control createCustomArea(Composite parent) { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 600; gd.heightHint = 300; String resource = "one-jar-help.txt"; StringBuffer help = null; try { help = readText(this.getClass().getResourceAsStream(resource)); } catch (IOException iox1) { help = new StringBuffer(); help.append("Unable to locate built-in help for One-JAR at: " + resource + ": " + iox1); } Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); FontData fd = font.getFontData()[0]; // Reduce the font-size. TODO: Should make this configurable in // preferences. fd.setHeight(fd.getHeight() - 2); font = new Font(text.getDisplay(), fd); text.setFont(font); text.setEditable(false); text.setLayoutData(gd); text.setText(help.toString()); Hyperlink href = new Hyperlink(parent, SWT.NONE); href.setText("http://one-jar.sourceforge.net"); href.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE)); href.setUnderlined(true); href.addHyperlinkListener(new IHyperlinkListener() { public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { try { SystemBrowserFactory factory = new SystemBrowserFactory(); factory.createBrowser().displayURL(e.getLabel()); } catch (Exception x) { MessageDialog.openError(e.display.getActiveShell(), "Unable to open " + e.getLabel(), "Unable to open browser: \n" + x.getStackTrace()); } } }); return text; } }; dialog.open(); }
From source file:net.sf.fjep.fatjar.wizard.FJExportWizardConfigPage.java
License:Open Source License
/** * Show the One-JAR license in a dialogbox. The first time the user sees * this they must accept its terms in order to be able to use One-JAR, under * its BSD-style license terms./*from w ww. j a v a 2 s. c om*/ * * @return The code from the dialog. 0==Accept, 1==Reject. */ private int showOneJARLicense() { // Show license. String buttons[] = new String[] { "Accept", "Decline" }; MessageDialog dialog = new MessageDialog(getShell(), "One-JAR License", null, "One-JAR is licensed according to the following terms. Please visit http://one-jar.sourceforge.net for more information.", MessageDialog.INFORMATION, buttons, 0) { protected Control createCustomArea(Composite parent) { // Put the license text in the dialog. Text text = new Text(parent, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY | SWT.MULTI); text.setEditable(false); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 200; text.setLayoutData(gd); // Load the license data as a resource. TODO: Resource this // name! try { JarInputStream jis = new JarInputStream( AguiPlugin.class.getResourceAsStream(AguiPlugin.ONE_JAR_BOOT)); JarEntry entry = (JarEntry) jis.getNextEntry(); StringBuffer license = new StringBuffer(); while (entry != null) { if (entry.getName().equals("doc/one-jar-license.txt")) { license = readText(jis); break; } entry = (JarEntry) jis.getNextEntry(); } text.setText(license.toString()); return text; } catch (Exception x) { text.setText("The One-JAR license is available at http://one-jar.sourceforge.net"); } return text; } }; return dialog.open(); }
From source file:net.sf.fjep.fatjar.wizards.export.ConfigPage.java
License:Open Source License
private void showOneJARHelp() { MessageDialog dialog = new MessageDialog(getShell(), "One-JAR", null, "One-JAR Help", MessageDialog.INFORMATION, new String[] { "OK" }, 0) { protected Font font; public boolean close() { boolean result; try { font.dispose();//from ww w. j a v a 2 s. c om } finally { result = super.close(); } return result; } protected Control createCustomArea(Composite parent) { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 600; gd.heightHint = 300; String resource = "one-jar-help.txt"; StringBuffer help = null; try { help = readText(this.getClass().getResourceAsStream(resource)); } catch (IOException iox1) { help = new StringBuffer(); help.append("Unable to locate built-in help for One-JAR at: " + resource + ": " + iox1); } Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); FontData fd = font.getFontData()[0]; // Reduce the font-size. TODO: Should make this configurable in preferences. fd.setHeight(fd.getHeight() - 2); font = new Font(text.getDisplay(), fd); text.setFont(font); text.setEditable(false); text.setLayoutData(gd); text.setText(help.toString()); Hyperlink href = new Hyperlink(parent, SWT.NONE); href.setText("http://one-jar.sourceforge.net"); href.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE)); href.setUnderlined(true); href.addHyperlinkListener(new IHyperlinkListener() { public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) { } public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { try { SystemBrowserFactory factory = new SystemBrowserFactory(); factory.createBrowser().displayURL(e.getLabel()); } catch (Exception x) { MessageDialog.openError(e.display.getActiveShell(), "Unable to open " + e.getLabel(), "Unable to open browser: \n" + x.getStackTrace()); } } }); return text; } }; dialog.open(); }
From source file:net.sf.fjep.fatjar.wizards.export.ConfigPage.java
License:Open Source License
/** * Show the One-JAR license in a dialogbox. The first time the user sees this * they must accept its terms in order to be able to use One-JAR, under its * BSD-style license terms./*from w w w. java 2 s . c o m*/ * @return The code from the dialog. 0==Accept, 1==Reject. */ private int showOneJARLicense() { // Show license. String buttons[] = new String[] { "Accept", "Decline" }; MessageDialog dialog = new MessageDialog(getShell(), "One-JAR License", null, "One-JAR is licensed according to the following terms. Please visit http://one-jar.sourceforge.net for more information.", MessageDialog.INFORMATION, buttons, 0) { protected Control createCustomArea(Composite parent) { // Put the license text in the dialog. Text text = new Text(parent, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY | SWT.MULTI); text.setEditable(false); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 200; text.setLayoutData(gd); // Load the license data as a resource. TODO: Resource this name! try { JarInputStream jis = new JarInputStream( AguiPlugin.class.getResourceAsStream(AguiPlugin.ONE_JAR_BOOT)); JarEntry entry = (JarEntry) jis.getNextEntry(); StringBuffer license = new StringBuffer(); while (entry != null) { if (entry.getName().equals("doc/one-jar-license.txt")) { license = readText(jis); break; } entry = (JarEntry) jis.getNextEntry(); } text.setText(license.toString()); return text; } catch (Exception x) { text.setText("The One-JAR license is available at http://one-jar.sourceforge.net"); } return text; } }; return dialog.open(); }
From source file:net.sf.freeqda.common.handler.LoadProjectHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); //TODO check for active project and close if exists // File standard dialog FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); // Initialise the dialog fileDialog.setText(DIALOG_TEXT);//from w w w .j av a 2 s . c o m fileDialog.setFilterNames(new String[] { MessageFormat.format(Messages.LoadProjectHandler_Filter_FQDAProjects, new Object[] { SUFFIX_FQDA_PROJECTS }), MessageFormat.format(Messages.LoadProjectHandler_Filter_AllFiles, new Object[] { SUFFIX_ALL_FILES }) }); fileDialog.setFilterExtensions(new String[] { SUFFIX_FQDA_PROJECTS, SUFFIX_ALL_FILES }); //TODO create platform dependent wildcards! // Open Dialog and save result of selection String selected = fileDialog.open(); /* * Check if dialog has been canceled */ if (selected == null) { new MessageDialog(shell, DIALOG_LOAD_CANCELED_TITLE, null, DIALOG_LOAD_CANCELED_MESSAGE, MessageDialog.WARNING, new String[] { DIALOG_LOAD_CANCELED_BUTTONS }, 0).open(); return null; } /* * Load selected project file */ try { ProjectManager.getInstance().load(new File(selected)); new MessageDialog(shell, DIALOG_PROJECT_LOADED_TITLE, null, MessageFormat.format(Messages.LoadProjectHandler_DialogProjectLoaded_Message, new Object[] { selected }), MessageDialog.INFORMATION, new String[] { DIALOG_PROJECT_LOADED_BUTTONS }, 0).open(); } catch (IOException e) { new MessageDialog(shell, DIALOG_LOADING_FAILED_TITLE, null, MessageFormat.format(Messages.LoadProjectHandler_DialogProjectLoadingFailed_Message, new Object[] { selected }), MessageDialog.ERROR, new String[] { DIALOG_LOADING_FAILED_BUTTONS }, 0).open(); e.printStackTrace(); } return null; }
From source file:net.sf.freeqda.common.handler.SaveProjectHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); /*//from w ww. j av a2 s. c o m * Load selected project file */ try { /* * Save project data */ JAXBUtils.saveProject(PM.getProjectFile()); ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(shell); /* * Save dirty editors */ for (IEditorPart editor : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getDirtyEditors()) { if (editor instanceof StyledEditor) { StyledEditor styledEditor = (StyledEditor) editor; styledEditor.doSave(progressMonitor.getProgressMonitor()); } else if (editor instanceof TaggedPassagesEditor) { TaggedPassagesEditor taggedPassagesEditor = (TaggedPassagesEditor) editor; taggedPassagesEditor.doSave(progressMonitor.getProgressMonitor()); } else { new MessageDialog(shell, SAVE_PROJECT_UNHANDLED_TITLE, null, SAVE_PROJECT_UNHANDLED_MESSAGE, MessageDialog.ERROR, new String[] { SAVE_PROJECT_UNHANDLED_BUTTON_CONFIRM }, 0).open(); } } new MessageDialog(shell, SAVE_PROJECT_SUCCESS_TITLE, null, SAVE_PROJECT_SUCCESS_MESSAGE, MessageDialog.INFORMATION, new String[] { SAVE_PROJECT_SUCCESS_BUTTON_CONFIRM }, 0).open(); } catch (IOException e) { new MessageDialog(shell, SAVE_PROJECT_FAILED_TITLE, null, MessageFormat.format(Messages.SaveProjectHandler_SaveProjectFailed_Message, new Object[] { PM.getProjectFile().getAbsolutePath() }), MessageDialog.ERROR, new String[] { SAVE_PROJECT_FAILED_BUTTON_CONFIRM }, 0).open(); e.printStackTrace(); } return null; }
From source file:net.sf.freeqda.common.wizard.newproject.NewProjectWizard.java
License:Open Source License
@Override public boolean performFinish() { File projectDirectory = new File(ProjectManager.getInstance().getWorkspaceDirectory() + File.separator + nameSelectionPage.getProjectName()); projectDirectory.mkdirs();//from ww w . j av a2 s .c o m Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); if (projectDirectory.exists() && projectDirectory.canRead() && projectDirectory.canExecute()) { File projectFile = new File(projectDirectory, ProjectManager.FQDA_PROJECT_FILE_NAME); ObjectFactory of = new ObjectFactory(); FQDAProjectType newProject = of.createFQDAProjectType(); newProject.setName(nameSelectionPage.getProjectName()); if (projectFile.exists()) { nameSelectionPage.setErrorMessage(MessageFormat.format(Messages.NewProjectWizard_ErrorProjectExists, new Object[] { projectFile.getAbsolutePath() })); return false; } try { JAXBUtils.saveProject(projectFile); ProjectManager.getInstance().load(projectFile); new MessageDialog(shell, MSG_CREATION_SUCCEEDED_TITLE, null, MSG_CREATION_SUCCEEDED_TEXT, MessageDialog.INFORMATION, new String[] { BUTTON_OK_LABEL }, 0).open(); return true; } catch (IOException e) { e.printStackTrace(); nameSelectionPage.setErrorMessage(MessageFormat.format( Messages.NewProjectWizard_ErrorProjectCreationFailed, new Object[] { e.getMessage() })); return false; } } else { nameSelectionPage.setErrorMessage(ERROR_CANNOT_WRITE); return false; } }