1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.browsing.ui.swt;
14 import java.util.Collections;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.simantics.browsing.ui.common.ColumnKeys;
19 import org.simantics.browsing.ui.common.node.ConstantInput;
21 final public class SWTConstantInput extends ConstantInput<ImageDescriptor> {
23 final private static Map<String, ImageDescriptor> NO_IMAGES = Collections.emptyMap();
25 public SWTConstantInput(Map<String, String> labels, Map<String, ImageDescriptor> imageDescriptors, int category) {
26 super(labels, imageDescriptors, category);
29 public static SWTConstantInput create(String label) {
30 return new SWTConstantInput(Collections.singletonMap(ColumnKeys.SINGLE, label), NO_IMAGES, 0);
33 public static SWTConstantInput create(String label, ImageDescriptor descriptor) {
34 return new SWTConstantInput(Collections.singletonMap(ColumnKeys.SINGLE, label), Collections.singletonMap(ColumnKeys.SINGLE, descriptor), 0);
38 public int hashCode() {
39 return labels.hashCode() + 31 * imageDescriptors.hashCode() + 41 * category;
43 public boolean equals(Object object) {
46 else if (object == null)
48 else if (SWTConstantInput.class != object.getClass())
50 SWTConstantInput r = (SWTConstantInput)object;
51 return r.labels.equals(labels) && r.imageDescriptors.equals(imageDescriptors) && r.category == category;