Java Code Examples for org.eclipse.jface.dialogs.MessageDialog.WARNING

The following are Jave code examples for showing how to use WARNING of the org.eclipse.jface.dialogs.MessageDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Tarski   File: AlloyToEMFHandler.java   Source Code and License Vote up 6 votes
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  final String alloyFilePath = MarkerPage.settings.get("alloyFile");
  try {
    TraceManager.get().loadSpec(alloyFilePath);
    final AlloyToEMF alloy2emf = new AlloyToEMF(alloyFilePath);
    alloy2emf.start();
    Display.getDefault().syncExec(new Runnable() {

      @Override
      public void run() {
        Visualization.showViz();
      }
    });
  } catch (final TraceException e) {
    final MessageDialog warningdialog = new MessageDialog(MarkerActivator.getShell(),
        "Alloy To EMF", null, e.getMessage(), MessageDialog.WARNING, new String[] {"OK"}, 0);
    if (warningdialog.open() != 0) {
      return null;
    }
  }
  return null;
}
 
Example 2
Project: Tarski   File: LoadSpecificationHandler.java   Source Code and License Vote up 6 votes
@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;
  }

  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;
}
 
Example 3
Project: Tarski   File: EmfToAlloyHandler.java   Source Code and License Vote up 6 votes
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    IFile file = AlloyParseUtil.getSelectedFile();
    if (file != null) {
      EMFToAlloy emfToAlloy = new EMFToAlloy(file);
      emfToAlloy.start();
    }
  } catch (IOException e) {
    final MessageDialog warningdialog =
        new MessageDialog(MarkerActivator.getShell(), "Alloy Example To EMF", null,
            e.getMessage(), MessageDialog.WARNING, new String[] {"OK"}, 0);
    if (warningdialog.open() != 0) {
      return null;
    }
    e.printStackTrace();
  }
  return null;
}
 
Example 4
Project: Tarski   File: MarkerMappingActionHyperlink.java   Source Code and License Vote up 6 votes
@Override
public void open() {

  final IFile file = MarkerActivator.getEditor().getEditorInput().getAdapter(IFile.class);

  final int start = this.fUrlRegion.getOffset();
  final int end = this.fUrlRegion.getOffset() + this.fUrlRegion.getLength();
  final IMarker beMapped = MarkerFactory.findMarkerWithAbsolutePosition(file, start, end);

  if (beMapped != null) {
    MarkerMapping.getInstance().runWithMarker(beMapped);
  } else {
    final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information",
        null, "Something goes wrong with this text fragments", MessageDialog.WARNING,
        new String[] {"OK"}, 0);
    dialog.open();
  }
}
 
Example 5
Project: Tarski   File: DeleteAllTraceElementsHandler.java   Source Code and License Vote up 5 votes
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  final MessageDialog warningDialog = new MessageDialog(MarkerActivator.getShell(), "Warning!",
      null, "You are about to delete all markers! Do you want to continue?",
      MessageDialog.WARNING, new String[] {"Yes", "No"}, 0);
  if (warningDialog.open() != 0) {
    return null;
  }

  if (AlloyUtilities.isExists()) {
    AlloyOtherSolutionReasoning.getInstance().finish();

    AlloyUtilities.clearRepository();
    AlloyUtilities.clearRelation();
    AlloyUtilities.clearSigs();
    AlloyUtilities.clearFields();

    try {
      ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(MarkerFactory.MARKER_MARKING, true,
          IResource.DEPTH_INFINITE);
    } catch (final CoreException e) {
      e.printStackTrace();
    }

    refreshActiveEditor();
  } 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;
}
 
Example 6
Project: Tarski   File: MarkAllInWorkspaceHandler.java   Source Code and License Vote up 5 votes
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;
  } else {
    MarkAllInWsWizard markAllWsWizard = new MarkAllInWsWizard(textSelection, this.file);
    WizardDialog selectionDialog = new WizardDialog(MarkerActivator.getShell(), markAllWsWizard);
    selectionDialog.open();
  }
}
 
Example 7
Project: Tarski   File: DeleteAllHandler.java   Source Code and License Vote up 4 votes
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 {
    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();
  }
}
 
Example 8
Project: Tarski   File: AddRemoveTypeHandler.java   Source Code and License Vote up 4 votes
private void addRemoveType() {
  if (!MarkerPage.isParsed()) {
    final MessageDialog parseCtrlDialog =
        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);
    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;
  }
}
 
Example 9
Project: Tarski   File: DeleteHandler.java   Source Code and License Vote up 4 votes
private void deleteMarker() {
  try {
    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();
  }
}
 
Example 10
Project: Tarski   File: UpdateSpecificationHandler.java   Source Code and License Vote up 4 votes
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  final String filePath = getFilePath();
  if (filePath == null) {
    return null;
  }

  final IEditorPart editor = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
      .getActivePage().getActiveEditor();;

  if (editor == null) {
    return null;
  }

  if (editor.isDirty()) {
    final IFile file = ResourceUtil.getFile(editor.getEditorInput());
    final MessageDialog warningdialog =
        new MessageDialog(MarkerActivator.getShell(), "Save Specification", null,
            file.getName()
                + " has been modified. You must save file for update the specification. Do you want to save now?",
            MessageDialog.WARNING, new String[] {"Yes", "No"}, 0);
    if (warningdialog.open() != 0) {
      return null;
    }

    AlloyOtherSolutionReasoning.getInstance().finish();
    editor.doSave(new NullProgressMonitor());
  }

  final String content = getContent(filePath);
  if (content == null) {
    return null;
  }

  AlloyUtilities.updateSpec(filePath, content);

  try {
    TraceManager.get().loadSpec(filePath);
  } catch (final TraceException e) {
    e.printStackTrace();
  }

  final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Status Information",
      null, "Specification has been updated.", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
  dialog.open();

  return null;
}
 
Example 11
Project: Tarski   File: AlloyToEMF.java   Source Code and License Vote up 4 votes
public void onException(TraceException e) {
  final MessageDialog warningdialog = new MessageDialog(null, "Alloy To EMF", null,
      e.getMessage(), MessageDialog.WARNING, new String[] {"OK"}, 0);
  warningdialog.open();
}
 
Example 12
Project: Tarski   File: AddRemoveTypeCommand.java   Source Code and License Vote up 4 votes
private void addRemoveType() {
  if (!MarkerPage.isParsed()) {
    final MessageDialog parseCtrlDialog =
        new MessageDialog(Activator.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);
    parseCtrlDialog.open();
    return;
  }

  final ActionSelectionDialog actionSelectionDialog =
      new ActionSelectionDialog(Activator.getShell());
  actionSelectionDialog.open();
  if (actionSelectionDialog.getReturnCode() == IDialogConstants.CANCEL_ID) {
    return;
  }

  IMarker selectedMarker = this.marker;
  selectedMarker = MarkUtilities.getLeaderOfMarker(selectedMarker);

  if (selectedMarker != null && selectedMarker.exists()) {
    this.findCandidateToTypeChangingMarkers(selectedMarker);
    if (actionSelectionDialog.getReturnCode() == IDialogConstants.YES_ID) {
      AddRemoveTypeCommand.addType(selectedMarker);
    } else if (actionSelectionDialog.getReturnCode() == IDialogConstants.NO_ID) {
      final MessageDialog warningDialog =
          new MessageDialog(Activator.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;
      }
      this.removeType(selectedMarker);
    }
  } else {
    final MessageDialog dialog =
        new MessageDialog(Activator.getShell(), "There is no marker in this position", null,
            "Please select valid marker", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
    dialog.open();
    return;
  }
}
 
Example 13
Project: Tarski   File: DeleteAtomCommand.java   Source Code and License Vote up 4 votes
private void deleteMarker() {
  try {
    final IMarker beDeleted = marker;
    if (beDeleted != null && beDeleted.exists()) {
      final MessageDialog warningDialog =
          new MessageDialog(Activator.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(beDeleted);
      final String sourceIdOfSelectedMarker = MarkUtilities.getSourceId(beDeleted);

      for (final IMarker iMarker : candidateToTypeChanging) {
        AnnotationFactory.convertAnnotationType(iMarker, true,
            MarkUtilities.compare(MarkUtilities.getSourceId(iMarker), sourceIdOfSelectedMarker),
            AlloyUtilities.getTotalTargetCount(iMarker));
      }
      final String markerText = MarkUtilities.getText(beDeleted);

      if (MarkUtilities.getLeaderId(beDeleted) != null) {
        final String markerGroupId = MarkUtilities.getGroupId(beDeleted);
        final List<IMarker> markers =
            MarkerFactory.findMarkersByGroupId(beDeleted.getResource(), 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(beDeleted);
        AnnotationFactory.removeAnnotation(beDeleted);
        beDeleted.delete();
      }
      final MessageDialog dialog =
          new MessageDialog(Activator.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();
  }
}