]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/workbench/action/OpenEditorAction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / action / OpenEditorAction.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.ui.workbench.action;
13
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;
21
22 /**
23  * A convenience implementation of IPriorityAction for opening a specified
24  * workbench EditorPart.
25  * 
26  * @author Tuukka Lehtonen
27  */
28 public class OpenEditorAction extends PriorityAction {
29
30     String   editorId;
31
32     Resource r;
33
34     public OpenEditorAction(int priority, String text, ImageDescriptor imgDesc, String editorId, Resource r) {
35         super(priority, text, imgDesc);
36         this.editorId = editorId;
37         this.r = r;
38     }
39
40     @Override
41     public void run() {
42         SafeRunner.run(new SafeRunnable() {
43             @Override
44             public void run() throws Exception {
45                 WorkbenchUtils.openEditor(editorId, new ResourceEditorInput(editorId, r));
46             }
47         });
48     }
49 }