Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2007-10-18 15:43:22 +0000
committerbvosburgh2007-10-18 15:43:22 +0000
commitc793cd9c4510a7afcc74eaa474ad579448e4586f (patch)
treeef1d7dc26dc9a9cdd94a9cd8170774de2ddedff2 /jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt
parent7bf48474e2b9f47e3c1c372188e5cd541c9e8268 (diff)
downloadwebtools.dali-c793cd9c4510a7afcc74eaa474ad579448e4586f.tar.gz
webtools.dali-c793cd9c4510a7afcc74eaa474ad579448e4586f.tar.xz
webtools.dali-c793cd9c4510a7afcc74eaa474ad579448e4586f.zip
[201159] model rework
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt')
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/SWTChangeEventDispatcherPlatformAdapter.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java3
2 files changed, 83 insertions, 2 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/SWTChangeEventDispatcherPlatformAdapter.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/SWTChangeEventDispatcherPlatformAdapter.java
new file mode 100644
index 0000000000..a6de60cdac
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/SWTChangeEventDispatcherPlatformAdapter.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal;
+
+import java.io.Serializable;
+
+import org.eclipse.jpt.utility.internal.model.ChangeEventDispatcher;
+import org.eclipse.jpt.utility.internal.model.UIChangeEventDispatcher;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * SWT-specific implementation of ChangeEventDispatcher.PlatformAdapter.
+ */
+public class SWTChangeEventDispatcherPlatformAdapter
+ implements UIChangeEventDispatcher.PlatformAdapter, Serializable
+{
+ // singleton
+ private static final UIChangeEventDispatcher.PlatformAdapter INSTANCE = new SWTChangeEventDispatcherPlatformAdapter();
+
+ private static final ChangeEventDispatcher DISPATCHER = new UIChangeEventDispatcher(INSTANCE);
+
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * Return the singleton.
+ */
+ public static UIChangeEventDispatcher.PlatformAdapter instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Return an SWT change event dispatcher.
+ */
+ public static ChangeEventDispatcher dispatcher() {
+ return DISPATCHER;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private SWTChangeEventDispatcherPlatformAdapter() {
+ super();
+ }
+
+ /**
+ * SWT check
+ */
+ public boolean currentThreadIsUIThread() {
+ return Thread.currentThread() == this.display().getThread();
+ }
+
+ /**
+ * Display.asyncExec(Runnable) seems to work OK;
+ * but using #syncExec() can somtimes make things
+ * more predictable when debugging.
+ */
+ public void executeOnUIThread(Runnable r) {
+ this.display().asyncExec(r);
+// this.display().syncExec(r);
+ }
+
+ private Display display() {
+ return PlatformUI.getWorkbench().getDisplay();
+ }
+
+ /**
+ * Serializable singleton support
+ */
+ private Object readResolve() {
+ return instance();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java
index a77a09b6c7..3750cb371c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java
@@ -49,8 +49,7 @@ public class TextEditorSelectionParticipant
this.textEditor.addPropertyListener(this.editorInputListener);
this.editorSelectionListener = new EditorSelectionListener();
this.postSelectionProvider().addPostSelectionChangedListener(this.editorSelectionListener);
-// this.currentSelection = this.calculateSelection();
- this.currentSelection = Selection.NULL_SELECTION;
+ this.currentSelection = this.calculateSelection();
}
// ********** ISelectionParticipant implementation **********

Back to the top