-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * 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.document.function;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Hashtable;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.simantics.document.WikiDocumentNode;\r
-import org.simantics.scenegraph.INode;\r
-import org.simantics.scenegraph.ParentNode;\r
-import org.simantics.scenegraph.ScenegraphUtils;\r
-import org.simantics.scl.runtime.function.Function1;\r
-import org.simantics.scl.runtime.function.Function2;\r
-\r
-abstract public class WikiDocumentNodeImpl extends ParentNode<WikiDocumentNode> implements WikiDocumentNode {\r
-\r
- public Boolean printInPDF = false;\r
- public String editText = null;\r
- \r
- private static final long serialVersionUID = 3394059912639648935L;\r
-\r
- class M implements Map<String, WikiDocumentNode> {\r
- \r
- ArrayList<WikiDocumentNode> list = new ArrayList<WikiDocumentNode>();\r
- Hashtable<String, WikiDocumentNode> table = new Hashtable<String, WikiDocumentNode>();\r
- \r
- @Override\r
- public void clear() {\r
- table.clear();\r
- list.clear();\r
- }\r
- @Override\r
- public boolean containsKey(Object arg0) {\r
- return table.containsKey(arg0);\r
- }\r
- @Override\r
- public boolean containsValue(Object arg0) {\r
- return table.containsValue(arg0);\r
- }\r
- @Override\r
- public Set<java.util.Map.Entry<String, WikiDocumentNode>> entrySet() {\r
- return table.entrySet();\r
- }\r
- @Override\r
- public WikiDocumentNode get(Object arg0) {\r
- return table.get(arg0);\r
- }\r
- @Override\r
- public boolean isEmpty() {\r
- return table.isEmpty();\r
- }\r
- @Override\r
- public Set<String> keySet() {\r
- return table.keySet();\r
- }\r
- @Override\r
- public WikiDocumentNode put(String arg0, WikiDocumentNode arg1) {\r
- WikiDocumentNode exist = table.put(arg0, arg1);\r
- if(exist != null) list.remove(exist);\r
- list.add(arg1);\r
- return exist;\r
- }\r
- @Override\r
- public void putAll(Map<? extends String, ? extends WikiDocumentNode> arg0) {\r
- for(Map.Entry<? extends String, ? extends WikiDocumentNode> entry : arg0.entrySet())\r
- put(entry.getKey(), entry.getValue());\r
- }\r
- @Override\r
- public WikiDocumentNode remove(Object arg0) {\r
- WikiDocumentNode node = table.remove(arg0);\r
- if(node != null) list.remove(node);\r
- return node;\r
- }\r
- @Override\r
- public int size() {\r
- return table.size();\r
- }\r
- @Override\r
- public Collection<WikiDocumentNode> values() {\r
- return list;\r
- }\r
- \r
- }\r
- \r
- @Override\r
- final public void asyncRemoveNode(INode node) {\r
- throw new Error();\r
- }\r
- \r
- @Override\r
- protected Map<String, WikiDocumentNode> createChildMap() {\r
- return new M();\r
- }\r
- \r
- @Override\r
- public Function1<Object, Boolean> getPropertyFunction(String propertyName) {\r
- return ScenegraphUtils.getMethodPropertyFunction(null, this, propertyName);\r
- }\r
- \r
- @Override\r
- public <T> T getProperty(String propertyName) {\r
- return null;\r
- }\r
- \r
- @Override\r
- public void setPropertyCallback(Function2<String, Object, Boolean> callback) {\r
- }\r
-\r
- protected void createChildren(StringBuilder b, boolean isPDF) {\r
- for(WikiDocumentNode node : children.values()) node.create(b, isPDF);\r
- }\r
- \r
- public void synchronizePrintInPDF(Boolean value) {\r
- this.printInPDF = value;\r
- }\r
- \r
- protected String getName() {\r
- for(String id : parent.getNodeIds()) {\r
- if(parent.getNode(id) == this) return id;\r
- }\r
- return "err";\r
- }\r
- \r
- public String getPath() {\r
- if(parent instanceof WikiDocumentNodeImpl) {\r
- // Do not include root\r
- if(parent.getParent() == null) return "";\r
- else return ((WikiDocumentNodeImpl)parent).getPath() + "/" + getName(); \r
- } else {\r
- return "";\r
- }\r
- }\r
- \r
- public void synchronizeEditText(String editText) {\r
- this.editText = editText;\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 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.document.function;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+import org.simantics.document.WikiDocumentNode;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.ParentNode;
+import org.simantics.scenegraph.ScenegraphUtils;
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.function.Function2;
+
+public abstract class WikiDocumentNodeImpl extends ParentNode<WikiDocumentNode> implements WikiDocumentNode {
+
+ public Boolean printInPDF = false;
+ public String editText = null;
+
+ private static final long serialVersionUID = 3394059912639648935L;
+
+ static class M implements Map<String, INode> {
+
+ ArrayList<INode> list = new ArrayList<>();
+ Hashtable<String, INode> table = new Hashtable<>();
+
+ @Override
+ public void clear() {
+ table.clear();
+ list.clear();
+ }
+ @Override
+ public boolean containsKey(Object arg0) {
+ return table.containsKey(arg0);
+ }
+ @Override
+ public boolean containsValue(Object arg0) {
+ return table.containsValue(arg0);
+ }
+ @Override
+ public Set<java.util.Map.Entry<String, INode>> entrySet() {
+ return table.entrySet();
+ }
+ @Override
+ public INode get(Object arg0) {
+ return table.get(arg0);
+ }
+ @Override
+ public boolean isEmpty() {
+ return table.isEmpty();
+ }
+ @Override
+ public Set<String> keySet() {
+ return table.keySet();
+ }
+ @Override
+ public INode put(String arg0, INode arg1) {
+ INode exist = table.put(arg0, arg1);
+ if(exist != null) list.remove(exist);
+ list.add(arg1);
+ return exist;
+ }
+ @Override
+ public void putAll(Map<? extends String, ? extends INode> arg0) {
+ for(Map.Entry<? extends String, ? extends INode> entry : arg0.entrySet())
+ put(entry.getKey(), entry.getValue());
+ }
+ @Override
+ public INode remove(Object arg0) {
+ INode node = table.remove(arg0);
+ if(node != null) list.remove(node);
+ return node;
+ }
+ @Override
+ public int size() {
+ return table.size();
+ }
+ @Override
+ public Collection<INode> values() {
+ return list;
+ }
+
+ }
+
+ @Override
+ final public void asyncRemoveNode(INode node) {
+ throw new Error();
+ }
+
+ @Override
+ protected Map<String, INode> createChildMap(int initialCapacity) {
+ return new M();
+ }
+
+ @Override
+ public Function1<Object, Boolean> getPropertyFunction(String propertyName) {
+ return ScenegraphUtils.getMethodPropertyFunction(null, this, propertyName);
+ }
+
+ @Override
+ public <T> T getProperty(String propertyName) {
+ return null;
+ }
+
+ @Override
+ public void setPropertyCallback(Function2<String, Object, Boolean> callback) {
+ }
+
+ protected void createChildren(StringBuilder b, boolean isPDF) {
+ for(WikiDocumentNode node : getNodes()) node.create(b, isPDF);
+ }
+
+ public void synchronizePrintInPDF(Boolean value) {
+ this.printInPDF = value;
+ }
+
+ protected String getName() {
+ for(String id : parent.getNodeIds()) {
+ if(parent.getNode(id) == this) return id;
+ }
+ return "err";
+ }
+
+ public String getPath() {
+ if(parent instanceof WikiDocumentNodeImpl) {
+ // Do not include root
+ if(parent.getParent() == null) return "";
+ else return ((WikiDocumentNodeImpl)parent).getPath() + "/" + getName();
+ } else {
+ return "";
+ }
+ }
+
+ public void synchronizeEditText(String editText) {
+ this.editText = editText;
+ }
+
+}