]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/viewpoints/ViewpointStub.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.common / src / org / simantics / browsing / ui / common / viewpoints / ViewpointStub.java
index 0e91bb907e14148f71d5a8313e978d1d772f5de0..4895d3f75425ed00df79a8703c7656a41e52c18a 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.common.viewpoints;\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.Viewpoint;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public abstract class ViewpointStub implements Viewpoint {\r
-\r
-    protected NodeContext[] children    = Viewpoint.PENDING_CHILDREN;\r
-    protected Boolean        hasChildren = Viewpoint.PENDING_HAS_CHILDREN;\r
-\r
-    final public void setChildren(PrimitiveQueryUpdater updater, NodeContext[] children) {\r
-        if (children == null)\r
-            throw new NullPointerException(this + ": null children produced by " + getClass().getName());\r
-        for(NodeContext c : children) updater.incRef(c);\r
-        for(NodeContext c : this.children) updater.decRef(c);\r
-        this.children = children;\r
-    }\r
-\r
-    public void setHasChildren(Boolean hasChildren) {\r
-        if (children == null)\r
-            throw new NullPointerException(this + ": null hasChildren produced by " + getClass().getName());\r
-        this.hasChildren = hasChildren;\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 NodeContext[] toContextsWithInput(Collection<?> 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 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.common.viewpoints;
+
+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.Viewpoint;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public abstract class ViewpointStub implements Viewpoint {
+
+    protected NodeContext[] children    = Viewpoint.PENDING_CHILDREN;
+    protected Boolean        hasChildren = Viewpoint.PENDING_HAS_CHILDREN;
+
+    final public void setChildren(PrimitiveQueryUpdater updater, NodeContext[] children) {
+        if (children == null)
+            throw new NullPointerException(this + ": null children produced by " + getClass().getName());
+        for(NodeContext c : children) updater.incRef(c);
+        for(NodeContext c : this.children) updater.decRef(c);
+        this.children = children;
+    }
+
+    public void setHasChildren(Boolean hasChildren) {
+        if (children == null)
+            throw new NullPointerException(this + ": null hasChildren produced by " + getClass().getName());
+        this.hasChildren = hasChildren;
+    }
+
+    /**
+     * 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 NodeContext[] toContextsWithInput(Collection<?> 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 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;
+    }
+
+}