Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2009-10-02 10:22:06 +0000
committercdumoulin2009-10-02 10:22:06 +0000
commit5678f31f45b8cff834ca555e4e9254dc723ce032 (patch)
tree42e8c3d68618ef08e418b64552e7af5defca723f
parentdd098d274aed16828a41e5222cb946d1ee6be0f7 (diff)
downloadorg.eclipse.papyrus-5678f31f45b8cff834ca555e4e9254dc723ce032.tar.gz
org.eclipse.papyrus-5678f31f45b8cff834ca555e4e9254dc723ce032.tar.xz
org.eclipse.papyrus-5678f31f45b8cff834ca555e4e9254dc723ce032.zip
ASSIGNED - bug 268775: [Sash Editor] Improve and finalize plugin
https://bugs.eclipse.org/bugs/show_bug.cgi?id=268775 Improve listener on IWorkbenchPartConstants.PROP_*. Detach the listener Propagate the event to the container.
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java12
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/EditorPart.java45
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java8
-rw-r--r--plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java4
4 files changed, 33 insertions, 36 deletions
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java
index bc03c9d7331..486947d158c 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java
@@ -45,7 +45,9 @@ public class SashWindowsEventsProvider {
/** Currently active page, or null if no container is actif */
private IPage activePage = null;
-
+ /**
+ * Listener on Eclipse Part changes
+ */
private IPartListener workbenchPartListener = new IPartListener(){
public void partOpened(IWorkbenchPart part) {
@@ -58,11 +60,11 @@ public class SashWindowsEventsProvider {
}
public void partClosed(IWorkbenchPart part) {
-// System.out.println("("+ part +")");
+// System.out.println("partClosed("+ part +")");
}
public void partBroughtToTop(IWorkbenchPart part) {
-// System.out.println("partClosed("+ part +")");
+// System.out.println("partBroughtToTop("+ part +")");
}
public void partActivated(IWorkbenchPart part) {
@@ -146,8 +148,8 @@ public class SashWindowsEventsProvider {
}
/**
- * Register a listener listeneing on editor change.
- * Page can be acuired with :
+ * Register a listener listening on editor change.
+ * Page can be acquired with :
* IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
*/
private void registerEditorChangedListener(IWorkbenchPage page) {
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/EditorPart.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/EditorPart.java
index 6690c3c044f..ca7d9163d51 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/EditorPart.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/EditorPart.java
@@ -80,21 +80,15 @@ public class EditorPart extends PagePart {
// protected TabFolderPart parent;
/**
- * Listen on mouse enter event.
- * Try to get an event indicating that the mouse enter over the editor.
- * This can be used to switch the active editor.
- * TODO This doesn't work yet.
- */
- private Listener mouseEnterListener = new Listener() {
-
- /**
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
- */
- public void handleEvent(Event event) {
- Point globalPos = new Point(event.x, event.y);
- System.out.println(this.getClass().getSimpleName() + ".handleEvent(" + eventName(event.type) + ", " + globalPos + ")");
+ * Listener on editorPart IWorkbenchPartConstants.PROP_DIRTY changes.
+ *
+ */
+ private IPropertyListener editorPartListener = new IPropertyListener() {
+
+ public void propertyChanged(Object source, int propId) {
+// if( propId == IWorkbenchPartConstants.PROP_DIRTY)
+ // propagate the change (PROP_DIRTY generally).
+ handlePropertyChange(propId);
}
};
@@ -218,15 +212,8 @@ public class EditorPart extends PagePart {
Composite editorParent = new Composite(parentControl, getOrientation(editor));
editorParent.setLayout(new FillLayout());
editor.createPartControl(editorParent);
- editor.addPropertyListener(new IPropertyListener() {
-
- public void propertyChanged(Object source, int propertyId) {
- EditorPart.this.handlePropertyChange(propertyId);
- }
- });
-
- // TODO test to be removed
-// attachListeners(editorParent, false);
+ // attach listeners
+ attachListeners(editorParent, false);
return editorParent;
}
@@ -244,7 +231,7 @@ public class EditorPart extends PagePart {
// theControl.addListener(SWT.MouseHover, mouseEnterListener);
// theControl.addListener(SWT.MouseUp, mouseEnterListener);
// theControl.addListener(SWT.MouseDown, mouseEnterListener);
- theControl.addListener(SWT.Activate, mouseEnterListener);
+// theControl.addListener(SWT.Activate, mouseEnterListener);
// if (recursive && theControl instanceof Composite) {
// Composite composite = (Composite) theControl;
@@ -256,6 +243,8 @@ public class EditorPart extends PagePart {
// attachListeners(control, true);
// }
// }
+ // Listen on editor name change
+ editorPart.addPropertyListener(editorPartListener);
}
/**
@@ -268,7 +257,7 @@ public class EditorPart extends PagePart {
// theControl.removeListener(SWT.MouseHover, mouseEnterListener);
// theControl.removeListener(SWT.MouseUp, mouseEnterListener);
// theControl.removeListener(SWT.MouseDown, mouseEnterListener);
- theControl.removeListener(SWT.Activate, mouseEnterListener);
+// theControl.removeListener(SWT.Activate, mouseEnterListener);
// if (recursive && theControl instanceof Composite) {
// Composite composite = (Composite) theControl;
@@ -280,6 +269,8 @@ public class EditorPart extends PagePart {
// detachListeners(control, false);
// }
// }
+ // Stop listening on editor name change
+ editorPart.removePropertyListener(editorPartListener);
}
@@ -298,7 +289,7 @@ public class EditorPart extends PagePart {
* the id of the property that changed
*/
private void handlePropertyChange(int propertyId) {
- getSashWindowContainer().firePropertyChange(propertyId);
+ getSashWindowContainer().firePropertyChange(propertyId, editorPart, editorModel);
}
/**
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java
index edc34b6ee0a..daddaeb4d29 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/SashWindowsContainer.java
@@ -193,10 +193,14 @@ public class SashWindowsContainer implements ISashWindowsContainer {
/**
* A change has happen in one of the inner parts. Relay the event.
* This method is called by inner parts whenever the event happen in one of the part.
+ * This method is used to relay the IWorkbenchPartConstants.PROP_* events from
+ * inner parts.
*
- * @param propertyId
+ * @param propertyId The event fired (one of IWorkbenchPartConstants.PROP_*)
+ * @param editorPart The nested IEditorPart firing the event.
+ * @param editorModel The IEditorModel used to create the IEditorPart.
*/
- protected void firePropertyChange(int propertyId) {
+ protected void firePropertyChange(int propertyId, IEditorPart editorPart, IEditorModel editorModel) {
// TODO Auto-generated method stub
}
diff --git a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java
index 3b392c80b31..5515a839bd1 100644
--- a/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java
+++ b/plugins/core/org.eclipse.papyrus.sasheditor/src2/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java
@@ -26,7 +26,7 @@ import org.eclipse.ui.IEditorPart;
/**
* A controller associated to a tabitem in a tabfolder. This controller contains a reference to
* a PagePart.
- * This class is used exclusively by the TabFolderPart. It shoulb be not used from elsewhere.
+ * This class is used exclusively by the TabFolderPart. It should be not used from elsewhere.
*
* @author dumoulin
*
@@ -39,7 +39,7 @@ public class TabItemPart {
// protected Object model;
/**
- * The child assocciated to this tabitem. The child is rendered by the tabitem.
+ * The child associated to this tabitem. The child is rendered by the tabitem.
*/
protected PagePart childPart;

Back to the top