X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FSWTConstantInput.java;fp=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FSWTConstantInput.java;h=2f461b024660f6b98b4132750cc4dd14bf83f62c;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..2f461b024 --- /dev/null +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/SWTConstantInput.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.browsing.ui.swt; + +import java.util.Collections; +import java.util.Map; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.common.node.ConstantInput; + +final public class SWTConstantInput extends ConstantInput { + + final private static Map NO_IMAGES = Collections.emptyMap(); + + public SWTConstantInput(Map labels, Map imageDescriptors, int category) { + super(labels, imageDescriptors, category); + } + + public static SWTConstantInput create(String label) { + return new SWTConstantInput(Collections.singletonMap(ColumnKeys.SINGLE, label), NO_IMAGES, 0); + } + + public static SWTConstantInput create(String label, ImageDescriptor descriptor) { + return new SWTConstantInput(Collections.singletonMap(ColumnKeys.SINGLE, label), Collections.singletonMap(ColumnKeys.SINGLE, descriptor), 0); + } + + @Override + public int hashCode() { + return labels.hashCode() + 31 * imageDescriptors.hashCode() + 41 * category; + } + + @Override + public boolean equals(Object object) { + if (this == object) + return true; + else if (object == null) + return false; + else if (SWTConstantInput.class != object.getClass()) + return false; + SWTConstantInput r = (SWTConstantInput)object; + return r.labels.equals(labels) && r.imageDescriptors.equals(imageDescriptors) && r.category == category; + } + +}