Java Code Examples for org.eclipse.ui.handlers.HandlerUtil#getCurrentSelectionChecked()

The following examples show how to use org.eclipse.ui.handlers.HandlerUtil#getCurrentSelectionChecked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenReportHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public @Nullable Object execute(@Nullable ExecutionEvent event) throws ExecutionException {

    /* Types should have been checked by the plugin.xml already */
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    List<?> elements = ((IStructuredSelection) selection).toList();

    Display.getDefault().syncExec(() -> elements.stream()
            .filter(TmfReportElement.class::isInstance)
            .map(TmfReportElement.class::cast)
            .map(TmfReportElement::getReport)
            .filter(LamiAnalysisReport.class::isInstance)
            .map(LamiAnalysisReport.class::cast)
            .forEach(lamiReport -> {
                try {
                    LamiReportViewFactory.createNewView(lamiReport);
                } catch (PartInitException e) {
                }
            }));

    return null;
}
 
Example 2
Source File: MergeTermsHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() > 1) {
		List<Term> termsToMerge = new ArrayList<>(currentSelection.size());
		currentSelection.toList().stream().filter(s -> s instanceof Term).forEach(s -> termsToMerge.add((Term) s));
		if (selectionValid(termsToMerge)) {
			MergeTermsDialog dialog = new MergeTermsDialog(null, termsToMerge);
			dialog.setBlockOnOpen(true);
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermMerger.merge(termsToMerge, dialog.getTargetTerm());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected terms must not share their paths.", null));
		}
		
	}
	return null;
}
 
Example 3
Source File: SplitTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term termToSplit = (Term) currentSelection.getFirstElement();
		if (selectionValid(termToSplit)) {
			SplitTermDialog dialog = new SplitTermDialog(null, termToSplit.getName());
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermSplitter.split(termToSplit, dialog.getDefaultTermName(), dialog.getFurtherTermNames());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected term must not have children.", null));
		}
	}
	return null;
}
 
Example 4
Source File: RenameTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {			
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term term = (Term) currentSelection.getFirstElement();	
		InputDialog dialog = new InputDialog(
				null,
				"Rename Term", 
				"Rename Term: " + term.getName() + " to:",
				term.getName(),
				null);
		dialog.setBlockOnOpen(true);
		if (dialog.open() == InputDialog.OK) {
			TermRenamer.rename(term, dialog.getValue());
		}
	}		
	return null;
}
 
Example 5
Source File: CreateTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term term = (Term) currentSelection.getFirstElement();	
		CreateTermDialog dialog = new CreateTermDialog(null, term.getName());
		dialog.setBlockOnOpen(true);
		if (dialog.open() == InputDialog.OK) {
			TermCreator.create(dialog.getTermName(), term, dialog.getTermPosition());							
		}
	}	
	return null;
}
 
Example 6
Source File: OpenBubbleChartHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	// get selection
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	List<BubbleDataContainer> data = processSelectionData((IStructuredSelection) selection);

	boolean dataWrittenSuccessfully = false;
	try {
		// overwrite csv with new data
		dataWrittenSuccessfully = overwriteCSVFile(data);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	// open website in default browser
	if (dataWrittenSuccessfully) {
		Program.launch(Activator.getUrl() + "bubble.index.html");
	}

	return null;
}
 
Example 7
Source File: RefreshHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    if (selection instanceof IStructuredSelection) {
        for (Object element : ((IStructuredSelection) selection).toList()) {
            if (element instanceof ITmfProjectModelElement) {
                IResource resource = ((ITmfProjectModelElement) element).getResource();
                if (resource != null) {
                    try {
                        resource.refreshLocal(IResource.DEPTH_INFINITE, null);
                    } catch (CoreException e) {
                        Activator.getDefault().logError("Error refreshing projects", e); //$NON-NLS-1$
                    }
                }
            }
        }
    }
    return null;
}
 
Example 8
Source File: NewModelHandlerSelectedDelegate.java    From tlaplus with MIT License 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	/*
	 * Try to get the spec from active navigator if any
	 */
	final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection != null && selection instanceof IStructuredSelection
			&& ((IStructuredSelection) selection).size() == 1) {
		Object selected = ((IStructuredSelection) selection).getFirstElement();
		if (selected instanceof ModelContentProvider.Group) {
			// Convert the group to its corresponding spec
			selected = ((Group) selected).getSpec();
		}

		if (selected instanceof Spec) {
			final Map<String, String> parameters = new HashMap<String, String>();
			// fill the spec name for the handler
			parameters.put(NewModelHandler.PARAM_SPEC_NAME, ((Spec) selected).getName());
			// delegate the call to the new model handler
			UIHelper.runCommand(NewModelHandler.COMMAND_ID, parameters);
		}
	}
	return null;
}
 
Example 9
Source File: OpenModelHandlerDelegate.java    From tlaplus with MIT License 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
    /*
     * Try to get the spec from active navigator if any
     */
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    if (selection != null && selection instanceof IStructuredSelection
            && ((IStructuredSelection) selection).size() == 1)
    {
        Object selected = ((IStructuredSelection) selection).getFirstElement();
        if (selected instanceof Model)
        {
            Map<String, String> parameters = new HashMap<String, String>();

            // fill the model name for the handler
            parameters.put(OpenModelHandler.PARAM_MODEL_NAME, ((Model) selected).getName());
            // delegate the call to the open model handler
            UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
        }
    }
    return null;
}
 
Example 10
Source File: ProjectFromSelectionHelper.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
public static List<IProject> getProjects(ExecutionEvent event) throws ExecutionException {
  List<IProject> projects = new ArrayList<>();

  ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
  if (selection instanceof IStructuredSelection) {
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    for (Object selected : structuredSelection.toList()) {
      IProject project = AdapterUtil.adapt(selected, IProject.class);
      if (project != null) {
        projects.add(project);
      }
    }
  }

  return projects;
}
 
Example 11
Source File: XpectCompareCommandHandler.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
Example 12
Source File: DeleteReportHandler.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public @Nullable Object execute(@Nullable ExecutionEvent event) throws ExecutionException {
    /* Types should have been checked by the plugin.xml already */
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    List<?> elements = ((IStructuredSelection) selection).toList();

    /* Ask the parent element to remove each corresponding report. */
    elements.stream()
            .filter(TmfReportElement.class::isInstance)
            .map(TmfReportElement.class::cast)
            .forEach(reportElem -> reportElem.getParent().removeReport(reportElem.getReport()));

    return null;
}
 
Example 13
Source File: DeleteTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() > 0) {			
		MessageDialog dialog = new MessageDialog(null,
				"Delete Term",
				null,
				"Are you sure you want to delete terms: " + 
						currentSelection.toList()
							.stream()
							.filter(s -> s instanceof Term)
							.map(s -> ((Term) s).getName())
							.collect(Collectors.joining(", ")),
				MessageDialog.QUESTION,
				new String[]{"Yes", "Cancel"},
				0);
		dialog.setBlockOnOpen(true);
		if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
			List<Term> termsToDelete = new ArrayList<>(currentSelection.size());
			currentSelection.toList().stream()
					.filter(s -> s instanceof Term)
					.forEach(s -> termsToDelete.add((Term) s));;
			TermDeleter.delete(termsToDelete);
		}
	}
	
	return null;
}
 
Example 14
Source File: MoveTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() > 0 ) {
		List<Term> termsToMove = new ArrayList<>(currentSelection.size());
		currentSelection.toList().stream().filter(s -> s instanceof Term).forEach(s -> termsToMove.add((Term) s));
		if (selectionValid(termsToMove)) {
			Model allowedTargets = computeAllowedTargets(termsToMove);				
			MoveTermDialog dialog = new MoveTermDialog(
					null, 
					termsToMove.stream().map(t -> t.getName()).collect(Collectors.toList()), 
					allowedTargets);
			dialog.setBlockOnOpen(true);
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermMover.move(termsToMove, (Term) dialog.getResult()[0], dialog.getTermPosition());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected terms must not share their paths.", null));
		}
	}
	
	return null;
}
 
Example 15
Source File: CreatePieChartHandler.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	// TODO: seems to be there is some refactoring needed in here
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	IViewPart part = null;
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		if (window != null) {
			IWorkbenchPage page = window.getActivePage();
			if (page != null) {
				part = page.showView(chartViewId);
			}
		}
	} catch (PartInitException e) {
		e.printStackTrace();
		return null;
	}
	if (part instanceof ICommunicationView) {
		view = (ICommunicationView) part;
	} else {
		return null;
	}

	view.getPreview().setTextToShow(noDataToDisplay);
	if (currentSelection.size() == 1) {
		view.getPreview().setDataPresent(true);
		ChartDataProvider provider = new ChartDataProvider();
		Term input = (Term) currentSelection.getFirstElement();
		Map<String, Integer> citeChartData = provider.calculateNumberOfPapersPerClass(input);
		PieChartConfiguration.get().getGeneralSettings().setChartTitle("Number of cites per subclass of " + input.getName());
		PieChartConfiguration.get().setPieTermSort(TermSort.SUBCLASS);
		Chart citeChart = ChartGenerator.createPie(citeChartData);
		view.setAndRenderChart(citeChart);
	} else {
		view.setAndRenderChart(null);
	}
	return null;
}
 
Example 16
Source File: CreateCiteHandler.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	// TODO: seems to be there is some refactoring needed in here
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	IViewPart part = null;
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		if (window != null) {
			IWorkbenchPage page = window.getActivePage();
			if (page != null) {
				part = page.showView(chartViewId);
			}
		}
	} catch (PartInitException e) {
		e.printStackTrace();
		return null;
	}
	if (part instanceof ICommunicationView) {
		view = (ICommunicationView) part;
	} else {
		return null;
	}

	view.getPreview().setTextToShow(noDataToDisplay);
	if (currentSelection.size() == 1) {
		view.getPreview().setDataPresent(true);
		ChartDataProvider provider = new ChartDataProvider();
		Term input = (Term) currentSelection.getFirstElement();
		Map<String, Integer> citeChartData = provider.calculateNumberOfPapersPerClass(input);
		BarChartConfiguration.get().getGeneralSettings().setChartTitle("Number of cites per subclass of " + input.getName());
		BarChartConfiguration.get().setTermSort(TermSort.SUBCLASS);
		Chart citeChart = ChartGenerator.createCiteBar(citeChartData);
		view.setAndRenderChart(citeChart);
	} else {
		view.setAndRenderChart(null);
	}
	return null;
}
 
Example 17
Source File: GenerateXpectReportCommandHandler.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * When called will check if provided data contains {@link Description test description} with failed status stored
 * in {@link N4IDEXpectView test view}. If that holds, will generate data for bug report in a console view,
 * otherwise will show message to reconfigure and rerun Xpect tests.
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();

	// handle failed suite
	if (desc.isSuite()) {
		final N4IDEXpectView finalview = view;

		boolean suitePassed = desc.getChildren().stream()
				.noneMatch(childDescription -> finalview.testsExecutionStatus.hasFailed(childDescription));

		if (suitePassed) {
			XpectFileContentsUtil.getXpectFileContentAccess(desc).ifPresent(
					xpectFielContentAccess -> {
						if (xpectFielContentAccess.containsFixme()) {
							generateAndDisplayReport(
									N4IDEXpectFileNameUtil.getSuiteName(desc),
									xpectFielContentAccess.getContetns());
						}
					});

		} else {
			XpectConsole console = ConsoleDisplayMgr.getOrCreate("generated bug for "
					+ N4IDEXpectFileNameUtil.getSuiteName(desc));
			console.clear();
			String ls = System.lineSeparator();
			console.log("Suite must be passing and contain XPECT FIXME marker to be submited bug report. Please :"
					+ ls + " - fix failing tests" + ls + " - mark test in question with XPECT FIXME");
		}
	}

	return null;
}
 
Example 18
Source File: CloneModelHandlerDelegate.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	final TLCSpec spec = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class);
	
	Model model = null;
	/*
	 * First try to get the model from the parameters. It is an optional
	 * parameter, so it may not have been set.
	 */
	final String paramModelName = (String) event.getParameter(PARAM_MODEL_NAME);
	final String paramForeignModelName = (String) event.getParameter(PARAM_FOREIGN_FULLY_QUALIFIED_MODEL_NAME);
	final boolean isForeignClone = (paramForeignModelName != null);
	if (paramModelName != null) {
		// The name is given which means the user clicked the main menu
		// instead of the spec explorer. Under the constraint that only ever
		// a single spec can be open, lookup the current spec to eventually
		// get the corresponding model.
		model = spec.getModel(paramModelName);
	} else if (isForeignClone) {
		model = TLCModelFactory.getByName(paramForeignModelName);
	} else {
		/*
		 * No parameter try to get it from active navigator if any
		 */
		final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
		if (selection != null && selection instanceof IStructuredSelection) {
			// model
			model = (Model) ((IStructuredSelection) selection).getFirstElement();
		}
	}

	if (model != null) {
		final InputDialog dialog = new InputDialog(UIHelper.getShellProvider().getShell(), "Clone model...",
				"Please input the new name of the model", spec.getModelNameSuggestion(model), new ModelNameValidator(spec));
		dialog.setBlockOnOpen(true);
		if (dialog.open() == Window.OK) {
			final String chosenName = dialog.getValue();

			if (isForeignClone) {
				if (model.copyIntoForeignSpec(spec, chosenName) == null) {
					throw new ExecutionException("Failed to copy with name " + chosenName
													+ " from model " + model.getName() + " in spec " + model.getSpec().getName());
				}
			} else {
				if (model.copy(chosenName) == null) {
					throw new ExecutionException("Failed to copy with name " + chosenName + " from model " + model.getName());
				}
			}

			// Open the previously created model
			final Map<String, String> parameters = new HashMap<String, String>();
			parameters.put(OpenModelHandler.PARAM_MODEL_NAME, chosenName);
			UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
		}
	}
	return null;
}
 
Example 19
Source File: CreateBubbleChartHandler.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	// TODO: seems to be there is some refactoring needed in here
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	IViewPart part = null;
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		if (window != null) {
			IWorkbenchPage page = window.getActivePage();
			if (page != null) {
				part = page.showView(chartViewId);
			}
		}
	} catch (PartInitException e) {
		e.printStackTrace();
		return null;
	}
	if (part instanceof ICommunicationView) {
		view = (ICommunicationView) part;
	} else {
		return null;
	}
	view.getPreview().setTextToShow(noDataToDisplay);
	if (currentSelection.size() == 2) {
		view.getPreview().setDataPresent(true);
		ChartDataProvider provider = new ChartDataProvider();
		@SuppressWarnings("unchecked")
		Iterator<Term> selectionIterator = currentSelection.iterator();
		Term first = selectionIterator.next();
		Term second = selectionIterator.next();
		List<BubbleDataContainer> bubbleChartData = provider.calculateBubbleChartData(first, second);
		BubbleChartConfiguration.get().getGeneralSettings().setChartTitle("Intersection of " + first.getName() + " and " + second.getName());
		Chart bubbleChart = ChartGenerator.createBubble(bubbleChartData,first,second);
		view.setAndRenderChart(bubbleChart);
	} else {
		view.setAndRenderChart(null);
	}
	return null;
}
 
Example 20
Source File: RenameModelHandlerDelegate.java    From tlaplus with MIT License 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
 {
     final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
     if (selection != null && selection instanceof IStructuredSelection)
     {
         // model file
         final Model model = (Model) ((IStructuredSelection) selection).getFirstElement();

         // a) fail if model is in use
if (model.isRunning()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename models",
			"Could not rename the model " + model.getName()
					+ ", because it is being model checked.");
	return null;
}
if (model.isSnapshot()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename model",
			"Could not rename the model " + model.getName()
					+ ", because it is a snapshot.");
	return null;
}

         // b) open dialog prompting for new model name
         final IInputValidator modelNameInputValidator = new ModelNameValidator(model.getSpec());
         final InputDialog dialog = new InputDialog(UIHelper.getShell(), "Rename model...",
                 "Please input the new name of the model", model.getName(), modelNameInputValidator);
         dialog.setBlockOnOpen(true);
         if(dialog.open() == Window.OK) {
         	// c1) close model editor if open
             IEditorPart editor = model.getAdapter(ModelEditor.class);
             if(editor != null) {
             	reopenModelEditorAfterRename = true;
             	UIHelper.getActivePage().closeEditor(editor, true);
             }
             // c2) close snapshot model editors 
             final Collection<Model> snapshots = model.getSnapshots();
	for (Model snapshot : snapshots) {
		editor = snapshot.getAdapter(ModelEditor.class);
		if (editor != null) {
			UIHelper.getActivePage().closeEditor(editor, true);
		}
	}
             
	final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
		@Override
		protected void execute(IProgressMonitor monitor)
				throws CoreException, InvocationTargetException, InterruptedException {
			// d) rename
			final String newModelName = dialog.getValue();
			model.rename(newModelName, monitor);

			// e) reopen (in UI thread)
			if (reopenModelEditorAfterRename) {
				UIHelper.runUIAsync(new Runnable() {
					/*
					 * (non-Javadoc)
					 * 
					 * @see java.lang.Runnable#run()
					 */
					public void run() {
						Map<String, String> parameters = new HashMap<String, String>();
						parameters.put(OpenModelHandler.PARAM_MODEL_NAME, newModelName);
						UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
					}
				});
			}
		}
	};
	final IRunnableContext ctxt = new ProgressMonitorDialog(UIHelper.getShell());
	try {
		ctxt.run(true, false, operation);
	} catch (InvocationTargetException | InterruptedException e) {
		throw new ExecutionException(e.getMessage(), e);
	}
          }
     }
     return null;
 }