]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/content/LabelDecorator.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui / src / org / simantics / browsing / ui / content / LabelDecorator.java
diff --git a/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/content/LabelDecorator.java b/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/content/LabelDecorator.java
new file mode 100644 (file)
index 0000000..0afcf95
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************\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.content;\r
+\r
+/**\r
+ * An interface for decorating aesthetic properties of an UI item, including the\r
+ * label text, font, background color and foreground color.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public interface LabelDecorator {\r
+\r
+    /**\r
+     * @param label the label before decoration\r
+     * @param column the name of the UI column which the label is for\r
+     * @param itemIndex the index of this label within its parenting\r
+     *        INodeContext\r
+     * @return the decorated label or <code>null</code> to denote\r
+     *         <em>no decoration</em>\r
+     */\r
+    String decorateLabel(String label, String column, int itemIndex);\r
+\r
+    <Color> Color decorateForeground(Color color, String column, int itemIndex);\r
+\r
+    <Color> Color decorateBackground(Color color, String column, int itemIndex);\r
+\r
+    /**\r
+     * @param font <code>null</code> if no default font is set ??\r
+     * @param column the name of the UI column which the label is for\r
+     * @param itemIndex the index of this label within its parenting\r
+     *        INodeContext\r
+     * @return the decorated font instance or <code>null</code> to indicate\r
+     *         "no decoration"\r
+     */\r
+    <Font> Font decorateFont(Font font, String column, int itemIndex);\r
+\r
+\r
+    /**\r
+     * Stub for simpler implementation of a LabelDecorator.\r
+     */\r
+    public static class Stub implements LabelDecorator {\r
+        @Override\r
+        public <Color> Color decorateBackground(Color color, String column, int itemIndex) {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public <Font> Font decorateFont(Font font, String column, int itemIndex) {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public <Color> Color decorateForeground(Color color, String column, int itemIndex) {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public String decorateLabel(String label, String column, int itemIndex) {\r
+            return null;\r
+        }\r
+    }\r
+\r
+}\r