| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.xtext.table.common; |
| |
| import java.util.Date; |
| |
| import com.vaadin.server.Resource; |
| import com.vaadin.shared.ui.MarginInfo; |
| import com.vaadin.ui.FormLayout; |
| import com.vaadin.ui.Image; |
| |
| public class CellSetImage extends FormLayout implements Comparable<CellSetImage> { |
| private static final long serialVersionUID = 4873534419157818152L; |
| private Object value = null; |
| private String resourceName; |
| |
| public Object getValue() { |
| return value; |
| } |
| |
| public CellSetImage(Object value, String caption, Resource resource, String resourceName, boolean hideLabel, String sizeString) { |
| super(); |
| this.value = value; |
| this.resourceName = resourceName; |
| setSpacing(false); |
| setMargin(new MarginInfo(false, false, false, false)); |
| Image img = null; |
| if (hideLabel) { |
| img = new Image("",resource); |
| } else { |
| img = new Image(caption,resource); |
| } |
| if (sizeString != null) { |
| img.setHeight(sizeString); |
| img.setWidth(sizeString); |
| } |
| addComponent(img); |
| setSizeUndefined(); |
| } |
| |
| @Override |
| public int compareTo(CellSetImage o) { |
| if (value.getClass().equals(String.class)) { |
| return ((String)value).compareTo((String)o.getValue()); |
| } |
| else if (value.getClass().equals(Date.class)) { |
| return ((Date)value).compareTo((Date)o.getValue()); |
| } |
| else if (value.getClass().equals(Double.class)) { |
| return ((Double) value).compareTo((Double)o.getValue()); |
| } |
| return 0; |
| } |
| |
| public String getResourceName() { |
| return resourceName; |
| } |
| } |