Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2017-08-29 17:06:36 +0000
committerJuergen Haug2017-08-29 17:06:36 +0000
commit849e7f9f39a3cf47aab7822d7b8a0bc50f355bb7 (patch)
treeedea8a43f2bdf810a1189e6f1cc8007855daec67 /plugins/org.eclipse.etrice.ui.common.base
parentc72ab314a29234cf980b85d12c18734747ee2176 (diff)
downloadorg.eclipse.etrice-849e7f9f39a3cf47aab7822d7b8a0bc50f355bb7.tar.gz
org.eclipse.etrice-849e7f9f39a3cf47aab7822d7b8a0bc50f355bb7.tar.xz
org.eclipse.etrice-849e7f9f39a3cf47aab7822d7b8a0bc50f355bb7.zip
[ui] activated xtext formatting on save
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/CustomPersistencyBehavior.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomPersistencyBehavior.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomPersistencyBehavior.java
index c9c9010ed..e5b656ba2 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomPersistencyBehavior.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomPersistencyBehavior.java
@@ -15,6 +15,7 @@ package org.eclipse.etrice.ui.common.base.editor;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -34,6 +35,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.xtext.diagnostics.Severity;
+import org.eclipse.xtext.resource.SaveOptions;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.serializer.ISerializer;
import org.eclipse.xtext.util.CancelIndicator;
@@ -59,6 +61,23 @@ public class CustomPersistencyBehavior extends DefaultPersistencyBehavior {
}
@Override
+ protected Map<Resource, Map<?, ?>> createSaveOptions() {
+ // save options for xtext: activate formatting
+ SaveOptions xtextSaveOptions = SaveOptions.newBuilder().format().getOptions();
+
+ Map<Resource, Map<?, ?>> saveOptions = super.createSaveOptions();
+ for(Resource res : saveOptions.keySet()) {
+ if(res instanceof XtextResource) {
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> optionMap = (Map<Object, Object>) saveOptions.get(res);
+ xtextSaveOptions.addTo(optionMap);
+ }
+ }
+
+ return saveOptions;
+ }
+
+ @Override
public void saveDiagram(IProgressMonitor monitor) {
boolean valid = validateResourcesBeforeSave(monitor);

Back to the top