catch up with branch daily
Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.osgi.hybrid.api/META-INF/MANIFEST.MF b/org.eclipse.osbp.osgi.hybrid.api/META-INF/MANIFEST.MF
index ed2aa0e..a5f0ae1 100644
--- a/org.eclipse.osbp.osgi.hybrid.api/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.osgi.hybrid.api/META-INF/MANIFEST.MF
@@ -22,7 +22,6 @@
org.apache.httpcomponents.httpclient,
org.jsoup,
org.eclipse.osbp.runtime.web.vaadin.databinding;bundle-version="[0.9.0,0.10.0)",
- refresher.osgi;bundle-version="[1.2.3,1.2.4)",
org.eclipse.osbp.preferences;bundle-version="[0.9.0,0.10.0)",
org.eclipse.osbp.webserver.messagequeue;bundle-version="[0.9.0,0.10.0)",
org.eclipse.osbp.runtime.common;bundle-version="[0.9.0,0.10.0)",
diff --git a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/AbstractHybridVaaclipseView.java b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/AbstractHybridVaaclipseView.java
index 85af892..9b193bf 100644
--- a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/AbstractHybridVaaclipseView.java
+++ b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/AbstractHybridVaaclipseView.java
@@ -14,6 +14,8 @@
*/
package org.eclipse.osbp.osgi.hybrid.api;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -22,6 +24,7 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+import javax.swing.Timer;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
@@ -64,18 +67,11 @@
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHybridVaaclipseView.class);
- public enum RenderMode {
- SYNCHRONOUSLY, ASYNCHRONOUSLY
- }
-
private IEclipseContext fEclipseContext;
private MApplication fE4App;
private VerticalLayout fParent;
private boolean fViewInitialized;
- private RenderMode renderMode = RenderMode.ASYNCHRONOUSLY;
- private boolean firstTime = true;
- private int pollingInterval = 2000;
/** The beeper. */
private Beeper beeper = new Beeper();
private Audio audio = new Audio();
@@ -85,6 +81,8 @@
private EPartService partService;
+ private Timer timer;
+
public AbstractHybridVaaclipseView() {}
/**
* <b><i><u>Warning:</u> never use initializing class attributes in the definition!<br>
@@ -101,7 +99,7 @@
fViewInitialized = false;
fParent = parent;
fRecursiveFocusBlurListener = RecursiveFocusBlurListener.attachFor(fParent);
-// parent.addComponent(beeper);
+ parent.addComponent(beeper);
// audio.setShowControls(false);
// parent.addComponent(audio);
// video.setShowControls(false);
@@ -114,10 +112,10 @@
HybridVaadinVaaclipseConnector.instance(fEclipseContext).addListener(this);
HybridVaadinVaaclipseConnector.instance(fEclipseContext).setE4Application(fE4App);
VaadinObservables.getRealm(UI.getCurrent());
- UI.getCurrent().setPollInterval(pollingInterval);
+// UI.getCurrent().setPollInterval(pollingInterval);
createView(fParent);
postInit(null);
- renderData(true);
+ renderData();
}
@PreDestroy
@@ -138,9 +136,6 @@
if (getThemeResourceService() != null) {
msg.setIcon(getThemeResourceService().getThemeResource("locksview.gif", ThemeResourceType.IMAGE));
}
- else {
- LOGGER.error("themeResourceService not set!");
- }
area.addComponent(msg);
}
@@ -218,44 +213,26 @@
protected abstract void createComponents();
- // renderData is used for components that are not fully embedded in vaadin's connector structure
- // and must be repainted when parent window resizes
- // but can also be used to make component rendering asynchronously from view creation
public void renderData() {
- LOGGER.debug("renderData not firsttime");
- renderData(false);
- }
-
- public void renderData(boolean firstTime) {
- // the first time we only want to be triggered by the initial createView process, not by changeLocale
- if (this.firstTime) {
- if (!firstTime) {
- LOGGER.debug("renderData ignored because not firsttime");
- return;
- } else {
- this.firstTime = false;
- }
- }
- if (UI.getCurrent() == null) {
- LOGGER.debug("renderData has no current ui");
- return;
- }
- if (renderMode == RenderMode.SYNCHRONOUSLY) {
- LOGGER.debug("render synchronously");
- UI.getCurrent().accessSynchronously(new Runnable() {
- @Override
- public void run() {
- createComponents();
- }
- });
+ LOGGER.debug("buffered render asynchronously. Class:{} ObjectID:{}", getClass().getName(), System.identityHashCode(this));
+ final UI currentUi = fEclipseContext.get(UI.class);
+ if(timer != null && timer.isRunning()) {
+ LOGGER.debug("{}", "buffered render restarted.");
+ timer.restart();
} else {
- LOGGER.debug("render asynchronously");
- UI.getCurrent().access(new Runnable() {
- @Override
- public void run() {
- createComponents();
- }
- });
+ timer = new Timer(500, e ->
+ currentUi.access(new Runnable() {
+ @Override
+ public void run() {
+ LOGGER.debug("execute render asynchronously. Class:{} ObjectID:{}", getClass().getName(),
+ System.identityHashCode(this));
+ VaadinObservables.activateRealm(currentUi);
+ createComponents();
+ }
+ })
+ );
+ timer.setRepeats(false);
+ timer.start();
}
}
@@ -314,19 +291,6 @@
}
/**
- * Try to authenticate with the credentials given!<br>
- * {@link #setAuthenticated(boolean)} will explicit be called!
- *
- * @param portalId
- * @param userName
- * @param password
- * @return true if the user was authenticated successful
- */
- // protected boolean tryToAuthenticate(String portalId, String userName, String password) {
- // return HybridVaadinVaaclipseConnector.instance().tryToAuthenticate(portalId, userName, password);
- // }
-
- /**
* Logout from the Shiro API and send a LOGOUT event via ActiveMQ
*/
protected void logout() {
@@ -361,7 +325,6 @@
@Override
public void partActivated(MPart part) {
if(part != null) {
- HybridVaadinVaaclipseConnector.instance(fEclipseContext).activatePartStateRefresher(part);
MPerspective active = HybridVaadinVaaclipseConnector.findCurrentPerspectiveFor(part);
if (active instanceof MPerspective) {
HybridVaadinVaaclipseConnector.instance(fEclipseContext).updatePerspectiveList();
@@ -372,23 +335,18 @@
@Override
public void partBroughtToTop(MPart part) {
- HybridVaadinVaaclipseConnector.instance(fEclipseContext).activatePartStateRefresher(part);
- LOGGER.debug("part {} brought to top", part);
}
@Override
public void partDeactivated(MPart part) {
- LOGGER.debug("part {} deactivated", part);
}
@Override
public void partHidden(MPart part) {
- LOGGER.debug("part {} hidden", part);
}
@Override
public void partVisible(MPart part) {
- LOGGER.debug("part {} visible", part);
}
/**
@@ -404,22 +362,6 @@
return HybridVaadinVaaclipseConnector.instance(fEclipseContext).tryToAuthenticate(portalId, userName, password);
}
- public RenderMode getRenderMode() {
- return renderMode;
- }
-
- public void setRenderMode(RenderMode renderMode) {
- this.renderMode = renderMode;
- }
-
- public int getPollingInterval() {
- return pollingInterval;
- }
-
- public void setPollingInterval(int pollingInterval) {
- this.pollingInterval = pollingInterval;
- }
-
public Beeper getBeeper() {
return beeper;
}
@@ -429,6 +371,4 @@
public Video getVideo() {
return video;
}
-// abstract void activate(MPart part);
-// abstract void deactivate(MPart part);
}
diff --git a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridCredentials.java b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridCredentials.java
index df2a162..34c5cc7 100644
--- a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridCredentials.java
+++ b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridCredentials.java
@@ -14,16 +14,6 @@
*/
package org.eclipse.osbp.osgi.hybrid.api;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.List;
-
-import org.apache.http.NameValuePair;
-import org.apache.http.client.utils.URLEncodedUtils;
-
-import com.vaadin.server.Page;
-import com.vaadin.ui.UI;
-
public class HybridCredentials {
private final String portalId;
diff --git a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridPartStateRefresher.java b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridPartStateRefresher.java
deleted file mode 100644
index 95dff23..0000000
--- a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridPartStateRefresher.java
+++ /dev/null
@@ -1,45 +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.osgi.hybrid.api;
-
-import com.github.wolfie.refresher.Refresher;
-
-import org.eclipse.osbp.preferences.ProductConfiguration;
-
-public class HybridPartStateRefresher extends Refresher {
-
- private static final long serialVersionUID = 2627881764074882845L;
- private boolean fActive;
- private final int fIntervalActive;
- private final int fIntervalInactive;
-
- public HybridPartStateRefresher(RefreshListener listener) {
- fIntervalActive = ProductConfiguration.getHybridRefresherMilliSecsActive();
- fIntervalInactive = ProductConfiguration.getHybridRefresherMilliSecsInactive();
- addListener(listener);
- setActive(true);
- }
-
- public void setActive(boolean active) {
- if (fActive != active) {
- fActive = active;
- setRefreshInterval(fActive ? fIntervalActive : fIntervalInactive);
- }
- }
-
- public boolean isActive() {
- return fActive;
- }
-}
diff --git a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridServiceBinder.java b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridServiceBinder.java
index aa0fdcb..ac16549 100644
--- a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridServiceBinder.java
+++ b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridServiceBinder.java
@@ -27,7 +27,7 @@
public class HybridServiceBinder {
private static final Set<IPresentationRenderer> sPresentationRenderers = new HashSet<>();
- private final static Logger log = LoggerFactory.getLogger("servicebinder");
+ private static final Logger log = LoggerFactory.getLogger("servicebinder");
private static IUserAccessService userAccessService;
diff --git a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridVaadinVaaclipseConnector.java b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridVaadinVaaclipseConnector.java
index f3751af..508c2e6 100644
--- a/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridVaadinVaaclipseConnector.java
+++ b/org.eclipse.osbp.osgi.hybrid.api/src/org/eclipse/osbp/osgi/hybrid/api/HybridVaadinVaaclipseConnector.java
@@ -17,7 +17,6 @@
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.net.URI;
import java.util.Collection;
import java.util.HashSet;
@@ -37,7 +36,6 @@
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
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.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
@@ -56,15 +54,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.github.wolfie.refresher.Refresher;
-import com.github.wolfie.refresher.Refresher.RefreshListener;
import com.vaadin.server.AbstractClientConnector;
-import com.vaadin.server.Extension;
import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;
-public class HybridVaadinVaaclipseConnector implements RefreshListener, IHybridVaadinVaaclipseListener {
+public class HybridVaadinVaaclipseConnector implements IHybridVaadinVaaclipseListener {
private static final long serialVersionUID = 7239729235615118954L;
private static final Logger LOGGER = LoggerFactory.getLogger(HybridVaadinVaaclipseConnector.class);
@@ -96,8 +91,6 @@
private String fLastFocusPerspectiveId = "";
private Queue<Map<String,Object>> fLastListOfPerspectives = new LinkedList<Map<String,Object>>();
private Queue<IEventForNextRefresh> fEventsForNextRefresh = null;
- private HybridPartStateRefresher fPartStateRefresher = null;
- private MPart fLastActivePart;
private AbstractClientConnector fLastExtensionHolder;
private boolean fPostInitForSessionHandled;
private boolean fPostInitForAuthenticationHandled;
@@ -158,13 +151,7 @@
return ((component != null) && "org.eclipse.osbp.vaaclipse.presentation.widgets.TrimmedWindowContent".equals(component.getClass().getCanonicalName()));
}
- @Override
- public void refresh(Refresher source) {
- // --- if not yet on TrimmedWindowContent ---
- if (!isTrimmedWindowContent()) {
- // --- re-active a part state refresher ---
- activatePartStateRefresher();
- }
+ public void refresh() {
// --- handle all events received via ActiveMq ---
while (!fEventsForNextRefresh.isEmpty()) {
IEventForNextRefresh event = fEventsForNextRefresh.poll();
@@ -330,100 +317,6 @@
fMqBrokerPort = ProductConfiguration.getActiveMqBrokerServerPort();
}
- /**
- * @return true if a refresher exists
- */
- protected boolean refresherExisting() {
- return (fPartStateRefresher != null);
- }
-
- /**
- * re-create a refresher if it is needed and not yet added to a TrimmedWindowContent
- */
- protected void activatePartStateRefresher() {
- if ((fMqConsumer != null) && !isTrimmedWindowContent() && (fLastActivePart != null)) {
- activatePartStateRefresher(fLastActivePart);
- }
- }
-
- /**
- * (re-)create a refresher for the MPart and not yet added to a TrimmedWindowContent
- * @param part
- */
- protected void activatePartStateRefresher(MPart part) {
- fLastActivePart = part;
- // --- create the event queue if it doesn't exists yet ---
- if (fEventsForNextRefresh == null) {
- fEventsForNextRefresh = new LinkedList<IEventForNextRefresh>();
- }
- // --- no refresher if not connected to any hybrid ---
- if (fMqConsumer == null) {
- return;
- }
- // --- no re-create refresher if it is already set on a TrimmedWindowContent ---
- if (isTrimmedWindowContent()) {
- return;
- }
- if (part != null) {
- Object object = part.getObject();
- // --- get the view connected to the MPart ---
- if (object instanceof AbstractHybridVaaclipseView) {
- AbstractHybridVaaclipseView view = (AbstractHybridVaaclipseView) object;
- // --- get the parent component ---
- AbstractClientConnector parent = view.getParent();
- Method addExtension = null;
- AbstractClientConnector extensionHolder = null;
- try {
- // --- traverse the parents to get the topmost extension holder ---
- while ((parent != null) && (parent.getParent() != null)) {
- try {
- // --- check each parent for ... ---
- for (Class cls = parent.getClass(); cls != null; cls = cls.getSuperclass()) {
- try {
- // --- ... each extended class ... ---
- if (cls.getDeclaredMethod("addExtension", Extension.class) != null) {
- // --- if it has a method addExtension(Extension) ---
- extensionHolder = parent;
- addExtension = cls.getDeclaredMethod("addExtension", Extension.class);
- break;
- }
- }
- catch (Exception e) {} // NOP
- }
- }
- catch (Exception e) {} // NOP
- // --- the parent ---
- parent = (AbstractClientConnector) parent.getParent();
- // --- if this instance is a TrimmedWindowContent itself ---
- if (HybridVaadinVaaclipseConnector.isTrimmedWindowContent(extensionHolder)) {
- break;
- }
- }
- // --- if a possible extension holder was found ---
- if (extensionHolder != null) {
- Collection<Extension> extensions = extensionHolder.getExtensions();
- for (Extension extension : extensions) {
- // --- if it already has a refresher ---
- if (extension instanceof HybridPartStateRefresher) {
- return;
- }
- }
- if (addExtension != null) {
- // --- enable the accessability of the method ---
- addExtension.setAccessible(true);
- // --- generate a new refresher; they can't be moved to another parent ---
- fPartStateRefresher = new HybridPartStateRefresher(this);
- addExtension.invoke(extensionHolder, new Object[] { fPartStateRefresher });
- // --- remember the last active extension holder ---
- fLastExtensionHolder = extensionHolder;
- }
- }
- }
- catch (Exception e) {} // NOP
- }
- }
- }
-
public void setE4Application(MApplication e4Application) {
fE4Application = e4Application;
}