List of usage examples for org.eclipse.jface.dialogs MessageDialog INFORMATION
int INFORMATION
To view the source code for org.eclipse.jface.dialogs MessageDialog INFORMATION.
Click Source Link
From source file:edu.pitt.dbmi.odie.ui.editors.analysis.ProposalsSection.java
License:Apache License
private void hookMyListeners() { ontologyTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override// w ww . ja va 2s. c o m public void selectionChanged(SelectionChangedEvent event) { if (ontologyTree.getViewer().getSelection().isEmpty()) { remButton.setEnabled(false); // noteButton.setEnabled(false); } else { remButton.setEnabled(true); List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection()).toList(); if (items.size() == 1) { // bioportalButton.setEnabled(true); IClass cl = items.get(0); // noteButton.setEnabled(!GeneralUtils.isProxyClass(cl)); } else { // noteButton.setEnabled(false); } } } }); addButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleSelection(); } private void handleSelection() { GeneralUtils .addToProposalOntologyWithDialog(((AnalysisEditorInput) editor.getEditorInput()).analysis); ontologyTree.refresh(); } @Override public void widgetSelected(SelectionEvent e) { handleSelection(); } }); remButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleSelection(); } private void handleSelection() { if (ontologyTree.getViewer().getSelection().isEmpty()) return; List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection()).toList(); String itemNames = ""; if (items.size() > 0) itemNames = "the selected concepts"; else itemNames = "'" + (items.get(0)).getName() + "'"; IOntology ontology = items.get(0).getOntology(); if (MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Remove Concept", "Are you sure you want to remove " + itemNames)) { for (IClass item : items) item.delete(); try { ontology.save(); Analysis analysis = ((AnalysisEditorInput) editor.getEditorInput()).getAnalysis(); GeneralUtils.refreshProposalLexicalSet(analysis); ontologyTree.refresh(); } catch (IOntologyException e) { e.printStackTrace(); GeneralUtils.showErrorDialog("Error", e.getMessage()); } } } @Override public void widgetSelected(SelectionEvent e) { handleSelection(); } }); shareButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } @Override public void widgetSelected(SelectionEvent e) { final Shell dialog = new Shell(GeneralUtils.getShell(), SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM); dialog.setText("Share"); dialog.setLayout(new GridLayout(3, true)); final Label label = new Label(dialog, SWT.NONE); label.setText("Select the community to contribute to"); GridData gd = new GridData(); gd.horizontalSpan = 3; gd.horizontalAlignment = SWT.LEFT; label.setLayoutData(gd); Button bioportalButton = new Button(dialog, SWT.PUSH); bioportalButton.setText("Bioportal"); gd = new GridData(); gd.horizontalAlignment = SWT.CENTER; bioportalButton.setLayoutData(gd); Button neuroLexButton = new Button(dialog, SWT.PUSH); neuroLexButton.setText("NeuroLex Wiki"); gd = new GridData(); gd.horizontalAlignment = SWT.CENTER; neuroLexButton.setLayoutData(gd); Button buttonCancel = new Button(dialog, SWT.PUSH); buttonCancel.setText("Cancel"); gd = new GridData(); gd.horizontalAlignment = SWT.CENTER; buttonCancel.setLayoutData(gd); dialog.pack(); Aesthetics.centerDialog(dialog); neuroLexButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (MessageDialog.openQuestion(GeneralUtils.getShell(), "Share on NeuroLex Wiki", "Do you want to create a new wiki page for the concept in the NeuroLex Wiki?")) { List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection()) .toList(); if (items.size() > 0) { IClass newc = items.get(0); String urlString = ODIEConstants.NEUROLEX_WIKI_CREATE_PAGE_PREFIX + newc.getName(); try { GeneralUtils.openURL(new URL(urlString)); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } dialog.close(); } } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); buttonCancel.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { dialog.close(); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); bioportalButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleSelection(); dialog.close(); } private void handleSelection() { if (ontologyTree.getViewer().getSelection().isEmpty()) { GeneralUtils.showErrorDialog("No Concept Selected", "Please select a new proposal concept to be suggested in the Bioportal Note"); return; } List<IClass> items = ((StructuredSelection) ontologyTree.getViewer().getSelection()) .toList(); if (items.size() > 0) { IClass newc = items.get(0); String bpURIStr = (String) newc .getPropertyValue(newc.getOntology().getProperty(IProperty.RDFS_IS_DEFINED_BY)); if (bpURIStr != null) { GeneralUtils.showErrorDialog("Concept already in Bioportal", newc.getName() + " is already part of an existing Bioportal " + "ontology. Please select a newly created concept to be submitted as a Bioportal note"); return; } IProperty p = newc.getOntology().getProperty(ODIEConstants.BIOPORTAL_NOTE_ID_PROPERTY); IProperty op = newc.getOntology() .getProperty(ODIEConstants.BIOPORTAL_ONTOLOGY_ID_PROPERTY); if (p != null) { String noteid = (String) newc.getPropertyValue(p); String ontologyid = (String) newc.getPropertyValue(op); if (noteid != null && ontologyid != null) { MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Bioportal note already exists", null, "A bioportal note was previously created for this concept.", MessageDialog.INFORMATION, new String[] { "View in Bioportal", IDialogConstants.OK_LABEL }, 0); int index = dialog.open(); if (index == 0) { String url = BioPortalRepository.DEFAULT_BIOPORTAL_URL + ontologyid + "/?noteid=" + noteid; try { GeneralUtils.openURL(new URL(url)); } catch (MalformedURLException e) { e.printStackTrace(); } } return; } } Analysis analysis = ((AnalysisEditorInput) editor.getEditorInput()).getAnalysis(); MiddleTier mt = Activator.getDefault().getMiddleTier(); BioportalNewProposalNoteWizard wizard = new BioportalNewProposalNoteWizard(analysis, newc); WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard); dialog.open(); } } @Override public void widgetSelected(SelectionEvent e) { handleSelection(); dialog.close(); } }); dialog.open(); } }); exportButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleSelection(); } private void handleSelection() { GeneralUtils.exportOntologyToCSVWithDialog((IOntology) ontologyTree.getViewer().getInput()); } @Override public void widgetSelected(SelectionEvent e) { handleSelection(); } }); }
From source file:edu.toronto.cs.se.modelepedia.petrinet.operator.PetriNetSimulate.java
License:Open Source License
@Override public EList<Model> execute(EList<Model> actualParameters) throws Exception { // simulate//from w w w.java 2 s . c o m PetriNet petrinet = (PetriNet) actualParameters.get(0).getEMFInstanceRoot(); boolean goodResult = !petrinet.getNodes().isEmpty(); // show result Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); int dialogType = (goodResult) ? MessageDialog.INFORMATION : MessageDialog.ERROR; String dialogMessage = (goodResult) ? "Good simulation result" : "Bad simulation result"; MessageDialog dialog = new MessageDialog(shell, "Simulation results", null, dialogMessage, dialogType, new String[] { "Ok" }, 0); dialog.open(); return null; }
From source file:eu.aniketos.securebpmn.util.DialogUtil.java
License:Apache License
/** * Opens a dialog window that contains an image and a message. * * @param title/*from w ww . jav a 2 s . co m*/ * The title of the message window. * @param message * The message to be displayed in the window. * @param image * The image that should be displayed in the window. * @param buttons * The labels of the Buttons the window should contain. * @param defaultButton * The index of the Button that should be selected by default. * @return The index of the Button that was pressed. */ public static int openMessageDialog(String title, String message, int image, String[] buttons, int defaultButton) { MessageDialog dialog; switch (image) { case INFO: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.INFORMATION, buttons, defaultButton); break; case WARNING: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.WARNING, buttons, defaultButton); break; case ERROR: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR, buttons, defaultButton); break; default: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.NONE, buttons, defaultButton); break; } return dialog.open(); }
From source file:eu.esdihumboldt.hale.io.haleconnect.ui.projects.ShareProjectWizard.java
License:Open Source License
@Override public boolean performFinish() { boolean result = super.performFinish(); if (result) { try {/*from w ww .ja va 2 s . c o m*/ URI clientAccessUrl = this.getProvider().getClientAccessUrl(); MessageDialog successDialog = new MessageDialog(getShell(), "Project upload successful", null, "Project was successfully uploaded to hale connect.", MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0) { @Override protected Control createCustomArea(Composite parent) { Link link = new Link(parent, SWT.WRAP); link.setText(MessageFormat.format( "To access this project online, please visit the following URL (login may be required):\n<a href=\"{0}\">{0}</a>.", clientAccessUrl)); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { // Open default external browser PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() .openURL(new URL(e.text)); } catch (Exception ex) { log.error(MessageFormat.format("Error opening browser: {0}", ex.getMessage()), e); } } }); return link; } }; successDialog.open(); log.info(MessageFormat.format( "Project was successfully uploaded to hale connect and is available online at \"{0}\"", clientAccessUrl)); } catch (IllegalArgumentException e) { // bad base path? log.error(MessageFormat.format("Error creating client access URL: {0}", e.getMessage()), e); log.userInfo("Project was successfully uploaded to hale connect."); } } return result; }
From source file:eu.hydrologis.jgrass.console.editor.actions.ConsoleEditorActionCompile.java
License:Open Source License
public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { JGrass console = ConsolePlugin.console(); if (null == console) { MessageDialog dialog = new MessageDialog(null, "Info", null, "Missing JGrass ConsoleEngine.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.setBlockOnOpen(true); dialog.open();//from w w w . j av a 2 s. co m } else { // JavaEditor editor = (JavaEditor) getTextEditor(); // ProjectOptions projectOptions = editor.projectOptions(); // PreferencesInitializer.initialize(projectOptions); // projectOptions // .setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(true)); // IDocument doc = editor.getDocumentProvider().getDocument( // editor.getEditorInput()); // editor.getTextConsole().clearConsole(); // console.dispatch(projectOptions, doc.get()); // String text = null; JavaEditor editor = (JavaEditor) getTextEditor(); ISelection selection = editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (!textSelection.isEmpty()) { text = textSelection.getText(); } } ProjectOptions projectOptions = editor.projectOptions(); PreferencesInitializer.initialize(projectOptions); // FIXME check how GRASS preferences are saved in the preferencespage // Object option = projectOptions.getOption(ProjectOptions.COMMON_GRASS_MAPSET); projectOptions.setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(true)); IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); editor.getTextConsole().clearConsole(); if (text == null || 0 >= text.length()) { text = doc.get(); } console.dispatch(projectOptions, text); } } }); }
From source file:eu.hydrologis.jgrass.console.editor.actions.ConsoleEditorActionRun.java
License:Open Source License
public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { JGrass console = ConsolePlugin.console(); if (null == console) { MessageDialog dialog = new MessageDialog(null, "Info", null, "Missing JGrass ConsoleEngine.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.setBlockOnOpen(true); dialog.open();//from ww w . ja v a 2 s . c o m } else { JavaEditor editor = (JavaEditor) getTextEditor(); IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); editor.getTextConsole().clearConsole(); ProjectOptions projectOptions = editor.projectOptions(); PreferencesInitializer.initialize(projectOptions); projectOptions.setOption(ProjectOptions.CONSOLE_COMPILE_ONLY, new Boolean(false)); String text = null; ISelection selection = editor.getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (!textSelection.isEmpty()) { text = textSelection.getText(); } } if (text == null || 0 >= text.length()) { text = doc.get(); } if (text != null) { List<String> commandsOnly = new ArrayList<String>(); List<String> settingsOnly = new ArrayList<String>(); // extract only the commands String[] scriptSplit = text.split("\n"); //$NON-NLS-1$ for (String string : scriptSplit) { if (string.trim().startsWith("#")) { continue; } commandsOnly.add(string); } // from the whole document extract the settings, even id not selected String allText = doc.get(); String[] allSplit = allText.split("\n"); //$NON-NLS-1$ for (String string : allSplit) { if (string.trim().startsWith("#")) { settingsOnly.add(string); } } StringBuffer sB = new StringBuffer(); for (String string : settingsOnly) { sB.append(string).append("\n"); } sB.append("\n\n"); for (String string : commandsOnly) { sB.append(string).append("\n"); } text = sB.toString(); } console.dispatch(projectOptions, text); } } }); }
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param infoMessage/*ww w. j a va2 s. com*/ * @param shell */ private static void info(final String infoMessage, final Shell shell) { Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.Info"), null, infoMessage, //$NON-NLS-1$ MessageDialog.INFORMATION, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.modelwriter.configuration.alloy.AlloyParser.java
License:Open Source License
private MarkerTypeElement convertToMarkerType(final Sig rootSig) { if (rootSig instanceof PrimSig) { final PrimSig primSig = (PrimSig) rootSig; MarkerTypeElement rootType;/* ww w.ja va 2s . c o m*/ if (primSig.isAbstract != null) { rootType = new MarkerTypeElement( primSig.toString().substring(primSig.toString().indexOf("/") + 1) + " {abs}"); } else { rootType = new MarkerTypeElement(primSig.toString().substring(primSig.toString().indexOf("/") + 1)); } try { if (primSig.children().isEmpty()) { return rootType; } else { for (int i = 0; i < primSig.children().size(); i++) { rootType.getChildren().add(this.convertToMarkerType(primSig.children().get(i))); } return rootType; } } catch (final Err e) { final MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Alloy Error Information", null, e.getMessage(), MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } } else if (rootSig instanceof SubsetSig) { final SubsetSig subsetSig = (SubsetSig) rootSig; String parentName = subsetSig.type().toString(); parentName = parentName.substring(parentName.indexOf("/") + 1, parentName.length() - 1); final MarkerTypeElement parentMarkerType = this.getMarkTypeElementByName(parentName, this.types); parentMarkerType.getChildren().add( new MarkerTypeElement(subsetSig.toString().substring(subsetSig.toString().indexOf("/") + 1))); } return null; }
From source file:eu.modelwriter.configuration.alloy.AlloyParser.java
License:Open Source License
private void parse(final String filename) { // AlloyUtilities.createXMLFromAlloy(filename); try {/* w w w. ja v a 2 s. c om*/ // Parse+typecheck the model // System.out.println("=========== Parsing+Typechecking " + filename + " ============="); Module world; final DocumentRoot documentRoot = this.createBaseXmlFile(); final EList<SigType> xmlSigList = documentRoot.getAlloy().getInstance().getSig(); final EList<FieldType> xmlFieldList = documentRoot.getAlloy().getInstance().getField(); int idIndex = 4; final Map<String, String> map = new LinkedHashMap<String, String>(); world = CompUtil.parseEverything_fromFile(new A4Reporter(), map, filename); for (final Module modules : world.getAllReachableModules()) { final SafeList<Sig> list = modules.getAllSigs(); for (final Sig sig : list) { if (sig instanceof PrimSig) { final PrimSig primSig = (PrimSig) sig; xmlSigList.add(this.getSigType(primSig, idIndex, xmlSigList)); idIndex++; if (primSig.children().size() == 0 && primSig.toString() .substring(primSig.toString().indexOf("/") + 1).equals("Univ")) { break; } if (primSig.isTopLevel()) { this.types.add(this.convertToMarkerType(primSig)); } } else if (sig instanceof SubsetSig) { final SubsetSig subsetSig = (SubsetSig) sig; this.convertToMarkerType(subsetSig); xmlSigList.add(this.getSigType(subsetSig, idIndex, xmlSigList)); idIndex++; // this.types.add(this.convertToMarkerType(subsetSig)); } } } this.setParentIdForSigTypes(xmlSigList); for (final Module modules : world.getAllReachableModules()) { final SafeList<Sig> list = modules.getAllSigs(); for (final Sig sig : list) { final SafeList<Field> fields = sig.getFields(); for (final Field field : fields) { xmlFieldList.add(this.getFieldType(field, idIndex, xmlFieldList, xmlSigList)); idIndex++; String product = ""; if (field.decl().expr.type().size() > 1) { final Iterator<ProductType> iter = field.decl().expr.type().iterator(); while (iter.hasNext()) { final Type.ProductType productType = iter.next(); if (iter.hasNext()) { product += productType.toString() .substring(productType.toString().indexOf("/") + 1) + ","; } else { product += productType.toString() .substring(productType.toString().indexOf("/") + 1); } } } else { product = field.decl().expr.type().toExpr().toString() .substring(field.decl().expr.type().toExpr().toString().indexOf("/") + 1); } final String str2 = field.label + " : " + field.sig.toString().substring(field.sig.toString().indexOf("/") + 1) + " -> " + field.decl().expr.mult() + " " + product; this.rels.add(str2); } } } final Iterator<Entry<String, String>> mapIter = map.entrySet().iterator(); while (mapIter.hasNext()) { final Entry<String, String> entry = mapIter.next(); final SourceType sourceType = persistenceFactory.eINSTANCE.createSourceType(); sourceType.setFilename(entry.getKey()); sourceType.setContent(entry.getValue()); documentRoot.getAlloy().getSource().add(sourceType); } AlloyUtilities.writeDocumentRoot(documentRoot); // AlloyUtilities.saveResource(AlloyUtilities.getResource(), documentRoot); final MessageDialog messageDialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Information", null, "Alloy file has been parsed succesfully", MessageDialog.INFORMATION, new String[] { "OK" }, 0); messageDialog.open(); } catch (final Err e) { final MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Alloy Error Information", null, e.getMessage(), MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } }
From source file:eu.modelwriter.marker.command.AddRemoveTypeHandler.java
License:Open Source License
private void addRemoveType() { if (!MarkerPage.isParsed()) { final MessageDialog parseCtrlDialog = new MessageDialog(MarkerActivator.getShell(), "Type Information", null,/* w ww . j a v a 2s . co m*/ "You dont have any marker type registered to system! \n" + "Please parse an alloy file first", MessageDialog.INFORMATION, new String[] { "OK" }, 0); parseCtrlDialog.open(); return; } final ActionSelectionDialog actionSelectionDialog = new ActionSelectionDialog(MarkerActivator.getShell()); actionSelectionDialog.open(); if (actionSelectionDialog.getReturnCode() == IDialogConstants.CANCEL_ID) { return; } if (selectedMarker != null && selectedMarker.exists()) { findCandidateToTypeChangingMarkers(selectedMarker); if (actionSelectionDialog.getReturnCode() == IDialogConstants.YES_ID) { addType(selectedMarker); } else if (actionSelectionDialog.getReturnCode() == IDialogConstants.NO_ID) { final MessageDialog warningDialog = new MessageDialog(MarkerActivator.getShell(), "Warning!", null, "If you remove marker's type, all relations of this marker has been removed! Do you want to continue to remove marker's type?", MessageDialog.WARNING, new String[] { "Yes", "No" }, 0); final int returnCode = warningDialog.open(); if (returnCode != 0) { return; } removeType(selectedMarker); } // MarkerUpdater.updateTargets(selectedMarker); // MarkerUpdater.updateSources(selectedMarker); } else { final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "There is no marker in this position", null, "Please select valid marker", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.open(); return; } }