| /** |
| * |
| * 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 v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| * |
| */ |
| |
| package org.eclipse.osbp.xtext.gridsource.ui.labeling |
| |
| import com.google.inject.Inject |
| import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider |
| import org.eclipse.jface.viewers.StyledString |
| import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider |
| import org.eclipse.osbp.infogrid.model.gridsource.CxGridProperty |
| import org.eclipse.osbp.infogrid.model.gridsource.CxGridSource |
| import org.eclipse.osbp.infogrid.model.gridsource.CxGridSourceInput |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropBooleanStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropButtonStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropDateStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropHtmlStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropImageStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropIndicatorStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropNumberStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropPriceStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropProgressbarStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropQuantityStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropTextStyle |
| import org.eclipse.osbp.infogrid.model.gridsource.util.Util |
| |
| /** |
| * Provides labels for a EObjects. |
| * |
| * see http://www.eclipse.org/Xtext/documentation.html#labelProvider |
| */ |
| class GridSourceLabelProvider extends DefaultEObjectLabelProvider { |
| |
| @Inject |
| new(AdapterFactoryLabelProvider delegate) { |
| super(delegate); |
| } |
| |
| // Labels and icons can be computed like this: |
| def text(CxGridProperty ele) { |
| Util.calcDotPath(ele).text(ele.style) |
| } |
| |
| def dispatch text(String prop, CxGridPropButtonStyle ele) { |
| prop.getDisplayString('''Button topic(«ele.eventTopic»)''') |
| } |
| |
| def dispatch text(String prop, CxGridPropHtmlStyle ele) { |
| prop.getDisplayString("Html") |
| } |
| |
| def dispatch text(String prop, CxGridPropBooleanStyle ele) { |
| prop.getDisplayString("Boolean") |
| } |
| |
| def dispatch text(String prop, CxGridPropDateStyle ele) { |
| prop.getDisplayString('''Date format(«ele.dateFormat»)''') |
| } |
| |
| def dispatch text(String prop, CxGridPropNumberStyle ele) { |
| prop.getDisplayString('''Number format(«ele.numberFormat»)''') |
| } |
| |
| def dispatch text(String prop, CxGridPropProgressbarStyle ele) { |
| prop.getDisplayString('''ProgressBar max(«ele.maxValue»)''') |
| } |
| |
| def dispatch text(String prop, CxGridPropIndicatorStyle ele) { |
| prop.getDisplayString('''Indicator red color < «ele.redEnds» green color > «ele.greenStarts»''') |
| } |
| |
| def dispatch text(String prop, CxGridPropQuantityStyle ele) { |
| prop.getDisplayString('''Quantity pattern(«ele.htmlPattern»)''') |
| } |
| |
| def dispatch text(String prop, CxGridPropPriceStyle ele) { |
| prop.getDisplayString('''Price pattern(«ele.htmlPattern»)''') |
| } |
| |
| def dispatch text(String prop, CxGridPropTextStyle ele) { |
| prop.getDisplayString("Text") |
| } |
| |
| def dispatch text(String prop, CxGridPropImageStyle ele) { |
| prop.getDisplayString("Image") |
| } |
| |
| def text(CxGridSourceInput ele) { |
| "Input".getDisplayString(ele.inputType.qualifiedName) |
| } |
| |
| def StyledString getDisplayString(String value, String description) { |
| val StyledString string = new StyledString(value) |
| if (!description.nullOrEmpty) |
| string.append(" : " + description, StyledString.DECORATIONS_STYLER) |
| |
| return string |
| } |
| |
| def image(CxGridSource ele) { |
| 'GridSource.png' |
| } |
| |
| def image(CxGridSourceInput ele) { |
| 'CxGridSourceInput.png' |
| } |
| |
| def image(CxGridProperty ele) { |
| 'CxGridProperty.png' |
| } |
| } |