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.ui.workbench.action;
\r
14 import org.eclipse.core.runtime.SafeRunner;
\r
15 import org.eclipse.jface.resource.ImageDescriptor;
\r
16 import org.eclipse.jface.util.SafeRunnable;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.ui.workbench.ResourceEditorInput;
\r
19 import org.simantics.utils.ui.action.PriorityAction;
\r
20 import org.simantics.utils.ui.workbench.WorkbenchUtils;
\r
23 * A convenience implementation of IPriorityAction for opening a specified
\r
24 * workbench EditorPart.
\r
26 * @author Tuukka Lehtonen
\r
28 public class OpenEditorAction extends PriorityAction {
\r
34 public OpenEditorAction(int priority, String text, ImageDescriptor imgDesc, String editorId, Resource r) {
\r
35 super(priority, text, imgDesc);
\r
36 this.editorId = editorId;
\r
42 SafeRunner.run(new SafeRunnable() {
\r
44 public void run() throws Exception {
\r
45 WorkbenchUtils.openEditor(editorId, new ResourceEditorInput(editorId, r));
\r