-/*******************************************************************************\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.modeling.ui.modelBrowser2.model;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.simantics.browsing.ui.common.node.IDeletable;\r
-import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.VariableReference;\r
-import org.simantics.modeling.PropertyVariables;\r
-import org.simantics.modeling.subscription.AddSubscriptionItems;\r
-import org.simantics.modeling.utils.VariableReferences;\r
-import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.datastructures.Callback;\r
-import org.simantics.utils.ui.ErrorLogger;\r
-import org.simantics.utils.ui.ISelectionUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class SubscriptionNode extends AbstractNode implements IDeletable, IDropTargetNode {\r
-\r
- public SubscriptionNode(Resource resource) {\r
- super(resource);\r
- }\r
-\r
- @Override\r
- public void drop(Object data) {\r
- if (!(data instanceof ISelection))\r
- return;\r
- final List<PropertyVariables> vars = ISelectionUtils.filterSelection((ISelection) data, PropertyVariables.class);\r
- if (!vars.isEmpty()) {\r
- List<VariableReference> references;\r
- try {\r
- references = SimanticsUI.getSession().syncRequest(VariableReferences.toReferences(vars));\r
- addSubscriptions(references);\r
- } catch (DatabaseException e) {\r
- ErrorLogger.defaultLogError(e);\r
- }\r
- } else {\r
- final List<VariableReference> references = ISelectionUtils.filterSelection((ISelection) data, VariableReference.class);\r
- if (!references.isEmpty()) {\r
- addSubscriptions(references);\r
- }\r
- }\r
- }\r
-\r
- private void addSubscriptions(List<VariableReference> references) {\r
- SimanticsUI.getSession().asyncRequest(new AddSubscriptionItems(resource, references), new Callback<DatabaseException>() {\r
- @Override\r
- public void run(DatabaseException e) {\r
- if (e != null)\r
- ErrorLogger.defaultLogError(e);\r
- }\r
- });\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.modeling.ui.modelBrowser2.model;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.simantics.browsing.ui.common.node.IDeletable;
+import org.simantics.browsing.ui.common.node.IDropTargetNode;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.VariableReference;
+import org.simantics.modeling.PropertyVariables;
+import org.simantics.modeling.subscription.AddSubscriptionItems;
+import org.simantics.modeling.utils.VariableReferences;
+import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.utils.datastructures.Callback;
+import org.simantics.utils.ui.ErrorLogger;
+import org.simantics.utils.ui.ISelectionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class SubscriptionNode extends AbstractNode implements IDeletable, IDropTargetNode {
+
+ public SubscriptionNode(Resource resource) {
+ super(resource);
+ }
+
+ @Override
+ public void drop(Object data) {
+ if (!(data instanceof ISelection))
+ return;
+ final List<PropertyVariables> vars = ISelectionUtils.filterSelection((ISelection) data, PropertyVariables.class);
+ if (!vars.isEmpty()) {
+ List<VariableReference> references;
+ try {
+ references = SimanticsUI.getSession().syncRequest(VariableReferences.toReferences(vars));
+ addSubscriptions(references);
+ } catch (DatabaseException e) {
+ ErrorLogger.defaultLogError(e);
+ }
+ } else {
+ final List<VariableReference> references = ISelectionUtils.filterSelection((ISelection) data, VariableReference.class);
+ if (!references.isEmpty()) {
+ addSubscriptions(references);
+ }
+ }
+ }
+
+ private void addSubscriptions(List<VariableReference> references) {
+ SimanticsUI.getSession().asyncRequest(new AddSubscriptionItems(resource, references), new Callback<DatabaseException>() {
+ @Override
+ public void run(DatabaseException e) {
+ if (e != null)
+ ErrorLogger.defaultLogError(e);
+ }
+ });
+ }
+
+}