-package org.simantics.ui.selection;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.UnaryRead;\r
-import org.simantics.db.common.utils.Logger;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-\r
-public class VariableWorkbenchSelectionElement implements WorkbenchSelectionElement {\r
- \r
- final private Variable variable;\r
- \r
- public VariableWorkbenchSelectionElement(Variable variable) {\r
- this.variable = variable;\r
- }\r
- \r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public <T> T getContent(WorkbenchSelectionContentType<T> contentType) {\r
- if(contentType instanceof AnyResource) {\r
- AnyResource type = (AnyResource)contentType;\r
- try {\r
- return (T) type.processor.sync(new UnaryRead<Variable, Resource>(variable) {\r
- @Override\r
- public Resource perform(ReadGraph graph) throws DatabaseException {\r
- return parameter.getRepresents(graph);\r
- }\r
- });\r
- } catch (DatabaseException e) {\r
- Logger.defaultLogError(e);\r
- }\r
- }\r
- else if(contentType instanceof AnyVariable) {\r
- return (T)variable;\r
- } \r
- return null;\r
- }\r
- \r
- @Override\r
- public int hashCode() {\r
- return variable.hashCode();\r
- }\r
- \r
- @Override\r
- public boolean equals(Object object) {\r
- if (this == object)\r
- return true;\r
- else if (object == null)\r
- return false;\r
- else if (!(object instanceof VariableWorkbenchSelectionElement))\r
- return false;\r
- VariableWorkbenchSelectionElement vwse = (VariableWorkbenchSelectionElement)object;\r
- return variable.equals(vwse.variable);\r
- }\r
- \r
-\r
-}\r
+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> T getContent(WorkbenchSelectionContentType<T> contentType) {
+ if(contentType instanceof AnyResource) {
+ AnyResource type = (AnyResource)contentType;
+ try {
+ return (T) type.processor.sync(new UnaryRead<Variable, Resource>(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);
+ }
+
+
+}