Java Code Examples for org.eclipse.jface.dialogs.MessageDialog.open()

The following are Jave code examples for showing how to use open() 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: CountMarkersInFileHandler.java   Source Code and License Vote up 7 votes
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ISelection sel = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
      .getSelectionService().getSelection();
  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;
}
 
Example 2
Project: Tarski   File: DeleteAllHandler.java   Source Code and License Vote up 6 votes
@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 {
    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 3
Project: Tarski   File: CountMarkersInResourceHandler.java   Source Code and License Vote up 6 votes
@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();
    }
  }
  return null;
}
 
Example 4
Project: Tarski   File: BoundSelectionPage.java   Source Code and License Vote up 6 votes
@Override
public boolean nextPressed() throws Exception {
  // if save enabled, make sure pred has a name that not starts with number
  if (saveEnabled && (Character.isDigit(getPredName().charAt(0)) || getPredName().isEmpty())) {
    predText.forceFocus();
    return false;
  }

  String predName = getPredName();
  if (!saveEnabled)
    predName = "temp_pred_name";

  A4Solution solution =
      getAlloyToEMF().executePred(predName, generatePredAndRun(predName), saveEnabled);
  if (solution != null) {
    AlloySolutionSelectionPage nextPage = (AlloySolutionSelectionPage) getNextPage();
    nextPage.setFirstSolution(solution);
    return true;
  } else {
    MessageDialog messageDialog = new MessageDialog(getShell(), "Error", null,
        "No instance found, try changing the bounds.", MessageDialog.INFORMATION, 0,
        new String[] {"OK"});
    messageDialog.open();
    return false;
  }
}
 
Example 5
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 6
Project: Tarski   File: MappingCommand.java   Source Code and License Vote up 6 votes
@Override
public void run() {
  if (AlloyUtilities.isExists()) {
    if (this.marker != null && this.marker.exists()) {
      MappingCommand.chooseForAction(this.marker);
    } 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();
    }
  } else {
    final MessageDialog infoDialog = new MessageDialog(Activator.getShell(), "System Information",
        null, "You dont have any registered alloy file to system.", MessageDialog.INFORMATION,
        new String[] {"OK"}, 0);
    infoDialog.open();
  }
}
 
Example 7
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 8
Project: Tarski   File: MappingHandler.java   Source Code and License Vote up 6 votes
@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();
    }
  } 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 9
Project: Tarski   File: MarkHandler.java   Source Code and License Vote up 5 votes
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  if (AlloyUtilities.isExists()) {
    createMarker();
    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;
}
 
Example 10
Project: n4js   File: CreateNewN4JSElementInModuleHandler.java   Source Code and License Vote up 5 votes
/**
 * Opens the wizard with the given id and passes it the selection.
 *
 * @param wizardId
 *            The wizard id of the eclipse newWizard registry
 * @param selection
 *            The selection
 */
private void openWizardForModule(String wizardId, IStructuredSelection selection, boolean nested) {

	// Retrieve wizard from registry
	IWizardDescriptor wizardDescriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(wizardId);

	if (wizardDescriptor == null) {
		return;
	}

	try {
		IWorkbenchWizard wizard = wizardDescriptor.createWizard();

		// Inject wizard members
		injector.injectMembers(wizard);

		// Create and open a new wizard dialog
		WizardDialog wizardDialog = new WizardDialog(UIUtils.getShell(), wizard);

		// If the wizard supports it, enable in module option
		if (wizard instanceof N4JSNewClassifierWizard<?>) {
			((N4JSNewClassifierWizard<?>) wizard).init(PlatformUI.getWorkbench(), selection, nested);
		} else {
			// Otherwise just pass it the initial selection
			wizard.init(PlatformUI.getWorkbench(), selection);
		}

		// wizardDialog.setTitle(wizard.getWindowTitle());
		wizardDialog.open();

	} catch (CoreException e) {
		/** Failed to create the wizard */
		Shell workbenchShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		MessageDialog.open(MessageDialog.ERROR, workbenchShell, "Failed to launch wizard",
				String.format("Failed to launch wizard %s", wizardId), SWT.SHEET);
		return;
	}

}
 
Example 11
Project: Tarski   File: MarkAllHandler.java   Source Code and License Vote up 5 votes
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  if (AlloyUtilities.isExists()) {
    this.createMarkers();
    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;
}
 
Example 12
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 13
Project: Tarski   File: AddRemoveTypeCommand.java   Source Code and License Vote up 5 votes
private void removeType(IMarker selectedMarker) {
  selectedMarker = AnnotationFactory.convertAnnotationType(selectedMarker, true, true,
      AlloyUtilities.getTotalTargetCount(selectedMarker));

  IMarker marker = null;
  for (int i = 1; i < this.candidateToTypeChanging.size(); i++) {
    marker = this.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(Activator.getShell(),
      "Removing Type Action", null, "Selected marker's type has been removed.",
      MessageDialog.INFORMATION, new String[] {"OK"}, 0);
  removeSuccessDialog.open();
}
 
Example 14
Project: gw4e.project   File: DialogManager.java   Source Code and License Vote up 5 votes
public static int displayYesNoQuestion(String title, String text) {
	if (isAutomatedMode ()) return getIntegerAutomatedModeDefaultValue();
	MessageDialog dialog = new MessageDialog(null, title, null, text, MessageDialog.QUESTION,
			new String[] { MessageUtil.getString("yes"), MessageUtil.getString("no") }, 0);
	int result = dialog.open();
	return result;
}
 
Example 15
Project: Hydrograph   File: HiveFieldDialogHelper.java   Source Code and License Vote up 5 votes
/**
 * 
 * Message dialog to be displayed if compare_fields() method returns false. 
 * 
 */
public int Message_Dialog()
{
	
	
		MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Rearrange Fields", null,
		    Messages.HIVE_PARTI_SEQ_ERROR, MessageDialog.ERROR, new String[] { "Rearrange Schema",
		  "Rearrange Partition Fields" }, 0);
		int result = dialog.open();
		return result;
}
 
Example 16
Project: Tarski   File: MarkerMapping.java   Source Code and License Vote up 5 votes
private void run() {
  if (MarkerMapping.marker != null && MarkerMapping.marker.exists()) {
    chooseForAction(MarkerMapping.marker);
  } 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();
  }
}
 
Example 17
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 18
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 19
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 20
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();
  }
}