-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.browsing.ui.graph.impl.contributor.labeler;\r
-\r
-import java.util.Map;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.Tester;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.content.Contributor;\r
-import org.simantics.browsing.ui.content.Labeler;\r
-import org.simantics.browsing.ui.content.Labeler.Modifier;\r
-import org.simantics.browsing.ui.content.LabelerFactory;\r
-import org.simantics.browsing.ui.graph.impl.contribution.FinalLabelerContributionImpl;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.UndoContext;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
-\r
-abstract public class ContextFinalLabelerContributorImpl implements Contributor<LabelerFactory> {\r
-\r
- abstract public String getLabel(ReadGraph graph, NodeContext input) throws DatabaseException;\r
-\r
- public int getCategory(ReadGraph graph, NodeContext input) throws DatabaseException {\r
- return 0;\r
- }\r
-\r
- public Modifier getModifier(ReadGraph graph, NodeContext input, String columnKey) throws DatabaseException {\r
- return null;\r
- }\r
-\r
- final private Class<?> clazz;\r
-\r
- @Override\r
- public Tester getNodeContextTester() {\r
- return null;\r
- }\r
-\r
- public ContextFinalLabelerContributorImpl() {\r
- clazz = Object.class;\r
- }\r
-\r
- public ContextFinalLabelerContributorImpl(Class<?> clazz) {\r
- this.clazz = clazz;\r
- }\r
-\r
- @Override\r
- public LabelerFactory getFactory() {\r
-\r
- return new LabelerFactory() {\r
-\r
- @Override\r
- public Labeler create(final PrimitiveQueryUpdater updater, NodeContext context, final LabelerKey key) {\r
-\r
- return new FinalLabelerContributionImpl(updater, context, key) {\r
-\r
- @Override\r
- public Map<String, String> labels(ReadGraph graph, NodeContext context) throws DatabaseException {\r
-\r
- String value = ContextFinalLabelerContributorImpl.this.getLabel(graph, context);\r
-\r
- return new ArrayMap<String, String>(ColumnKeys.KEYS_SINGLE,\r
- new String[] { value });\r
-\r
- }\r
-\r
- @Override\r
- public Modifier getModifier(ReadGraph graph, UndoContext undoContext, NodeContext context, String columnKey) throws DatabaseException {\r
-\r
- return ContextFinalLabelerContributorImpl.this.getModifier(graph, context, columnKey);\r
-\r
- }\r
-\r
- @Override\r
- public int category(ReadGraph graph, NodeContext context) throws DatabaseException {\r
-\r
- return ContextFinalLabelerContributorImpl.this.getCategory(graph, context);\r
-\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return ContextFinalLabelerContributorImpl.this.toString();\r
- }\r
-\r
- };\r
-\r
- }\r
-\r
- };\r
-\r
- }\r
-\r
- @Override\r
- public Class<?> getInputClass() {\r
- return clazz;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * 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.browsing.ui.graph.impl.contributor.labeler;
+
+import java.util.Map;
+
+import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.PrimitiveQueryUpdater;
+import org.simantics.browsing.ui.Tester;
+import org.simantics.browsing.ui.common.ColumnKeys;
+import org.simantics.browsing.ui.content.Contributor;
+import org.simantics.browsing.ui.content.Labeler;
+import org.simantics.browsing.ui.content.Labeler.Modifier;
+import org.simantics.browsing.ui.content.LabelerFactory;
+import org.simantics.browsing.ui.graph.impl.contribution.FinalLabelerContributionImpl;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.UndoContext;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.utils.datastructures.ArrayMap;
+
+abstract public class ContextFinalLabelerContributorImpl implements Contributor<LabelerFactory> {
+
+ abstract public String getLabel(ReadGraph graph, NodeContext input) throws DatabaseException;
+
+ public int getCategory(ReadGraph graph, NodeContext input) throws DatabaseException {
+ return 0;
+ }
+
+ public Modifier getModifier(ReadGraph graph, NodeContext input, String columnKey) throws DatabaseException {
+ return null;
+ }
+
+ final private Class<?> clazz;
+
+ @Override
+ public Tester getNodeContextTester() {
+ return null;
+ }
+
+ public ContextFinalLabelerContributorImpl() {
+ clazz = Object.class;
+ }
+
+ public ContextFinalLabelerContributorImpl(Class<?> clazz) {
+ this.clazz = clazz;
+ }
+
+ @Override
+ public LabelerFactory getFactory() {
+
+ return new LabelerFactory() {
+
+ @Override
+ public Labeler create(final PrimitiveQueryUpdater updater, NodeContext context, final LabelerKey key) {
+
+ return new FinalLabelerContributionImpl(updater, context, key) {
+
+ @Override
+ public Map<String, String> labels(ReadGraph graph, NodeContext context) throws DatabaseException {
+
+ String value = ContextFinalLabelerContributorImpl.this.getLabel(graph, context);
+
+ return new ArrayMap<String, String>(ColumnKeys.KEYS_SINGLE,
+ new String[] { value });
+
+ }
+
+ @Override
+ public Modifier getModifier(ReadGraph graph, UndoContext undoContext, NodeContext context, String columnKey) throws DatabaseException {
+
+ return ContextFinalLabelerContributorImpl.this.getModifier(graph, context, columnKey);
+
+ }
+
+ @Override
+ public int category(ReadGraph graph, NodeContext context) throws DatabaseException {
+
+ return ContextFinalLabelerContributorImpl.this.getCategory(graph, context);
+
+ }
+
+ @Override
+ public String toString() {
+ return ContextFinalLabelerContributorImpl.this.toString();
+ }
+
+ };
+
+ }
+
+ };
+
+ }
+
+ @Override
+ public Class<?> getInputClass() {
+ return clazz;
+ }
+
+}