List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:eu.modelwriter.marker.command.DeleteAllHandler.java
License:Open Source License
private void deleteMarkers() { this.editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); this.file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() .getEditorInput().getAdapter(IFile.class); this.selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); try {/*from w ww . j a v a 2s.c o m*/ final IMarker beDeleted = this.getMarker(); if (beDeleted != null && beDeleted.exists()) { final MessageDialog warningDialog = new MessageDialog(MarkerActivator.getShell(), "Warning!", null, "If you delete markers, all relations of these markers has been removed! Do you want to continue to delete markers?", MessageDialog.WARNING, new String[] { "YES", "NO" }, 0); if (warningDialog.open() != 0) { return; } this.findCandidateToTypeChangingMarkers(beDeleted); final String sourceIdOfSelectedMarker = MarkUtilities.getSourceId(beDeleted); for (final IMarker iMarker : this.candidateToTypeChanging) { AnnotationFactory.convertAnnotationType(iMarker, true, MarkUtilities.compare(MarkUtilities.getSourceId(iMarker), sourceIdOfSelectedMarker), AlloyUtilities.getTotalTargetCount(iMarker)); } final String markerText = MarkUtilities.getText(beDeleted); if (MarkUtilities.getGroupId(beDeleted) != null) { final String markerGroupId = MarkUtilities.getGroupId(beDeleted); final List<IMarker> markers = MarkerFactory.findMarkersByGroupId(this.file, markerGroupId); for (int i = markers.size() - 1; i >= 0; i--) { this.deleteFromAlloyXML(markers.get(i)); AnnotationFactory.removeAnnotation(markers.get(i)); markers.get(i).delete(); } } else { this.deleteFromAlloyXML(beDeleted); AnnotationFactory.removeAnnotation(beDeleted); beDeleted.delete(); } final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark will be deleted by this wizard", null, "\"" + markerText + "\" has been selected to be unmarked", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } } catch (final CoreException e) { e.printStackTrace(); } }
From source file:eu.modelwriter.marker.command.DeleteAllHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { this.candidateToTypeChanging = new ArrayList<IMarker>(); this.deleteMarkers(); this.refresh(); if (AlloyUtilities.isExists()) { this.candidateToTypeChanging = new ArrayList<IMarker>(); this.deleteMarkers(); this.refresh(); } else {/*from ww w. j av a2 s. c o m*/ 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.DeleteHandler.java
License:Open Source License
private void deleteMarker() { try {// ww w .jav a 2 s . c o m if (marker != null && marker.exists()) { final MessageDialog warningDialog = new MessageDialog(MarkerActivator.getShell(), "Warning!", null, "If you delete marker, all relations of this marker has been removed! Do you want to continue to delete marker?", MessageDialog.WARNING, new String[] { "YES", "NO" }, 0); if (warningDialog.open() != 0) { return; } findCandidateToTypeChangingMarkers(marker); final String sourceIdOfSelectedMarker = MarkUtilities.getSourceId(marker); for (final IMarker iMarker : candidateToTypeChanging) { AnnotationFactory.convertAnnotationType(iMarker, true, MarkUtilities.compare(MarkUtilities.getSourceId(iMarker), sourceIdOfSelectedMarker), AlloyUtilities.getTotalTargetCount(iMarker)); } final String markerText = MarkUtilities.getText(marker); if (MarkUtilities.getLeaderId(marker) != null) { final String markerGroupId = MarkUtilities.getGroupId(marker); final List<IMarker> markers = MarkerFactory.findMarkersByGroupId(file, markerGroupId); for (int i = markers.size() - 1; i >= 0; i--) { deleteFromAlloyXML(markers.get(i)); AnnotationFactory.removeAnnotation(markers.get(i)); markers.get(i).delete(); } } else { deleteFromAlloyXML(marker); AnnotationFactory.removeAnnotation(marker); marker.delete(); } final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark will be deleted by this wizard", null, "\"" + markerText + "\" has been selected to be unmarked", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } } catch (final CoreException e) { e.printStackTrace(); } }
From source file:eu.modelwriter.marker.command.DeleteHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { AlloyOtherSolutionReasoning.getInstance().finish(); 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(); marker = getMarkerFromEditor();//from ww w. j ava 2s . c om deleteMarker(); refresh(); } 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.LoadSpecificationHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final MessageDialog warningdialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information", null, "If new alloy file will be parsed , your all marker type will be lost !", MessageDialog.WARNING, new String[] { "OK", "Cancel" }, 0); if (warningdialog.open() != 0) { return null; }// www. java2s.c o m final String filePath = getFilePath(); if (filePath == null) { return null; } AlloyParseUtil.parse(filePath); try { TraceManager.get().loadSpec(filePath); } catch (final TraceException e) { e.printStackTrace(); } return null; }
From source file:eu.modelwriter.marker.command.MappingHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { if (AlloyUtilities.isExists()) { MarkerMapping.getInstance().runWithSelection(); if (Activator.getDefault().getWorkbench().getWorkbenchWindows()[0].getActivePage() .findView(Visualization.ID) != null) { Visualization.showViz();//from w w w .ja v a 2s. c om } } 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.MarkAllHandler.java
License:Open Source License
private void createMarkers() { this.editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); this.file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() .getEditorInput().getAdapter(IFile.class); this.selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); ITextSelection textSelection = (ITextSelection) this.selection; if (MarkerFactory.findMarkerWithAbsolutePosition(this.file, textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength()) != null) { MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information", null, "In these area, there is already a marker", MessageDialog.WARNING, new String[] { "OK" }, 0); dialog.open(); } else {/*from www.ja v a 2 s .c om*/ String content = MarkerFactory.getCurrentEditorContent(); int index = 0; int offset = 0; int length = textSelection.getLength(); String id = UUID.randomUUID().toString(); String leader_id = UUID.randomUUID().toString(); if (length != 0) { while ((offset = content.toLowerCase().indexOf(textSelection.getText().toLowerCase(), index)) != -1) { TextSelection nextSelection = new TextSelection(MarkerFactory.getDocument(), offset, length); if (MarkerFactory.findMarkerWithAbsolutePosition(this.file, offset, offset + length) == null) { IMarker mymarker = MarkerFactory.createMarker(this.file, nextSelection); MarkUtilities.setGroupId(mymarker, id); if (textSelection.getOffset() == offset) { MarkUtilities.setLeaderId(mymarker, leader_id); } AnnotationFactory.addAnnotation(mymarker, AnnotationFactory.ANNOTATION_MARKING); this.addToAlloyXML(mymarker); } index = offset + length; } // MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), // "Mark Information will be provided by this wizard.", null, // "\"" + textSelection.getText() + "\" has been selected to be marked", // MessageDialog.INFORMATION, new String[] {"OK"}, 0); // dialog.open(); } else { MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information will be provided by this wizard.", null, "Please select a valid information", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } } }
From source file:eu.modelwriter.marker.command.MarkAllHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { if (AlloyUtilities.isExists()) { this.createMarkers(); this.refresh(); } else {/* w ww .j a v a 2s. c o m*/ 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.MarkAllInWorkspaceHandler.java
License:Open Source License
private void createMarkersWs() { ITextSelection textSelection = (ITextSelection) this.selection; if (MarkerFactory.findMarkerWithAbsolutePosition(this.file, textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength()) != null) { MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information", null, "In these area, there is already a marker", MessageDialog.WARNING, new String[] { "OK" }, 0); dialog.open(); return;/*from w w w. j av a 2s . c o m*/ } else { MarkAllInWsWizard markAllWsWizard = new MarkAllInWsWizard(textSelection, this.file); WizardDialog selectionDialog = new WizardDialog(MarkerActivator.getShell(), markAllWsWizard); selectionDialog.open(); } }
From source file:eu.modelwriter.marker.command.MarkAllInWorkspaceHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { if (AlloyUtilities.isExists()) { this.file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() .getEditorInput().getAdapter(IFile.class); this.selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection();// w w w . j a v a2 s . c om this.createMarkersWs(); this.refresh(); } else { 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; }