X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=inline;f=bundles%2Forg.simantics.modeling.template2d.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Ftemplate2d%2Fui%2Fadapters%2FIsInModelTest.java;h=ac3d7513f7f0ad42a042463729f61ed6dbcb120e;hb=f496d2407d0f78557e323986a04eb2b3020d4eff;hp=50e2952488e6360fa3b0479e6acb41c6b8c7a305;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.template2d.ui/src/org/simantics/modeling/template2d/ui/adapters/IsInModelTest.java b/bundles/org.simantics.modeling.template2d.ui/src/org/simantics/modeling/template2d/ui/adapters/IsInModelTest.java index 50e295248..ac3d7513f 100644 --- a/bundles/org.simantics.modeling.template2d.ui/src/org/simantics/modeling/template2d/ui/adapters/IsInModelTest.java +++ b/bundles/org.simantics.modeling.template2d.ui/src/org/simantics/modeling/template2d/ui/adapters/IsInModelTest.java @@ -1,57 +1,57 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Semantum Oy - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.template2d.ui.adapters; - -import org.simantics.browsing.ui.model.tests.Test; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.PossibleModel; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.Variables; - -/** - * @author Tuukka Lehtonen - */ -public enum IsInModelTest implements Test { - - INSTANCE; - - public static IsInModelTest get() { - return INSTANCE; - } - - @Override - public boolean isCompatible(Class contentType) { - return Variable.class.equals(contentType) || - Resource.class.equals(contentType); - } - - @Override - public boolean test(ReadGraph graph, Object content) throws DatabaseException { - if (content instanceof Variable) { - Variable v = (Variable) content; - //System.out.println("Test variable: " + v.getURI(graph)); - Resource model = Variables.getPossibleModel(graph, v); - //System.out.println("variable model: " + NameUtils.getURIOrSafeNameInternal(graph, model)); - return model != null; - } else if (content instanceof Resource) { - Resource r = (Resource) content; - //System.out.println("Test resource: " + NameUtils.getURIOrSafeNameInternal(graph, r)); - Resource model = graph.syncRequest(new PossibleModel(r)); - //System.out.println("resource model: " + NameUtils.getURIOrSafeNameInternal(graph, model)); - return model != null; - } - return false; - } - -} +/******************************************************************************* + * Copyright (c) 2013 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: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.template2d.ui.adapters; + +import org.simantics.browsing.ui.model.tests.Test; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.PossibleModel; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; + +/** + * @author Tuukka Lehtonen + */ +public enum IsInModelTest implements Test { + + INSTANCE; + + public static IsInModelTest get() { + return INSTANCE; + } + + @Override + public boolean isCompatible(Class contentType) { + return Variable.class.equals(contentType) || + Resource.class.equals(contentType); + } + + @Override + public boolean test(ReadGraph graph, Object content) throws DatabaseException { + if (content instanceof Variable) { + Variable v = (Variable) content; + //System.out.println("Test variable: " + v.getURI(graph)); + Resource model = Variables.getPossibleModel(graph, v); + //System.out.println("variable model: " + NameUtils.getURIOrSafeNameInternal(graph, model)); + return model != null; + } else if (content instanceof Resource) { + Resource r = (Resource) content; + //System.out.println("Test resource: " + NameUtils.getURIOrSafeNameInternal(graph, r)); + Resource model = graph.syncRequest(new PossibleModel(r)); + //System.out.println("resource model: " + NameUtils.getURIOrSafeNameInternal(graph, model)); + return model != null; + } + return false; + } + +}