Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2017-07-17 07:51:57 -0400
committerJuergen Haug2017-07-17 08:16:15 -0400
commitecc96202d41f697201ee7ba49cbf85faf74a62b9 (patch)
treecfb4273a588d8fec00ad4f7485f978c5a21beda2
parentdfef135b427a62fcb8738908b95ab4f43b5ac96c (diff)
downloadorg.eclipse.etrice-ecc96202d41f697201ee7ba49cbf85faf74a62b9.tar.gz
org.eclipse.etrice-ecc96202d41f697201ee7ba49cbf85faf74a62b9.tar.xz
org.eclipse.etrice-ecc96202d41f697201ee7ba49cbf85faf74a62b9.zip
[ui] fixed error markers after diagram creation
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/plugin.xml2
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomPersistencyBehavior.java13
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomUpdateBehavior.java3
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramEditorBase.java12
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResource.java65
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResourceFactory.java25
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java4
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/plugin.xml2
9 files changed, 103 insertions, 24 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/plugin.xml b/plugins/org.eclipse.etrice.ui.behavior/plugin.xml
index 9e79ff1bd..b8217ba65 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/plugin.xml
+++ b/plugins/org.eclipse.etrice.ui.behavior/plugin.xml
@@ -51,7 +51,7 @@
<extension
point="org.eclipse.emf.ecore.extension_parser">
<parser
- class="org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl"
+ class="org.eclipse.etrice.ui.common.base.resource.DiagramResourceFactory"
type="behavior">
</parser>
</extension>
diff --git a/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF
index 1447e447e..6abca91f9 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF
@@ -35,4 +35,5 @@ Export-Package: org.eclipse.etrice.ui.common.base,
org.eclipse.etrice.ui.common.base.editor,
org.eclipse.etrice.ui.common.base.preferences,
org.eclipse.etrice.ui.common.base.quickfix,
+ org.eclipse.etrice.ui.common.base.resource,
org.eclipse.etrice.ui.common.base.support
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 570db9648..c9c9010ed 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,7 +15,6 @@ 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;
@@ -26,7 +25,6 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.etrice.core.common.scoping.RelativeFileURIHandler;
import org.eclipse.etrice.ui.common.base.UIBaseActivator;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior;
@@ -61,17 +59,6 @@ public class CustomPersistencyBehavior extends DefaultPersistencyBehavior {
}
@Override
- protected Map<Resource, Map<?, ?>> createSaveOptions() {
- Map<Resource, Map<?, ?>> resMap = super.createSaveOptions();
-
- @SuppressWarnings("unchecked")
- Map<Object, Object> diagSaveOptions = (Map<Object, Object>) resMap.get(diagramBehavior.getDiagramTypeProvider().getDiagram().eResource());
- RelativeFileURIHandler.addToOptions(diagSaveOptions);
-
- return resMap;
- }
-
- @Override
public void saveDiagram(IProgressMonitor monitor) {
boolean valid = validateResourcesBeforeSave(monitor);
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomUpdateBehavior.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomUpdateBehavior.java
index c75872535..1502fb98f 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomUpdateBehavior.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/CustomUpdateBehavior.java
@@ -23,7 +23,6 @@ import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
import org.eclipse.emf.workspace.IWorkspaceCommandStack;
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
-import org.eclipse.etrice.core.common.scoping.RelativeFileURIHandler;
import org.eclipse.etrice.core.fsm.ui.FSMUiModule;
import org.eclipse.graphiti.ui.editor.DefaultUpdateBehavior;
import org.eclipse.graphiti.ui.editor.DiagramBehavior;
@@ -69,8 +68,6 @@ public class CustomUpdateBehavior extends DefaultUpdateBehavior {
resourceSet = new XtextResourceSet();
}
- RelativeFileURIHandler.addToOptions(resourceSet.getLoadOptions());
-
final IWorkspaceCommandStack workspaceCommandStack = new GFWorkspaceCommandStackImpl(new DefaultOperationHistory());
final TransactionalEditingDomainImpl editingDomain = new TransactionalEditingDomainImpl(new ComposedAdapterFactory(
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 8b02d6f61..1e468eedc 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
@@ -97,12 +97,16 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU
*/
@Override
public void setFocus() {
+ if (getGraphicalViewer() == null) {
+ return;
+ }
+
boolean dirtyAlready = isDirty();
// inside this call auto refresh will happen if (and turn the editor dirty)
super.setFocus();
- if (superClassListener.isChangeInSuperClass())
+ if (superClassListener != null && superClassListener.isChangeInSuperClass())
superClassChanged();
if (!dirtyAlready && isDirty())
@@ -127,8 +131,10 @@ public abstract class DiagramEditorBase extends DiagramEditor implements IInputU
public void dispose() {
mte.unsetTarget(getEditingDomain());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener(superClassListener);
- superClassListener.dispose();
+ if(superClassListener != null) {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener(superClassListener);
+ superClassListener.dispose();
+ }
super.dispose();
}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResource.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResource.java
new file mode 100644
index 000000000..2ee928879
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResource.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.base.resource;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+import org.eclipse.etrice.core.common.scoping.RelativeFileURIHandler;
+
+import com.google.common.collect.Maps;
+
+public class DiagramResource extends XMIResourceImpl {
+
+ public DiagramResource() {
+ super();
+ }
+
+ public DiagramResource(URI uri) {
+ super(uri);
+ }
+
+ @Override
+ public void load(Map<?, ?> options) throws IOException {
+ // force RelativeFileURIHandler
+ Map<Object, Object> optionsCopy = (options == null) ? getDefaultLoadOptions() : Maps.newHashMap(options);
+ super.load(RelativeFileURIHandler.addToOptions(optionsCopy));
+ }
+
+ @Override
+ public void save(Map<?, ?> options) throws IOException {
+ // force RelativeFileURIHandler
+ Map<Object, Object> optionsCopy = (options == null) ? getDefaultSaveOptions() : Maps.newHashMap(options);
+ super.save(RelativeFileURIHandler.addToOptions(optionsCopy));
+ }
+
+ @Override
+ public Map<Object, Object> getDefaultSaveOptions() {
+ if (defaultSaveOptions == null) {
+ return RelativeFileURIHandler.addToOptions(super.getDefaultLoadOptions());
+ }
+
+ return super.getDefaultSaveOptions();
+ }
+
+ @Override
+ public Map<Object, Object> getDefaultLoadOptions() {
+ if (defaultLoadOptions == null) {
+ return RelativeFileURIHandler.addToOptions(super.getDefaultLoadOptions());
+ }
+
+ return super.getDefaultLoadOptions();
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResourceFactory.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResourceFactory.java
new file mode 100644
index 000000000..36b3f09fa
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/resource/DiagramResourceFactory.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * juergen.haug@protos.de (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.base.resource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+public class DiagramResourceFactory extends XMIResourceFactoryImpl {
+
+ @Override
+ public Resource createResource(URI uri) {
+ return new DiagramResource(uri);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
index 0cbde7990..22c5831ab 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
@@ -30,7 +30,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.etrice.core.common.scoping.RelativeFileURIHandler;
import org.eclipse.etrice.core.common.ui.linking.GlobalNonPlatformURIEditorOpener;
import org.eclipse.etrice.ui.common.base.UIBaseActivator;
import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;
@@ -46,7 +45,6 @@ import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
-import com.google.common.collect.Maps;
import com.google.inject.Inject;
/**
@@ -134,7 +132,7 @@ public abstract class DiagramAccessBase {
populateDiagram(rootObject, diagram);
try {
- diagRes.save(RelativeFileURIHandler.addToOptions(Maps.newHashMap()));
+ diagRes.save(null);
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/plugin.xml b/plugins/org.eclipse.etrice.ui.structure/plugin.xml
index 261e788a8..6421078d3 100644
--- a/plugins/org.eclipse.etrice.ui.structure/plugin.xml
+++ b/plugins/org.eclipse.etrice.ui.structure/plugin.xml
@@ -51,7 +51,7 @@
<extension
point="org.eclipse.emf.ecore.extension_parser">
<parser
- class="org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl"
+ class="org.eclipse.etrice.ui.common.base.resource.DiagramResourceFactory"
type="structure">
</parser>
</extension>

Back to the top