List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param errorMessage//from w ww. j a v a2 s. c om * @param shell */ private static void error(final String errorMessage, Shell shell) { Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.error"), null, errorMessage, //$NON-NLS-1$ MessageDialog.ERROR, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param warningMessage//from w ww . j a v a2 s .c o m * @param shell */ private static void warning(final String warningMessage, Shell shell) { Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.warning"), null, //$NON-NLS-1$ warningMessage, MessageDialog.WARNING, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java
License:Open Source License
/** * @param infoMessage// w w w . j a v a 2 s . co m * @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;/* w w w .j a v a 2s . c om*/ 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 . jav a 2s . co m // 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 va 2 s . com "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; } }
From source file:eu.modelwriter.marker.command.AddRemoveTypeHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { if (AlloyUtilities.isExists()) { candidateToTypeChanging = new ArrayList<IMarker>(); file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() .getEditorInput().getAdapter(IFile.class); selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); selectedMarker = MarkUtilities.getLeaderOfMarker(getMarker()); addRemoveType();//w ww .j av a 2 s . com if (Activator.getDefault().getWorkbench().getWorkbenchWindows()[0].getActivePage() .findView(Visualization.ID) != null) { Visualization.showViz(); } } else { final MessageDialog infoDialog = new MessageDialog(MarkerActivator.getShell(), "System Information", null, "You dont have any registered alloy file to system.", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); infoDialog.open(); } return null; }
From source file:eu.modelwriter.marker.command.AddRemoveTypeHandler.java
License:Open Source License
private void removeType(IMarker selectedMarker) { selectedMarker = AnnotationFactory.convertAnnotationType(selectedMarker, true, true, AlloyUtilities.getTotalTargetCount(selectedMarker)); IMarker marker = null;/* ww w .jav a 2s .c o m*/ for (int i = 1; i < candidateToTypeChanging.size(); i++) { marker = candidateToTypeChanging.get(i); AnnotationFactory.convertAnnotationType(marker, true, MarkUtilities.compare(marker, selectedMarker), AlloyUtilities.getTotalTargetCount(marker)); } AlloyUtilities.removeAllRelationsOfMarker(selectedMarker); AlloyUtilities.removeRelationOfMarker(selectedMarker); if (MarkUtilities.getGroupId(selectedMarker) != null) { final List<IMarker> group = MarkerFactory.findMarkersByGroupId(selectedMarker.getResource(), MarkUtilities.getGroupId(selectedMarker)); for (final IMarker iMarker : group) { AlloyUtilities.removeTypeFromMarker(iMarker); MarkUtilities.setType(iMarker, null); } } else { AlloyUtilities.removeTypeFromMarker(selectedMarker); MarkUtilities.setType(selectedMarker, null); } final MessageDialog removeSuccessDialog = new MessageDialog(MarkerActivator.getShell(), "Removing Type Action", null, "Selected marker's type has been removed.", MessageDialog.INFORMATION, new String[] { "OK" }, 0); removeSuccessDialog.open(); }
From source file:eu.modelwriter.marker.command.CountMarkersInFileHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection sel = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection();//from w w w.j a v a 2 s .c om if (sel instanceof ITreeSelection) { ITreeSelection treeSel = (ITreeSelection) sel; if (treeSel.getFirstElement() instanceof IFile) { IFile file = (IFile) treeSel.getFirstElement(); List<IMarker> markers = MarkerFactory.findMarkers(file); MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Marker Count", null, markers.size() + " marker(s)", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } } return null; }
From source file:eu.modelwriter.marker.command.CountMarkersInResourceHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = MarkerFactory.getSelection(); if (selection instanceof ITreeSelection) { ITreeSelection treeSelection = (ITreeSelection) selection; if (treeSelection.getFirstElement() instanceof IOpenable || treeSelection.getFirstElement() instanceof IFile) { IResource resource = ((IAdaptable) treeSelection.getFirstElement()).getAdapter(IResource.class); List<IMarker> markers = MarkerFactory.findMarkers(resource); MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Marker Count", null, markers.size() + " marker(s)", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); }//from w w w . ja v a 2 s.co m } return null; }