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

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

Introduction

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

Prototype

int WARNING

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

Click Source Link

Document

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

Usage

From source file:eu.geclipse.workflow.ui.internal.actions.GetJobDescriptionFromFileAction.java

License:Open Source License

/**
 * Fires up a GridFileDialog and fetches the contents of a user-chosen JSDL
 * file./*from   ww w . jav  a 2 s  .com*/
 */
public void run(final IAction action) {
    FileDialog dialog = new FileDialog(this.myShell, SWT.OPEN);
    String[] exts = { "*.jsdl" }; //$NON-NLS-1$
    dialog.setFilterExtensions(exts);
    // this bit find the root directory of the workflow
    TransactionalEditingDomain domain = this.mySelectedElement.getEditingDomain();
    ResourceSet resourceSet = domain.getResourceSet();
    Resource res = resourceSet.getResources().get(0);
    URI wfRootUri = res.getURI();
    String wfRootPath = wfRootUri.path();
    this.dirs = wfRootPath.split("/"); //$NON-NLS-1$
    String projectName = this.dirs[2];
    this.wfRootFileStore = GridModel.getRoot().getFileStore().getChild(projectName);
    dialog.setFilterPath(this.wfRootFileStore.toString());
    if (dialog.open() != null) {
        String result = dialog.getFileName();
        if ((result != null) && (result.length() > 0)) {
            String filePath = dialog.getFilterPath() + "/" + result; //$NON-NLS-1$
            // filePath = filePath.replace(' ', '+');
            java.net.URI filePathUri = null;
            filePathUri = URIUtil.toURI(filePath);
            IFile jsdlFile = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePathUri)[0];
            IWorkflowJob selectedJob = (IWorkflowJob) this.mySelectedElement.resolveSemanticElement();
            if (!(selectedJob.getName() == null && selectedJob.getJobDescription() == null)) {
                MessageDialog confirmDialog = new MessageDialog(null,
                        Messages.getString("WorkflowJobDragDropEditPolicy_confirmationTitle"), //$NON-NLS-1$
                        null, Messages.getString("WorkflowJobDragDropEditPolicy_userPrompt"), //$NON-NLS-1$
                        true ? MessageDialog.QUESTION : MessageDialog.WARNING,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
                int confirmResult = confirmDialog.open();
                if (confirmResult == 0) {
                    JSDLJobDescription jsdl = new JSDLJobDescription(jsdlFile);
                    AbstractTransactionalCommand copyCommand = new CopyJobDescToWorkflowCommand(
                            this.mySelectedElement.resolveSemanticElement(), jsdl);
                    AbstractTransactionalCommand updatePortsCommand = new UpdateJobPortsCommand(
                            GetJobDescriptionFromFileAction.this.mySelectedElement, jsdl);
                    try {
                        OperationHistoryFactory.getOperationHistory().execute(copyCommand,
                                new NullProgressMonitor(), null);
                        OperationHistoryFactory.getOperationHistory().execute(updatePortsCommand,
                                new NullProgressMonitor(), null);
                    } catch (ExecutionException eE) {
                        eE.printStackTrace();
                    }
                }
            }
        }
    }
}

From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java

License:Open Source License

/**
 * @param warningMessage//from  ww  w. j  av a 2 s. com
 * @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.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 .ja va 2s.  c  om*/
                "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.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  . ja  v a 2  s  . co 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.DeleteHandler.java

License:Open Source License

private void deleteMarker() {
    try {//from   w  ww  .  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.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;
    }//  w w w.ja v  a2s .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.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  w w. j a v  a2 s . co m*/
    } 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();
        }
    }
}

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();/*w  w  w  . ja v  a  2  s  .c o  m*/
        return;
    } else {
        MarkAllInWsWizard markAllWsWizard = new MarkAllInWsWizard(textSelection, this.file);
        WizardDialog selectionDialog = new WizardDialog(MarkerActivator.getShell(), markAllWsWizard);
        selectionDialog.open();
    }
}

From source file:eu.modelwriter.marker.command.MarkWithTypeHandler.java

License:Open Source License

private Object markWithType() {
    file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()
            .getEditorInput().getAdapter(IFile.class);
    selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
    editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();

    if (!MarkerPage.isParsed()) {
        final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Type Information", null,
                "You dont have any marker type registered to system! \n" + "Please parse an alloy file first",
                MessageDialog.INFORMATION, new String[] { "OK" }, 0);
        dialog.open();//from  w  ww.j  a  va2  s. com
        return null;
    }

    final IMarker selectedMarker = getMarker();
    if (selectedMarker != null) {
        final 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 null;
    } else if (selection instanceof ITextSelection && ((ITextSelection) selection).getLength() == 0) {
        final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information", null,
                "Please make a valid selection", MessageDialog.WARNING, new String[] { "OK" }, 0);
        dialog.open();
        return null;
    }

    final MarkerWizard markerWizard = new MarkerWizard(selection, file);
    final WizardDialog dialog = new WizardDialog(MarkerActivator.getShell(), markerWizard);
    dialog.open();

    Visualization.showViz();
    return null;
}

From source file:eu.modelwriter.marker.internal.MarkerFactory.java

License:Open Source License

/**
 * Creates a Marker from TextSelection/*w  w w.j ava  2  s  .  c  o  m*/
 */
public static IMarker createMarker(final IResource resource, final ITextSelection selection) {
    try {
        IMarker createdMarker = null;

        if (selection != null && !selection.getText().isEmpty()) {

            if (MarkerFactory.findMarkerWithAbsolutePosition(resource, selection.getOffset(),
                    selection.getOffset() + selection.getLength()) != null) {

                final 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 null;
            }

            final int start = selection.getOffset();
            final int end = selection.getOffset() + selection.getLength();

            final HashMap<String, Object> map = new HashMap<>();

            MarkerUtilities.setLineNumber(map, selection.getStartLine());
            MarkerUtilities.setMessage(map, "Marker Type : non-type");
            MarkerUtilities.setCharStart(map, start);
            MarkerUtilities.setCharEnd(map, end);
            map.put(IMarker.TEXT, selection.getText());
            map.put(IMarker.LOCATION, selection.getStartLine());
            map.put(IMarker.SOURCE_ID, MarkerFactory.generateId());
            map.put(MarkUtilities.MARKER_TYPE, null);
            MarkerUtilities.createMarker(resource, map, MarkerFactory.MARKER_MARKING);

            createdMarker = MarkerFactory.findMarkerWithAbsolutePosition(resource, start, end);

        } else {
            final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information", null,
                    "Please perform a valid selection", MessageDialog.WARNING, new String[] { "OK" }, 0);
            dialog.open();
        }
        return createdMarker;
    } catch (final CoreException e) {
        e.printStackTrace();
    }
    return null;
}