]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ContributionStub.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / ContributionStub.java
index 27f14392702410fcace1e9b89a22a6a19f319fcf..3b6fb52f5c2a4c3f66765db822acec6ad3cec755 100644 (file)
-/*******************************************************************************\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.Collection;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.common.NodeContextBuilder;\r
-import org.simantics.browsing.ui.common.NodeContextUtil;\r
-import org.simantics.browsing.ui.content.ViewpointContribution;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public abstract class ContributionStub implements ViewpointContribution {\r
-\r
-    protected Collection<NodeContext> children    = ViewpointContribution.PENDING_CONTRIBUTION;\r
-\r
-    public void setChildren(PrimitiveQueryUpdater updater, Collection<NodeContext> children) {\r
-       \r
-        if (children == null)\r
-            throw new NullPointerException("null children produced by " + getClass().getName());\r
-\r
-       for(NodeContext c : children) updater.incRef(c);\r
-        for(NodeContext c : this.children) updater.decRef(c);\r
-        \r
-        this.children = children;\r
-        \r
-    }\r
-\r
-    /**\r
-     * A utility method for transforming an array of objects into an\r
-     * INodeContext array which is the return value of a ViewpointFactory.\r
-     * \r
-     * <p>\r
-     * The INodeContext's are constructed using\r
-     * {@link NodeContextBuilder#buildWithInput(Object)}.\r
-     * </p>\r
-     * \r
-     * @param children\r
-     * @return the specified children wrapped into simple <code>INodeContext</code>s\r
-     */\r
-    public NodeContext[] toContextsWithInput(Object... children) {\r
-        return NodeContextUtil.toContextsWithInput(children);\r
-    }\r
-\r
-    /**\r
-     * A utility method for transforming a collection of objects into an\r
-     * INodeContext array which is the return value of a ViewpointFactory.\r
-     * \r
-     * <p>\r
-     * The INodeContext's are constructed using\r
-     * {@link NodeContextBuilder#buildWithInput(Object)}.\r
-     * </p>\r
-     * \r
-     * @param children\r
-     * @return the specified children wrapped into simple <code>INodeContext</code>s\r
-     */\r
-    public Collection<NodeContext> toContextsWithInput(Collection<?> children) {\r
-        return NodeContextUtil.toContextCollectionWithInput(children);\r
-    }\r
-\r
-    /**\r
-     * A utility method for transforming a collection of objects into an\r
-     * INodeContext array which is the return value of a ViewpointFactory.\r
-     * \r
-     * <p>\r
-     * The INodeContext's are constructed using the specified factory.\r
-     * </p>\r
-     * \r
-     * @param children\r
-     * @return the specified children wrapped into INodeContext's through the\r
-     *         specified <code>factory</code>\r
-     */\r
-    public NodeContext[] toContexts(Collection<?> children, NodeContextUtil.NodeContextFactory factory) {\r
-        return NodeContextUtil.toContexts(children, factory);\r
-    }\r
-\r
-    /**\r
-     * @param <T>\r
-     * @param clazz\r
-     * @return input of the specified class\r
-     * @throws ClassCastException if the input class does not match the\r
-     *         specified class\r
-     * @throws NullPointerException if the input is null\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    protected <T> T getInput(NodeContext context) {\r
-        Object o = context.getConstant(BuiltinKeys.INPUT);\r
-        if (o == null)\r
-            throw new NullPointerException("null input");\r
-        return (T) o;\r
-    }\r
-\r
-    /**\r
-     * @param <T>\r
-     * @param clazz\r
-     * @return <code>null</code> if input is <code>null</code> or if the class\r
-     *         does not match\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    protected <T> T tryGetInput(NodeContext context, Class<T> clazz) {\r
-        Object o = context.getConstant(BuiltinKeys.INPUT);\r
-        if (o != null && clazz.isInstance(o))\r
-            return (T) o;\r
-        return null;\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.Collection;
+
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.PrimitiveQueryUpdater;
+import org.simantics.browsing.ui.common.NodeContextBuilder;
+import org.simantics.browsing.ui.common.NodeContextUtil;
+import org.simantics.browsing.ui.content.ViewpointContribution;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public abstract class ContributionStub implements ViewpointContribution {
+
+    protected Collection<NodeContext> children    = ViewpointContribution.PENDING_CONTRIBUTION;
+
+    public void setChildren(PrimitiveQueryUpdater updater, Collection<NodeContext> children) {
+       
+        if (children == null)
+            throw new NullPointerException("null children produced by " + getClass().getName());
+
+       for(NodeContext c : children) updater.incRef(c);
+        for(NodeContext c : this.children) updater.decRef(c);
+        
+        this.children = children;
+        
+    }
+
+    /**
+     * A utility method for transforming an array of objects into an
+     * INodeContext array which is the return value of a ViewpointFactory.
+     * 
+     * <p>
+     * The INodeContext's are constructed using
+     * {@link NodeContextBuilder#buildWithInput(Object)}.
+     * </p>
+     * 
+     * @param children
+     * @return the specified children wrapped into simple <code>INodeContext</code>s
+     */
+    public NodeContext[] toContextsWithInput(Object... children) {
+        return NodeContextUtil.toContextsWithInput(children);
+    }
+
+    /**
+     * A utility method for transforming a collection of objects into an
+     * INodeContext array which is the return value of a ViewpointFactory.
+     * 
+     * <p>
+     * The INodeContext's are constructed using
+     * {@link NodeContextBuilder#buildWithInput(Object)}.
+     * </p>
+     * 
+     * @param children
+     * @return the specified children wrapped into simple <code>INodeContext</code>s
+     */
+    public Collection<NodeContext> toContextsWithInput(Collection<?> children) {
+        return NodeContextUtil.toContextCollectionWithInput(children);
+    }
+
+    /**
+     * A utility method for transforming a collection of objects into an
+     * INodeContext array which is the return value of a ViewpointFactory.
+     * 
+     * <p>
+     * The INodeContext's are constructed using the specified factory.
+     * </p>
+     * 
+     * @param children
+     * @return the specified children wrapped into INodeContext's through the
+     *         specified <code>factory</code>
+     */
+    public NodeContext[] toContexts(Collection<?> children, NodeContextUtil.NodeContextFactory factory) {
+        return NodeContextUtil.toContexts(children, factory);
+    }
+
+    /**
+     * @param <T>
+     * @param clazz
+     * @return input of the specified class
+     * @throws ClassCastException if the input class does not match the
+     *         specified class
+     * @throws NullPointerException if the input is null
+     */
+    @SuppressWarnings("unchecked")
+    protected <T> T getInput(NodeContext context) {
+        Object o = context.getConstant(BuiltinKeys.INPUT);
+        if (o == null)
+            throw new NullPointerException("null input");
+        return (T) o;
+    }
+
+    /**
+     * @param <T>
+     * @param clazz
+     * @return <code>null</code> if input is <code>null</code> or if the class
+     *         does not match
+     */
+    @SuppressWarnings("unchecked")
+    protected <T> T tryGetInput(NodeContext context, Class<T> clazz) {
+        Object o = context.getConstant(BuiltinKeys.INPUT);
+        if (o != null && clazz.isInstance(o))
+            return (T) o;
+        return null;
+    }
+
+}