catch up with branch daily
Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/jenkins.build.config.xml b/jenkins.build.config.xml
index 03eef5b..d7ab7df 100644
--- a/jenkins.build.config.xml
+++ b/jenkins.build.config.xml
@@ -27,7 +27,6 @@
<jenkins.build.dependency>org.eclipse.osbp.ui.api</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.utils</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.vaaclipse</jenkins.build.dependency>
- <jenkins.build.dependency>org.eclipse.osbp.vaaclipse.addons.common.api</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.vaadin.emf</jenkins.build.dependency>
<jenkins.build.dependency>org.eclipse.osbp.xtext.datamart.common</jenkins.build.dependency>
</jenkins.build.dependencies>
diff --git a/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF b/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF
index cc7c24c..39e7f6b 100644
--- a/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.utils.ui/META-INF/MANIFEST.MF
@@ -8,8 +8,7 @@
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.osbp.utils.vaadin;version="0.9.0",
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"
+ org.eclipse.osbp.utils.vaadin.bpmn;version="0.9.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)",
@@ -27,14 +26,12 @@
org.eclipse.e4.ui.services,
org.eclipse.e4.core.di.extensions,
org.eclipse.osbp.runtime.common;bundle-version="0.9.0",
- org.eclipse.osbp.vaaclipse.addons.common.api;bundle-version="0.9.0",
org.eclipse.e4.ui.workbench;bundle-version="1.4.0",
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",
- javax.persistence;bundle-version="2.1.0",
- javax.validation.api;bundle-version="1.1.0"
+ javax.persistence;bundle-version="2.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/MDXDialog.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MDXDialog.java
index 2c83b78..e861fc9 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
@@ -115,8 +115,6 @@
// for simplicity we only take the first entity used in a cube definition to establish connection
connection = persistenceService.getMondrianConnection(mondrianService.getPersistenceUnit(),
mondrianService.getPackageName());
- persistenceService.registerPersistenceUnit(mondrianService.getPersistenceUnit(),
- mondrianService.getClassLoader());
} catch (SQLException e) {
LOGGER.error("{}", e);
}
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MessageDialog.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MessageDialog.java
index f0fa793..d133523 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MessageDialog.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/MessageDialog.java
@@ -32,6 +32,8 @@
setClosable(false);
setModal(true);
VerticalLayout subContent = new VerticalLayout();
+ subContent.setWidth("300px");
+ subContent.setHeight("200px");
subContent.setMargin(true);
setContent(subContent);
label = new Label(messageText);
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 cb09447..a1ac177 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
@@ -63,8 +63,6 @@
@Override
public void buttonClick(ClickEvent event) {
- //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);
@@ -74,7 +72,7 @@
center();
}
- public SelectDialog init(IEventDispatcher eventDispatcher, String sender, String topic, Map<String, String> list, String selectedItem, String messageText, String okText) {
+ public SelectDialog init(IEventDispatcher eventDispatcher, String sender, String topic, Map<String, Object> list, Object selectedItem, String messageText, String okText) {
this.eventDispatcher = eventDispatcher;
this.sender = sender;
this.topic = topic;
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 b225d1d..91e8d70 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
@@ -63,11 +63,12 @@
workArea.addComponent(topArea);
workArea.addComponent(multiArea);
workArea.setExpandRatio(multiArea, 1);
-
- parent.setPrimaryStyleName("osbp");
- parent.addStyleName(EnumCssClass.VIEW.toString());
- parent.addComponent(workArea);
- parent.setExpandRatio(workArea, 1);
+ if(parent != null) {
+ parent.setPrimaryStyleName("osbp");
+ parent.addStyleName(EnumCssClass.VIEW.toString());
+ parent.addComponent(workArea);
+ parent.setExpandRatio(workArea, 1);
+ }
}
@Override
diff --git a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnConverter.java b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnConverter.java
index b67ef40..041cae3 100644
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnConverter.java
+++ b/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/bpmn/BpmnConverter.java
@@ -60,7 +60,7 @@
private Map<String, BpmnNode> bpmnComponents = new HashMap<>();
private Map<String, BpmnNode> bpmnSeqFlowComponents = new HashMap<>();
- private List<String> nsTagNamePrefixes = new ArrayList<String>();
+ private List<String> nsTagNamePrefixes = new ArrayList<>();
private String tagNamePrefix = "";
@@ -97,11 +97,11 @@
nsTagNamePrefixes.clear();
}
- public void loadBPMN(String fileURL) {
+ public boolean loadBPMN(String fileURL) {
clearBPMN();
if (fileURL == null) {
- log.debug("fileURL was null");
- return;
+ log.error("loadBPMN: unable to load BPM definition - fileURL is 'null'");
+ return false;
}
// read from url
InputStream in = null;
@@ -110,10 +110,10 @@
in = url.openStream();
} catch (MalformedURLException e1) {
log.error(e1.getLocalizedMessage());
- return;
+ return false;
} catch (IOException e2) {
log.error(e2.getLocalizedMessage());
- return;
+ return false;
}
readXML(in);
try {
@@ -121,6 +121,7 @@
} catch (IOException e) {
log.error(e.getLocalizedMessage());
}
+ return true;
}
public void readXML(InputStream inputStream) {
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 fafc1a5..c1f0004 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
@@ -85,22 +85,26 @@
});
}
- public void drawBpmn(String processId) {
+ public boolean drawBpmn(String processId) {
+ this.processId = null;
log.debug("start creating bpmn");
bpmnConverter.clearBPMN();
// get the result
if (processId != null) {
- log.debug("start loading bpmn");
+ log.debug("start loading bpmn {}", processId);
if (bpmEngine != null) {
- bpmnConverter.loadBPMN(bpmEngine.getResourceName(processId));
+ if( bpmnConverter.loadBPMN(bpmEngine.getResourceName(processId)) ) {
+ setSizeFull();
+ getState().bpmnCreationCode = bpmnConverter.getBpmnJsCreationCode();
+ log.debug("finished creating bpmn");
+ this.processId = processId;
+ return true;
+ }
} else {
- log.debug("bpm not licensed");
+ log.info("bpmEngine not installed");
}
- setSizeFull();
- getState().bpmnCreationCode = bpmnConverter.getBpmnJsCreationCode();
- log.debug("finished creating bpmn");
}
- this.processId = processId;
+ return false;
}
@Override
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 97a83c9..06b70de 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
@@ -62,7 +62,9 @@
setPosition(Page.getCurrent().getBrowserWindowWidth()-(int)width, Page.getCurrent().getBrowserWindowHeight()-(int)height);
inner.setHeight(height, Unit.PIXELS);
inner.setWidth(width, Unit.PIXELS);
- bpmnRenderer.drawBpmn(processId);
+ if ( !bpmnRenderer.drawBpmn(processId) ) {
+ closeBpmn();
+ }
}
});
}
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
deleted file mode 100644
index e82e2d2..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsPopup.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.osbp.utils.vaadin.problems;
-
-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;
-import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
-
-import com.vaadin.server.ClientConnector.DetachListener;
-import com.vaadin.ui.Window;
-
-public class ProblemsPopup extends Window implements DetachListener {
- /**
- *
- */
- private static final long serialVersionUID = -1106131179854247707L;
- private transient IEventDispatcher eventDispatcher;
- private ProblemsViewContent problemsViewContent;
- 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);
- this.addDetachListener(this);
- setClosable(true);
- setModal(false);
- setCaption(dslMetadataService.translate(locale.toLanguageTag(), "validationReport"));
- problemsViewContent = new ProblemsViewContent();
- setContent(problemsViewContent.createComponents(eclipseContext, locale, sender, topic));
- setWidth("550px");
- }
-
- @Override
- public void setLocale(Locale locale) {
- super.setLocale(locale);
- setCaption(dslMetadataService.translate(locale.toLanguageTag(), "validationReport"));
- if(problemsViewContent != null) {
- problemsViewContent.setLocale(locale);
- }
- }
-
- @Override
- public void detach(DetachEvent event) {
-
- 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
deleted file mode 100644
index 601cce7..0000000
--- a/org.eclipse.osbp.utils.ui/src/org/eclipse/osbp/utils/vaadin/problems/ProblemsViewContent.java
+++ /dev/null
@@ -1,685 +0,0 @@
-package org.eclipse.osbp.utils.vaadin.problems;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.annotation.PreDestroy;
-
-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;
-import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherCommand;
-import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
-import org.eclipse.osbp.runtime.common.validation.IStatus;
-import org.eclipse.osbp.runtime.common.validation.IStatus.Severity;
-import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
-import org.eclipse.osbp.vaaclipse.addons.common.api.IE4Topics;
-import org.eclipse.osbp.vaaclipse.addons.common.api.ResourceUtil;
-import org.eclipse.osbp.vaaclipse.addons.common.api.status.IStatusManager;
-import org.eclipse.osbp.vaaclipse.addons.common.api.status.IStatusScope;
-import org.osgi.service.event.EventHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.server.Resource;
-import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Table.ColumnHeaderMode;
-import com.vaadin.ui.Table.RowHeaderMode;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-
-public class ProblemsViewContent extends VerticalLayout { // NOSONAR
- private static final String MESSAGE_CODE = "messageCode";
-
- private static final String CREATOR_CLASS = "creatorClass";
-
- private static final String MESSAGE_PATH = "messagePath";
-
- private static final String SEVERITY = "severity";
-
- private static final String BUNDLE_SYMBOLIC_NAME = "bundleSymbolicName";
-
- private static final String PART_NAME = "partName";
-
- private static final String FIELD_NAME = "fieldName";
-
- private static final String MESSAGE = "message";
-
- /**
- *
- */
- private static final long serialVersionUID = -8512352376339527845L;
-
- /** The Constant LOGGER. */
- private static final Logger LOGGER = LoggerFactory.getLogger(ProblemsViewContent.class);
-
- /** The status manager. */
- private transient IStatusManager statusManager;
-
- /** The part service. */
- private transient EPartService partService;
-
- /** The event broker. */
- private transient IEventBroker eventBroker;
-
- /** The table. */
- private Table table;
-
- /** The container. */
- private BeanItemContainer<StatusBean> container;
-
- /** The current timer. */
- private transient Timer currentTimer;
-
- /** The changed validations handler. */
- private transient EventHandler changedValidationsHandler;
-
- /** The changed scope handler. */
- private transient EventHandler changedScopeHandler;
-
- /** The detail label. */
- private Label detailLabel;
-
- private Locale locale;
-
- private transient IDSLMetadataService dslMetadataService;
-
- private String sender;
-
- private String topic;
-
- private transient IEventDispatcher eventDispatcher;
-
- private MPerspective perspective;
-
- /**
- * Inits the view content.
- *
- * @param locale
- * the locale
- * @return the vertical layout
- */
- @SuppressWarnings("serial")
- public Component createComponents(IEclipseContext eclipseContext, Locale locale, String sender, String topic) {
- this.sender = sender;
- this.topic = topic;
- eventDispatcher = eclipseContext.get(IEventDispatcher.class);
- dslMetadataService = eclipseContext.get(IDSLMetadataService.class);
- 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();
- table.setSelectable(true);
- table.setSizeFull();
- table.setPageLength(5);
- parent.addComponent(table);
-
- container = new BeanItemContainer<>(StatusBean.class);
- table.setContainerDataSource(container);
-
- table.setVisibleColumns(MESSAGE, FIELD_NAME, PART_NAME, BUNDLE_SYMBOLIC_NAME, SEVERITY, MESSAGE_PATH,
- CREATOR_CLASS, MESSAGE_CODE);
- table.setColumnCollapsingAllowed(true);
- table.setColumnCollapsed(SEVERITY, true);
- table.setColumnCollapsed(BUNDLE_SYMBOLIC_NAME, true);
- table.setColumnCollapsed(MESSAGE_PATH, true);
- table.setColumnCollapsed(CREATOR_CLASS, true);
- table.setColumnCollapsed(MESSAGE_CODE, true);
-
- table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
- table.setItemIconPropertyId("severityImage");
-
- table.setColumnHeaderMode(ColumnHeaderMode.EXPLICIT_DEFAULTS_ID);
- table.setColumnHeader(MESSAGE, dslMetadataService.translate(locale.toLanguageTag(), MESSAGE));
- table.setColumnHeader(FIELD_NAME, dslMetadataService.translate(locale.toLanguageTag(), FIELD_NAME));
- table.setColumnHeader(PART_NAME, dslMetadataService.translate(locale.toLanguageTag(), PART_NAME));
- table.setColumnHeader(BUNDLE_SYMBOLIC_NAME,
- dslMetadataService.translate(locale.toLanguageTag(), BUNDLE_SYMBOLIC_NAME));
- table.setColumnHeader(SEVERITY, dslMetadataService.translate(locale.toLanguageTag(), SEVERITY));
- table.setColumnHeader(MESSAGE_PATH, dslMetadataService.translate(locale.toLanguageTag(), MESSAGE_PATH));
- table.setColumnHeader(CREATOR_CLASS, dslMetadataService.translate(locale.toLanguageTag(), CREATOR_CLASS));
- table.setColumnHeader(MESSAGE_CODE, dslMetadataService.translate(locale.toLanguageTag(), MESSAGE_CODE));
-
- table.addItemClickListener(new ItemClickEvent.ItemClickListener() {
- @Override
- public void itemClick(ItemClickEvent event) {
- focusStatus(event);
- }
- });
-
- table.addValueChangeListener(e -> showDetailMessage((StatusBean) e.getProperty().getValue()));
-
- detailLabel = new Label();
- detailLabel.setPrimaryStyleName("detailmessage");
- detailLabel.setContentMode(ContentMode.HTML);
- detailLabel.setSizeFull();
- parent.addComponent(detailLabel);
- table.focus();
-
- parent.setExpandRatio(table, 0.85f);
- parent.setExpandRatio(detailLabel, 0.15f);
-
- // handle changed validation scopes
- //
- changedScopeHandler = e -> refreshContent();
-
- // handle changes in validation results
- //
- eventBroker.subscribe(IE4Topics.StatusManagerEvents.ACTIVE_SCOPE_CHANGED_TOPIC, changedScopeHandler);
- changedValidationsHandler = e -> refreshContent();
-
- eventBroker.subscribe(IE4Topics.StatusManagerEvents.VALIDATIONS_CHANGED_TOPIC, changedValidationsHandler);
- return parent;
- }
-
- /**
- * Shows the detail message.
- *
- * @param statusBean
- * the status bean
- */
- protected void showDetailMessage(StatusBean statusBean) {
- if (statusBean != null) {
- detailLabel.setValue(statusBean.getMessage().getValue());
- } else {
- detailLabel.setValue(null);
- }
- }
-
- /**
- * Tries to put the focus to the field involved in the problem.
- *
- * @param event
- * the event
- */
- protected void focusStatus(ItemClickEvent event) {
- StatusBean status = (StatusBean) event.getItemId();
-
- String mPartId = status.getPartId();
- if (mPartId != null && !mPartId.equals("")) {
- MPart mPart = partService.findPart(mPartId);
- if (mPart != null) {
- partService.bringToTop(mPart);
- partService.activate(mPart);
-
- String fieldId = status.getFieldId();
- if (fieldId != null && !fieldId.equals("")) {
- // send a focus field event to the mpart
- eventBroker.post(IE4Topics.PartEvents.FOCUS_FIELD_TOPIC, createFocusFieldEvent(mPartId, fieldId));
- }
- }
- }
- }
-
- /**
- * Creates an event to focus a field in a MPart.
- *
- * @param mPartId
- * the m part id
- * @param fieldId
- * the field id
- * @return the map
- */
- protected Map<String, Object> createFocusFieldEvent(String mPartId, String fieldId) {
- Map<String, Object> properties = new HashMap<>();
- properties.put(IE4Topics.PartEvents.PROP_MPART_ID, mPartId);
- properties.put(IE4Topics.PartEvents.PROP_FIELD_ID, fieldId);
- return properties;
- }
-
- /**
- * Refreshes the content of the active MPart.
- */
- protected void refreshContent() {
- synchronized (this) {
- // Wait for 250ms before refreshing the table. Most probably several
- // validation events will
- // arrive in the next milliseconds
- if (currentTimer == null) {
- currentTimer = new Timer();
- currentTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- UI.getCurrent().accessSynchronously(() -> {
- container.removeAllItems();
- IStatusScope scope = statusManager.getActiveScope();
- if (scope != null) {
- container.addAll(mapStatus(scope));
- }
- detailLabel.setValue("");
- LOGGER.debug("{}", "Table refreshed.");
- resetTimer();
- if (container.size() == 0) {
- EventDispatcherEvent evt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, topic, sender);
- eventDispatcher.sendEvent(evt);
- } else {
- table.select(container.getIdByIndex(0));
- }
- });
- }
- }, 250);
- LOGGER.debug("{}", "Scheduled Table-Refresh-Timer.");
- } else {
- LOGGER.debug("{}", "Timer already active.");
- }
- }
- }
-
- /**
- * Reset timer.
- */
- protected void resetTimer() {
- synchronized (this) {
- currentTimer = null;
- }
- }
-
- /**
- * Map status.
- *
- * @param scope
- * the scope
- * @return the list
- */
- protected List<StatusBean> mapStatus(IStatusScope scope) {
- List<StatusBean> result = new ArrayList<>();
- for (IStatus status : scope.getAllStatus()) {
- result.add(StatusBean.create(status, dslMetadataService, locale));
- }
- return result;
- }
-
- /**
- * Map status.
- *
- * @param manager
- * the manager
- * @return the list
- */
- protected List<StatusBean> mapStatus(IStatusManager manager) {
- List<StatusBean> result = new ArrayList<>();
- for (IStatus status : manager.getAllScopeStatus()) {
- result.add(StatusBean.create(status, dslMetadataService, locale));
- }
- return result;
- }
-
- /**
- * Dispose.
- */
- @PreDestroy
- protected void dispose() {
- eventBroker.unsubscribe(changedScopeHandler);
- eventBroker.unsubscribe(changedValidationsHandler);
-
- changedScopeHandler = null;
- changedValidationsHandler = null;
- table = null;
- container = null;
- }
-
- /**
- * The Class StatusBean.
- */
- public static class StatusBean {
-
- /** The severity image. */
- @SuppressWarnings("unused")
- private Resource severityImage;
-
- /** The severity. */
- private Severity severity;
-
- /** The bundle symbolic name. */
- private String bundleSymbolicName;
-
- /** The message code. */
- private String messageCode;
-
- /** The message. */
- private Label message;
-
- /** The exception. */
- private Exception exception;
-
- /** The part id. */
- private String partId;
-
- /** The field id. */
- private String fieldId;
-
- /** The part name. */
- private String partName;
-
- /** The field name. */
- private String fieldName;
-
- /** The message path. */
- private String messagePath;
-
- /** The creator class. */
- private String creatorClass;
-
- /** The field value. */
- private String fieldValue;
-
- /**
- * Creates the.
- *
- * @param status
- * the status
- * @param i18nService
- * the i18n service
- * @param locale
- * the locale
- * @return the status bean
- */
- public static StatusBean create(IStatus status, IDSLMetadataService dslMetadataService, Locale locale) {
- StatusBean bean = new StatusBean();
- bean.severity = status.getSeverity();
- bean.bundleSymbolicName = status.getBundleSymblicName();
- bean.messageCode = status.getCode();
- bean.fieldValue = (String) status.getProperty(IStatus.PROP_FIELD_VALUE);
- String errorMessage = dslMetadataService.translate(locale.toLanguageTag(), status.getMessage());
- if(bean.fieldValue != null) {
- errorMessage = errorMessage.replace("{0}", bean.fieldValue);
- }
- bean.message = new Label(errorMessage,
- ContentMode.HTML);
- bean.exception = status.getException();
-
- bean.partId = (String) status.getProperty(IStatus.PROP_UI_APPLICATION_ID);
- bean.fieldId = (String) status.getProperty(IStatus.PROP_FIELD_ID);
- String fieldI18nKey = (String) status.getProperty(IStatus.PROP_FIELD_I18N_KEY);
-
- bean.partName = dslMetadataService.translate(locale.toLanguageTag(), bean.partId);
- if (fieldI18nKey != null && !fieldI18nKey.equals("")) {
- bean.fieldName = dslMetadataService.translate(locale.toLanguageTag(), fieldI18nKey);
- } else {
- bean.fieldName = dslMetadataService.translate(locale.toLanguageTag(), bean.fieldId);
- }
-
- bean.creatorClass = (String) status.getProperty(IStatus.PROP_CREATOR);
- bean.messagePath = (String) status.getProperty(IStatus.PROP_JAVAX_PROPERTY_PATH);
- return bean;
- }
-
- /**
- * Gets the severity image.
- *
- * @return the severityImage
- */
- public Resource getSeverityImage() {
- switch (severity) {
- case OK:
- case INFO:
- return ResourceUtil.getResource(
- "platform:/plugin/org.eclipse.osbp.utils.ui/images/info_tsk.png");
- case WARNING:
- return ResourceUtil.getResource(
- "platform:/plugin/org.eclipse.osbp.utils.ui/images/warn_tsk.png");
- case ERROR:
- case CRITICAL:
- case SYSTEMERROR:
- return ResourceUtil.getResource(
- "platform:/plugin/org.eclipse.osbp.utils.ui/images/error_tsk.png");
- default:
- return null;
- }
- }
-
- /**
- * Sets the severity image.
- *
- * @param severityImage
- * the severityImage to set
- */
- public void setSeverityImage(Resource severityImage) {
- this.severityImage = severityImage;
- }
-
- /**
- * Gets the severity.
- *
- * @return the severity
- */
- public Severity getSeverity() {
- return severity;
- }
-
- /**
- * Sets the severity.
- *
- * @param severity
- * the severity to set
- */
- public void setSeverity(Severity severity) {
- this.severity = severity;
- }
-
- /**
- * Gets the bundle symbolic name.
- *
- * @return the bundleSymbolicName
- */
- public String getBundleSymbolicName() {
- return bundleSymbolicName;
- }
-
- /**
- * Sets the bundle symbolic name.
- *
- * @param bundleSymbolicName
- * the bundleSymbolicName to set
- */
- public void setBundleSymbolicName(String bundleSymbolicName) {
- this.bundleSymbolicName = bundleSymbolicName;
- }
-
- /**
- * Gets the message.
- *
- * @return the message
- */
- public Label getMessage() {
- return message;
- }
-
- /**
- * Sets the message.
- *
- * @param message
- * the message to set
- */
- public void setMessage(Label message) {
- this.message = message;
- }
-
- /**
- * Gets the exception.
- *
- * @return the exception
- */
- public Exception getException() {
- return exception;
- }
-
- /**
- * Sets the exception.
- *
- * @param exception
- * the exception to set
- */
- public void setException(Exception exception) {
- this.exception = exception;
- }
-
- /**
- * Gets the part id.
- *
- * @return the partId
- */
- public String getPartId() {
- return partId;
- }
-
- /**
- * Sets the part id.
- *
- * @param partId
- * the partId to set
- */
- public void setPartId(String partId) {
- this.partId = partId;
- }
-
- /**
- * Gets the field id.
- *
- * @return the fieldId
- */
- public String getFieldId() {
- return fieldId;
- }
-
- /**
- * Sets the field id.
- *
- * @param fieldId
- * the fieldId to set
- */
- public void setFieldId(String fieldId) {
- this.fieldId = fieldId;
- }
-
- /**
- * Gets the part name.
- *
- * @return the partName
- */
- public String getPartName() {
- return partName;
- }
-
- /**
- * Sets the part name.
- *
- * @param partName
- * the partName to set
- */
- public void setPartName(String partName) {
- this.partName = partName;
- }
-
- /**
- * Gets the field name.
- *
- * @return the fieldName
- */
- public String getFieldName() {
- return fieldName;
- }
-
- /**
- * Sets the field name.
- *
- * @param fieldName
- * the fieldName to set
- */
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- /**
- * Gets the message path.
- *
- * @return the messagePath
- */
- public String getMessagePath() {
- return messagePath;
- }
-
- /**
- * Sets the message path.
- *
- * @param messagePath
- * the messagePath to set
- */
- public void setMessagePath(String messagePath) {
- this.messagePath = messagePath;
- }
-
- /**
- * Gets the message code.
- *
- * @return the messageCode
- */
- public String getMessageCode() {
- return messageCode;
- }
-
- /**
- * Sets the message code.
- *
- * @param messageCode
- * the messageCode to set
- */
- public void setMessageCode(String messageCode) {
- this.messageCode = messageCode;
- }
-
- /**
- * Gets the creator class.
- *
- * @return the creatorClass
- */
- public String getCreatorClass() {
- return creatorClass;
- }
-
- /**
- * Sets the creator class.
- *
- * @param creatorClass
- * the creatorClass to set
- */
- public void setCreatorClass(String creatorClass) {
- this.creatorClass = creatorClass;
- }
-
- }
-
- @Override
- public void setLocale(Locale locale) {
- this.locale = locale;
- if (table != null) {
- table.setColumnHeader(MESSAGE, dslMetadataService.translate(locale.toLanguageTag(), MESSAGE));
- table.setColumnHeader(FIELD_NAME, dslMetadataService.translate(locale.toLanguageTag(), FIELD_NAME));
- table.setColumnHeader(PART_NAME, dslMetadataService.translate(locale.toLanguageTag(), PART_NAME));
- table.setColumnHeader(BUNDLE_SYMBOLIC_NAME,
- dslMetadataService.translate(locale.toLanguageTag(), BUNDLE_SYMBOLIC_NAME));
- table.setColumnHeader(SEVERITY, dslMetadataService.translate(locale.toLanguageTag(), SEVERITY));
- table.setColumnHeader(MESSAGE_PATH, dslMetadataService.translate(locale.toLanguageTag(), MESSAGE_PATH));
- table.setColumnHeader(CREATOR_CLASS, dslMetadataService.translate(locale.toLanguageTag(), CREATOR_CLASS));
- table.setColumnHeader(MESSAGE_CODE, dslMetadataService.translate(locale.toLanguageTag(), MESSAGE_CODE));
- refreshContent();
- }
- }
-}