catch up with branch daily
Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.utils.ui/.classpath b/org.eclipse.osbp.utils.ui/.classpath
index 502f456..30a5795 100644
--- a/org.eclipse.osbp.utils.ui/.classpath
+++ b/org.eclipse.osbp.utils.ui/.classpath
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="src-gen/"/>
+ <classpathentry kind="src" path="test/"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF b/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF
index c51eb3f..cc7c24c 100644
--- a/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF
@@ -10,8 +10,7 @@
org.eclipse.osbp.utils.vaadin.beeper;version="0.9.0",
org.eclipse.osbp.utils.vaadin.bpmn;version="0.9.0",
org.eclipse.osbp.utils.vaadin.problems;version="0.9.0"
-Require-Bundle: org.apache.commons.lang,
- com.vaadin.server;bundle-version="[7.7.6,7.8.0)",
+Require-Bundle: com.vaadin.server;bundle-version="[7.7.6,7.8.0)",
com.vaadin.shared;bundle-version="[7.7.6,7.8.0)",
com.vaadin.client;bundle-version="[7.7.6,7.8.0)",
org.eclipse.e4.core.services;bundle-version="1.2.1",
@@ -33,7 +32,9 @@
org.eclipse.osbp.core.api;bundle-version="0.9.0",
org.eclipse.osbp.vaadin.emf.api;bundle-version="0.9.0",
org.eclipse.osbp.vaadin.emf;bundle-version="0.9.0",
- org.eclipse.osbp.dsl.entity.xtext;bundle-version="0.9.0"
+ org.eclipse.osbp.dsl.entity.xtext;bundle-version="0.9.0",
+ javax.persistence;bundle-version="2.1.0",
+ javax.validation.api;bundle-version="1.1.0"
Bundle-Vendor: Eclipse OSBP
Import-Package: com.google.gwt.dev.json;version="2.7.0",
com.vaadin.ui,
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/CellSetImage.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/CellSetImage.java
deleted file mode 100644
index 353fd69..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/CellSetImage.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-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;
-
- public Object getValue() {
- return value;
- }
-
- public CellSetImage(Object value, String caption, Resource resource, boolean hideLabel, String sizeString) {
- super();
- this.value = value;
- 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;
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/DTOInfoDialog.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/DTOInfoDialog.java
index 3854112..d6ecc39 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/DTOInfoDialog.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/DTOInfoDialog.java
@@ -20,8 +20,8 @@
import java.util.Locale;
import java.util.regex.Pattern;
-import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherCommand;
import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
@@ -64,11 +64,13 @@
private ObjectProperty<String> createdAtProp;
private ObjectProperty<String> updatedByProp;
private ObjectProperty<String> updatedAtProp;
+ private MPerspective perspective;
public DTOInfoDialog(IEclipseContext eclipseContext, Locale locale, String sender, String topic) {
super();
this.dslMetadataService = eclipseContext.get(IDSLMetadataService.class);
this.eventDispatcher = eclipseContext.get(IEventDispatcher.class);
+ this.perspective = eclipseContext.get(MPerspective.class);
this.addDetachListener(this);
this.sender = sender;
this.topic = topic;
@@ -107,7 +109,7 @@
private static final long serialVersionUID = 5512635792523351385L;
@Override
public void buttonClick(ClickEvent event) {
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.CLOSE, topic, sender);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, topic, sender);
eventDispatcher.sendEvent(evnt);
}
});
@@ -160,7 +162,7 @@
@Override
public void detach(DetachEvent event) {
- EventDispatcherEvent evt = new EventDispatcherEvent(EventDispatcherCommand.CLOSE, topic, sender);
+ EventDispatcherEvent evt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, topic, sender);
eventDispatcher.sendEvent(evt);
}
}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MDXDialog.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MDXDialog.java
index ac81324..2c83b78 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MDXDialog.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MDXDialog.java
@@ -37,7 +37,6 @@
import com.vaadin.server.ClientConnector.DetachListener;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.RowHeaderMode;
@@ -54,7 +53,6 @@
*/
private static final long serialVersionUID = 3461161019240158996L;
private static final Logger LOGGER = LoggerFactory.getLogger(MDXDialog.class);
- private Label label;
private TextArea input;
private Button button;
private Component tableLayout;
@@ -73,8 +71,6 @@
public MDXDialog(IEclipseContext eclipseContext) {
super();
addDetachListener(this);
- setWidth("800px");
- setHeight("800px");
dslMetadataService = eclipseContext.get(IDSLMetadataService.class);
persistenceService = eclipseContext.get(IPersistenceService.class);
user = eclipseContext.get(IUser.class);
@@ -85,10 +81,7 @@
VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
setContent(subContent);
- label = new Label();
- label.addStyleName("os-querylabel");
- label.setCaption(messageText);
- subContent.addComponent(label);
+ setCaption(messageText);
subContent.setSpacing(true);
subLayout = new VerticalLayout();
subContent.addComponent(subLayout);
@@ -98,6 +91,9 @@
input.setWordwrap(true);
input.setSizeFull();
input.setValue(sampleText);
+ input.setWidth("600px");
+ input.setHeight("150px");
+
subLayout.addComponent(input);
button = new Button(buttonText);
button.addClickListener(e -> executeQuery());
@@ -182,13 +178,13 @@
return component;
}
- @SuppressWarnings("unchecked")
private Component createTable(DerivedCellSet cellSet) {
List<Integer> coordinate = new ArrayList<>(coordinateSystem);
VerticalLayout container = new VerticalLayout();
Table table = new Table();
table.setImmediate(true);
table.setMultiSelect(false);
+ table.setSelectable(true);
table.setRowHeaderMode(RowHeaderMode.HIDDEN);
table.setSizeFull();
container.addComponent(table);
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/PropertyLookup.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/PropertyLookup.java
deleted file mode 100644
index 0571327..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/PropertyLookup.java
+++ /dev/null
@@ -1,807 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.osbp.blob.component.BlobComponent;
-import org.eclipse.osbp.ui.api.customfields.IBlobService;
-import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
-import org.eclipse.osbp.ui.api.themes.IThemeResourceService;
-import org.eclipse.osbp.ui.api.themes.IThemeResourceService.ThemeResourceType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.vaadin.data.util.converter.Converter.ConversionException;
-import com.vaadin.server.Resource;
-
-class DoubleComparator implements Comparator<Double> {
- @Override
- public int compare(Double arg0, Double arg1) {
- return arg0.compareTo(arg1);
- }
-}
-
-class IntegerComparator implements Comparator<Integer> {
- @Override
- public int compare(Integer arg0, Integer arg1) {
- return arg0.compareTo(arg1);
- }
-}
-
-class BigDecimalComparator implements Comparator<BigDecimal> {
- @Override
- public int compare(BigDecimal arg0, BigDecimal arg1) {
- return arg0.compareTo(arg1);
- }
-}
-
-class DateComparator implements Comparator<Date> {
- @Override
- public int compare(Date o1, Date o2) {
- return o1.compareTo(o2);
- }
-}
-
-public class PropertyLookup {
- private final IThemeResourceService themeResourceService;
- private final IDSLMetadataService dslMetadataService;
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PropertyLookup.class);
- // datatypes
- public static final int NOT_SET = -1;
- public static final int DATE = 0;
- public static final int NUMBER = 1;
- public static final int BIGDECIMAL = 2;
- public static final int STRING = 3;
- public static final int INTEGER = 4;
- public static final int LONG = 5;
-
- // infotype
- public static final int STYLE = 0;
- public static final int RESOURCE = 1;
-
- String format = null;
- String defaultStyle = null;
-
- boolean styleDiscreteValues = false;
- boolean resourceDiscreteValues = false;
- boolean tooltipDiscreteValues = false;
- boolean hideLabel = false;
- boolean collapseColumn = false;
- String tooltipPattern = null;
- private Map<Date, Resource> dateResourceMap = new TreeMap<>(new DateComparator());
- private Map<Date, String> dateStyleMap = new TreeMap<>(new DateComparator());
- private Map<Date, String> dateTooltipMap = new TreeMap<>(new DateComparator());
- private Map<Double, Resource> doubleResourceMap = new TreeMap<>(new DoubleComparator());
- private Map<Double, String> doubleStyleMap = new TreeMap<>(new DoubleComparator());
- private Map<Double, String> doubleTooltipMap = new TreeMap<>(new DoubleComparator());
- private Map<Integer, Resource> intResourceMap = new TreeMap<>(new IntegerComparator());
- private Map<Integer, String> intStyleMap = new TreeMap<>(new IntegerComparator());
- private Map<Integer, String> intTooltipMap = new TreeMap<>(new IntegerComparator());
- private Map<String, Resource> stringResourceMap = new HashMap<>();
- private Map<String, String> stringStyleMap = new HashMap<>();
- private Map<String, String> stringTooltipMap = new HashMap<>();
- private Locale locale;
- private int defaultType = NOT_SET;
- private boolean isImage = false;
- private boolean isBlob = false;
- private boolean isEnum = false;
- private StringToFormattedDateConverter dateConv = new StringToFormattedDateConverter();
- private StringToFormattedDoubleConverter numberConv = new StringToFormattedDoubleConverter();
- private StringToFormattedBigDecimalConverter bigDecimalConv = new StringToFormattedBigDecimalConverter();
- private StringToFormattedIntegerConverter intConv = new StringToFormattedIntegerConverter();
- private StringToFormattedLongConverter longConv = new StringToFormattedLongConverter();
- private String imagePath = null;
- private String imageParameterPattern = null;
- private String imageParameterFormat = null;
- private String resizeString = null;
- private Resource columnIcon = null;
- private int resolutionId = 0;
- private IBlobService blobService;
- @SuppressWarnings("rawtypes")
- private Class<?> enumClass;
-
- public PropertyLookup(IThemeResourceService themeResourceService, IDSLMetadataService dslMetadataService,
- IBlobService blobService, Locale locale) {
- this.themeResourceService = themeResourceService;
- this.dslMetadataService = dslMetadataService;
- this.blobService = blobService;
- this.locale = locale;
- }
-
- public PropertyLookup setLocale(Locale locale) {
- this.locale = locale;
- return this;
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public String getFormat() {
- return format;
- }
-
- public PropertyLookup setFormat(String format) {
- this.format = format;
- dateConv.setLookup(this);
- numberConv.setLookup(this);
- bigDecimalConv.setLookup(this);
- return this;
- }
-
- public String getTooltipPattern() {
- return tooltipPattern;
- }
-
- public PropertyLookup setTooltipPattern(String tooltipPattern) {
- this.tooltipPattern = tooltipPattern;
- return this;
- }
-
- public String getTooltip(Object value) {
- String tooltip = null;
- String item = "";
- switch (defaultType) {
- case DATE:
- item = dateConv.convertToPresentation((Date) value, String.class, locale);
- break;
- case NUMBER:
- try {
- item = numberConv.convertToPresentation(getDoubleValue(value), String.class, locale);
- } catch (ConversionException e) {
- LOGGER.error("{}", e);
- }
- break;
- case INTEGER:
- try {
- item = intConv.convertToPresentation((Integer) value, String.class, locale);
- } catch (ConversionException e) {
- LOGGER.error("{}", e);
- }
- break;
- case LONG:
- try {
- item = longConv.convertToPresentation((Long) value, String.class, locale);
- } catch (ConversionException e) {
- LOGGER.error("{}", e);
- }
- break;
- case BIGDECIMAL:
- try {
- item = bigDecimalConv.convertToPresentation(getBigDecimalValue(value), String.class, locale);
- } catch (ConversionException e) {
- LOGGER.error("{}", e);
- }
- break;
- case STRING:
- item = (String) value;
- LOGGER.debug("getTooltip >" + item + "<");
- break;
- default:
- break;
- }
- if (tooltipPattern != null) {
- LOGGER.debug("getTooltip pattern >" + tooltipPattern + "< result:" + tooltip);
- tooltip = String.format(tooltipPattern, item);
- } else if (value != null) {
- tooltip = item;
- }
- return tooltip;
- }
-
- public Resource getColumnIcon() {
- return columnIcon;
- }
-
- public PropertyLookup setColumnIcon(String resourceName) {
- columnIcon = themeResourceService.getThemeResource(resourceName, ThemeResourceType.ICON);
- return this;
- }
-
- public boolean isBlob() {
- return isBlob;
- }
-
- public PropertyLookup setBlob(boolean isBlob, int resolutionId) {
- this.isBlob = isBlob;
- this.resolutionId = resolutionId;
- return this;
- }
-
- public boolean isEnum() {
- return isEnum;
- }
-
- @SuppressWarnings("rawtypes")
- public PropertyLookup setEnum(boolean isEnum, Class<?> enumClass) {
- this.isEnum = isEnum;
- this.enumClass = enumClass;
- return this;
- }
-
- public String getResizeString() {
- return resizeString;
- }
-
- public PropertyLookup setResizeString(String resizeString) {
- this.resizeString = resizeString;
- return this;
- }
-
- public StringToFormattedDateConverter getDateConverter() {
- return dateConv;
- }
-
- public StringToFormattedDoubleConverter getNumberConverter() {
- return numberConv;
- }
-
- public StringToFormattedIntegerConverter getIntegerConverter() {
- return intConv;
- }
-
- public StringToFormattedBigDecimalConverter getBigDecimalConverter() {
- return bigDecimalConv;
- }
-
- /**
- * @param until
- * @param resourceName
- */
- public PropertyLookup addResourceInterval(Date until, String resourceName) {
- Resource resource = themeResourceService.getThemeResource(resourceName, ThemeResourceType.ICON);
- dateResourceMap.put(until, resource);
- isImage = true;
- defaultType = DATE;
- return this;
- }
-
- public PropertyLookup addStyleInterval(Date until, String styleName) {
- dateStyleMap.put(until, styleName);
- defaultType = DATE;
- return this;
- }
-
- public PropertyLookup addTooltipInterval(Date until, String tooltip) {
- dateTooltipMap.put(until, tooltip);
- defaultType = DATE;
- return this;
- }
-
- public PropertyLookup addResourceLookup(Date value, String resourceName) {
- resourceDiscreteValues = true;
- addResourceInterval(value, resourceName);
- return this;
- }
-
- public PropertyLookup addStyleLookup(Date value, String styleName) {
- styleDiscreteValues = true;
- addStyleInterval(value, styleName);
- return this;
- }
-
- public PropertyLookup addTooltipLookup(Date value, String tooltip) {
- tooltipDiscreteValues = true;
- addResourceInterval(value, tooltip);
- return this;
- }
-
- public PropertyLookup addResourceLookup(String value, String resourceName) {
- Resource resource = themeResourceService.getThemeResource(resourceName, ThemeResourceType.ICON);
- stringResourceMap.put(value, resource);
- isImage = true;
- defaultType = STRING;
- return this;
- }
-
- public PropertyLookup addStyleLookup(String value, String styleName) {
- stringStyleMap.put(value, styleName);
- defaultType = STRING;
- return this;
- }
-
- public PropertyLookup addTooltipLookup(String value, String tooltip) {
- stringTooltipMap.put(value, tooltip);
- defaultType = STRING;
- return this;
- }
-
- public PropertyLookup addResourceLookup(int value, String resourceName) {
- resourceDiscreteValues = true;
- addResourceInterval(value, resourceName);
- return this;
- }
-
- public PropertyLookup addStyleLookup(int value, String styleName) {
- styleDiscreteValues = true;
- addStyleInterval(value, styleName);
- return this;
- }
-
- public PropertyLookup addTooltipLookup(int value, String tooltip) {
- tooltipDiscreteValues = true;
- addTooltipInterval(value, tooltip);
- return this;
- }
-
- public PropertyLookup addResourceInterval(int until, String resourceName) {
- Resource resource = themeResourceService.getThemeResource(resourceName, ThemeResourceType.ICON);
- intResourceMap.put(until, resource);
- isImage = true;
- defaultType = INTEGER;
- return this;
- }
-
- public PropertyLookup addStyleInterval(int until, String styleName) {
- intStyleMap.put(until, styleName);
- defaultType = INTEGER;
- return this;
- }
-
- public PropertyLookup addTooltipInterval(int until, String tooltip) {
- intTooltipMap.put(until, tooltip);
- defaultType = INTEGER;
- return this;
- }
-
- public PropertyLookup addResourceLookup(double value, String resourceName) {
- resourceDiscreteValues = true;
- addResourceInterval(value, resourceName);
- return this;
- }
-
- public PropertyLookup addStyleLookup(double value, String styleName) {
- styleDiscreteValues = true;
- addStyleInterval(value, styleName);
- return this;
- }
-
- public PropertyLookup addTooltipLookup(double value, String tooltip) {
- tooltipDiscreteValues = true;
- addTooltipInterval(value, tooltip);
- return this;
- }
-
- public PropertyLookup addResourceInterval(double until, String resourceName) {
- Resource resource = themeResourceService.getThemeResource(resourceName, ThemeResourceType.ICON);
- doubleResourceMap.put(until, resource);
- isImage = true;
- defaultType = NUMBER;
- return this;
- }
-
- public PropertyLookup addStyleInterval(double until, String styleName) {
- doubleStyleMap.put(until, styleName);
- defaultType = NUMBER;
- return this;
- }
-
- public PropertyLookup addTooltipInterval(double until, String tooltip) {
- doubleTooltipMap.put(until, tooltip);
- defaultType = NUMBER;
- return this;
- }
-
- public boolean isHideLabel() {
- return hideLabel;
- }
-
- public PropertyLookup setHideLabel(boolean hideLabel) {
- this.hideLabel = hideLabel;
- return this;
- }
-
- public boolean isCollapseColumn() {
- return collapseColumn;
- }
-
- public PropertyLookup setCollapseColumn(boolean collapseColumn) {
- this.collapseColumn = collapseColumn;
- return this;
- }
-
- protected double getDoubleValue(Object value) {
- if (value instanceof Double) {
- return (Double) value;
- } else if (value instanceof Float) {
- return (Float) value;
- } else if (value instanceof Long) {
- return (Long) value;
- }
- return 0;
- }
-
- protected BigDecimal getBigDecimalValue(Object value) {
- if (value instanceof BigDecimal) {
- return (BigDecimal) value;
- }
- return BigDecimal.ZERO;
- }
-
- public int getType() {
- return defaultType;
- }
-
- public PropertyLookup setType(int type) {
- this.defaultType = type;
- return this;
- }
-
- @SuppressWarnings("rawtypes")
- public Object getValueObject(Object value) {
- if (value == null) {
- return null;
- }
- switch (defaultType) {
- case DATE:
- for (Date key : dateResourceMap.keySet()) {
- if ((resourceDiscreteValues && ((Date) value).equals(key))
- || (!resourceDiscreteValues && ((Date) value).before(key))) {
- return new CellSetImage(value, dateConv.convertToPresentation((Date) value, String.class, locale),
- dateResourceMap.get(key), hideLabel, resizeString);
- }
- }
- // if it should be an image and no match was found, return an empty
- // image to avoid complaints
- if (isImage) {
- return new CellSetImage(value, dateConv.convertToPresentation((Date) value, String.class, locale), null,
- hideLabel, resizeString);
- }
- break;
- case NUMBER:
- double doubleValue = getDoubleValue(value);
- for (Double key : doubleResourceMap.keySet()) {
- if ((resourceDiscreteValues && doubleValue == key) || (!resourceDiscreteValues && doubleValue <= key)) {
- return new CellSetImage(doubleValue,
- numberConv.convertToPresentation(doubleValue, String.class, locale),
- doubleResourceMap.get(key), hideLabel, resizeString);
- }
- }
- if (imagePath != null) {
- String path = imagePath;
- if (imageParameterPattern != null) {
- path = path.replace(imageParameterPattern, String.format(imageParameterFormat, doubleValue));
- }
- Resource res = themeResourceService.getThemeResource(path, ThemeResourceType.ICON);
- return new CellSetImage(doubleValue,
- numberConv.convertToPresentation(doubleValue, String.class, locale), res, hideLabel,
- resizeString);
- }
- // if it should be an image and no match was found, return an empty
- // image to avoid complaints
- if (isImage) {
- return new CellSetImage(doubleValue,
- numberConv.convertToPresentation(doubleValue, String.class, locale), null, hideLabel,
- resizeString);
- }
- break;
- case INTEGER:
- Integer intValue = (Integer) value;
- for (Integer key : intResourceMap.keySet()) {
- if ((resourceDiscreteValues && intValue == key) || (!resourceDiscreteValues && intValue <= key)) {
- return new CellSetImage(intValue, intConv.convertToPresentation(intValue, String.class, locale),
- intResourceMap.get(key), hideLabel, resizeString);
- }
- }
- if (imagePath != null) {
- String path = imagePath;
- if (imageParameterPattern != null) {
- path = path.replace(imageParameterPattern, String.format(imageParameterFormat, intValue));
- }
- Resource res = themeResourceService.getThemeResource(path, ThemeResourceType.ICON);
- return new CellSetImage(intValue, intConv.convertToPresentation(intValue, String.class, locale), res,
- hideLabel, resizeString);
- }
- // if it should be an image and no match was found, return an empty
- // image to avoid complaints
- if (isImage) {
- return new CellSetImage(intValue, intConv.convertToPresentation(intValue, String.class, locale), null,
- hideLabel, resizeString);
- }
- if (isEnum) {
- return dslMetadataService.translate(locale.toLanguageTag(),
- ((Enum) enumClass.getEnumConstants()[intValue]).name().toLowerCase(locale));
- }
- break;
- case LONG:
- Long longValue = (Long) value;
- for (Integer key : intResourceMap.keySet()) {
- if ((resourceDiscreteValues && longValue == (long) key)
- || (!resourceDiscreteValues && longValue <= (long) key)) {
- return new CellSetImage(longValue, longConv.convertToPresentation(longValue, String.class, locale),
- intResourceMap.get(key), hideLabel, resizeString);
- }
- }
- if (imagePath != null) {
- String path = imagePath;
- if (imageParameterPattern != null) {
- path = path.replace(imageParameterPattern,
- String.format(imageParameterFormat, longValue.intValue()));
- }
- Resource res = themeResourceService.getThemeResource(path, ThemeResourceType.ICON);
- return new CellSetImage(longValue, longConv.convertToPresentation(longValue, String.class, locale), res,
- hideLabel, resizeString);
- }
- // if it should be an image and no match was found, return an empty
- // image to avoid complaints
- if (isImage) {
- return new CellSetImage(longValue, longConv.convertToPresentation(longValue, String.class, locale),
- null, hideLabel, resizeString);
- }
- break;
- case BIGDECIMAL:
- BigDecimal bigValue = getBigDecimalValue(value);
- for (Double key : doubleResourceMap.keySet()) {
- BigDecimal bdKey = new BigDecimal(key);
- if ((resourceDiscreteValues && bigValue.equals(bdKey))
- || (!resourceDiscreteValues && bigValue.compareTo(bdKey) <= 0)) {
- return new CellSetImage(bigValue,
- bigDecimalConv.convertToPresentation(bigValue, String.class, locale),
- doubleResourceMap.get(key), hideLabel, resizeString);
- }
- }
- if (imagePath != null) {
- String path = imagePath;
- if (imageParameterPattern != null) {
- path = path.replace(imageParameterPattern, String.format(imageParameterFormat, bigValue));
- }
- Resource res = themeResourceService.getThemeResource(path, ThemeResourceType.ICON);
- return new CellSetImage(bigValue, bigDecimalConv.convertToPresentation(bigValue, String.class, locale),
- res, hideLabel, resizeString);
- }
- // if it should be an image and no match was found, return an empty
- // image to avoid complaints
- if (isImage) {
- return new CellSetImage(bigValue, bigDecimalConv.convertToPresentation(bigValue, String.class, locale),
- null, hideLabel, resizeString);
- }
- break;
- case STRING:
- for (String key : stringResourceMap.keySet()) {
- if (key.equals(value)) {
- return new CellSetImage(value, (String) value, stringResourceMap.get(key), hideLabel, resizeString);
- }
- }
- if (imagePath != null) {
- String path = imagePath;
- if (imageParameterPattern != null) {
- path = path.replace(imageParameterPattern, String.format(imageParameterFormat, (String) value));
- }
- Resource res = themeResourceService.getThemeResource(path, ThemeResourceType.ICON);
- return new CellSetImage(value, (String) value, res, hideLabel, resizeString);
- }
- if (isBlob) {
- return new BlobComponent(blobService, (String) value, resolutionId);
- }
- // if it should be an image and no match was found, return an empty
- // image to avoid complaints
- if (isImage) {
- return new CellSetImage(value, (String) value, null, hideLabel, resizeString);
- }
- break;
- default:
- break;
- }
- return value;
- }
-
- public String getValueTooltip(Object value) {
- switch (defaultType) {
- case DATE:
- for (Date key : dateTooltipMap.keySet()) {
- if ((tooltipDiscreteValues && ((Date) value).equals(key))
- || (!tooltipDiscreteValues && ((Date) value).before(key))) {
- return dslMetadataService.translate(locale.toLanguageTag(), dateTooltipMap.get(key));
- }
- }
- break;
- case NUMBER:
- double doubleValue = getDoubleValue(value);
- for (Double key : doubleTooltipMap.keySet()) {
- if ((tooltipDiscreteValues && doubleValue == key) || (!tooltipDiscreteValues && doubleValue <= key)) {
- return dslMetadataService.translate(locale.toLanguageTag(), doubleTooltipMap.get(key));
- }
- }
- break;
- case INTEGER:
- Integer intValue = (Integer) value;
- for (Integer key : intTooltipMap.keySet()) {
- if ((tooltipDiscreteValues && intValue == key) || (!tooltipDiscreteValues && intValue <= key)) {
- return dslMetadataService.translate(locale.toLanguageTag(), intTooltipMap.get(key));
- }
- }
- break;
- case LONG:
- Long longValue = (Long) value;
- for (Integer key : intTooltipMap.keySet()) {
- if ((tooltipDiscreteValues && longValue == (long) key)
- || (!tooltipDiscreteValues && longValue <= (long) key)) {
- return dslMetadataService.translate(locale.toLanguageTag(), intTooltipMap.get(key));
- }
- }
- break;
- case BIGDECIMAL:
- BigDecimal bigValue = BigDecimal.ZERO;
- bigValue = getBigDecimalValue(value);
- for (Double key : doubleTooltipMap.keySet()) {
- BigDecimal bdKey = new BigDecimal(key);
- if ((tooltipDiscreteValues && bigValue.equals(bdKey))
- || (!tooltipDiscreteValues && bigValue.compareTo(bdKey) <= 0)) {
- return dslMetadataService.translate(locale.toLanguageTag(), doubleTooltipMap.get(key));
- }
- }
- break;
- case STRING:
- for (String key : stringTooltipMap.keySet()) {
- if (key.equals(value)) {
- return dslMetadataService.translate(locale.toLanguageTag(), stringTooltipMap.get(key));
- }
- }
- break;
- default:
- break;
- }
- return getTooltip(value);
- }
-
- public String getDefaultStyle() {
- return defaultStyle;
- }
-
- public PropertyLookup setDefaultStyle(Class<?> type, boolean isHeader) {
- if (isHeader) {
- defaultStyle = "rowheader";
- } else if (type.equals(double.class) || type.equals(Double.class) || type.equals(float.class)
- || type.equals(Float.class) || type.equals(int.class) || type.equals(Integer.class)
- || type.equals(long.class) || type.equals(Long.class) || type.equals(BigDecimal.class)) {
- defaultStyle = "v-align-right";
- } else if (type.equals(String.class)) {
- defaultStyle = "v-align-left";
- } else if (type.equals(Date.class) || type.equals(Timestamp.class)) {
- defaultStyle = "v-align-left";
- } else if (type.equals(CellSetImage.class)) {
- defaultStyle = "v-align-center";
- }
- return this;
- }
-
- public String getValueStyle(Object value, int rowNumber) {
- switch (defaultType) {
- case DATE:
- if (dateStyleMap.size() == 0) {
- return defaultStyle;
- }
- for (Date key : dateStyleMap.keySet()) {
- if ((styleDiscreteValues && ((Date) value).equals(key))
- || (!styleDiscreteValues && ((Date) value).before(key))) {
- return dateStyleMap.get(key);
- }
- }
- break;
- case NUMBER:
- if (doubleStyleMap.size() == 0) {
- return defaultStyle;
- }
- double doubleValue = getDoubleValue(value);
- for (Double key : doubleStyleMap.keySet()) {
- if ((styleDiscreteValues && doubleValue == key) || (!styleDiscreteValues && doubleValue <= key)) {
- return doubleStyleMap.get(key);
- }
- }
- break;
- case INTEGER:
- if (intStyleMap.size() == 0) {
- return defaultStyle;
- }
- Integer intValue = (Integer) value;
- for (Integer key : intStyleMap.keySet()) {
- if ((styleDiscreteValues && intValue == key) || (!styleDiscreteValues && intValue <= key)) {
- return intStyleMap.get(key);
- }
- }
- break;
- case LONG:
- if (intStyleMap.size() == 0) {
- return defaultStyle;
- }
- Long longValue = (Long) value;
- for (Integer key : intStyleMap.keySet()) {
- if ((styleDiscreteValues && longValue == (long) key)
- || (!styleDiscreteValues && longValue <= (long) key)) {
- return intStyleMap.get(key);
- }
- }
- break;
- case BIGDECIMAL:
- if (doubleStyleMap.size() == 0) {
- return defaultStyle;
- }
- BigDecimal bigDecimalValue = BigDecimal.ZERO;
- bigDecimalValue = getBigDecimalValue(value);
- for (Double key : doubleStyleMap.keySet()) {
- BigDecimal bdKey = new BigDecimal(key);
- if ((styleDiscreteValues && bigDecimalValue.equals(bdKey))
- || (!styleDiscreteValues && bigDecimalValue.compareTo(bdKey) <= 0)) {
- return doubleStyleMap.get(key);
- }
- }
- break;
- case STRING:
- if (stringStyleMap.size() == 0) {
- return defaultStyle;
- }
- for (String key : stringStyleMap.keySet()) {
- if (key.equals(value)) {
- return stringStyleMap.get(key);
- }
- }
- break;
- default:
- break;
- }
- return defaultStyle;
- }
-
- public Class<?> getPropertyType(Class<?> defaultType) {
- if (defaultType.equals(double.class) || defaultType.equals(Double.class) || defaultType.equals(float.class)
- || defaultType.equals(Float.class)) {
- this.defaultType = NUMBER;
- } else if (defaultType.equals(Integer.class) || defaultType.equals(int.class)) {
- this.defaultType = INTEGER;
- } else if (defaultType.equals(long.class) || defaultType.equals(Long.class)) {
- this.defaultType = LONG;
- } else if (defaultType.equals(BigDecimal.class)) {
- this.defaultType = BIGDECIMAL;
- } else if (defaultType.equals(String.class)) {
- this.defaultType = STRING;
- } else if (defaultType.equals(Date.class) || defaultType.equals(Timestamp.class)) {
- this.defaultType = DATE;
- }
- if (isImage) {
- return CellSetImage.class;
- }
- if (isBlob) {
- return BlobComponent.class;
- }
- if (isEnum) {
- return String.class;
- }
- return defaultType;
- }
-
- public PropertyLookup setImageService(String path, boolean hasParameter) {
- isImage = true;
- imagePath = path;
- if (hasParameter) {
- String[] token = path.split("%");
- // there must only be one parameter for the moment
- if (token.length == 3) {
- imageParameterPattern = "%" + token[1] + "%";
- imageParameterFormat = "%" + token[1];
- }
- }
- return this;
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SelectDialog.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SelectDialog.java
index acc73b9..cb09447 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SelectDialog.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SelectDialog.java
@@ -17,6 +17,7 @@
import java.util.Map;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherCommand;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherDataTag;
@@ -62,7 +63,9 @@
@Override
public void buttonClick(ClickEvent event) {
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.OK, topic, sender);
+ //TODO Franck to be tested in runtime
+ //MPerspective perspective = getContext().get(MPerspective.class);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(null, EventDispatcherCommand.OK, topic, sender);
evnt.addItem(EventDispatcherDataTag.OBJECT, combo.getValue());
eventDispatcher.sendEvent(evnt);
}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SimpleDateFormatter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SimpleDateFormatter.java
deleted file mode 100644
index 4f9ca8a..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/SimpleDateFormatter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.text.DateFormat;
-import java.util.Locale;
-
-public class SimpleDateFormatter {
-
- public static DateFormat getFormat(String format, Locale locale) {
- DateFormat dateFormat = null;
- if (format.equals("SHORTDATE")) {
- dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
- }
- if (format.equals("MEDIUMDATE")) {
- dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
- }
- if (format.equals("LONGDATE")) {
- dateFormat = DateFormat.getDateInstance(DateFormat.LONG, locale);
- }
- if (format.equals("FULLDATE")) {
- dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
- }
- if (format.equals("SHORTTIME")) {
- dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
- }
- if (format.equals("MEDIUMTIME")) {
- dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
- }
- if (format.equals("LONGTIME")) {
- dateFormat = DateFormat.getTimeInstance(DateFormat.LONG, locale);
- }
- if (format.equals("FULLTIME")) {
- dateFormat = DateFormat.getTimeInstance(DateFormat.FULL, locale);
- }
- if (format.equals("SHORTDATESHORTTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
- }
- if (format.equals("SHORTDATEMEDIUMTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
- }
- if (format.equals("SHORTDATELONGTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale);
- }
- if (format.equals("SHORTDATEFULLTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL, locale);
- }
- if (format.equals("MEDIUMDATESHORTTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale);
- }
- if (format.equals("MEDIUMDATEMEDIUMTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale);
- }
- if (format.equals("MEDIUMDATELONGTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG, locale);
- }
- if (format.equals("MEDIUMDATEFULLTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.FULL, locale);
- }
- if (format.equals("LONGDATESHORTTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, locale);
- }
- if (format.equals("LONGDATEMEDIUMTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, locale);
- }
- if (format.equals("LONGDATELONGTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
- }
- if (format.equals("LONGDATEFULLTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL, locale);
- }
- if (format.equals("FULLDATESHORTTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT, locale);
- }
- if (format.equals("FULLDATEMEDIUMTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, locale);
- }
- if (format.equals("FULLDATELONGTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG, locale);
- }
- if (format.equals("FULLDATEFULLTIME")) {
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale);
- }
- dateFormat.setLenient(false);
- return dateFormat;
- }
-
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedBigDecimalConverter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedBigDecimalConverter.java
deleted file mode 100644
index c813ec7..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedBigDecimalConverter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import com.vaadin.data.util.converter.StringToBigDecimalConverter;
-
-public class StringToFormattedBigDecimalConverter extends StringToBigDecimalConverter {
- private static final long serialVersionUID = -4298862937719948986L;
- private PropertyLookup lookup = null;
- private DecimalFormat decimalFormat = null;
-
- public void setLookup(PropertyLookup lookup) {
- this.lookup = lookup;
- }
-
- protected DecimalFormat getFormat(Locale locale) {
- if (locale == null) {
- if (lookup == null) {
- locale = Locale.getDefault();
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- } else {
- locale = lookup.getLocale();
- }
- }
- if (lookup == null || lookup.getFormat() == null) {
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- }
- try {
- decimalFormat = new DecimalFormat(StringEscapeUtils.unescapeHtml(lookup.getFormat()), new DecimalFormatSymbols(locale));
- } catch (IllegalArgumentException e){
- String msg = String.format("formatter %s is invalid for decimal numbers: %s", lookup.getFormat(), e.getLocalizedMessage());
- throw new ConversionException(msg);
- }
-
- return decimalFormat;
- }
-
- @Override
- protected Number convertToNumber(String value, Class<? extends Number> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- // Remove leading and trailing white space
- value = value.trim();
-
- // Parse and detect errors. If the full string was not used, it is
- // an error.
- ParsePosition parsePosition = new ParsePosition(0);
- Number parsedValue = getFormat(locale).parse(value, parsePosition);
- if (parsePosition.getIndex() != value.length()) {
- throw new ConversionException("Could not convert '" + value
- + "' to " + getModelType().getName());
- }
-
- if (parsedValue == null) {
- // Convert "" to null
- return null;
- }
- return parsedValue;
- }
-
-
- @Override
- public String convertToPresentation(BigDecimal value, Class<? extends String> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- return getFormat(locale).format(value);
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedDateConverter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedDateConverter.java
deleted file mode 100644
index 068a14d..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedDateConverter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.text.DateFormat;
-import java.util.Locale;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import com.vaadin.data.util.converter.StringToDateConverter;
-
-public class StringToFormattedDateConverter extends StringToDateConverter {
- private static final long serialVersionUID = 721600785465571493L;
- private PropertyLookup lookup = null;
-
- public void setLookup(PropertyLookup lookup) {
- this.lookup = lookup;
- }
-
- protected DateFormat getDefaultFormat(Locale locale) {
- if (locale == null) {
- locale = Locale.getDefault();
- }
-
- DateFormat f = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
- f.setLenient(false);
- return f;
- }
-
- @Override
- protected DateFormat getFormat(Locale locale) {
- if (locale == null) {
- if (lookup == null) {
- locale = Locale.getDefault();
- return getDefaultFormat(locale);
- } else {
- locale = lookup.getLocale();
- }
- }
-
- if (lookup == null || lookup.getFormat() == null) {
- return getDefaultFormat(locale);
- }
-
- return SimpleDateFormatter.getFormat(StringEscapeUtils.unescapeHtml(lookup.getFormat()), locale);
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedDoubleConverter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedDoubleConverter.java
deleted file mode 100644
index 3147f06..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedDoubleConverter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import com.vaadin.data.util.converter.StringToDoubleConverter;
-
-public class StringToFormattedDoubleConverter extends StringToDoubleConverter {
- private static final long serialVersionUID = -4298862937719948986L;
- private PropertyLookup lookup = null;
- private DecimalFormat decimalFormat = null;
-
- public void setLookup(PropertyLookup lookup) {
- this.lookup = lookup;
- }
-
- protected DecimalFormat getFormat(Locale locale) {
- if (locale == null) {
- if (lookup == null) {
- locale = Locale.getDefault();
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- } else {
- locale = lookup.getLocale();
- }
- }
- if (lookup == null || lookup.getFormat() == null) {
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- }
- try {
- decimalFormat = new DecimalFormat(StringEscapeUtils.unescapeHtml(lookup.getFormat()), new DecimalFormatSymbols(locale));
- } catch (IllegalArgumentException e){
- String msg = String.format("formatter %s is invalid for decimal numbers: %s", lookup.getFormat(), e.getLocalizedMessage());
- throw new ConversionException(msg);
- }
-
- return decimalFormat;
- }
-
- @Override
- protected Number convertToNumber(String value, Class<? extends Number> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- // Remove leading and trailing white space
- value = value.trim();
-
- // Parse and detect errors. If the full string was not used, it is
- // an error.
- ParsePosition parsePosition = new ParsePosition(0);
- Number parsedValue = getFormat(locale).parse(value, parsePosition);
- if (parsePosition.getIndex() != value.length()) {
- throw new ConversionException("Could not convert '" + value
- + "' to " + getModelType().getName());
- }
-
- if (parsedValue == null) {
- // Convert "" to null
- return null;
- }
- return parsedValue;
- }
-
-
- @Override
- public String convertToPresentation(Double value, Class<? extends String> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- return getFormat(locale).format(value);
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedIntegerConverter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedIntegerConverter.java
deleted file mode 100644
index d4ad898..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedIntegerConverter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import com.vaadin.data.util.converter.StringToBigDecimalConverter;
-import com.vaadin.data.util.converter.StringToIntegerConverter;
-
-public class StringToFormattedIntegerConverter extends StringToIntegerConverter {
- /**
- *
- */
- private static final long serialVersionUID = -1587429363693818150L;
- private PropertyLookup lookup = null;
- private DecimalFormat decimalFormat = null;
-
- public void setLookup(PropertyLookup lookup) {
- this.lookup = lookup;
- }
-
- protected DecimalFormat getFormat(Locale locale) {
- if (locale == null) {
- if (lookup == null) {
- locale = Locale.getDefault();
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- } else {
- locale = lookup.getLocale();
- }
- }
- if (lookup == null || lookup.getFormat() == null) {
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- }
- try {
- decimalFormat = new DecimalFormat(StringEscapeUtils.unescapeHtml(lookup.getFormat()), new DecimalFormatSymbols(locale));
- } catch (IllegalArgumentException e){
- String msg = String.format("formatter %s is invalid for decimal numbers: %s", lookup.getFormat(), e.getLocalizedMessage());
- throw new ConversionException(msg);
- }
-
- return decimalFormat;
- }
-
- @Override
- protected Number convertToNumber(String value, Class<? extends Number> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- // Remove leading and trailing white space
- value = value.trim();
-
- // Parse and detect errors. If the full string was not used, it is
- // an error.
- ParsePosition parsePosition = new ParsePosition(0);
- Number parsedValue = getFormat(locale).parse(value, parsePosition);
- if (parsePosition.getIndex() != value.length()) {
- throw new ConversionException("Could not convert '" + value
- + "' to " + getModelType().getName());
- }
-
- if (parsedValue == null) {
- // Convert "" to null
- return null;
- }
- return parsedValue;
- }
-
-
- @Override
- public String convertToPresentation(Integer value, Class<? extends String> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- return getFormat(locale).format(value);
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedLongConverter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedLongConverter.java
deleted file mode 100644
index dcffe62..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/StringToFormattedLongConverter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- *
- * 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.utils.vaadin;
-
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import com.vaadin.data.util.converter.StringToBigDecimalConverter;
-import com.vaadin.data.util.converter.StringToIntegerConverter;
-import com.vaadin.data.util.converter.StringToLongConverter;
-
-public class StringToFormattedLongConverter extends StringToLongConverter {
- /**
- *
- */
- private static final long serialVersionUID = -1587429363693818150L;
- private PropertyLookup lookup = null;
- private DecimalFormat decimalFormat = null;
-
- public void setLookup(PropertyLookup lookup) {
- this.lookup = lookup;
- }
-
- protected DecimalFormat getFormat(Locale locale) {
- if (locale == null) {
- if (lookup == null) {
- locale = Locale.getDefault();
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- } else {
- locale = lookup.getLocale();
- }
- }
- if (lookup == null || lookup.getFormat() == null) {
- return (DecimalFormat) DecimalFormat.getInstance(locale);
- }
- try {
- decimalFormat = new DecimalFormat(StringEscapeUtils.unescapeHtml(lookup.getFormat()), new DecimalFormatSymbols(locale));
- } catch (IllegalArgumentException e){
- String msg = String.format("formatter %s is invalid for decimal numbers: %s", lookup.getFormat(), e.getLocalizedMessage());
- throw new ConversionException(msg);
- }
-
- return decimalFormat;
- }
-
- @Override
- protected Number convertToNumber(String value, Class<? extends Number> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- // Remove leading and trailing white space
- value = value.trim();
-
- // Parse and detect errors. If the full string was not used, it is
- // an error.
- ParsePosition parsePosition = new ParsePosition(0);
- Number parsedValue = getFormat(locale).parse(value, parsePosition);
- if (parsePosition.getIndex() != value.length()) {
- throw new ConversionException("Could not convert '" + value
- + "' to " + getModelType().getName());
- }
-
- if (parsedValue == null) {
- // Convert "" to null
- return null;
- }
- return parsedValue;
- }
-
-
- @Override
- public String convertToPresentation(Long value, Class<? extends String> targetType, Locale locale) throws ConversionException {
- if (value == null) {
- return null;
- }
-
- return getFormat(locale).format(value);
- }
-}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/ViewLayoutManager.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/ViewLayoutManager.java
index c48dab4..b225d1d 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/ViewLayoutManager.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/ViewLayoutManager.java
@@ -19,7 +19,6 @@
import org.eclipse.osbp.ui.api.themes.EnumCssClass;
import com.vaadin.server.Extension;
-import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
@@ -29,11 +28,9 @@
* The Class ViewLayoutManager.
*/
public class ViewLayoutManager implements IViewLayoutManager {
- private static final long serialVersionUID = 6497632074130627336L;
private Label label;
private ExtendedVerticalLayout workArea;
private HorizontalLayout topArea;
- private HorizontalLayout multiArea;
private VerticalLayout sideArea;
private VerticalLayout dataArea;
@@ -55,7 +52,7 @@
dataArea.addStyleName(EnumCssClass.DATA_AREA.toString());
dataArea.setSizeFull();
- multiArea = new HorizontalLayout(sideArea, dataArea);
+ HorizontalLayout multiArea = new HorizontalLayout(sideArea, dataArea);
multiArea.addStyleName(EnumCssClass.MULTI_AREA.toString());
multiArea.setSizeFull();
multiArea.setExpandRatio(dataArea, 1);
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/YesNoDialog.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/YesNoDialog.java
index 9dc3b50..34a9619 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/YesNoDialog.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/YesNoDialog.java
@@ -61,7 +61,7 @@
@Override
public void buttonClick(ClickEvent event) {
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.YES, topic, sender);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(null, EventDispatcherCommand.YES, topic, sender);
evnt.addItem(EventDispatcherDataTag.OBJECT, item);
eventDispatcher.sendEvent(evnt);
}
@@ -76,7 +76,7 @@
@Override
public void buttonClick(ClickEvent event) {
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.NO, topic, sender);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(null, EventDispatcherCommand.NO, topic, sender);
evnt.addItem(EventDispatcherDataTag.OBJECT, item);
eventDispatcher.sendEvent(evnt);
}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/Beeper.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/Beeper.java
index 3574e52..64953c7 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/Beeper.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/Beeper.java
@@ -5,13 +5,22 @@
import com.vaadin.annotations.JavaScript;
import com.vaadin.ui.AbstractJavaScriptComponent;
-@JavaScript("js/beeper_connector.js")
+@JavaScript("js/BeeperConnector.js")
public class Beeper extends AbstractJavaScriptComponent implements IBeeper {
private static final long serialVersionUID = 5930949036795746638L;
@Override
public void beep(Integer duration, Integer frequency) {
- callFunction("beep", duration, frequency);
+// callFunction("playSound", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/355309/G4.mp3");
+// callFunction("playSound", "theme://icon/applause-4.mp3");
+// callFunction("playSound", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/355309/Eb4.mp3");
+// callFunction("playSound", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/355309/G4.mp3");
+ callFunction("beepSound", duration, frequency);
}
+
+ @Override
+ public void playSound(String url) {
+ callFunction("playSound", url);
+ }
}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/js/BeeperConnector.js b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/js/BeeperConnector.js
new file mode 100644
index 0000000..2c7e35c
--- /dev/null
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/js/BeeperConnector.js
@@ -0,0 +1,62 @@
+window.org_eclipse_osbp_utils_vaadin_beeper_Beeper = function() {
+ var audioCtx = new (window.AudioContext || window.webkitAudioContext || window.audioContext);
+ var soundBuffer = null;
+ var bufferLoader;
+ this.beepSound = function(duration, frequency) {
+ var oscillator = audioCtx.createOscillator();
+ var gainNode = audioCtx.createGain();
+ oscillator.connect(gainNode);
+ gainNode.connect(audioCtx.destination);
+ if (frequency){
+ oscillator.frequency.value = frequency;
+ }
+ setTimeout(function(){
+ oscillator.stop();
+ oscillator.disconnect();
+ gainNode.disconnect();
+ }, (duration ? duration : 1500));
+ oscillator.start();
+ };
+ function loadSound(url) {
+ var request = new XMLHttpRequest();
+ request.open('GET', url, true);
+ request.responseType = 'arraybuffer';
+ // Decode asynchronously
+ request.onload = function() {
+ audioCtx.decodeAudioData(request.response, function(buffer) {
+ var source = audioCtx.createBufferSource(); // creates a sound source
+ source.buffer = buffer; // tell the source which sound to play
+ source.connect(audioCtx.destination); // connect the source to the context's destination (the speakers)
+ source.start(0); // play the source now
+ },
+ function(e){"Error with decoding audio data" + e.err}
+ );
+ }
+ request.send();
+ }
+ this.playSound = function playSound(url) {
+ loadSound(url);
+// soundInit();
+ }
+ function soundInit() {
+ bufferLoader = new BufferLoader(audioCtx, [
+ 'sounds/baby-babble-1.mp3',
+ 'sounds/people-cheering.mp3',
+ 'sounds/y1.mp3',
+ 'sounds/applause-4.mp3', ],
+ finishedLoading);
+ bufferLoader.load();
+ }
+ function finishedLoading(bufferList) {
+ // Create two sources and play them both together.
+ var source1 = audioCtx.createBufferSource();
+ var source2 = audioCtx.createBufferSource();
+ source1.buffer = bufferList[0];
+ source2.buffer = bufferList[1];
+
+ source1.connect(audioCtx.destination);
+ source2.connect(audioCtx.destination);
+ source1.start(0);
+ source2.start(0);
+ }
+};
\ No newline at end of file
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/js/beeper_connector.js b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/js/beeper_connector.js
deleted file mode 100644
index 642cd3a..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/beeper/js/beeper_connector.js
+++ /dev/null
@@ -1,18 +0,0 @@
-window.org_eclipse_osbp_utils_vaadin_beeper_Beeper = function() {
- var audioCtx = new (window.AudioContext || window.webkitAudioContext || window.audioContext);
- this.beep = function(duration, frequency) {
- var oscillator = audioCtx.createOscillator();
- var gainNode = audioCtx.createGain();
- oscillator.connect(gainNode);
- gainNode.connect(audioCtx.destination);
- if (frequency){
- oscillator.frequency.value = frequency;
- }
- oscillator.start();
- setTimeout(function(){
- oscillator.stop();
- oscillator.disconnect();
- gainNode.disconnect();
- }, (duration ? duration : 500));
- };
-};
\ No newline at end of file
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnRenderer.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnRenderer.java
index ff083e9..fafc1a5 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnRenderer.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnRenderer.java
@@ -4,26 +4,20 @@
import java.util.UUID;
import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.core.di.extensions.EventUtils;
-import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.osbp.bpm.api.IBPMEngine;
import org.eclipse.osbp.bpm.api.IBlipBPMFunctionProvider;
-import org.eclipse.osbp.eventbroker.EventBrokerMsg;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
-import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherCommand;
-import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherDataTag;
+import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.user.IUser;
import org.eclipse.osbp.utils.vaadin.YesNoDialog;
-import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import com.vaadin.annotations.JavaScript;
import com.vaadin.ui.AbstractJavaScriptComponent;
import com.vaadin.ui.JavaScriptFunction;
import com.vaadin.ui.UI;
-import com.vaadin.ui.Window;
import elemental.json.JsonArray;
@@ -43,7 +37,6 @@
private transient IUser user;
private String processId;
private YesNoDialog yesnoDialog;
- private transient EventHandler dispatchYesNo;
private String startProcessText;
private String answerYesText;
private String answerNoText;
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnWindow.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnWindow.java
index a26df21..97a83c9 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnWindow.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnWindow.java
@@ -35,12 +35,13 @@
private BpmnRenderer bpmnRenderer;
private float width = 820;
private float height = 650;
+ private VerticalLayout inner;
public BpmnWindow(IBPMEngine bpmEngine, IBlipBPMFunctionProvider blip, IEclipseContext context) {
super();
setClosable(true);
setModal(false);
- VerticalLayout inner = new VerticalLayout();
+ inner = new VerticalLayout();
inner.setMargin(false);
inner.setSizeFull();
setContent(inner);
@@ -59,8 +60,8 @@
@Override
public void run() {
setPosition(Page.getCurrent().getBrowserWindowWidth()-(int)width, Page.getCurrent().getBrowserWindowHeight()-(int)height);
- setHeight(height, Unit.PIXELS);
- setWidth(width, Unit.PIXELS);
+ inner.setHeight(height, Unit.PIXELS);
+ inner.setWidth(width, Unit.PIXELS);
bpmnRenderer.drawBpmn(processId);
}
});
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsPopup.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsPopup.java
index f5a15af..e82e2d2 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsPopup.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsPopup.java
@@ -3,6 +3,7 @@
import java.util.Locale;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherCommand;
import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
@@ -21,11 +22,13 @@
private String sender;
private String topic;
private transient IDSLMetadataService dslMetadataService;
+ private MPerspective perspective;
public ProblemsPopup(IEclipseContext eclipseContext, Locale locale, String sender, String topic) {
super();
eventDispatcher = eclipseContext.get(IEventDispatcher.class);
dslMetadataService = eclipseContext.get(IDSLMetadataService.class);
+ perspective = eclipseContext.get(MPerspective.class);
this.sender = sender;
this.topic = topic;
super.setLocale(locale);
@@ -49,7 +52,8 @@
@Override
public void detach(DetachEvent event) {
- EventDispatcherEvent evt = new EventDispatcherEvent(EventDispatcherCommand.CLOSE, topic, sender);
+
+ EventDispatcherEvent evt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, topic, sender);
eventDispatcher.sendEvent(evt);
}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsViewContent.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsViewContent.java
index 548ccde..601cce7 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsViewContent.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsViewContent.java
@@ -12,6 +12,7 @@
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
@@ -102,6 +103,8 @@
private transient IEventDispatcher eventDispatcher;
+ private MPerspective perspective;
+
/**
* Inits the view content.
*
@@ -118,6 +121,8 @@
statusManager = eclipseContext.get(IStatusManager.class);
partService = eclipseContext.get(EPartService.class);
eventBroker = eclipseContext.get(IEventBroker.class);
+ perspective = eclipseContext.get(MPerspective.class);
+
this.locale = locale;
VerticalLayout parent = new VerticalLayout();
table = new Table();
@@ -262,7 +267,7 @@
LOGGER.debug("{}", "Table refreshed.");
resetTimer();
if (container.size() == 0) {
- EventDispatcherEvent evt = new EventDispatcherEvent(EventDispatcherCommand.CLOSE, topic, sender);
+ EventDispatcherEvent evt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, topic, sender);
eventDispatcher.sendEvent(evt);
} else {
table.select(container.getIdByIndex(0));