X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2Feditor%2FOpenDefaultEditor.java;fp=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2Feditor%2FOpenDefaultEditor.java;h=4e75611e03bf4515d57f7b08ce3a6b4f5a84612b;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=a38515ad088f08aadffacf37b21ef56669056cd6;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/OpenDefaultEditor.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/OpenDefaultEditor.java index a38515ad0..4e75611e0 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/OpenDefaultEditor.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/OpenDefaultEditor.java @@ -1,61 +1,61 @@ -/******************************************************************************* - * 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.editor; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.ui.DoubleClickEvent; -import org.simantics.ui.IDoubleClickAction; -import org.simantics.ui.workbench.action.IWorkbenchActionHints; -import org.simantics.ui.workbench.action.ResourceEditorAdapterAction; - -/** - * @author Tuukka Lehtonen - */ -public class OpenDefaultEditor implements IDoubleClickAction { - - @Override - public void doubleClickEvent(DoubleClickEvent e) { - ReadGraph g = e.getGraph(); - Object r = e.getResource(); - - Boolean remember = e.getHintContext().getHint(IWorkbenchActionHints.KEY_REMEMBER); - final boolean rememberChoice = remember != null ? remember : false; - - Boolean ask = e.getHintContext().getHint(IWorkbenchActionHints.KEY_ALWAYS_ASK); - boolean alwaysAsk = ask != null ? ask : false; - - EditorAdapter primaryAdapter = EditorRegistry.getInstance().getMappings().get(r); - if (!alwaysAsk && primaryAdapter != null) { - e.add(new ResourceEditorAdapterAction(primaryAdapter, r)); - } else { - try { - EditorAdapter[] editorAdapters = EditorRegistry.getInstance().getAdaptersFor(g, r); - for (final EditorAdapter a : editorAdapters) { - e.add(new ResourceEditorAdapterAction(a, r) { - @Override - protected void safeRun() throws Exception { - super.safeRun(); - - if (rememberChoice) { - // Make this choice the default for the next time. - EditorRegistry.getInstance().getMappings().put(getResource(), getAdapter()); - } - } - }); - } - } catch (DatabaseException ex) { - } - } - } - -} +/******************************************************************************* + * 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.editor; + +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.ui.DoubleClickEvent; +import org.simantics.ui.IDoubleClickAction; +import org.simantics.ui.workbench.action.IWorkbenchActionHints; +import org.simantics.ui.workbench.action.ResourceEditorAdapterAction; + +/** + * @author Tuukka Lehtonen + */ +public class OpenDefaultEditor implements IDoubleClickAction { + + @Override + public void doubleClickEvent(DoubleClickEvent e) { + ReadGraph g = e.getGraph(); + Object r = e.getResource(); + + Boolean remember = e.getHintContext().getHint(IWorkbenchActionHints.KEY_REMEMBER); + final boolean rememberChoice = remember != null ? remember : false; + + Boolean ask = e.getHintContext().getHint(IWorkbenchActionHints.KEY_ALWAYS_ASK); + boolean alwaysAsk = ask != null ? ask : false; + + EditorAdapter primaryAdapter = EditorRegistry.getInstance().getMappings().get(r); + if (!alwaysAsk && primaryAdapter != null) { + e.add(new ResourceEditorAdapterAction(primaryAdapter, r)); + } else { + try { + EditorAdapter[] editorAdapters = EditorRegistry.getInstance().getAdaptersFor(g, r); + for (final EditorAdapter a : editorAdapters) { + e.add(new ResourceEditorAdapterAction(a, r) { + @Override + protected void safeRun() throws Exception { + super.safeRun(); + + if (rememberChoice) { + // Make this choice the default for the next time. + EditorRegistry.getInstance().getMappings().put(getResource(), getAdapter()); + } + } + }); + } + } catch (DatabaseException ex) { + } + } + } + +}