Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-05-07 21:21:06 +0000
committerThomas Schindl2010-05-07 21:21:06 +0000
commit0d9a8fb99430b6bd33edfc3562665828317ab493 (patch)
tree4f576424b86137418432661b8b09c9ff2a19ef7b
parente3e16ca48d3d97ac90f22cfc6f6c0c9686d9b990 (diff)
downloadorg.eclipse.e4.tools-0d9a8fb99430b6bd33edfc3562665828317ab493.tar.gz
org.eclipse.e4.tools-0d9a8fb99430b6bd33edfc3562665828317ab493.tar.xz
org.eclipse.e4.tools-0d9a8fb99430b6bd33edfc3562665828317ab493.zip
[Bug 304584] - [Tooling] Implement Workbench-Model-Toolingv20100510-1130
* adding dirty lifecycle support
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java21
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java13
2 files changed, 28 insertions, 6 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java
index 201d7036..518468e1 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java
@@ -2,19 +2,36 @@ package org.eclipse.e4.tools.emf.editor3x;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.tools.emf.editor3x.compat.E4CompatEditorPart;
import org.eclipse.e4.tools.emf.editor3x.emf.EditUIUtil;
import org.eclipse.e4.tools.emf.ui.common.XMIModelResource;
+import org.eclipse.e4.tools.emf.ui.common.IModelResource.ModelListener;
import org.eclipse.emf.common.util.URI;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.EditorPart;
public class XMIResourceFunction extends ContextFunction {
@Override
- public Object compute(IEclipseContext context, Object[] arguments) {
+ public Object compute(final IEclipseContext context, Object[] arguments) {
final IEditorInput input = context.get(IEditorInput.class);
+ final E4CompatEditorPart part = (E4CompatEditorPart) context.get(EditorPart.class);
+
if( input != null ) {
URI resourceURI = EditUIUtil.getURI(input);
- return new XMIModelResource(resourceURI);
+ final XMIModelResource resource = new XMIModelResource(resourceURI);
+ resource.addModelListener(new ModelListener() {
+
+ public void dirtyChanged() {
+ context.set(EditorPart.class.getName()+".dirty", resource.isDirty());
+ part.firePropertyChange(EditorPart.PROP_DIRTY);
+ }
+
+ public void commandStackChanged() {
+
+ }
+ });
+ return resource;
}
return null;
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java
index 93688351..440d7d2a 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java
@@ -37,8 +37,8 @@ public class E4CompatEditorPart extends EditorPart implements IExecutableExtensi
@Override
public void doSave(IProgressMonitor monitor) {
- // TODO Auto-generated method stub
-
+ IContributionFactory factory = (IContributionFactory) context.get(IContributionFactory.class);
+ factory.call(instance, null, "doSave", context, null);
}
@Override
@@ -66,9 +66,14 @@ public class E4CompatEditorPart extends EditorPart implements IExecutableExtensi
}
@Override
+ public void firePropertyChange(int propertyId) {
+ super.firePropertyChange(propertyId);
+ }
+
+ @Override
public boolean isDirty() {
- // TODO Auto-generated method stub
- return false;
+ Boolean b = (Boolean) context.get(EditorPart.class.getName()+".dirty");
+ return b != null && b;
}
@Override

Back to the top