X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fselection%2FVariableWorkbenchSelectionElement.java;h=4b4418bef9e9c12e9637f3a7219d584e6f879c90;hb=d76a05bd894c0fa00dd9ad28e167b284433d008d;hp=1f49facc7af67f6eda4d031cd2ab5e0ee390c3f1;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/selection/VariableWorkbenchSelectionElement.java b/bundles/org.simantics.ui/src/org/simantics/ui/selection/VariableWorkbenchSelectionElement.java index 1f49facc7..4b4418bef 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/selection/VariableWorkbenchSelectionElement.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/selection/VariableWorkbenchSelectionElement.java @@ -1,58 +1,58 @@ -package org.simantics.ui.selection; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.UnaryRead; -import org.simantics.db.common.utils.Logger; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; - -public class VariableWorkbenchSelectionElement implements WorkbenchSelectionElement { - - final private Variable variable; - - public VariableWorkbenchSelectionElement(Variable variable) { - this.variable = variable; - } - - @SuppressWarnings("unchecked") - @Override - public T getContent(WorkbenchSelectionContentType contentType) { - if(contentType instanceof AnyResource) { - AnyResource type = (AnyResource)contentType; - try { - return (T) type.processor.sync(new UnaryRead(variable) { - @Override - public Resource perform(ReadGraph graph) throws DatabaseException { - return parameter.getRepresents(graph); - } - }); - } catch (DatabaseException e) { - Logger.defaultLogError(e); - } - } - else if(contentType instanceof AnyVariable) { - return (T)variable; - } - return null; - } - - @Override - public int hashCode() { - return variable.hashCode(); - } - - @Override - public boolean equals(Object object) { - if (this == object) - return true; - else if (object == null) - return false; - else if (!(object instanceof VariableWorkbenchSelectionElement)) - return false; - VariableWorkbenchSelectionElement vwse = (VariableWorkbenchSelectionElement)object; - return variable.equals(vwse.variable); - } - - -} +package org.simantics.ui.selection; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.UnaryRead; +import org.simantics.db.common.utils.Logger; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; + +public class VariableWorkbenchSelectionElement implements WorkbenchSelectionElement { + + final private Variable variable; + + public VariableWorkbenchSelectionElement(Variable variable) { + this.variable = variable; + } + + @SuppressWarnings("unchecked") + @Override + public T getContent(WorkbenchSelectionContentType contentType) { + if(contentType instanceof AnyResource) { + AnyResource type = (AnyResource)contentType; + try { + return (T) type.processor.sync(new UnaryRead(variable) { + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return parameter.getRepresents(graph); + } + }); + } catch (DatabaseException e) { + Logger.defaultLogError(e); + } + } + else if(contentType instanceof AnyVariable) { + return (T)variable; + } + return null; + } + + @Override + public int hashCode() { + return variable.hashCode(); + } + + @Override + public boolean equals(Object object) { + if (this == object) + return true; + else if (object == null) + return false; + else if (!(object instanceof VariableWorkbenchSelectionElement)) + return false; + VariableWorkbenchSelectionElement vwse = (VariableWorkbenchSelectionElement)object; + return variable.equals(vwse.variable); + } + + +}