summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-03-11 13:27:50 (EDT)
committerJuergen Haug2013-03-15 07:34:16 (EDT)
commit00ab09fae0785341c2bf54f81e077030d15c5eea (patch)
treebdaa9bb8821303918aa08afd4c69826052a702c6
parent453d96b8348b21cc0ac57ec201d225764c3b0ef2 (diff)
downloadorg.eclipse.etrice-00ab09fae0785341c2bf54f81e077030d15c5eea.zip
org.eclipse.etrice-00ab09fae0785341c2bf54f81e077030d15c5eea.tar.gz
org.eclipse.etrice-00ab09fae0785341c2bf54f81e077030d15c5eea.tar.bz2
[ui] (Bug 369516) add first level elements of imported model as childrenrefs/changes/91/11191/1
of import in outline view Change-Id: I662cc573c8b387350583a13853064740123a1c6d
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineTreeProvider.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineTreeProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineTreeProvider.java
index be372de..a3494be 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineTreeProvider.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineTreeProvider.java
@@ -12,18 +12,24 @@
package org.eclipse.etrice.core.ui.outline;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorInstanceMapping;
import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.ExternalPort;
+import org.eclipse.etrice.core.room.Import;
import org.eclipse.etrice.core.room.LogicalThread;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Operation;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.PortOperation;
import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SAPRef;
import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.ServiceImplementation;
@@ -33,8 +39,10 @@ import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.ui.internal.RoomActivator;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.xtext.scoping.impl.ImportUriResolver;
import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider;
+import com.google.inject.Inject;
/**
* customization of the default outline structure
@@ -52,6 +60,8 @@ public class RoomOutlineTreeProvider extends DefaultOutlineTreeProvider {
private static final Object REG_PORT_CLASS_LABEL = "regular port class";
private static final Object CONJ_PORT_CLASS_LABEL = "conjugated port class";
+ @Inject ImportUriResolver importUriResolver;
+
protected boolean _isLeaf(ActorClass ac) {
if (ac.getIfPorts().size()>0 || ac.getIfSPPs().size()>0) {
return false;
@@ -232,6 +242,42 @@ public class RoomOutlineTreeProvider extends DefaultOutlineTreeProvider {
return true;
}
+ protected void _createChildren(IOutlineNode parentNode, Import im) {
+ String uriString = importUriResolver.resolve(im);
+
+ URI uri = URI.createURI(uriString);
+ ResourceSet rs = new ResourceSetImpl();
+ RoomModel refModel = null;
+
+ try {
+ Resource res = rs.getResource(uri, true);
+ if(res != null && !res.getContents().isEmpty() && res.getContents().get(0) instanceof RoomModel)
+ refModel = (RoomModel)res.getContents().get(0);
+ }catch (RuntimeException re) {
+ }
+
+ if(refModel != null){
+ for(EObject firstLevelElement : refModel.getActorClasses())
+ _createNode(parentNode, firstLevelElement);
+ for(EObject firstLevelElement : refModel.getDataClasses())
+ _createNode(parentNode, firstLevelElement);
+ for(EObject firstLevelElement : refModel.getExternalTypes())
+ _createNode(parentNode, firstLevelElement);
+ for(EObject firstLevelElement : refModel.getPrimitiveTypes())
+ _createNode(parentNode, firstLevelElement);
+ for(EObject firstLevelElement : refModel.getProtocolClasses())
+ _createNode(parentNode, firstLevelElement);
+ for(EObject firstLevelElement : refModel.getSubSystemClasses())
+ _createNode(parentNode, firstLevelElement);
+ for(EObject firstLevelElement : refModel.getSystems())
+ _createNode(parentNode, firstLevelElement);
+ }
+ }
+
+ protected boolean _isLeaf(Import im){
+ return false;
+ }
+
private void createExtraNode(EObject obj, IOutlineNode parent, Object text){
createEObjectNode(parent, obj, RoomActivator.getInstance().getImageRegistry().get("defaultoutlinenode.gif"), text, false);
}