]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/SWTConstantInput.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / SWTConstantInput.java
diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/SWTConstantInput.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/SWTConstantInput.java
new file mode 100644 (file)
index 0000000..2f461b0
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************\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.browsing.ui.swt;\r
+\r
+import java.util.Collections;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.common.node.ConstantInput;\r
+\r
+final public class SWTConstantInput extends ConstantInput<ImageDescriptor> {\r
+       \r
+       final private static Map<String, ImageDescriptor> NO_IMAGES = Collections.emptyMap(); \r
+       \r
+    public SWTConstantInput(Map<String, String> labels, Map<String, ImageDescriptor> imageDescriptors, int category) {\r
+               super(labels, imageDescriptors, category);\r
+       }\r
+\r
+       public static SWTConstantInput create(String label) {\r
+       return new SWTConstantInput(Collections.singletonMap(ColumnKeys.SINGLE, label), NO_IMAGES, 0);\r
+    }\r
+\r
+       public static SWTConstantInput create(String label, ImageDescriptor descriptor) {\r
+       return new SWTConstantInput(Collections.singletonMap(ColumnKeys.SINGLE, label), Collections.singletonMap(ColumnKeys.SINGLE, descriptor), 0);\r
+    }\r
+\r
+       @Override\r
+       public int hashCode() {\r
+               return labels.hashCode() + 31 * imageDescriptors.hashCode() + 41 * category;\r
+       }\r
+       \r
+    @Override\r
+    public boolean equals(Object object) {\r
+        if (this == object)\r
+            return true;\r
+        else if (object == null)\r
+            return false;\r
+        else if (SWTConstantInput.class != object.getClass())\r
+            return false;\r
+        SWTConstantInput r = (SWTConstantInput)object;\r
+        return r.labels.equals(labels) && r.imageDescriptors.equals(imageDescriptors) && r.category == category;\r
+    }\r
+       \r
+}\r