Example usage for org.eclipse.jface.dialogs MessageDialog INFORMATION

List of usage examples for org.eclipse.jface.dialogs MessageDialog INFORMATION

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog INFORMATION.

Prototype

int INFORMATION

To view the source code for org.eclipse.jface.dialogs MessageDialog INFORMATION.

Click Source Link

Document

Constant for the info image, or a simple dialog with the info image and a single OK button (value 2).

Usage

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 w w .j av a2 s.c om*/
        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;//from  ww w.j a  v a 2s.  c om
    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 a2s  . c  o  m*/
    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 . j  a v a 2  s. c o  m*/
        }
    }
    return null;
}

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 ww w  .  jav a 2  s.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 a 2s. co 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 {/* w  ww.  j a  v  a2  s  . co  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();/*w  w w.ja v  a 2s  . co  m*/

        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.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();/* w w  w  .  jav  a2s .  c  o  m*/
        }
    } 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();/*from   w  ww .jav a 2s.com*/
    } else {
        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();
        }
    }
}