X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2Faction%2FResourceEditorAdapterAction.java;fp=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2Faction%2FResourceEditorAdapterAction.java;h=9cb9fde81e1e83699f6ae2ef6db799cac26a1018;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=1376c74c81da2fbd101288c10e8f18ee12249af8;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/action/ResourceEditorAdapterAction.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/action/ResourceEditorAdapterAction.java index 1376c74c8..9cb9fde81 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/action/ResourceEditorAdapterAction.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/action/ResourceEditorAdapterAction.java @@ -1,80 +1,80 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.ui.workbench.action; - -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.jface.util.SafeRunnable; -import org.simantics.db.Resource; -import org.simantics.ui.workbench.editor.EditorAdapter; -import org.simantics.utils.ui.action.IPriorityAction; -import org.simantics.utils.ui.action.PriorityAction; - -/** - * @author Tuukka Lehtonen - */ -public class ResourceEditorAdapterAction extends PriorityAction { - - private static final boolean DEBUG = false; - - protected EditorAdapter adapter; - - protected Object resource; - - public ResourceEditorAdapterAction(EditorAdapter adapter, Object r) { - super(makeName(adapter), adapter.getIcon()); - this.adapter = adapter; - this.resource = r; - } - - public static String makeName(EditorAdapter adapter) { - if (DEBUG) { - return adapter.getName() + " (" + adapter.getClass().getName() + ")[" + adapter.getPriority() + "]"; - } - return adapter.getName(); - } - - @Override - public final void run() { - SafeRunner.run(new SafeRunnable() { - @Override - public void run() throws Exception { - safeRun(); - } - }); - } - - protected void safeRun() throws Exception { - adapter.openEditor(resource); - } - - public EditorAdapter getAdapter() { - return adapter; - } - - public Object getResource() { - return resource; - } - - @Override - public int getPriority() { - return adapter.getPriority(); - } - - public static IPriorityAction[] toActions(EditorAdapter[] adapters, Resource forResource) { - IPriorityAction[] actions = new IPriorityAction[adapters.length]; - for (int i = 0; i < adapters.length; ++i) { - actions[i] = new ResourceEditorAdapterAction(adapters[i], forResource); - } - return actions; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.ui.workbench.action; + +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.jface.util.SafeRunnable; +import org.simantics.db.Resource; +import org.simantics.ui.workbench.editor.EditorAdapter; +import org.simantics.utils.ui.action.IPriorityAction; +import org.simantics.utils.ui.action.PriorityAction; + +/** + * @author Tuukka Lehtonen + */ +public class ResourceEditorAdapterAction extends PriorityAction { + + private static final boolean DEBUG = false; + + protected EditorAdapter adapter; + + protected Object resource; + + public ResourceEditorAdapterAction(EditorAdapter adapter, Object r) { + super(makeName(adapter), adapter.getIcon()); + this.adapter = adapter; + this.resource = r; + } + + public static String makeName(EditorAdapter adapter) { + if (DEBUG) { + return adapter.getName() + " (" + adapter.getClass().getName() + ")[" + adapter.getPriority() + "]"; + } + return adapter.getName(); + } + + @Override + public final void run() { + SafeRunner.run(new SafeRunnable() { + @Override + public void run() throws Exception { + safeRun(); + } + }); + } + + protected void safeRun() throws Exception { + adapter.openEditor(resource); + } + + public EditorAdapter getAdapter() { + return adapter; + } + + public Object getResource() { + return resource; + } + + @Override + public int getPriority() { + return adapter.getPriority(); + } + + public static IPriorityAction[] toActions(EditorAdapter[] adapters, Resource forResource) { + IPriorityAction[] actions = new IPriorityAction[adapters.length]; + for (int i = 0; i < adapters.length; ++i) { + actions[i] = new ResourceEditorAdapterAction(adapters[i], forResource); + } + return actions; + } + +}