Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2019-10-18 16:15:17 +0000
committerHenrik Rentz-Reichert2019-10-18 16:15:17 +0000
commit0327d439a3964c16ef650d251c8599d2830ab452 (patch)
treebc06bc44dd304f6676caf152779049decbef3a42 /plugins/org.eclipse.etrice.ui.common.base
parent1537b53a166a6a7f16a37df9ca6686049dceb608 (diff)
downloadorg.eclipse.etrice-0327d439a3964c16ef650d251c8599d2830ab452.tar.gz
org.eclipse.etrice-0327d439a3964c16ef650d251c8599d2830ab452.tar.xz
org.eclipse.etrice-0327d439a3964c16ef650d251c8599d2830ab452.zip
Bug 550882 - [diagram] diagram close with "don't save" does not work
* fixed the bug (for all editors) * removed commented-out code Change-Id: I53f80d00cc297bd6daa36f02d230a5349781f8ea
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.common.base')
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java19
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SaveOnFocusLostListener.java29
2 files changed, 25 insertions, 23 deletions
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java
index 4c91be7cd..9674a3860 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java
@@ -14,6 +14,8 @@
package org.eclipse.etrice.ui.common.base.editor;
+import static org.eclipse.ui.PlatformUI.getWorkbench;
+
import java.util.Collection;
import java.util.Map;
@@ -23,6 +25,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.common.ui.editor.ISaveOnFocusLostEditor;
import org.eclipse.etrice.core.common.ui.linking.GlobalNonPlatformURIEditorOpener;
import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
import org.eclipse.etrice.core.fsm.ui.FSMUiModule;
@@ -45,15 +48,13 @@ import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
-import static org.eclipse.ui.PlatformUI.getWorkbench;
-
import com.google.inject.Injector;
/**
* @author Henrik Rentz-Reichert
*
*/
-public abstract class DiagramEditorBase extends DiagramEditor implements IInputUriHolder {
+public abstract class DiagramEditorBase extends DiagramEditor implements IInputUriHolder, ISaveOnFocusLostEditor {
private final static String CONTEXT_ID = "org.eclipse.etrice.ui.common.base.context";
@@ -63,6 +64,8 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU
private SuperClassListener superClassListener;
+ private boolean isClosing = false;
+
public DiagramEditorBase(Object textEditorClass) {
this.textEditorClass = textEditorClass;
@@ -254,4 +257,14 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU
}
+ @Override
+ public int promptToSaveOnClose() {
+ isClosing = true;
+ return DEFAULT;
+ }
+
+ public boolean isClosing() {
+ return isClosing;
+ }
+
}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SaveOnFocusLostListener.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SaveOnFocusLostListener.java
index 6ed93791d..8b6cf8913 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SaveOnFocusLostListener.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/SaveOnFocusLostListener.java
@@ -15,6 +15,7 @@
package org.eclipse.etrice.ui.common.base.editor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.etrice.core.common.ui.editor.ISaveOnFocusLostEditor;
import org.eclipse.etrice.ui.common.base.UIBaseActivator;
import org.eclipse.etrice.ui.common.base.preferences.UIBasePreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -26,7 +27,7 @@ import org.eclipse.ui.IWorkbenchPart;
* @author Henrik Rentz-Reichert
*
*/
-public class SaveOnFocusLostListener implements IPartListener/*, CommandStackListener*/ {
+public class SaveOnFocusLostListener implements IPartListener {
private final IEditorPart editor;
private final IPreferenceStore store;
@@ -39,7 +40,6 @@ public class SaveOnFocusLostListener implements IPartListener/*, CommandStackLis
public SaveOnFocusLostListener(IEditorPart editor) {
this.editor = editor;
this.store = UIBaseActivator.getDefault().getPreferenceStore();
- //editor.getEditingDomain().getCommandStack().addCommandStackListener(this);
editor.getSite().getPage().addPartListener(this);
}
@@ -62,19 +62,17 @@ public class SaveOnFocusLostListener implements IPartListener/*, CommandStackLis
@Override
public void partDeactivated(IWorkbenchPart part) {
- if(part != editor)
+ if (part != editor)
return;
+ if (part instanceof ISaveOnFocusLostEditor) {
+ if (((ISaveOnFocusLostEditor) part).isClosing()) {
+ return;
+ }
+ }
+
boolean isSaveOnFocus = store.getBoolean(UIBasePreferenceConstants.SAVE_DIAG_ON_FOCUS_LOST);
if (isActive && isSaveOnFocus && editor.isDirty()) {
-// if (editor.getEditingDomain() instanceof TransactionalEditingDomainImpl) {
-// TransactionalEditingDomainImpl ted = (TransactionalEditingDomainImpl) editor.getEditingDomain();
-// if (ted.getActiveTransaction()!=null) {
-// // avoid to run into dead-lock
-// saveAfterCurrentCommand = true;
-// return;
-// }
-// }
editor.doSave(new NullProgressMonitor());
}
}
@@ -82,15 +80,6 @@ public class SaveOnFocusLostListener implements IPartListener/*, CommandStackLis
@Override
public void partOpened(IWorkbenchPart part) {
}
-
-// @Override
-// public void commandStackChanged(EventObject event) {
-//
-// if (saveAfterCurrentCommand) {
-// saveAfterCurrentCommand = false;
-// editor.doSave(new NullProgressMonitor());
-// }
-// }
public void setActive(boolean isActive){
this.isActive = isActive;

Back to the top