[Bug 522623] Fix 'save all' conflict with Sirius Editor
Remove doSave() implementation and fix regression: Since
ActivityExplorerEditor became a ISaveablesSource,
closing Eclipse with a dirty session does not propose to save changes
because ActivityExplorerEditor.isSaveOnCloseNeeded() method return
false.
Bug: Bug 522623
Change-Id: I177f504d119b122b386aef4d8f0b3e334e9a3652
Signed-off-by: Jeremy Aubry <jaubry@obeo.fr>
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
index c1673e0..da05ca8 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
@@ -25,11 +25,8 @@
import org.eclipse.amalgam.explorer.activity.ui.internal.intf.IActivityExplorerEditorSessionListener;
import org.eclipse.amalgam.explorer.activity.ui.internal.intf.IVisibility;
import org.eclipse.amalgam.explorer.activity.ui.internal.util.ActivityExplorerLoggerService;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ILabelDecorator;
@@ -53,7 +50,6 @@
import org.eclipse.ui.forms.editor.IFormPage;
import org.eclipse.ui.forms.editor.SharedHeaderFormEditor;
import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.statushandlers.StatusManager;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
@@ -355,24 +351,8 @@
*/
@Override
public void doSave(IProgressMonitor monitor) {
- if (isDirty()) {
- try {
- Saveable[] saveables = getSaveables();
- if (saveables.length == 1 && saveables[0] != null) {
- try {
- saveables[0].doSave(monitor);
- } catch (CoreException ce) {
- StatusManager.getManager().handle(new Status(IStatus.ERROR, getBundleId(ce), ce.getMessage(), ce), StatusManager.BLOCK);
- }
- } else {
- // ISaveableSource returned 0 or more than 1 saveables.
- throw new IllegalArgumentException(String.format(Messages.ActivityExplorerEditor_IEditingSessionRetrieval_WrongNumberOfSaveables, ISaveablesSource.class.getSimpleName(),
- SessionUIManager.INSTANCE.getOrCreateUISession(getEditorInput().getSession()).getClass().getSimpleName(), Saveable.class.getSimpleName(), saveables.length));
- }
- } catch (RuntimeException rte) {
- StatusManager.getManager().handle(new Status(IStatus.ERROR, getBundleId(rte), rte.getMessage(), rte), StatusManager.BLOCK);
- }
- }
+ // Ignore. This method is not called because ActivityExplorerEditor implements ISaveablesSource.
+ // All saves will go through the ISaveablesSource / Saveable protocol.
}
/**
@@ -498,11 +478,13 @@
*/
@Override
public boolean isDirty() {
- final Session session = getEditorInput().getSession();
- if (null != session) {
- return SessionStatus.DIRTY.equals(session.getStatus());
- }
- return false;
+ Saveable[] saveables = getSaveables();
+ for (Saveable saveable : saveables) {
+ if (saveable.isDirty()) {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -515,15 +497,6 @@
}
/**
- * {@inheritDoc}
- */
- @Override
- public boolean isSaveOnCloseNeeded() {
- // See with SBo, we don't want to save on close.
- return false;
- }
-
- /**
* Unregister the session listener and set the session to <code>null</code>.
*/
private void unregisterSession() {
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/Messages.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/Messages.java
index f3690cc..a993742 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/Messages.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/Messages.java
@@ -20,6 +20,7 @@
private static final String BUNDLE_NAME = "org.eclipse.amalgam.explorer.activity.ui.api.editor.messages"; //$NON-NLS-1$
public static String ActivityExplorerEditor_1;
public static String ActivityExplorerEditor_Error_Message;
+ public static String ActivityExplorerEditor_IEditingSessionRetrieval_ShouldAlsoImplementISaveablesSource;
static {
// initialize resource bundle
@@ -29,7 +30,4 @@
private Messages() {
// Private constructor.
}
-
- public static String ActivityExplorerEditor_IEditingSessionRetrieval_ShouldAlsoImplementISaveablesSource;
- public static String ActivityExplorerEditor_IEditingSessionRetrieval_WrongNumberOfSaveables;
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/messages.properties b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/messages.properties
index 1e5ac86..f4725c0 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/messages.properties
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/messages.properties
@@ -11,4 +11,3 @@
ActivityExplorerEditor_1=Cannot reopen session, please reopen from the Project Explorer
ActivityExplorerEditor_Error_Message=Cannot reopen session, please reopen from Project Explorer
ActivityExplorerEditor_IEditingSessionRetrieval_ShouldAlsoImplementISaveablesSource=Amalgam expects implementations of %s to also implement %s.
-ActivityExplorerEditor_IEditingSessionRetrieval_WrongNumberOfSaveables=%s of concrete type %s should provide exactly 1 non-null %s. Found: %d. This should never happen.
\ No newline at end of file