-/*******************************************************************************\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;\r
-\r
-import java.util.Map;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.DataSource;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.common.labelers.LabelerContent;\r
-import org.simantics.browsing.ui.common.labelers.LabelerStub;\r
-import org.simantics.browsing.ui.graph.impl.request.ParametrizedResourceQuery;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.procedure.Listener;\r
-\r
-/**\r
- * A version of LazyLabeler that uses a set of arbitrary parameters to describe\r
- * the label resource query within the class.\r
- * \r
- * @author Tuukka Lehtonen\r
- * \r
- * @see LazyGraphLabeler a non-parametrized version (more light-weight)\r
- */\r
-public abstract class LazyParametrizedGraphLabeler extends LabelerStub {\r
-\r
- private final ParametrizedResourceQuery<LabelerContent> labelQuery;\r
- private final Listener<LabelerContent> labelProcedure;\r
- private final PrimitiveQueryUpdater updater;\r
-\r
- // DEBUG\r
- static int debugCounter = 0;\r
-\r
- public LazyParametrizedGraphLabeler(final PrimitiveQueryUpdater updater, final NodeContext context, final BuiltinKeys.LabelerKey key, Object... parameters) {\r
- this.updater = updater;\r
- this.labelQuery = new ParametrizedResourceQuery<LabelerContent>(getClass(), context, parameters) {\r
- @Override\r
- public LabelerContent perform(ReadGraph graph) throws DatabaseException {\r
- return new LabelerContent(category(graph), labels(graph));\r
- }\r
-\r
- };\r
- this.labelProcedure = new Listener<LabelerContent>() {\r
-\r
- @Override\r
- public void execute(LabelerContent result) {\r
- setContent(result);\r
- updater.scheduleReplace(context, key, LazyParametrizedGraphLabeler.this);\r
- }\r
-\r
- @Override\r
- public void exception(Throwable t) {\r
- t.printStackTrace();\r
- }\r
-\r
- @Override\r
- public boolean isDisposed() {\r
- return updater.isDisposed();\r
- }\r
-\r
- };\r
- }\r
-\r
- @Override\r
- public Map<String, String> getLabels() {\r
-// new Exception().printStackTrace();\r
- if (content == LabelerContent.NO_CONTENT) {\r
- final DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);\r
-\r
- source.schedule(graph -> {\r
- try {\r
- graph.syncRequest(labelQuery, labelProcedure);\r
- } catch (DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
- });\r
- }\r
-\r
- return content.labels;\r
- }\r
-\r
- // OVERRIDE\r
-\r
- public abstract Map<String, String> labels(ReadGraph graph) throws DatabaseException;\r
-\r
- public int category(ReadGraph graph) {\r
- return content.category;\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;
+
+import java.util.Map;
+
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.DataSource;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.PrimitiveQueryUpdater;
+import org.simantics.browsing.ui.common.labelers.LabelerContent;
+import org.simantics.browsing.ui.common.labelers.LabelerStub;
+import org.simantics.browsing.ui.graph.impl.request.ParametrizedResourceQuery;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.procedure.Listener;
+
+/**
+ * A version of LazyLabeler that uses a set of arbitrary parameters to describe
+ * the label resource query within the class.
+ *
+ * @author Tuukka Lehtonen
+ *
+ * @see LazyGraphLabeler a non-parametrized version (more light-weight)
+ */
+public abstract class LazyParametrizedGraphLabeler extends LabelerStub {
+
+ private final ParametrizedResourceQuery<LabelerContent> labelQuery;
+ private final Listener<LabelerContent> labelProcedure;
+ private final PrimitiveQueryUpdater updater;
+
+ // DEBUG
+ static int debugCounter = 0;
+
+ public LazyParametrizedGraphLabeler(final PrimitiveQueryUpdater updater, final NodeContext context, final BuiltinKeys.LabelerKey key, Object... parameters) {
+ this.updater = updater;
+ this.labelQuery = new ParametrizedResourceQuery<LabelerContent>(getClass(), context, parameters) {
+ @Override
+ public LabelerContent perform(ReadGraph graph) throws DatabaseException {
+ return new LabelerContent(category(graph), labels(graph));
+ }
+
+ };
+ this.labelProcedure = new Listener<LabelerContent>() {
+
+ @Override
+ public void execute(LabelerContent result) {
+ setContent(result);
+ updater.scheduleReplace(context, key, LazyParametrizedGraphLabeler.this);
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ t.printStackTrace();
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return updater.isDisposed();
+ }
+
+ };
+ }
+
+ @Override
+ public Map<String, String> getLabels() {
+// new Exception().printStackTrace();
+ if (content == LabelerContent.NO_CONTENT) {
+ final DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);
+
+ source.schedule(graph -> {
+ try {
+ graph.syncRequest(labelQuery, labelProcedure);
+ } catch (DatabaseException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+
+ return content.labels;
+ }
+
+ // OVERRIDE
+
+ public abstract Map<String, String> labels(ReadGraph graph) throws DatabaseException;
+
+ public int category(ReadGraph graph) {
+ return content.category;
+ }
+
+}