]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/TreeTruncationDecoratorFactory.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / TreeTruncationDecoratorFactory.java
index 6087e741033ed8049d4e962fa1e4b9d318f71ef6..85bef735bf62d68b5a7f27d6d817e8a6c8b191b2 100644 (file)
@@ -1,91 +1,91 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2012 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.swt;\r
-\r
-import java.util.Collections;\r
-import java.util.Set;\r
-\r
-import org.eclipse.jface.resource.FontDescriptor;\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.NodeQueryManager;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.content.LabelDecorator;\r
-import org.simantics.browsing.ui.content.PrunedChildrenResult;\r
-\r
-/**\r
- * A label decorator factory that shows a [children shown/total] suffix for a\r
- * node context when it is expanded.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public class TreeTruncationDecoratorFactory {\r
-\r
-    protected int         withStyle;\r
-    protected Set<String> decoratedColumns;\r
-\r
-    public TreeTruncationDecoratorFactory(int withStyle) {\r
-        this(withStyle, Collections.singleton(ColumnKeys.SINGLE));\r
-    }\r
-\r
-    public TreeTruncationDecoratorFactory(int withStyle, Set<String> decoratedColumns) {\r
-        this.withStyle = withStyle;\r
-        this.decoratedColumns = decoratedColumns;\r
-    }\r
-\r
-    public LabelDecorator create(NodeQueryManager manager, NodeContext context) {\r
-        boolean expanded = manager.query(context, BuiltinKeys.IS_EXPANDED);\r
-        if (!expanded)\r
-            return null;\r
-\r
-        PrunedChildrenResult prunedChildren = manager.query(context, BuiltinKeys.PRUNED_CHILDREN);\r
-        NodeContext[] finalChildren = manager.query(context, BuiltinKeys.FINAL_CHILDREN);\r
-        final int prunedLength = prunedChildren.getPrunedChildren().length;\r
-        final int finalLength = finalChildren.length;\r
-        if (prunedLength == finalLength) {\r
-            if (finalLength >= 10) {\r
-                return new LabelDecorator.Stub() {\r
-                    @Override\r
-                    public String decorateLabel(String label, String column, int itemIndex) {\r
-                        if (decoratedColumns.contains(column))\r
-                            return label + " [" + finalLength + "]";\r
-                        return null;\r
-                    }\r
-                    @Override\r
-                    public <F> F decorateFont(F font, String column, int itemIndex) {\r
-                        //if (decoratedColumns.contains(column))\r
-                        //    return (F) ((FontDescriptor) font).withStyle(withStyle);\r
-                        return null;\r
-                    }\r
-                };\r
-            }\r
-            return null;\r
-        }\r
-\r
-        return new LabelDecorator.Stub() {\r
-            @Override\r
-            public String decorateLabel(String label, String column, int itemIndex) {\r
-                if (decoratedColumns.contains(column))\r
-                    return label + " [showing " + finalLength + "/" + prunedLength + "]";\r
-                return null;\r
-            }\r
-            @SuppressWarnings("unchecked")\r
-            @Override\r
-            public <F> F decorateFont(F font, String column, int itemIndex) {\r
-                if (decoratedColumns.contains(column))\r
-                    return (F) ((FontDescriptor) font).withStyle(withStyle);\r
-                return null;\r
-            }\r
-        };\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 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.browsing.ui.swt;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.jface.resource.FontDescriptor;
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.NodeQueryManager;
+import org.simantics.browsing.ui.common.ColumnKeys;
+import org.simantics.browsing.ui.content.LabelDecorator;
+import org.simantics.browsing.ui.content.PrunedChildrenResult;
+
+/**
+ * A label decorator factory that shows a [children shown/total] suffix for a
+ * node context when it is expanded.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class TreeTruncationDecoratorFactory {
+
+    protected int         withStyle;
+    protected Set<String> decoratedColumns;
+
+    public TreeTruncationDecoratorFactory(int withStyle) {
+        this(withStyle, Collections.singleton(ColumnKeys.SINGLE));
+    }
+
+    public TreeTruncationDecoratorFactory(int withStyle, Set<String> decoratedColumns) {
+        this.withStyle = withStyle;
+        this.decoratedColumns = decoratedColumns;
+    }
+
+    public LabelDecorator create(NodeQueryManager manager, NodeContext context) {
+        boolean expanded = manager.query(context, BuiltinKeys.IS_EXPANDED);
+        if (!expanded)
+            return null;
+
+        PrunedChildrenResult prunedChildren = manager.query(context, BuiltinKeys.PRUNED_CHILDREN);
+        NodeContext[] finalChildren = manager.query(context, BuiltinKeys.FINAL_CHILDREN);
+        final int prunedLength = prunedChildren.getPrunedChildren().length;
+        final int finalLength = finalChildren.length;
+        if (prunedLength == finalLength) {
+            if (finalLength >= 10) {
+                return new LabelDecorator.Stub() {
+                    @Override
+                    public String decorateLabel(String label, String column, int itemIndex) {
+                        if (decoratedColumns.contains(column))
+                            return label + " [" + finalLength + "]";
+                        return null;
+                    }
+                    @Override
+                    public <F> F decorateFont(F font, String column, int itemIndex) {
+                        //if (decoratedColumns.contains(column))
+                        //    return (F) ((FontDescriptor) font).withStyle(withStyle);
+                        return null;
+                    }
+                };
+            }
+            return null;
+        }
+
+        return new LabelDecorator.Stub() {
+            @Override
+            public String decorateLabel(String label, String column, int itemIndex) {
+                if (decoratedColumns.contains(column))
+                    return label + " [showing " + finalLength + "/" + prunedLength + "]";
+                return null;
+            }
+            @SuppressWarnings("unchecked")
+            @Override
+            public <F> F decorateFont(F font, String column, int itemIndex) {
+                if (decoratedColumns.contains(column))
+                    return (F) ((FontDescriptor) font).withStyle(withStyle);
+                return null;
+            }
+        };
+    }
+
 }
\ No newline at end of file
 }
\ No newline at end of file