1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.modeling.ui.modelBrowser.handlers;
\r
14 import org.eclipse.core.commands.AbstractHandler;
\r
15 import org.eclipse.core.commands.ExecutionEvent;
\r
16 import org.eclipse.core.commands.ExecutionException;
\r
17 import org.eclipse.jface.action.IStatusLineManager;
\r
18 import org.eclipse.jface.viewers.ISelection;
\r
19 import org.eclipse.ui.IActionBars;
\r
20 import org.eclipse.ui.IWorkbenchPart;
\r
21 import org.eclipse.ui.handlers.HandlerUtil;
\r
22 import org.simantics.browsing.ui.GraphExplorer;
\r
23 import org.simantics.browsing.ui.NodeContext;
\r
24 import org.simantics.browsing.ui.common.ColumnKeys;
\r
25 import org.simantics.utils.ui.ISelectionUtils;
\r
26 import org.simantics.utils.ui.workbench.WorkbenchUtils;
\r
28 public class RenameNodeHandler extends AbstractHandler {
\r
31 public Object execute(ExecutionEvent event) throws ExecutionException {
\r
32 ISelection sel = HandlerUtil.getCurrentSelection(event);
\r
33 NodeContext ctx = ISelectionUtils.filterSingleSelection(sel, NodeContext.class);
\r
37 IWorkbenchPart part = HandlerUtil.getActivePart(event);
\r
41 IActionBars bars = WorkbenchUtils.getActionBars(part);
\r
42 IStatusLineManager status = bars.getStatusLineManager();
\r
44 GraphExplorer graphExplorer = (GraphExplorer) part.getAdapter(GraphExplorer.class);
\r
45 if (graphExplorer != null) {
\r
46 String error = graphExplorer.startEditing(ctx, ColumnKeys.SINGLE);
\r
47 if (error != null) {
\r
48 status.setErrorMessage(error);
\r
50 status.setErrorMessage(null);
\r