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

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

Introduction

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

Prototype

public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
        int dialogImageType, int defaultIndex, String... dialogButtonLabels) 

Source Link

Document

Create a message dialog.

Usage

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,/*from   w ww.  j  av a  2  s .  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;
    }
}

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();//from   w w w.  jav a  2s . 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  .ja v  a2s .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   ww w .  j a v a  2 s.  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 www  .  j a  va 2  s  . c  om*/
        }
    }
    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 {/* w w w.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 {/* www.  j ava2s  .  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 {/*w w  w.  j a v  a 2s  .  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();//  w  w  w  .  j  av a 2 s .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;
    }//from www.j a v a2  s. 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;
}