1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.ui.workbench.action;
14 import org.eclipse.core.runtime.SafeRunner;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.jface.util.SafeRunnable;
17 import org.simantics.db.Resource;
18 import org.simantics.ui.workbench.ResourceEditorInput;
19 import org.simantics.utils.ui.action.PriorityAction;
20 import org.simantics.utils.ui.workbench.WorkbenchUtils;
23 * A convenience implementation of IPriorityAction for opening a specified
24 * workbench EditorPart.
26 * @author Tuukka Lehtonen
28 public class OpenEditorAction extends PriorityAction {
34 public OpenEditorAction(int priority, String text, ImageDescriptor imgDesc, String editorId, Resource r) {
35 super(priority, text, imgDesc);
36 this.editorId = editorId;
42 SafeRunner.run(new SafeRunnable() {
44 public void run() throws Exception {
45 WorkbenchUtils.openEditor(editorId, new ResourceEditorInput(editorId, r));