summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-09-28 08:44:08 (EDT)
committerSteffen Kriese2010-09-28 08:44:08 (EDT)
commitc1c48a739829958c5fa0cde2164fa91c96efdbd0 (patch)
treea8fb06684456e391acd7bb9d0d835b0ecaa9908c
parente81066866c519d939a75a40451f2078a11ccef23 (diff)
downloadorg.eclipse.riena-c1c48a739829958c5fa0cde2164fa91c96efdbd0.zip
org.eclipse.riena-c1c48a739829958c5fa0cde2164fa91c96efdbd0.tar.gz
org.eclipse.riena-c1c48a739829958c5fa0cde2164fa91c96efdbd0.tar.bz2
Applied Patch #325346 Riena UIProcess not working when running with RAP
-rw-r--r--org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/ProgressProviderBridge.java17
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java6
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/DefaultStatuslineContentFactory.java63
-rw-r--r--org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java24
4 files changed, 76 insertions, 34 deletions
diff --git a/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/ProgressProviderBridge.java b/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/ProgressProviderBridge.java
index cf5830e..41f9deb 100644
--- a/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/ProgressProviderBridge.java
+++ b/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/ProgressProviderBridge.java
@@ -15,7 +15,9 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.core.runtime.jobs.ProgressProvider;
import org.eclipse.riena.core.singleton.SingletonProvider;
@@ -34,6 +36,7 @@ public class ProgressProviderBridge extends ProgressProvider {
public ProgressProviderBridge() {
jobUiProcess = Collections.synchronizedMap(new HashMap<Job, UIProcess>());
+ Job.getJobManager().addJobChangeListener(new JobObserver());
}
public static ProgressProviderBridge instance() {
@@ -76,4 +79,18 @@ public class ProgressProviderBridge extends ProgressProvider {
public void unregisterMapping(final Job job) {
jobUiProcess.remove(job);
}
+
+ private final class JobObserver extends JobChangeAdapter {
+
+ @Override
+ public void scheduled(final IJobChangeEvent event) {
+ registerMapping(event.getJob(), createDefaultUIProcess(event.getJob()));
+ }
+
+ @Override
+ public void done(final IJobChangeEvent event) {
+ unregisterMapping(event.getJob());
+ }
+
+ }
}
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java
index 3dadddb..8688414 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/StatuslineUIProcessRidget.java
@@ -56,6 +56,8 @@ public class StatuslineUIProcessRidget extends AbstractRidget implements IStatus
private IVisualContextManager contextLocator;
+ Display display = Display.getCurrent();
+
public StatuslineUIProcessRidget() {
Wire.instance(processManager).andStart(Activator.getDefault().getContext());
buildTrigger();
@@ -351,14 +353,14 @@ public class StatuslineUIProcessRidget extends AbstractRidget implements IStatus
* updates the user interface taking care of thread serialization
*/
private void updateUserInterface() {
- if (Display.getDefault().getThread().equals(Thread.currentThread())) {
+ if (display.getThread().equals(Thread.currentThread())) {
// update on the current thread = user interface thread
updateBaseAndList();
return;
}
// we are not on the user interface thread
- Display.getDefault().asyncExec(new Runnable() {
+ display.asyncExec(new Runnable() {
public void run() {
updateBaseAndList();
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/DefaultStatuslineContentFactory.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/DefaultStatuslineContentFactory.java
index 510ed68..820a741 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/DefaultStatuslineContentFactory.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/DefaultStatuslineContentFactory.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.riena.core.util.RAPDetector;
import org.eclipse.riena.core.util.ReflectionUtils;
/**
@@ -35,40 +36,46 @@ public class DefaultStatuslineContentFactory implements IStatusLineContentFactor
public void createContent(final Statusline statusline) {
statusline.setLayout(new FormLayout());
- final StatuslineTime time = new StatuslineTime(statusline, SWT.NONE);
- FormData formData = new FormData();
- formData.top = new FormAttachment(0, 0);
- formData.bottom = new FormAttachment(100, 0);
- formData.right = new FormAttachment(100, 0);
- time.setLayoutData(formData);
- Control lastControl = time;
+ FormData formData = null;
+ Control lastControl = null;
+ Control spacerControl = null;
- Control spacerControl = createSpacer(statusline);
- if (spacerControl != null) {
+ if (!RAPDetector.isRAPavailable()) {
+ final StatuslineTime time = new StatuslineTime(statusline, SWT.NONE);
formData = new FormData();
formData.top = new FormAttachment(0, 0);
formData.bottom = new FormAttachment(100, 0);
- formData.right = new FormAttachment(lastControl, 0);
- spacerControl.setLayoutData(formData);
- lastControl = spacerControl;
- }
-
- final StatuslineDate date = new StatuslineDate(statusline, SWT.NONE);
- formData = new FormData();
- formData.top = new FormAttachment(0, 0);
- formData.bottom = new FormAttachment(100, 0);
- formData.right = new FormAttachment(lastControl, 0);
- date.setLayoutData(formData);
- lastControl = date;
+ formData.right = new FormAttachment(100, 0);
+ time.setLayoutData(formData);
+ lastControl = time;
+
+ spacerControl = createSpacer(statusline);
+ if (spacerControl != null) {
+ formData = new FormData();
+ formData.top = new FormAttachment(0, 0);
+ formData.bottom = new FormAttachment(100, 0);
+ formData.right = new FormAttachment(lastControl, 0);
+ spacerControl.setLayoutData(formData);
+ lastControl = spacerControl;
+ }
- spacerControl = createSpacer(statusline);
- if (spacerControl != null) {
+ final StatuslineDate date = new StatuslineDate(statusline, SWT.NONE);
formData = new FormData();
formData.top = new FormAttachment(0, 0);
formData.bottom = new FormAttachment(100, 0);
formData.right = new FormAttachment(lastControl, 0);
- spacerControl.setLayoutData(formData);
- lastControl = spacerControl;
+ date.setLayoutData(formData);
+ lastControl = date;
+
+ spacerControl = createSpacer(statusline);
+ if (spacerControl != null) {
+ formData = new FormData();
+ formData.top = new FormAttachment(0, 0);
+ formData.bottom = new FormAttachment(100, 0);
+ formData.right = new FormAttachment(lastControl, 0);
+ spacerControl.setLayoutData(formData);
+ lastControl = spacerControl;
+ }
}
final StatuslineNumber number = createStatuslineNumber(statusline);
@@ -77,7 +84,11 @@ public class DefaultStatuslineContentFactory implements IStatusLineContentFactor
formData1 = new FormData();
formData1.top = new FormAttachment(0, 0);
formData1.bottom = new FormAttachment(100, 0);
- formData1.right = new FormAttachment(lastControl, 0);
+ if (RAPDetector.isRAPavailable()) {
+ formData1.right = new FormAttachment(100, 0);
+ } else {
+ formData1.right = new FormAttachment(lastControl, 0);
+ }
number.setLayoutData(formData1);
lastControl = number;
diff --git a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java
index 295b793..d23bb61 100644
--- a/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java
+++ b/org.eclipse.riena.ui.swt/src/org/eclipse/riena/ui/swt/uiprocess/SwtUISynchronizer.java
@@ -37,6 +37,12 @@ public class SwtUISynchronizer implements IUISynchronizer {
private static List<Runnable> asyncJobs = Collections.synchronizedList(new ArrayList<Runnable>());
private static Thread displayObserver;
private static AtomicBoolean workbenchShutdown = new AtomicBoolean(false);
+ private final Display display;
+
+ public SwtUISynchronizer() {
+ // we try to remember the display. This is a hack for Riena on RAP.
+ this.display = Display.getCurrent();
+ }
/**
* @see IUISynchronizer#syncExec(Runnable)
@@ -102,9 +108,10 @@ public class SwtUISynchronizer implements IUISynchronizer {
// TODO [ev] I think there are two problems with this code:
// (a) getDisplay().isDisposed() will NPE when getDisplay() == null
- // (b) if the display is disposed, we won't get another one. What happens with
+ // (b) if the display is disposed, we won't get another one. What happens with
// the things that need to run?
- while (PlatformUI.isWorkbenchRunning() && getDisplay() == null || getDisplay().isDisposed()) {
+ while (PlatformUI.isWorkbenchRunning() && getDisplay() == null
+ || (getDisplay() != null && getDisplay().isDisposed())) {
try {
Thread.sleep(50);
} catch (final InterruptedException e) {
@@ -122,6 +129,10 @@ public class SwtUISynchronizer implements IUISynchronizer {
syncIter.remove();
}
+ if (getDisplay() == null) {
+ return;
+ }
+
// execute jobs (asyncExec)
final Iterator<Runnable> asyncIter = asyncJobs.iterator();
while (asyncIter.hasNext()) {
@@ -184,10 +195,11 @@ public class SwtUISynchronizer implements IUISynchronizer {
}
public Display getDisplay() {
- if (hasDisplay()) {
- return PlatformUI.getWorkbench().getDisplay();
+ if (display != null) {
+ return display;
}
- return null;
+
+ return PlatformUI.getWorkbench().getDisplay();
}
private Logger getLogger() {
@@ -195,7 +207,7 @@ public class SwtUISynchronizer implements IUISynchronizer {
}
protected boolean hasDisplay() {
- return PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getDisplay() != null;
+ return display != null || PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getDisplay() != null;
}
/**