diff options
69 files changed, 3557 insertions, 2681 deletions
diff --git a/modellib/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF b/modellib/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF index 1052970a0..199a9d8ea 100644 --- a/modellib/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF +++ b/modellib/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: eTrice Model Library -Bundle-SymbolicName: org.eclipse.etrice.modellib -Bundle-Version: 0.1.0 -Bundle-Vendor: eTrice (Incubation) +Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eTrice Model Library
+Bundle-SymbolicName: org.eclipse.etrice.modellib
+Bundle-Version: 0.1.0
+Bundle-Vendor: eTrice (Incubation)
diff --git a/plugins/org.eclipse.etrice.core.room.ui/.gitignore b/plugins/org.eclipse.etrice.core.room.ui/.gitignore index ba077a403..092357e47 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/.gitignore +++ b/plugins/org.eclipse.etrice.core.room.ui/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/plugins/org.eclipse.etrice.core.room.ui/build.properties b/plugins/org.eclipse.etrice.core.room.ui/build.properties index a0c7d1504..2ec6ec11e 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/build.properties +++ b/plugins/org.eclipse.etrice.core.room.ui/build.properties @@ -1,6 +1,6 @@ -source.. = src/,src-gen/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - icons/ - +source.. = src/,src-gen/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
+
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomUiModule.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomUiModule.java index 68da579fc..94086de72 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomUiModule.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomUiModule.java @@ -1,29 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui; - -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * Use this class to register components to be used within the IDE. - */ -public class RoomUiModule extends org.eclipse.etrice.core.ui.AbstractRoomUiModule { - public RoomUiModule(AbstractUIPlugin plugin) { - super(plugin); - } - - // contributed by org.eclipse.xtext.generator.validation.JavaValidatorFragment - @org.eclipse.xtext.service.SingletonBinding(eager=true) public Class<? extends org.eclipse.etrice.core.validation.RoomJavaValidator> bindRoomJavaValidator() { - return org.eclipse.etrice.core.ui.RoomModelValidator.class; - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class RoomUiModule extends org.eclipse.etrice.core.ui.AbstractRoomUiModule {
+ public RoomUiModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+
+ // contributed by org.eclipse.xtext.generator.validation.JavaValidatorFragment
+ @org.eclipse.xtext.service.SingletonBinding(eager=true) public Class<? extends org.eclipse.etrice.core.validation.RoomJavaValidator> bindRoomJavaValidator() {
+ return org.eclipse.etrice.core.ui.RoomModelValidator.class;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java index 1982c4b69..e8dc61237 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java @@ -1,110 +1,110 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui.contentassist; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.ui.contentassist.AbstractRoomProposalProvider; -import org.eclipse.etrice.core.validation.ValidationUtil; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.viewers.StyledString; -import org.eclipse.swt.graphics.Image; -import org.eclipse.xtext.resource.IEObjectDescription; -import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext; - -import com.google.common.base.Function; - -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.RoomPackage; -/** - * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#contentAssist on how to customize content assistant - */ -public class RoomProposalProvider extends AbstractRoomProposalProvider { - - protected class FilteredProposalCreator implements Function<IEObjectDescription, ICompletionProposal> { - private IProposalFilter filter; - private final ContentAssistContext contentAssistContext; - private final String ruleName; - - protected FilteredProposalCreator(IProposalFilter filter, ContentAssistContext contentAssistContext, String ruleName) { - this.filter = filter; - this.contentAssistContext = contentAssistContext; - this.ruleName = ruleName; - } - - public ICompletionProposal apply(IEObjectDescription candidate) { - if (candidate == null) - return null; - ICompletionProposal result = null; - String proposal = candidate.getName(); - if (ruleName != null) - proposal = getValueConverter().toString(proposal, ruleName); - EObject objectOrProxy = candidate.getEObjectOrProxy(); - - // three new lines in code taken from org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.DefaultProposalCreator - if (!objectOrProxy.eIsProxy() && filter!=null) - if (!filter.accept(contentAssistContext, candidate)) - return null; - - StyledString displayString = getStyledDisplayString(objectOrProxy, candidate.getQualifiedName(), candidate.getName()); - Image image = getImage(objectOrProxy); - result = createCompletionProposal(proposal, displayString, image, contentAssistContext); - getPriorityHelper().adjustCrossReferencePriority(result, contentAssistContext.getPrefix()); - return result; - } - - } - - protected class ActorRefFilter implements IProposalFilter { - - @Override - public boolean accept(ContentAssistContext context, IEObjectDescription candidate) { - if (!(context.getCurrentModel() instanceof ActorRef)) - // unexpected call?? - return false; - - ActorRef ar = (ActorRef) context.getCurrentModel(); - if (!(ar.eContainer() instanceof ActorClass)) - // can not filter due to lack of information - return true; - - ActorClass ac = (ActorClass) ar.eContainer(); - - EObject objectOrProxy = candidate.getEObjectOrProxy(); - - if (objectOrProxy instanceof ActorClass) { - ActorClass referenced = (ActorClass) objectOrProxy; - return !ValidationUtil.isReferencing(referenced, ac); - } - - return false; - } - - } - - protected Function<IEObjectDescription, ICompletionProposal> getProposalFactory(String ruleName, ContentAssistContext contentAssistContext) { - if (contentAssistContext!=null && contentAssistContext.getCurrentModel().eClass()==RoomPackage.eINSTANCE.getActorRef()) - return new FilteredProposalCreator(new ActorRefFilter(), contentAssistContext, ruleName); - - // delegate to default - return super.getProposalFactory(ruleName, contentAssistContext); - } - -// public void completeActorRef_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { -// super.completeActorRef_Type( -// model, -// assignment, -// context, -// acceptor); -// } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui.contentassist;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.ui.contentassist.AbstractRoomProposalProvider;
+import org.eclipse.etrice.core.validation.ValidationUtil;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
+
+import com.google.common.base.Function;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.RoomPackage;
+/**
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#contentAssist on how to customize content assistant
+ */
+public class RoomProposalProvider extends AbstractRoomProposalProvider {
+
+ protected class FilteredProposalCreator implements Function<IEObjectDescription, ICompletionProposal> {
+ private IProposalFilter filter;
+ private final ContentAssistContext contentAssistContext;
+ private final String ruleName;
+
+ protected FilteredProposalCreator(IProposalFilter filter, ContentAssistContext contentAssistContext, String ruleName) {
+ this.filter = filter;
+ this.contentAssistContext = contentAssistContext;
+ this.ruleName = ruleName;
+ }
+
+ public ICompletionProposal apply(IEObjectDescription candidate) {
+ if (candidate == null)
+ return null;
+ ICompletionProposal result = null;
+ String proposal = candidate.getName();
+ if (ruleName != null)
+ proposal = getValueConverter().toString(proposal, ruleName);
+ EObject objectOrProxy = candidate.getEObjectOrProxy();
+
+ // three new lines in code taken from org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.DefaultProposalCreator
+ if (!objectOrProxy.eIsProxy() && filter!=null)
+ if (!filter.accept(contentAssistContext, candidate))
+ return null;
+
+ StyledString displayString = getStyledDisplayString(objectOrProxy, candidate.getQualifiedName(), candidate.getName());
+ Image image = getImage(objectOrProxy);
+ result = createCompletionProposal(proposal, displayString, image, contentAssistContext);
+ getPriorityHelper().adjustCrossReferencePriority(result, contentAssistContext.getPrefix());
+ return result;
+ }
+
+ }
+
+ protected class ActorRefFilter implements IProposalFilter {
+
+ @Override
+ public boolean accept(ContentAssistContext context, IEObjectDescription candidate) {
+ if (!(context.getCurrentModel() instanceof ActorRef))
+ // unexpected call??
+ return false;
+
+ ActorRef ar = (ActorRef) context.getCurrentModel();
+ if (!(ar.eContainer() instanceof ActorClass))
+ // can not filter due to lack of information
+ return true;
+
+ ActorClass ac = (ActorClass) ar.eContainer();
+
+ EObject objectOrProxy = candidate.getEObjectOrProxy();
+
+ if (objectOrProxy instanceof ActorClass) {
+ ActorClass referenced = (ActorClass) objectOrProxy;
+ return !ValidationUtil.isReferencing(referenced, ac);
+ }
+
+ return false;
+ }
+
+ }
+
+ protected Function<IEObjectDescription, ICompletionProposal> getProposalFactory(String ruleName, ContentAssistContext contentAssistContext) {
+ if (contentAssistContext!=null && contentAssistContext.getCurrentModel().eClass()==RoomPackage.eINSTANCE.getActorRef())
+ return new FilteredProposalCreator(new ActorRefFilter(), contentAssistContext, ruleName);
+
+ // delegate to default
+ return super.getProposalFactory(ruleName, contentAssistContext);
+ }
+
+// public void completeActorRef_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+// super.completeActorRef_Type(
+// model,
+// assignment,
+// context,
+// acceptor);
+// }
+}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomDescriptionLabelProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomDescriptionLabelProvider.java index 50479b063..f73106cfc 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomDescriptionLabelProvider.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomDescriptionLabelProvider.java @@ -1,36 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui.labeling; - -import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider; - -/** - * Provides labels for a IEObjectDescriptions and IResourceDescriptions. - * - * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider - */ -public class RoomDescriptionLabelProvider extends DefaultDescriptionLabelProvider { - -/* - //Labels and icons can be computed like this: - - String text(IEObjectDescription ele) { - return "my "+ele.getName(); - } - - String image(IEObjectDescription ele) { - return ele.getEClass().getName() + ".gif"; - } -*/ - -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui.labeling;
+
+import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider;
+
+/**
+ * Provides labels for a IEObjectDescriptions and IResourceDescriptions.
+ *
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
+ */
+public class RoomDescriptionLabelProvider extends DefaultDescriptionLabelProvider {
+
+/*
+ //Labels and icons can be computed like this:
+
+ String text(IEObjectDescription ele) {
+ return "my "+ele.getName();
+ }
+
+ String image(IEObjectDescription ele) {
+ return ele.getEClass().getName() + ".gif";
+ }
+*/
+
+}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomLabelProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomLabelProvider.java index f36cc0add..51c17a8b9 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomLabelProvider.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/labeling/RoomLabelProvider.java @@ -1,303 +1,303 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui.labeling; - -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider; - -import com.google.inject.Inject; - -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.Attribute; -import org.eclipse.etrice.core.room.BaseState; -import org.eclipse.etrice.core.room.Import; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.core.room.SubSystemRef; -import org.eclipse.etrice.core.room.LogicalSystem; -import org.eclipse.etrice.core.room.DataClass; -import org.eclipse.etrice.core.room.ExternalPort; -import org.eclipse.etrice.core.room.FreeType; -import org.eclipse.etrice.core.room.FreeTypedID; -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.ProtocolClass; -import org.eclipse.etrice.core.room.RefinedState; -import org.eclipse.etrice.core.room.SAPRef; -import org.eclipse.etrice.core.room.SPPRef; -import org.eclipse.etrice.core.room.ServiceImplementation; -import org.eclipse.etrice.core.room.Type; -import org.eclipse.etrice.core.room.TypedID; - -/** - * Provides labels for a EObjects. - * - * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider - */ -public class RoomLabelProvider extends DefaultEObjectLabelProvider { - - @Inject - public RoomLabelProvider(AdapterFactoryLabelProvider delegate) { - super(delegate); - } - - // custom images for ROOM classes - - String image(RoomModel rm) { - return "RoomModel.gif"; - } - - String image(Import im) { - return "RoomModelImport.gif"; - } - - String image(DataClass dc) { - return "DataClass.gif"; - } - - String image(ProtocolClass pc) { - return "ProtocolClass.gif"; - } - - String image(ActorClass ac) { - return "ActorClass.gif"; - } - - String image(SubSystemClass cc) { - return "SubSystemClass.gif"; - } - - String image(LogicalSystem sys) { - return "LogicalSystem.gif"; - } - - String image(SAPRef sap) { - return "SAP.gif"; - } - - String image(SPPRef spp) { - return "SPP.gif"; - } - - String image(ActorRef ar) { - return "ActorRef.gif"; - } - - String image(SubSystemRef ar) { - return "SubSystemRef.gif"; - } - - String image(BaseState state) { - return "State.gif"; - } - - String image(RefinedState state) { - return "RefinedState.gif"; - } - - String image(ServiceImplementation svc) { - return "ServiceImpl.gif"; - } - - String image(Message state) { - return "Message.gif"; - } - - String image(Operation op) { - return "Operation.gif"; - } - - String image(Port p) { - ActorClass ac = (ActorClass) p.eContainer(); - boolean relay = true; - if (ac.getIntPorts().contains(p)) { - relay = false; - } - else { - for (ExternalPort ep : ac.getExtPorts()) { - if (ep.getIfport()==p) { - relay = false; - break; - } - } - } - if (relay) - if (p.isConjugated()) - if (p.getMultiplicity()>1) - return "ConjReplRelayPort.gif"; - else - return "ConjRelayPort.gif"; - else - if (p.getMultiplicity()>1) - return "ReplRelayPort.gif"; - else - return "RelayPort.gif"; - else - if (p.isConjugated()) - if (p.getMultiplicity()>1) - return "ConjReplPort.gif"; - else - return "ConjPort.gif"; - else - if (p.getMultiplicity()>1) - return "ReplPort.gif"; - else - return "Port.gif"; - } - - // custom labels - - String text(Import im) { - return "import "+im.getImportedNamespace(); - } - - String text(DataClass dc) { - String base = dc.getBase()!=null? " extends "+dc.getBase().getName():""; - return dc.getName()+base; - } - - String text(ProtocolClass pc) { - String base = pc.getBase()!=null? " extends "+pc.getBase().getName():""; - return pc.getName()+base; - } - - String text(ActorClass ac) { - String base = ac.getBase()!=null? " extends "+ac.getBase().getName():""; - return ac.getName()+base; - } - - String text(Port p) { - String location = null; - ActorClass ac = (ActorClass) p.eContainer(); - if (ac.getIntPorts().contains(p)) - location = "internal"; - else { - for (ExternalPort ep : ac.getExtPorts()) { - if (ep.getIfport()==p) { - location = "external"; - break; - } - } - } - if (location==null) - location = "relay"; - String conjugated = p.isConjugated()?"conjugated ":""; - String multiplicity = p.getMultiplicity()>1? ("["+p.getMultiplicity()+"]"):""; - String protocol = p.getProtocol()!=null? (" : "+p.getProtocol().getName()):""; - return conjugated+" "+location+" Port "+p.getName()+multiplicity+protocol; - } - - String text(ExternalPort ep) { - return text(ep.getIfport()); - } - - String text(SAPRef sap) { - String protocol = sap.getProtocol()!=null? (" : "+sap.getProtocol().getName()):""; - return "SAP "+sap.getName()+protocol; - } - - String text(SPPRef spp) { - String protocol = spp.getProtocol()!=null? (" : "+spp.getProtocol().getName()):""; - return "SPP "+spp.getName()+protocol; - } - - String text(ServiceImplementation svc) { - if (svc.getSpp()==null) - return "Implementation"; - - String protocol = svc.getSpp().getProtocol()!=null? (" : "+svc.getSpp().getProtocol().getName()):""; - return "Implementation of "+svc.getSpp().getName()+protocol; - } - - String text(ActorRef ref) { - String cls = ref.getType()!=null? (" : "+ref.getType().getName()):""; - return "ref "+ref.getName()+cls; - } - - String text(SubSystemRef ref) { - String cls = ref.getType()!=null? (" : "+ref.getType().getName()):""; - return "ref "+ref.getName()+cls; - } - - private String getName(Type tp) { - if (tp.getType()!=null) - return tp.getType().getName(); - else if (tp.getPrim()!=null) - return tp.getPrim().getName(); - else - return "?"; - } - - private String getName(FreeType tp) { - if (tp.getType()!=null) - return tp.getType(); - else if (tp.getPrim()!=null) - return tp.getPrim().getName(); - else - return "?"; - } - - String text(Attribute attr) { - String type = attr.getType()!=null? (" : "+getName(attr.getType())):""; - return "Attr "+attr.getName()+type; - } - - String text(Operation op) { - String rt = op.getReturntype()!=null? ": "+getName(op.getReturntype()):""; - String signature = ""; - for (FreeTypedID arg : op.getArguments()) { - if (signature.isEmpty()) - signature = arg.getName()+": "+getName(arg.getType()); - else - signature += ", "+arg.getName()+": "+getName(arg.getType()); - } - signature = "("+signature+")"; - return op.getName()+signature+rt; - } - - String text(Message m) { - String signature = ""; - for (TypedID arg : m.getArguments()) { - if (signature.isEmpty()) - signature = arg.getName()+":"+getName(arg.getType()); - else - signature += ","+arg.getName()+":"+getName(arg.getType()); - } - signature = "("+signature+")"; - return m.getName()+signature; - } - - String text(BaseState s) { - return s.getName(); - } - - String text(RefinedState rs) { - if (rs.getBase()!=null) - return text(rs.getBase()); - - return ""; - } -/* - //Labels and icons can be computed like this: - - String text(MyModel ele) { - return "my "+ele.getName(); - } - - String image(MyModel ele) { - return "MyModel.gif"; - } -*/ -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui.labeling;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
+
+import com.google.inject.Inject;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.BaseState;
+import org.eclipse.etrice.core.room.Import;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.SubSystemRef;
+import org.eclipse.etrice.core.room.LogicalSystem;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.ExternalPort;
+import org.eclipse.etrice.core.room.FreeType;
+import org.eclipse.etrice.core.room.FreeTypedID;
+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.ProtocolClass;
+import org.eclipse.etrice.core.room.RefinedState;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.Type;
+import org.eclipse.etrice.core.room.TypedID;
+
+/**
+ * Provides labels for a EObjects.
+ *
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
+ */
+public class RoomLabelProvider extends DefaultEObjectLabelProvider {
+
+ @Inject
+ public RoomLabelProvider(AdapterFactoryLabelProvider delegate) {
+ super(delegate);
+ }
+
+ // custom images for ROOM classes
+
+ String image(RoomModel rm) {
+ return "RoomModel.gif";
+ }
+
+ String image(Import im) {
+ return "RoomModelImport.gif";
+ }
+
+ String image(DataClass dc) {
+ return "DataClass.gif";
+ }
+
+ String image(ProtocolClass pc) {
+ return "ProtocolClass.gif";
+ }
+
+ String image(ActorClass ac) {
+ return "ActorClass.gif";
+ }
+
+ String image(SubSystemClass cc) {
+ return "SubSystemClass.gif";
+ }
+
+ String image(LogicalSystem sys) {
+ return "LogicalSystem.gif";
+ }
+
+ String image(SAPRef sap) {
+ return "SAP.gif";
+ }
+
+ String image(SPPRef spp) {
+ return "SPP.gif";
+ }
+
+ String image(ActorRef ar) {
+ return "ActorRef.gif";
+ }
+
+ String image(SubSystemRef ar) {
+ return "SubSystemRef.gif";
+ }
+
+ String image(BaseState state) {
+ return "State.gif";
+ }
+
+ String image(RefinedState state) {
+ return "RefinedState.gif";
+ }
+
+ String image(ServiceImplementation svc) {
+ return "ServiceImpl.gif";
+ }
+
+ String image(Message state) {
+ return "Message.gif";
+ }
+
+ String image(Operation op) {
+ return "Operation.gif";
+ }
+
+ String image(Port p) {
+ ActorClass ac = (ActorClass) p.eContainer();
+ boolean relay = true;
+ if (ac.getIntPorts().contains(p)) {
+ relay = false;
+ }
+ else {
+ for (ExternalPort ep : ac.getExtPorts()) {
+ if (ep.getIfport()==p) {
+ relay = false;
+ break;
+ }
+ }
+ }
+ if (relay)
+ if (p.isConjugated())
+ if (p.getMultiplicity()>1)
+ return "ConjReplRelayPort.gif";
+ else
+ return "ConjRelayPort.gif";
+ else
+ if (p.getMultiplicity()>1)
+ return "ReplRelayPort.gif";
+ else
+ return "RelayPort.gif";
+ else
+ if (p.isConjugated())
+ if (p.getMultiplicity()>1)
+ return "ConjReplPort.gif";
+ else
+ return "ConjPort.gif";
+ else
+ if (p.getMultiplicity()>1)
+ return "ReplPort.gif";
+ else
+ return "Port.gif";
+ }
+
+ // custom labels
+
+ String text(Import im) {
+ return "import "+im.getImportedNamespace();
+ }
+
+ String text(DataClass dc) {
+ String base = dc.getBase()!=null? " extends "+dc.getBase().getName():"";
+ return dc.getName()+base;
+ }
+
+ String text(ProtocolClass pc) {
+ String base = pc.getBase()!=null? " extends "+pc.getBase().getName():"";
+ return pc.getName()+base;
+ }
+
+ String text(ActorClass ac) {
+ String base = ac.getBase()!=null? " extends "+ac.getBase().getName():"";
+ return ac.getName()+base;
+ }
+
+ String text(Port p) {
+ String location = null;
+ ActorClass ac = (ActorClass) p.eContainer();
+ if (ac.getIntPorts().contains(p))
+ location = "internal";
+ else {
+ for (ExternalPort ep : ac.getExtPorts()) {
+ if (ep.getIfport()==p) {
+ location = "external";
+ break;
+ }
+ }
+ }
+ if (location==null)
+ location = "relay";
+ String conjugated = p.isConjugated()?"conjugated ":"";
+ String multiplicity = p.getMultiplicity()>1? ("["+p.getMultiplicity()+"]"):"";
+ String protocol = p.getProtocol()!=null? (" : "+p.getProtocol().getName()):"";
+ return conjugated+" "+location+" Port "+p.getName()+multiplicity+protocol;
+ }
+
+ String text(ExternalPort ep) {
+ return text(ep.getIfport());
+ }
+
+ String text(SAPRef sap) {
+ String protocol = sap.getProtocol()!=null? (" : "+sap.getProtocol().getName()):"";
+ return "SAP "+sap.getName()+protocol;
+ }
+
+ String text(SPPRef spp) {
+ String protocol = spp.getProtocol()!=null? (" : "+spp.getProtocol().getName()):"";
+ return "SPP "+spp.getName()+protocol;
+ }
+
+ String text(ServiceImplementation svc) {
+ if (svc.getSpp()==null)
+ return "Implementation";
+
+ String protocol = svc.getSpp().getProtocol()!=null? (" : "+svc.getSpp().getProtocol().getName()):"";
+ return "Implementation of "+svc.getSpp().getName()+protocol;
+ }
+
+ String text(ActorRef ref) {
+ String cls = ref.getType()!=null? (" : "+ref.getType().getName()):"";
+ return "ref "+ref.getName()+cls;
+ }
+
+ String text(SubSystemRef ref) {
+ String cls = ref.getType()!=null? (" : "+ref.getType().getName()):"";
+ return "ref "+ref.getName()+cls;
+ }
+
+ private String getName(Type tp) {
+ if (tp.getType()!=null)
+ return tp.getType().getName();
+ else if (tp.getPrim()!=null)
+ return tp.getPrim().getName();
+ else
+ return "?";
+ }
+
+ private String getName(FreeType tp) {
+ if (tp.getType()!=null)
+ return tp.getType();
+ else if (tp.getPrim()!=null)
+ return tp.getPrim().getName();
+ else
+ return "?";
+ }
+
+ String text(Attribute attr) {
+ String type = attr.getType()!=null? (" : "+getName(attr.getType())):"";
+ return "Attr "+attr.getName()+type;
+ }
+
+ String text(Operation op) {
+ String rt = op.getReturntype()!=null? ": "+getName(op.getReturntype()):"";
+ String signature = "";
+ for (FreeTypedID arg : op.getArguments()) {
+ if (signature.isEmpty())
+ signature = arg.getName()+": "+getName(arg.getType());
+ else
+ signature += ", "+arg.getName()+": "+getName(arg.getType());
+ }
+ signature = "("+signature+")";
+ return op.getName()+signature+rt;
+ }
+
+ String text(Message m) {
+ String signature = "";
+ for (TypedID arg : m.getArguments()) {
+ if (signature.isEmpty())
+ signature = arg.getName()+":"+getName(arg.getType());
+ else
+ signature += ","+arg.getName()+":"+getName(arg.getType());
+ }
+ signature = "("+signature+")";
+ return m.getName()+signature;
+ }
+
+ String text(BaseState s) {
+ return s.getName();
+ }
+
+ String text(RefinedState rs) {
+ if (rs.getBase()!=null)
+ return text(rs.getBase());
+
+ return "";
+ }
+/*
+ //Labels and icons can be computed like this:
+
+ String text(MyModel ele) {
+ return "my "+ele.getName();
+ }
+
+ String image(MyModel ele) {
+ return "MyModel.gif";
+ }
+*/
+}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineNodeAdapterFactory.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineNodeAdapterFactory.java index 807f0c17a..41e9611a6 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineNodeAdapterFactory.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomOutlineNodeAdapterFactory.java @@ -1,38 +1,38 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui.outline; - -import org.eclipse.xtext.ui.editor.outline.actions.DefaultContentOutlineNodeAdapterFactory; - -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.core.room.LogicalSystem; - -public class RoomOutlineNodeAdapterFactory extends DefaultContentOutlineNodeAdapterFactory { - - private static final Class<?>[] types = { - // provide list of classes to adapt to, e.g.: - // Entity.class - // Service.class - ActorClass.class, - SubSystemClass.class, - LogicalSystem.class - }; - - @Override - public Class<?>[] getAdapterList() { - return types; - } - -} - +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui.outline;
+
+import org.eclipse.xtext.ui.editor.outline.actions.DefaultContentOutlineNodeAdapterFactory;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.LogicalSystem;
+
+public class RoomOutlineNodeAdapterFactory extends DefaultContentOutlineNodeAdapterFactory {
+
+ private static final Class<?>[] types = {
+ // provide list of classes to adapt to, e.g.:
+ // Entity.class
+ // Service.class
+ ActorClass.class,
+ SubSystemClass.class,
+ LogicalSystem.class
+ };
+
+ @Override
+ public Class<?>[] getAdapterList() {
+ return types;
+ }
+
+}
+
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomTransformer.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomTransformer.java index bb301453d..9482fdd94 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomTransformer.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/RoomTransformer.java @@ -1,159 +1,159 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui.outline; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.xtext.ui.editor.outline.ContentOutlineNode; -import org.eclipse.xtext.ui.editor.outline.transformer.AbstractDeclarativeSemanticModelTransformer; - -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.Attribute; -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.ProtocolClass; -import org.eclipse.etrice.core.room.SAPRef; -import org.eclipse.etrice.core.room.SPPRef; -import org.eclipse.etrice.core.room.ServiceImplementation; -import org.eclipse.etrice.core.room.State; - -/** - * customization of the default outline structure - * - */ -public class RoomTransformer extends AbstractDeclarativeSemanticModelTransformer { - // cf. org.eclipse.xtext.example.ui.outline.FowlerDslTransformer - - // transform actor class - - public boolean consumeNode(ActorClass ac) { - return true; - } - - public ContentOutlineNode createNode(ActorClass ac, ContentOutlineNode outlineParentNode) { - ContentOutlineNode result = super.createNode(ac, outlineParentNode); - if (ac.getIfPorts().size()>0 || ac.getIfSPPs().size()>0) { - ContentOutlineNode iface = new ContentOutlineNode("Interface"); - result.getChildren().add(iface); - for (Port port : ac.getIfPorts()) - transformSemanticNode(port, iface); - for (SPPRef spp : ac.getIfSPPs()) - transformSemanticNode(spp, iface); - } - if (ac.getIntPorts().size()>0 || ac.getServiceImplementations().size()>0 || - ac.getStrSAPs().size()>0 || ac.getAttributes().size()>0 || - ac.getActorRefs().size()>0) { - ContentOutlineNode structure = new ContentOutlineNode("Structure"); - result.getChildren().add(structure); - for (Port port : ac.getIntPorts()) - transformSemanticNode(port, structure); - for (ServiceImplementation svc : ac.getServiceImplementations()) - transformSemanticNode(svc, structure); - for (SAPRef sap : ac.getStrSAPs()) - transformSemanticNode(sap, structure); - for (Attribute attr : ac.getAttributes()) - transformSemanticNode(attr, structure); - for (ActorRef ar : ac.getActorRefs()) - transformSemanticNode(ar, structure); - } - if (ac.getOperations().size()>0 || ac.getStateMachine()!=null) { - ContentOutlineNode behavior = new ContentOutlineNode("Behavior"); - result.getChildren().add(behavior); - for (Operation op : ac.getOperations()) - transformSemanticNode(op, behavior); - if (ac.getStateMachine()!=null) { - ContentOutlineNode sm = new ContentOutlineNode("StateMachine"); - behavior.getChildren().add(sm); - for (State s : ac.getStateMachine().getStates()) { - transformSemanticNode(s, sm); - } - } - } - return result; - } - - public List<EObject> getChildren(ActorClass ac) { - return Collections.emptyList(); - } - - // transform state - - public boolean consumeNode(State state) { - return true; - } - - public ContentOutlineNode createNode(State state, ContentOutlineNode outlineParentNode) { - ContentOutlineNode result = super.createNode(state, outlineParentNode); - - if (state.getSubgraph()!=null) - for (State s : state.getSubgraph().getStates()) { - transformSemanticNode(s, result); - } - - return result; - } - - public List<EObject> getChildren(State state) { - return Collections.emptyList(); - } - - // transform protocol - - public boolean consumeNode(ProtocolClass pc) { - return true; - } - - public ContentOutlineNode createNode(ProtocolClass pc, ContentOutlineNode outlineParentNode) { - ContentOutlineNode result = super.createNode(pc, outlineParentNode); - - if (pc.getIncomingMessages().size()>0) { - ContentOutlineNode msgs = new ContentOutlineNode("incoming"); - result.getChildren().add(msgs); - for (Message m : pc.getIncomingMessages()) - transformSemanticNode(m, msgs); - } - - if (pc.getOutgoingMessages().size()>0) { - ContentOutlineNode msgs = new ContentOutlineNode("outgoing"); - result.getChildren().add(msgs); - for (Message m : pc.getOutgoingMessages()) - transformSemanticNode(m, msgs); - } - - return result; - } - - public List<EObject> getChildren(ProtocolClass pc) { - return Collections.emptyList(); - } - - public boolean consumeNode(Message m) { - return true; - } - - public List<EObject> getChildren(Message m) { - return Collections.emptyList(); - } - - public boolean consumeNode(Operation op) { - return true; - } - - public List<EObject> getChildren(Operation op) { - return Collections.emptyList(); - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui.outline;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.ui.editor.outline.ContentOutlineNode;
+import org.eclipse.xtext.ui.editor.outline.transformer.AbstractDeclarativeSemanticModelTransformer;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.Attribute;
+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.ProtocolClass;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.State;
+
+/**
+ * customization of the default outline structure
+ *
+ */
+public class RoomTransformer extends AbstractDeclarativeSemanticModelTransformer {
+ // cf. org.eclipse.xtext.example.ui.outline.FowlerDslTransformer
+
+ // transform actor class
+
+ public boolean consumeNode(ActorClass ac) {
+ return true;
+ }
+
+ public ContentOutlineNode createNode(ActorClass ac, ContentOutlineNode outlineParentNode) {
+ ContentOutlineNode result = super.createNode(ac, outlineParentNode);
+ if (ac.getIfPorts().size()>0 || ac.getIfSPPs().size()>0) {
+ ContentOutlineNode iface = new ContentOutlineNode("Interface");
+ result.getChildren().add(iface);
+ for (Port port : ac.getIfPorts())
+ transformSemanticNode(port, iface);
+ for (SPPRef spp : ac.getIfSPPs())
+ transformSemanticNode(spp, iface);
+ }
+ if (ac.getIntPorts().size()>0 || ac.getServiceImplementations().size()>0 ||
+ ac.getStrSAPs().size()>0 || ac.getAttributes().size()>0 ||
+ ac.getActorRefs().size()>0) {
+ ContentOutlineNode structure = new ContentOutlineNode("Structure");
+ result.getChildren().add(structure);
+ for (Port port : ac.getIntPorts())
+ transformSemanticNode(port, structure);
+ for (ServiceImplementation svc : ac.getServiceImplementations())
+ transformSemanticNode(svc, structure);
+ for (SAPRef sap : ac.getStrSAPs())
+ transformSemanticNode(sap, structure);
+ for (Attribute attr : ac.getAttributes())
+ transformSemanticNode(attr, structure);
+ for (ActorRef ar : ac.getActorRefs())
+ transformSemanticNode(ar, structure);
+ }
+ if (ac.getOperations().size()>0 || ac.getStateMachine()!=null) {
+ ContentOutlineNode behavior = new ContentOutlineNode("Behavior");
+ result.getChildren().add(behavior);
+ for (Operation op : ac.getOperations())
+ transformSemanticNode(op, behavior);
+ if (ac.getStateMachine()!=null) {
+ ContentOutlineNode sm = new ContentOutlineNode("StateMachine");
+ behavior.getChildren().add(sm);
+ for (State s : ac.getStateMachine().getStates()) {
+ transformSemanticNode(s, sm);
+ }
+ }
+ }
+ return result;
+ }
+
+ public List<EObject> getChildren(ActorClass ac) {
+ return Collections.emptyList();
+ }
+
+ // transform state
+
+ public boolean consumeNode(State state) {
+ return true;
+ }
+
+ public ContentOutlineNode createNode(State state, ContentOutlineNode outlineParentNode) {
+ ContentOutlineNode result = super.createNode(state, outlineParentNode);
+
+ if (state.getSubgraph()!=null)
+ for (State s : state.getSubgraph().getStates()) {
+ transformSemanticNode(s, result);
+ }
+
+ return result;
+ }
+
+ public List<EObject> getChildren(State state) {
+ return Collections.emptyList();
+ }
+
+ // transform protocol
+
+ public boolean consumeNode(ProtocolClass pc) {
+ return true;
+ }
+
+ public ContentOutlineNode createNode(ProtocolClass pc, ContentOutlineNode outlineParentNode) {
+ ContentOutlineNode result = super.createNode(pc, outlineParentNode);
+
+ if (pc.getIncomingMessages().size()>0) {
+ ContentOutlineNode msgs = new ContentOutlineNode("incoming");
+ result.getChildren().add(msgs);
+ for (Message m : pc.getIncomingMessages())
+ transformSemanticNode(m, msgs);
+ }
+
+ if (pc.getOutgoingMessages().size()>0) {
+ ContentOutlineNode msgs = new ContentOutlineNode("outgoing");
+ result.getChildren().add(msgs);
+ for (Message m : pc.getOutgoingMessages())
+ transformSemanticNode(m, msgs);
+ }
+
+ return result;
+ }
+
+ public List<EObject> getChildren(ProtocolClass pc) {
+ return Collections.emptyList();
+ }
+
+ public boolean consumeNode(Message m) {
+ return true;
+ }
+
+ public List<EObject> getChildren(Message m) {
+ return Collections.emptyList();
+ }
+
+ public boolean consumeNode(Operation op) {
+ return true;
+ }
+
+ public List<EObject> getChildren(Operation op) {
+ return Collections.emptyList();
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java index 5cc555bbb..c52b11d6d 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java +++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java @@ -1,30 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.ui.quickfix; - -import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider; - -public class RoomQuickfixProvider extends DefaultQuickfixProvider { - -// @Fix(MyJavaValidator.INVALID_TYPE_NAME) -// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) { -// acceptor.accept(issue, "Capitalize name", "Capitalize name of type", "upcase.png", new IModification() { -// public void apply(IModificationContext context) throws BadLocationException { -// IXtextDocument xtextDocument = context.getXtextDocument(); -// String firstLetter = xtextDocument.get(issue.getOffset(), 1); -// xtextDocument.replace(issue.getOffset(), 1, Strings.toFirstUpper(firstLetter)); -// } -// }); -// } - -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.ui.quickfix;
+
+import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider;
+
+public class RoomQuickfixProvider extends DefaultQuickfixProvider {
+
+// @Fix(MyJavaValidator.INVALID_TYPE_NAME)
+// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {
+// acceptor.accept(issue, "Capitalize name", "Capitalize name of type", "upcase.png", new IModification() {
+// public void apply(IModificationContext context) throws BadLocationException {
+// IXtextDocument xtextDocument = context.getXtextDocument();
+// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
+// xtextDocument.replace(issue.getOffset(), 1, Strings.toFirstUpper(firstLetter));
+// }
+// });
+// }
+
+}
diff --git a/plugins/org.eclipse.etrice.core.room/.gitignore b/plugins/org.eclipse.etrice.core.room/.gitignore index ba077a403..092357e47 100644 --- a/plugins/org.eclipse.etrice.core.room/.gitignore +++ b/plugins/org.eclipse.etrice.core.room/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/plugins/org.eclipse.etrice.core.room/build.properties b/plugins/org.eclipse.etrice.core.room/build.properties index bed6e1e91..8dae154d1 100644 --- a/plugins/org.eclipse.etrice.core.room/build.properties +++ b/plugins/org.eclipse.etrice.core.room/build.properties @@ -1,4 +1,4 @@ -source.. = src/,src-gen/ -bin.includes = META-INF/,\ - .,\ +source.. = src/,src-gen/
+bin.includes = META-INF/,\
+ .,\
plugin.xml
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.core.room/plugin.xml b/plugins/org.eclipse.etrice.core.room/plugin.xml index efcfcd738..14513883a 100644 --- a/plugins/org.eclipse.etrice.core.room/plugin.xml +++ b/plugins/org.eclipse.etrice.core.room/plugin.xml @@ -1,18 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> - -<plugin> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <package - uri = "http://www.eclipse.org/etrice/Room" - class = "org.eclipse.etrice.core.room.RoomPackage" - genModel = "org/eclipse/etrice/core/Room.genmodel" /> - - </extension> - - - - - -</plugin> +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/etrice/Room"
+ class = "org.eclipse.etrice.core.room.RoomPackage"
+ genModel = "org/eclipse/etrice/core/Room.genmodel" />
+
+ </extension>
+
+
+
+
+
+</plugin>
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/GenerateRoom.mwe2 b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/GenerateRoom.mwe2 index e88ae0055..dd947e340 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/GenerateRoom.mwe2 +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/GenerateRoom.mwe2 @@ -1,129 +1,129 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - - -module org.eclipse.etrice.core.Room - -import org.eclipse.emf.mwe.utils.* -import org.eclipse.xtext.generator.* -import org.eclipse.xtext.ui.generator.* - -var grammarURI = "classpath:/org/eclipse/etrice/core/Room.xtext" -var file.extensions = "room" -var projectName = "org.eclipse.etrice.core.room" -var runtimeProject = "../${projectName}" - -Workflow { - bean = StandaloneSetup { - platformUri = "${runtimeProject}/.." - } - - component = DirectoryCleaner { - directory = "${runtimeProject}/src-gen" - } - - component = DirectoryCleaner { - directory = "${runtimeProject}.ui/src-gen" - } - - component = Generator { - pathRtProject = runtimeProject - pathUiProject = "${runtimeProject}.ui" - projectNameRt = projectName - projectNameUi = "${projectName}.ui" - - language = { - uri = grammarURI - fileExtensions = file.extensions - - // Java API to access grammar elements (required by several other fragments) - fragment = grammarAccess.GrammarAccessFragment {} - - // generates Java API for the generated EPackages - fragment = ecore.EcoreGeneratorFragment { - // referencedGenModels = "uri to genmodel, uri to next genmodel" - } - - // the serialization component - fragment = parseTreeConstructor.ParseTreeConstructorFragment {} - - // a custom ResourceFactory for use with EMF - fragment = resourceFactory.ResourceFactoryFragment { - fileExtensions = file.extensions - } - - // the following fragment tries to use the Antlr Generator fragment which can be installed via update manager from http://download.itemis.com/updates/ - fragment = AntlrDelegatingFragment {} - - /* - If you don't want to use the Antlr fragment for some reason, remove the antlr fragment and uncomment the packrat parser fragment below. - fragment = parser.PackratParserFragment {} - */ - - // check-based API for validation - /* - fragment = validation.CheckFragment {} - */ - - // java-based API for validation - fragment = validation.JavaValidatorFragment { - composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" - composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" - } - - // scoping and exporting API - /* - fragment = scoping.ImportURIScopingFragment {} - fragment = exporting.SimpleNamesFragment {} - */ - - // scoping and exporting API - fragment = scoping.ImportNamespacesScopingFragment {} - fragment = exporting.QualifiedNamesFragment {} - - // formatter API - fragment = formatting.FormatterFragment {} - - // labeling API - fragment = labeling.LabelProviderFragment {} - - // outline API - fragment = outline.TransformerFragment {} - fragment = outline.OutlineNodeAdapterFactoryFragment {} - fragment = outline.QuickOutlineFragment {} - - // java-based API for content assistance - fragment = contentAssist.JavaBasedContentAssistFragment {} - - // the following fragment tries to use the Antlr based content assist - // fragment which can be downloaded from http://www.itemis.com - // and will be ignored if it's not available. - fragment = DelegatingGeneratorFragment { - delegate = "de.itemis.xtext.antlr.XtextAntlrUiGeneratorFragment" - message="You are generating without ANTLR. It is highly recommended to download and use the plugin \'de.itemis.xtext.antlr\' \n\t using the update site http://download.itemis.com/updates/." - } - - fragment = builder.BuilderIntegrationFragment {} - - // project wizard (optional) - /* - fragment = projectWizard.SimpleProjectWizardFragment { - generatorProjectName = "${projectName}.generator" - modelFileExtension = file.extensions - } - */ - - // quickfix API - fragment = quickfix.QuickfixProviderFragment {} - } - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+
+module org.eclipse.etrice.core.Room
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+
+var grammarURI = "classpath:/org/eclipse/etrice/core/Room.xtext"
+var file.extensions = "room"
+var projectName = "org.eclipse.etrice.core.room"
+var runtimeProject = "../${projectName}"
+
+Workflow {
+ bean = StandaloneSetup {
+ platformUri = "${runtimeProject}/.."
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}/src-gen"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.ui/src-gen"
+ }
+
+ component = Generator {
+ pathRtProject = runtimeProject
+ pathUiProject = "${runtimeProject}.ui"
+ projectNameRt = projectName
+ projectNameUi = "${projectName}.ui"
+
+ language = {
+ uri = grammarURI
+ fileExtensions = file.extensions
+
+ // Java API to access grammar elements (required by several other fragments)
+ fragment = grammarAccess.GrammarAccessFragment {}
+
+ // generates Java API for the generated EPackages
+ fragment = ecore.EcoreGeneratorFragment {
+ // referencedGenModels = "uri to genmodel, uri to next genmodel"
+ }
+
+ // the serialization component
+ fragment = parseTreeConstructor.ParseTreeConstructorFragment {}
+
+ // a custom ResourceFactory for use with EMF
+ fragment = resourceFactory.ResourceFactoryFragment {
+ fileExtensions = file.extensions
+ }
+
+ // the following fragment tries to use the Antlr Generator fragment which can be installed via update manager from http://download.itemis.com/updates/
+ fragment = AntlrDelegatingFragment {}
+
+ /*
+ If you don't want to use the Antlr fragment for some reason, remove the antlr fragment and uncomment the packrat parser fragment below.
+ fragment = parser.PackratParserFragment {}
+ */
+
+ // check-based API for validation
+ /*
+ fragment = validation.CheckFragment {}
+ */
+
+ // java-based API for validation
+ fragment = validation.JavaValidatorFragment {
+ composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
+ composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+ }
+
+ // scoping and exporting API
+ /*
+ fragment = scoping.ImportURIScopingFragment {}
+ fragment = exporting.SimpleNamesFragment {}
+ */
+
+ // scoping and exporting API
+ fragment = scoping.ImportNamespacesScopingFragment {}
+ fragment = exporting.QualifiedNamesFragment {}
+
+ // formatter API
+ fragment = formatting.FormatterFragment {}
+
+ // labeling API
+ fragment = labeling.LabelProviderFragment {}
+
+ // outline API
+ fragment = outline.TransformerFragment {}
+ fragment = outline.OutlineNodeAdapterFactoryFragment {}
+ fragment = outline.QuickOutlineFragment {}
+
+ // java-based API for content assistance
+ fragment = contentAssist.JavaBasedContentAssistFragment {}
+
+ // the following fragment tries to use the Antlr based content assist
+ // fragment which can be downloaded from http://www.itemis.com
+ // and will be ignored if it's not available.
+ fragment = DelegatingGeneratorFragment {
+ delegate = "de.itemis.xtext.antlr.XtextAntlrUiGeneratorFragment"
+ message="You are generating without ANTLR. It is highly recommended to download and use the plugin \'de.itemis.xtext.antlr\' \n\t using the update site http://download.itemis.com/updates/."
+ }
+
+ fragment = builder.BuilderIntegrationFragment {}
+
+ // project wizard (optional)
+ /*
+ fragment = projectWizard.SimpleProjectWizardFragment {
+ generatorProjectName = "${projectName}.generator"
+ modelFileExtension = file.extensions
+ }
+ */
+
+ // quickfix API
+ fragment = quickfix.QuickfixProviderFragment {}
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.properties b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.properties index 8b01fc0dd..74519ad8f 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.properties +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.properties @@ -1,3 +1,3 @@ -grammarURI=classpath:/org/eclipse/etrice/core/Room.xtext -file.extensions=room -projectName=org.eclipse.etrice.core.room +grammarURI=classpath:/org/eclipse/etrice/core/Room.xtext
+file.extensions=room
+projectName=org.eclipse.etrice.core.room
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.xtext b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.xtext index c2126f7b3..3d8519934 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.xtext +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.xtext @@ -1,376 +1,376 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -/** - * @author Henrik Rentz-Reichert and Thomas Schuetz - * - * XText Grammar for ROOM models - * this grammar is the base for the ROOM tool eTrice - * - */ - -grammar org.eclipse.etrice.core.Room with org.eclipse.xtext.common.Terminals - -generate room "http://www.eclipse.org/etrice/Room" - -RoomModel : -'RoomModel' name=FQN '{' - (imports+=Import)* - ( - dataClasses+=DataClass | - protocolClasses+=ProtocolClass | - actorClasses+=ActorClass | - subSystemClasses+=SubSystemClass | - systems+=LogicalSystem - )+ - '}' -; - -RoomClass: DataClass | ProtocolClass | StructureClass; -StructureClass: ActorContainerClass | LogicalSystem; -ActorContainerClass: ActorClass | SubSystemClass; - -// ************************************************************** -// data class - -// cf. decision DSL2: fixed size data types -// convert appropriately for Java and issue an error if size not available -enum PrimitiveType: - void = 'void' | - int8 = 'int8' | - int16 = 'int16' | - int32 = 'int32' | - uint8 = 'uint8' | - uint16 = 'uint16' | - uint32 = 'uint32' | - float32 = 'float32' | - float64 = 'float64' | - boolean = 'boolean' | - string = 'string' | - char = 'char'; - - -TypedID: - name=ID ':' type=Type; -FreeTypedID: - name=ID ':' type=FreeType; - -Type: prim=PrimitiveType | type=[DataClass|FQN]; -FreeType: prim=PrimitiveType | type=ID; - -// TODOHRR: define detail level language? -DataClass: - 'DataClass' name=ID ('extends' base=[DataClass|FQN])? '{' - (imports+=Import)* - attributes+=Attribute+ - operations+=Operation* - '}'; - -Attribute: - 'Attribute' name=ID ('[' size=INT ']')? ':' type=Type; - -// TODOHRR: pass arguments and return value by value/reference -Operation: - 'Operation' name=ID '(' (arguments+=FreeTypedID (',' arguments+=FreeTypedID)*)? ')' (':' returntype=FreeType)? - detailCode=DetailCode - ; - -// ************************************************************** -// protocol class - -ProtocolClass: - 'ProtocolClass' name=ID ('extends' base=[ProtocolClass|FQN])? '{' - ('usercode1' userCode1=DetailCode)? - ('usercode2' userCode2=DetailCode)? - 'incoming' '{' incomingMessages+=Message* '}' - 'outgoing' '{' outgoingMessages+=Message* '}' - ('regular' 'PortClass' regular=PortClass)? - ('conjugate' 'PortClass' conjugate=PortClass)? - (semantics=ProtocolSemantics)? - '}'; - -Message: - 'Message' name=ID '(' (arguments+=TypedID (',' arguments+=TypedID)*)? ')'; - -PortClass: - '{' - ('usercode' userCode=DetailCode)? - (attributes+=Attribute | - operations+=Operation | - msgHandlers+=MessageHandler)+ - '}'; - -MessageHandler: - 'handle' msg=[Message|ID] - detailCode=DetailCode - ; - -ProtocolSemantics: - 'semantics' '{' - rules+=SemanticsRule+ - '}'; - -SemanticsRule: SemanticsInRule | SemanticsOutRule; - -SemanticsInRule: 'in' msg=[Message|ID] '->' '{' - followUps+=SemanticsRule* - '}'; - -SemanticsOutRule: 'out' msg=[Message|ID] '->' '{' - followUps+=SemanticsRule* - '}'; - -// ************************************************************** -// actor class - -// some notes on ports -// -// in ROOM ports can be contained in the structure and/or the interface -// p in s ==> internal end port -// p in i ==> relay port -// p in i and p in s ==> external end port -// since double containment is not supported we decided to define external ports as reference to interface ports -ActorClass: - (abstract?='abstract')? 'ActorClass' name=ID ('extends' base=[ActorClass|FQN])? '{' - ('Interface' '{' - ifPorts+=Port* - ifSPPs+=SPPRef* - '}')? - ('Structure' '{' - ('usercode1' userCode1=DetailCode)? - ('usercode2' userCode2=DetailCode)? - (intPorts+=Port | - extPorts+=ExternalPort)* - serviceImplementations+=ServiceImplementation* - strSAPs+=SAPRef* - attributes+=Attribute* - actorRefs+=ActorRef* - bindings+=Binding* - connections+=LayerConnection* - '}')? - ('Behavior' '{' - operations+=Operation* - (stateMachine=StateMachine)? - '}')? - '}'; - -InterfaceItem: Port | SAPRef | SPPRef; - -Port: - (conjugated?='conjugated')? 'Port' name=ID ('[' multiplicity=INT ']')? ':' protocol=[ProtocolClass|FQN] ; -ExternalPort: - 'external' 'Port' ifport=[Port|ID] ; - -SAPRef: - // we omitted the SAP type (Timing/Frame/Exception) - 'SAP' name=ID ':' protocol=[ProtocolClass|FQN] ; - -SPPRef: - 'SPP' name=ID ':' protocol=[ProtocolClass|FQN] ; -ServiceImplementation: - 'ServiceImplementation' 'of' spp=[SPPRef|ID]; - -LogicalSystem: - 'LogicalSystem' name=ID '{' - subSystems+=SubSystemRef+ - bindings+=Binding* - connections+=LayerConnection* - '}'; - -ActorContainerRef: SubSystemRef | ActorRef; - -SubSystemRef: - 'SubSystemRef' name=ID ':' type=[SubSystemClass|FQN]; - -SubSystemClass: - 'SubSystemClass' name=ID '{' - relayPorts+=Port* - ifSPPs+=SPPRef* - actorRefs+=ActorRef+ - bindings+=Binding* - connections+=LayerConnection* - threads+=LogicalThread* - '}'; - -LogicalThread: - 'LogicalThread' name=ID '{' - instances+=ActorInstancePath (',' instances+=ActorInstancePath)* - '}'; - -ActorInstancePath: - segments+=ID ('.' segments+=ID)*; - -// TODOHRR: bindings for replicated ports -// (1) declare several bindings -// (2) use a notation with 1 to n bindings -Binding: - 'Binding' endpoint1=BindingEndPoint 'and' endpoint2=BindingEndPoint ; - -BindingEndPoint: - (actorRef=[ActorContainerRef|ID]'.')? port=[Port|ID]; - -LayerConnection: - 'LayerConnection' from=SAPoint 'satisfied_by' to=SPPoint -; - -SAPoint: RefSAPoint | RelaySAPoint; - -RefSAPoint: - // satisfies a sub actor - 'ref' ref=[ActorContainerRef|ID]; -RelaySAPoint: - // relays from own interface - 'relay_sap' relay=[SPPRef|ID]; - -SPPoint: - ref=[ActorContainerRef|ID] '.' service=[SPPRef|ID] -; - -// TODOHRR: support replicated actors -ActorRef: - 'ActorRef' name=ID ':' type=[ActorClass|FQN]; - - -// ************************************************************** -// state machine - -StateGraphNode: State | ChoicePoint | TrPoint; -StateGraphItem: StateGraphNode | Transition; - -State: BaseState | RefinedState; - -StateGraph: - '{' - ( - states+=State | - trPoints+=TrPoint | - chPoints+=ChoicePoint | - transitions+=Transition - )+ - '}'; - -StateMachine returns StateGraph: - 'StateMachine' '{' - ( - states+=State | - trPoints+=TrPoint | - chPoints+=ChoicePoint | - transitions+=Transition - )+ - '}'; - -// entry and exit code have multiplicity many: in BaseState to be able to add derived class codes here, -// in RefinedState to still have both features in the common base class State -BaseState: - 'State' name=ID '{' - ('entry' entryCode=DetailCode)? - ('exit' exitCode=DetailCode)? - ('subgraph' subgraph=StateGraph)? - '}'; - -RefinedState: - 'RefinedState' base=[BaseState|FQN] '{' - ('entry' entryCode=DetailCode)? - ('exit' exitCode=DetailCode)? - ('subgraph' subgraph=StateGraph)? - '}'; - -// TODOHRR: provide a means to call super class code (cf. ROOM p. 310f) -// super() keyword or flag like in Trice -DetailCode: - '{' - commands+=STRING+ - '}'; - -TrPoint: TransitionPoint | EntryPoint | ExitPoint; - -TransitionPoint: - (handler?='handler')? 'TransitionPoint' name=ID; - -EntryPoint: - 'EntryPoint' name=ID; - -ExitPoint: - 'ExitPoint' name=ID; - -ChoicePoint: - 'ChoicePoint' name=ID; - -Transition: InitialTransition | NonInitialTransition; -NonInitialTransition: TriggeredTransition | ContinuationTransition | CPBranchTransition; - -InitialTransition: - 'Transition' (name=ID)? ':' 'initial' '->' to=TransitionTerminal '{' - ('action' action=DetailCode)? - '}'; - -ContinuationTransition: - 'Transition' (name=ID)? ':' from=TransitionTerminal '->' to=TransitionTerminal '{' - ('action' action=DetailCode)? - '}'; - -TriggeredTransition: - 'Transition' (name=ID)? ':' from=TransitionTerminal '->' to=TransitionTerminal '{' - 'triggers' '{' - triggers+=Trigger ('or' triggers+=Trigger)* - '}' - ('action' action=DetailCode)? - '}'; - -CPBranchTransition: - 'Transition' (name=ID)? ':' from=TransitionTerminal '->' to=TransitionTerminal '{' - 'cond' condition=DetailCode - ('action' action=DetailCode)? - '}'; - -TransitionTerminal: StateTerminal | TrPointTerminal | SubStateTrPointTerminal | ChoicepointTerminal; - -StateTerminal: - state=[BaseState|ID]; -TrPointTerminal: - 'my' trPoint=[TrPoint|ID]; -SubStateTrPointTerminal: - trPoint=[TrPoint|ID] 'of' state=[BaseState|ID]; -ChoicepointTerminal: - 'cp' cp=[ChoicePoint|ID]; - -//TransitionSource: TransitionTerminal|ChoicePointCaseRef|ChoicePointDefaultRef; -//TransitionSource: TransitionTerminal|ChoicePointRef; -//TransitionDest: TransitionTerminal|ChoicePointRef; - -//ChoicePointCaseRef: 'cp' cp=[ChoicePoint|ID] 'case' case=[ChoicePointCase|ID]; -//ChoicePointDefaultRef: 'cp' cp=[ChoicePoint|ID] 'default'; -//ChoicePointRef: 'cp' cp=[ChoicePoint|ID]; - -Trigger: - '<' msgFromIfPairs+=MessageFromIf ('|' msgFromIfPairs+=MessageFromIf)* - (guard=Guard)? '>' -; - -MessageFromIf: - message=[Message|ID] ':' from=[InterfaceItem|ID] -; - -Guard: - 'guard' guard=DetailCode; - -// ************************************************************** -// general - -Import : - 'import' importedNamespace=ImportedFQN; - -ImportedFQN: - FQN ('.' '*')?; - -FQN: - ID ('.' ID)*; +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+/**
+ * @author Henrik Rentz-Reichert and Thomas Schuetz
+ *
+ * XText Grammar for ROOM models
+ * this grammar is the base for the ROOM tool eTrice
+ *
+ */
+
+grammar org.eclipse.etrice.core.Room with org.eclipse.xtext.common.Terminals
+
+generate room "http://www.eclipse.org/etrice/Room"
+
+RoomModel :
+'RoomModel' name=FQN '{'
+ (imports+=Import)*
+ (
+ dataClasses+=DataClass |
+ protocolClasses+=ProtocolClass |
+ actorClasses+=ActorClass |
+ subSystemClasses+=SubSystemClass |
+ systems+=LogicalSystem
+ )+
+ '}'
+;
+
+RoomClass: DataClass | ProtocolClass | StructureClass;
+StructureClass: ActorContainerClass | LogicalSystem;
+ActorContainerClass: ActorClass | SubSystemClass;
+
+// **************************************************************
+// data class
+
+// cf. decision DSL2: fixed size data types
+// convert appropriately for Java and issue an error if size not available
+enum PrimitiveType:
+ void = 'void' |
+ int8 = 'int8' |
+ int16 = 'int16' |
+ int32 = 'int32' |
+ uint8 = 'uint8' |
+ uint16 = 'uint16' |
+ uint32 = 'uint32' |
+ float32 = 'float32' |
+ float64 = 'float64' |
+ boolean = 'boolean' |
+ string = 'string' |
+ char = 'char';
+
+
+TypedID:
+ name=ID ':' type=Type;
+FreeTypedID:
+ name=ID ':' type=FreeType;
+
+Type: prim=PrimitiveType | type=[DataClass|FQN];
+FreeType: prim=PrimitiveType | type=ID;
+
+// TODOHRR: define detail level language?
+DataClass:
+ 'DataClass' name=ID ('extends' base=[DataClass|FQN])? '{'
+ (imports+=Import)*
+ attributes+=Attribute+
+ operations+=Operation*
+ '}';
+
+Attribute:
+ 'Attribute' name=ID ('[' size=INT ']')? ':' type=Type;
+
+// TODOHRR: pass arguments and return value by value/reference
+Operation:
+ 'Operation' name=ID '(' (arguments+=FreeTypedID (',' arguments+=FreeTypedID)*)? ')' (':' returntype=FreeType)?
+ detailCode=DetailCode
+ ;
+
+// **************************************************************
+// protocol class
+
+ProtocolClass:
+ 'ProtocolClass' name=ID ('extends' base=[ProtocolClass|FQN])? '{'
+ ('usercode1' userCode1=DetailCode)?
+ ('usercode2' userCode2=DetailCode)?
+ 'incoming' '{' incomingMessages+=Message* '}'
+ 'outgoing' '{' outgoingMessages+=Message* '}'
+ ('regular' 'PortClass' regular=PortClass)?
+ ('conjugate' 'PortClass' conjugate=PortClass)?
+ (semantics=ProtocolSemantics)?
+ '}';
+
+Message:
+ 'Message' name=ID '(' (arguments+=TypedID (',' arguments+=TypedID)*)? ')';
+
+PortClass:
+ '{'
+ ('usercode' userCode=DetailCode)?
+ (attributes+=Attribute |
+ operations+=Operation |
+ msgHandlers+=MessageHandler)+
+ '}';
+
+MessageHandler:
+ 'handle' msg=[Message|ID]
+ detailCode=DetailCode
+ ;
+
+ProtocolSemantics:
+ 'semantics' '{'
+ rules+=SemanticsRule+
+ '}';
+
+SemanticsRule: SemanticsInRule | SemanticsOutRule;
+
+SemanticsInRule: 'in' msg=[Message|ID] '->' '{'
+ followUps+=SemanticsRule*
+ '}';
+
+SemanticsOutRule: 'out' msg=[Message|ID] '->' '{'
+ followUps+=SemanticsRule*
+ '}';
+
+// **************************************************************
+// actor class
+
+// some notes on ports
+//
+// in ROOM ports can be contained in the structure and/or the interface
+// p in s ==> internal end port
+// p in i ==> relay port
+// p in i and p in s ==> external end port
+// since double containment is not supported we decided to define external ports as reference to interface ports
+ActorClass:
+ (abstract?='abstract')? 'ActorClass' name=ID ('extends' base=[ActorClass|FQN])? '{'
+ ('Interface' '{'
+ ifPorts+=Port*
+ ifSPPs+=SPPRef*
+ '}')?
+ ('Structure' '{'
+ ('usercode1' userCode1=DetailCode)?
+ ('usercode2' userCode2=DetailCode)?
+ (intPorts+=Port |
+ extPorts+=ExternalPort)*
+ serviceImplementations+=ServiceImplementation*
+ strSAPs+=SAPRef*
+ attributes+=Attribute*
+ actorRefs+=ActorRef*
+ bindings+=Binding*
+ connections+=LayerConnection*
+ '}')?
+ ('Behavior' '{'
+ operations+=Operation*
+ (stateMachine=StateMachine)?
+ '}')?
+ '}';
+
+InterfaceItem: Port | SAPRef | SPPRef;
+
+Port:
+ (conjugated?='conjugated')? 'Port' name=ID ('[' multiplicity=INT ']')? ':' protocol=[ProtocolClass|FQN] ;
+ExternalPort:
+ 'external' 'Port' ifport=[Port|ID] ;
+
+SAPRef:
+ // we omitted the SAP type (Timing/Frame/Exception)
+ 'SAP' name=ID ':' protocol=[ProtocolClass|FQN] ;
+
+SPPRef:
+ 'SPP' name=ID ':' protocol=[ProtocolClass|FQN] ;
+ServiceImplementation:
+ 'ServiceImplementation' 'of' spp=[SPPRef|ID];
+
+LogicalSystem:
+ 'LogicalSystem' name=ID '{'
+ subSystems+=SubSystemRef+
+ bindings+=Binding*
+ connections+=LayerConnection*
+ '}';
+
+ActorContainerRef: SubSystemRef | ActorRef;
+
+SubSystemRef:
+ 'SubSystemRef' name=ID ':' type=[SubSystemClass|FQN];
+
+SubSystemClass:
+ 'SubSystemClass' name=ID '{'
+ relayPorts+=Port*
+ ifSPPs+=SPPRef*
+ actorRefs+=ActorRef+
+ bindings+=Binding*
+ connections+=LayerConnection*
+ threads+=LogicalThread*
+ '}';
+
+LogicalThread:
+ 'LogicalThread' name=ID '{'
+ instances+=ActorInstancePath (',' instances+=ActorInstancePath)*
+ '}';
+
+ActorInstancePath:
+ segments+=ID ('.' segments+=ID)*;
+
+// TODOHRR: bindings for replicated ports
+// (1) declare several bindings
+// (2) use a notation with 1 to n bindings
+Binding:
+ 'Binding' endpoint1=BindingEndPoint 'and' endpoint2=BindingEndPoint ;
+
+BindingEndPoint:
+ (actorRef=[ActorContainerRef|ID]'.')? port=[Port|ID];
+
+LayerConnection:
+ 'LayerConnection' from=SAPoint 'satisfied_by' to=SPPoint
+;
+
+SAPoint: RefSAPoint | RelaySAPoint;
+
+RefSAPoint:
+ // satisfies a sub actor
+ 'ref' ref=[ActorContainerRef|ID];
+RelaySAPoint:
+ // relays from own interface
+ 'relay_sap' relay=[SPPRef|ID];
+
+SPPoint:
+ ref=[ActorContainerRef|ID] '.' service=[SPPRef|ID]
+;
+
+// TODOHRR: support replicated actors
+ActorRef:
+ 'ActorRef' name=ID ':' type=[ActorClass|FQN];
+
+
+// **************************************************************
+// state machine
+
+StateGraphNode: State | ChoicePoint | TrPoint;
+StateGraphItem: StateGraphNode | Transition;
+
+State: BaseState | RefinedState;
+
+StateGraph:
+ '{'
+ (
+ states+=State |
+ trPoints+=TrPoint |
+ chPoints+=ChoicePoint |
+ transitions+=Transition
+ )+
+ '}';
+
+StateMachine returns StateGraph:
+ 'StateMachine' '{'
+ (
+ states+=State |
+ trPoints+=TrPoint |
+ chPoints+=ChoicePoint |
+ transitions+=Transition
+ )+
+ '}';
+
+// entry and exit code have multiplicity many: in BaseState to be able to add derived class codes here,
+// in RefinedState to still have both features in the common base class State
+BaseState:
+ 'State' name=ID '{'
+ ('entry' entryCode=DetailCode)?
+ ('exit' exitCode=DetailCode)?
+ ('subgraph' subgraph=StateGraph)?
+ '}';
+
+RefinedState:
+ 'RefinedState' base=[BaseState|FQN] '{'
+ ('entry' entryCode=DetailCode)?
+ ('exit' exitCode=DetailCode)?
+ ('subgraph' subgraph=StateGraph)?
+ '}';
+
+// TODOHRR: provide a means to call super class code (cf. ROOM p. 310f)
+// super() keyword or flag like in Trice
+DetailCode:
+ '{'
+ commands+=STRING+
+ '}';
+
+TrPoint: TransitionPoint | EntryPoint | ExitPoint;
+
+TransitionPoint:
+ (handler?='handler')? 'TransitionPoint' name=ID;
+
+EntryPoint:
+ 'EntryPoint' name=ID;
+
+ExitPoint:
+ 'ExitPoint' name=ID;
+
+ChoicePoint:
+ 'ChoicePoint' name=ID;
+
+Transition: InitialTransition | NonInitialTransition;
+NonInitialTransition: TriggeredTransition | ContinuationTransition | CPBranchTransition;
+
+InitialTransition:
+ 'Transition' (name=ID)? ':' 'initial' '->' to=TransitionTerminal '{'
+ ('action' action=DetailCode)?
+ '}';
+
+ContinuationTransition:
+ 'Transition' (name=ID)? ':' from=TransitionTerminal '->' to=TransitionTerminal '{'
+ ('action' action=DetailCode)?
+ '}';
+
+TriggeredTransition:
+ 'Transition' (name=ID)? ':' from=TransitionTerminal '->' to=TransitionTerminal '{'
+ 'triggers' '{'
+ triggers+=Trigger ('or' triggers+=Trigger)*
+ '}'
+ ('action' action=DetailCode)?
+ '}';
+
+CPBranchTransition:
+ 'Transition' (name=ID)? ':' from=TransitionTerminal '->' to=TransitionTerminal '{'
+ 'cond' condition=DetailCode
+ ('action' action=DetailCode)?
+ '}';
+
+TransitionTerminal: StateTerminal | TrPointTerminal | SubStateTrPointTerminal | ChoicepointTerminal;
+
+StateTerminal:
+ state=[BaseState|ID];
+TrPointTerminal:
+ 'my' trPoint=[TrPoint|ID];
+SubStateTrPointTerminal:
+ trPoint=[TrPoint|ID] 'of' state=[BaseState|ID];
+ChoicepointTerminal:
+ 'cp' cp=[ChoicePoint|ID];
+
+//TransitionSource: TransitionTerminal|ChoicePointCaseRef|ChoicePointDefaultRef;
+//TransitionSource: TransitionTerminal|ChoicePointRef;
+//TransitionDest: TransitionTerminal|ChoicePointRef;
+
+//ChoicePointCaseRef: 'cp' cp=[ChoicePoint|ID] 'case' case=[ChoicePointCase|ID];
+//ChoicePointDefaultRef: 'cp' cp=[ChoicePoint|ID] 'default';
+//ChoicePointRef: 'cp' cp=[ChoicePoint|ID];
+
+Trigger:
+ '<' msgFromIfPairs+=MessageFromIf ('|' msgFromIfPairs+=MessageFromIf)*
+ (guard=Guard)? '>'
+;
+
+MessageFromIf:
+ message=[Message|ID] ':' from=[InterfaceItem|ID]
+;
+
+Guard:
+ 'guard' guard=DetailCode;
+
+// **************************************************************
+// general
+
+Import :
+ 'import' importedNamespace=ImportedFQN;
+
+ImportedFQN:
+ FQN ('.' '*')?;
+
+FQN:
+ ID ('.' ID)*;
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java index d12cc0851..7db4714b7 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomRuntimeModule.java @@ -1,35 +1,35 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core; - -import org.eclipse.etrice.core.naming.RoomFragmentProvider; -import org.eclipse.etrice.core.naming.RoomQualifiedNameProvider; -import org.eclipse.xtext.naming.IQualifiedNameProvider; -import org.eclipse.xtext.resource.IFragmentProvider; - - -/** - * Use this class to register components to be used within the IDE. - */ -public class RoomRuntimeModule extends org.eclipse.etrice.core.AbstractRoomRuntimeModule { - - @Override - public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { - return RoomQualifiedNameProvider.class; - } - - @Override - public Class<? extends IFragmentProvider> bindIFragmentProvider() { - return RoomFragmentProvider.class; - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core;
+
+import org.eclipse.etrice.core.naming.RoomFragmentProvider;
+import org.eclipse.etrice.core.naming.RoomQualifiedNameProvider;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.resource.IFragmentProvider;
+
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class RoomRuntimeModule extends org.eclipse.etrice.core.AbstractRoomRuntimeModule {
+
+ @Override
+ public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
+ return RoomQualifiedNameProvider.class;
+ }
+
+ @Override
+ public Class<? extends IFragmentProvider> bindIFragmentProvider() {
+ return RoomFragmentProvider.class;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomStandaloneSetup.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomStandaloneSetup.java index 4e5490356..7233be345 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomStandaloneSetup.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomStandaloneSetup.java @@ -1,29 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - - - -package org.eclipse.etrice.core; - -import org.eclipse.etrice.core.RoomStandaloneSetupGenerated; - -/** - * Initialization support for running Xtext languages - * without equinox extension registry - */ -public class RoomStandaloneSetup extends RoomStandaloneSetupGenerated{ - - public static void doSetup() { - new RoomStandaloneSetup().createInjectorAndDoEMFRegistration(); - } -} - +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+
+
+package org.eclipse.etrice.core;
+
+import org.eclipse.etrice.core.RoomStandaloneSetupGenerated;
+
+/**
+ * Initialization support for running Xtext languages
+ * without equinox extension registry
+ */
+public class RoomStandaloneSetup extends RoomStandaloneSetupGenerated{
+
+ public static void doSetup() {
+ new RoomStandaloneSetup().createInjectorAndDoEMFRegistration();
+ }
+}
+
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/formatting/RoomFormatter.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/formatting/RoomFormatter.java index bfbb4edc5..79c5515a2 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/formatting/RoomFormatter.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/formatting/RoomFormatter.java @@ -1,34 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.formatting; - -import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter; -import org.eclipse.xtext.formatting.impl.FormattingConfig; - -/** - * This class contains custom formatting description. - * - * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting - * on how and when to use it - * - * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example - */ -public class RoomFormatter extends AbstractDeclarativeFormatter { - - @Override - protected void configureFormatting(FormattingConfig c) { - //org.eclipse.etrice.core.services.RoomGrammarAccess f = (org.eclipse.etrice.core.services.RoomGrammarAccess) getGrammarAccess(); - - //... - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.formatting;
+
+import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
+import org.eclipse.xtext.formatting.impl.FormattingConfig;
+
+/**
+ * This class contains custom formatting description.
+ *
+ * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting
+ * on how and when to use it
+ *
+ * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
+ */
+public class RoomFormatter extends AbstractDeclarativeFormatter {
+
+ @Override
+ protected void configureFormatting(FormattingConfig c) {
+ //org.eclipse.etrice.core.services.RoomGrammarAccess f = (org.eclipse.etrice.core.services.RoomGrammarAccess) getGrammarAccess();
+
+ //...
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java index c2fb02994..20c3aae15 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomFragmentProvider.java @@ -656,6 +656,9 @@ public class RoomFragmentProvider implements IFragmentProvider { if (ar.getName().equals(name))
return ar;
}
+ if (rc instanceof ActorClass)
+ if (((ActorClass) rc).getBase()!=null)
+ return getActorContainerRef(((ActorClass) rc).getBase(), name);
}
else if (rc instanceof LogicalSystem) {
for (SubSystemRef ssr : ((LogicalSystem) rc).getSubSystems()) {
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java index c9b7109c7..3549345b7 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.scoping; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.xtext.resource.IEObjectDescription; -import org.eclipse.xtext.scoping.IScope; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -public class FilteringScope implements IScope { - - private IScope delegate; - private Predicate<IEObjectDescription> filter; - - public FilteringScope(IScope delegate, Predicate<IEObjectDescription> filter) { - this.delegate = delegate; - this.filter = filter; - } - - public IScope getOuterScope() { - return new FilteringScope(delegate.getOuterScope(), filter); - } - - public Iterable<IEObjectDescription> getContents() { - return filter(delegate.getContents()); - } - - public Iterable<IEObjectDescription> getAllContents() { - return filter(delegate.getAllContents()); - } - - public IEObjectDescription getContentByName(String name) { - return filter(delegate.getContentByName(name)); - } - - public IEObjectDescription getContentByEObject(EObject object) { - return filter(delegate.getContentByEObject(object)); - } - - public Iterable<IEObjectDescription> getAllContentsByEObject(EObject object) { - return filter(delegate.getAllContentsByEObject(object)); - } - - protected Iterable<IEObjectDescription> filter( - Iterable<IEObjectDescription> unfiltered) { - return Iterables.filter(unfiltered, filter); - } - - protected IEObjectDescription filter(IEObjectDescription contentByEObject) { - if (!filter.apply(contentByEObject)) - return null; - return contentByEObject; - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.scoping;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class FilteringScope implements IScope {
+
+ private IScope delegate;
+ private Predicate<IEObjectDescription> filter;
+
+ public FilteringScope(IScope delegate, Predicate<IEObjectDescription> filter) {
+ this.delegate = delegate;
+ this.filter = filter;
+ }
+
+ public IScope getOuterScope() {
+ return new FilteringScope(delegate.getOuterScope(), filter);
+ }
+
+ public Iterable<IEObjectDescription> getContents() {
+ return filter(delegate.getContents());
+ }
+
+ public Iterable<IEObjectDescription> getAllContents() {
+ return filter(delegate.getAllContents());
+ }
+
+ public IEObjectDescription getContentByName(String name) {
+ return filter(delegate.getContentByName(name));
+ }
+
+ public IEObjectDescription getContentByEObject(EObject object) {
+ return filter(delegate.getContentByEObject(object));
+ }
+
+ public Iterable<IEObjectDescription> getAllContentsByEObject(EObject object) {
+ return filter(delegate.getAllContentsByEObject(object));
+ }
+
+ protected Iterable<IEObjectDescription> filter(
+ Iterable<IEObjectDescription> unfiltered) {
+ return Iterables.filter(unfiltered, filter);
+ }
+
+ protected IEObjectDescription filter(IEObjectDescription contentByEObject) {
+ if (!filter.apply(contentByEObject))
+ return null;
+ return contentByEObject;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java index 048f418f4..02a3085eb 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/RoomScopeProvider.java @@ -1,803 +1,803 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.scoping; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.core.room.ActorContainerClass; -import org.eclipse.etrice.core.room.ActorRef; -import org.eclipse.etrice.core.room.BaseState; -import org.eclipse.etrice.core.room.BindingEndPoint; -import org.eclipse.etrice.core.room.ChoicePoint; -import org.eclipse.etrice.core.room.ChoicepointTerminal; -import org.eclipse.etrice.core.room.ExternalPort; -import org.eclipse.etrice.core.room.InterfaceItem; -import org.eclipse.etrice.core.room.Message; -import org.eclipse.etrice.core.room.MessageFromIf; -import org.eclipse.etrice.core.room.MessageHandler; -import org.eclipse.etrice.core.room.Port; -import org.eclipse.etrice.core.room.ProtocolClass; -import org.eclipse.etrice.core.room.RefSAPoint; -import org.eclipse.etrice.core.room.RefinedState; -import org.eclipse.etrice.core.room.RelaySAPoint; -import org.eclipse.etrice.core.room.SAPRef; -import org.eclipse.etrice.core.room.SPPRef; -import org.eclipse.etrice.core.room.SPPoint; -import org.eclipse.etrice.core.room.SemanticsInRule; -import org.eclipse.etrice.core.room.SemanticsOutRule; -import org.eclipse.etrice.core.room.ServiceImplementation; -import org.eclipse.etrice.core.room.State; -import org.eclipse.etrice.core.room.StateGraph; -import org.eclipse.etrice.core.room.StateTerminal; -import org.eclipse.etrice.core.room.SubStateTrPointTerminal; -import org.eclipse.etrice.core.room.SubSystemClass; -import org.eclipse.etrice.core.room.SubSystemRef; -import org.eclipse.etrice.core.room.TrPoint; -import org.eclipse.etrice.core.room.TrPointTerminal; -import org.eclipse.xtext.resource.EObjectDescription; -import org.eclipse.xtext.resource.IEObjectDescription; -import org.eclipse.xtext.scoping.IScope; -import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider; -import org.eclipse.xtext.scoping.impl.SimpleScope; - - -/** - * This class contains custom scoping description. - * - * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping - * on how and when to use it - * - */ -public class RoomScopeProvider extends AbstractDeclarativeScopeProvider { - - public static final String STATE_PATH_DELIMITER = "."; - - /** - * first container of type {@link StateGraph} ({@link State}, {@link StateMachine}) - * @param obj - * @return StateGraph Container - */ - private StateGraph getStateGraph(EObject obj) { - EObject ctx = obj.eContainer(); - while (!(ctx instanceof StateGraph) && ctx.eContainer()!=null) - ctx = ctx.eContainer(); - if (ctx instanceof StateGraph) - return (StateGraph) ctx; - - return null; - } - - /** - * first container of type {@link ActorClass} - * @param obj - * @return ActorClass container - */ - private ActorClass getActorClass(EObject obj) { - EObject ctx = obj.eContainer(); - while (!(ctx instanceof ActorClass) && ctx.eContainer()!=null) - ctx = ctx.eContainer(); - if (ctx instanceof ActorClass) - return (ActorClass) ctx; - - return null; - } - - /** - * first container of type {@link ActorClass} - * @param obj - * @return ActorClass container - */ - private ActorContainerClass getActorContainerClass(EObject obj) { - EObject ctx = obj.eContainer(); - while (!(ctx instanceof ActorContainerClass) && ctx.eContainer()!=null) - ctx = ctx.eContainer(); - if (ctx instanceof ActorContainerClass) - return (ActorContainerClass) ctx; - - return null; - } - - /** - * first container of type {@link ProtocolClass} - * @param obj - * @return ActorClass container - */ - private ProtocolClass getProtocolClass(EObject obj) { - EObject ctx = obj.eContainer(); - while (!(ctx instanceof ProtocolClass) && ctx.eContainer()!=null) - ctx = ctx.eContainer(); - if (ctx instanceof ProtocolClass) - return (ProtocolClass) ctx; - - return null; - } - - /** - * check whether port is referenced by external port - * @param p - port to be checked - * @param ports - list of external ports - * @return true if contained - */ - private boolean isContained(Port p, EList<ExternalPort> ports) { - for (ExternalPort port : ports) { - if (port.getIfport()==p) - return true; - } - return false; - } - - /** - * recursively collect all {@link BaseState}s of an actor class in a list - * @param ac - * @param states - */ - private void collectAllStates(ActorClass ac, - LinkedList<BaseState> states) { - while (ac!=null) { - collectStates(ac.getStateMachine(), states); - ac = ac.getBase(); - } - } - - private void collectStates(StateGraph sg, - LinkedList<BaseState> states) { - - if (sg==null) - return; - - for (State s : sg.getStates()) { - if (s instanceof BaseState) - states.add((BaseState) s); - } - for (State s : sg.getStates()) { - collectStates(s.getSubgraph(), states); - } - } - - /** - * compute the path of a {@link BaseState} - * @param bs - * @return the path - */ - private String getStatePath(BaseState bs) { - EObject parent = bs.eContainer().eContainer(); - if (parent instanceof BaseState) - return getStatePath((BaseState) parent)+STATE_PATH_DELIMITER+bs.getName(); - else if (parent instanceof RefinedState) { - BaseState base = ((RefinedState) parent).getBase(); - if (base!=null) - return getStatePath(base)+STATE_PATH_DELIMITER+bs.getName(); - } - return bs.getName(); - } - - /** - * return a list of base classes of an {@link ActorClass}, parent classes first. - * The list includes the class itself - * @param ac - * @return - */ - private LinkedList<ActorClass> getBaseClasses(ActorClass ac) { - LinkedList<ActorClass> classes = new LinkedList<ActorClass>(); - if (ac!=null) { - classes.addFirst(ac); - while (ac.getBase()!=null) { - ac = ac.getBase(); - classes.addFirst(ac); - } - } - return classes; - } - - /** - * return a list of base classes of an {@link ProtocolClass}, parent classes first. - * The list includes the class itself - * @param pc - * @return - */ - private LinkedList<ProtocolClass> getBaseClasses(ProtocolClass pc) { - LinkedList<ProtocolClass> classes = new LinkedList<ProtocolClass>(); - classes.addFirst(pc); - while (pc.getBase()!=null) { - pc = pc.getBase(); - classes.addFirst(pc); - } - return classes; - } - - /** - * return the {@link BaseState} of a {@link State} - * @param s - * @return the state itself if a BaseState or the BaseState for a {@link RefinedState} - */ - private BaseState getBaseState(State s) { - if (s instanceof BaseState) - return (BaseState) s; - else if (s instanceof RefinedState) - return ((RefinedState) s).getBase(); - else - return null; - } - - private IScope getStateScopes(EObject obj) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - // first state in container hierarchy - StateGraph parent = getStateGraph(obj); - - // collect states of my parent - if (parent!=null) { - for (State s : parent.getStates()) { - BaseState bs = getBaseState(s); - scopes.add(EObjectDescription.create(bs.getName(), bs)); - } - - // if my parent is a refined state we also add its base state contents - if (parent.eContainer() instanceof RefinedState) { - parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph(); - if (parent!=null) - for (State s : parent.getStates()) { - BaseState bs = getBaseState(s); - scopes.add(EObjectDescription.create(bs.getName(), bs)); - } - } - else if (parent.eContainer() instanceof ActorClass) { - ActorClass ac = (ActorClass) parent.eContainer(); - if (ac.getBase()!=null) { - for (State s : ac.getBase().getStateMachine().getStates()) { - BaseState bs = getBaseState(s); - scopes.add(EObjectDescription.create(bs.getName(), bs)); - } - } - } - } - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of State scopes for a {@link StateTerminal} - * @param st - the transition endpoint or terminal - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_StateTerminal_state(StateTerminal st, EReference ref) { - return getStateScopes(st); - } - - /** - * returns a flat list of TransitionPoint scopes for a {@link TrPointTerminal} - * @param ep - the transition endpoint or terminal - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_TrPointTerminal_trPoint(TrPointTerminal ep, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - StateGraph parent = getStateGraph(ep); - StateGraph targetStateGraph = parent; - - getTrPointScopes(scopes, targetStateGraph); - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of TransitionPoint scopes for a {@link SubStateTrPointTerminal} - * @param ep - the transition endpoint or terminal - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_SubStateTrPointTerminal_trPoint(SubStateTrPointTerminal ep, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - StateGraph parent = getStateGraph(ep); - StateGraph targetStateGraph = parent; - if (ep.getState()!=null) { - targetStateGraph = ep.getState().getSubgraph(); // always a BaseState - - // if one of our siblings is a RefinedState of our target we take that as target - for (State sibling : parent.getStates()) { - if (sibling instanceof RefinedState) { - if (((RefinedState)sibling).getBase()==ep.getState()) - targetStateGraph = sibling.getSubgraph(); - } - } - } - - getTrPointScopes(scopes, targetStateGraph); - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - private void getTrPointScopes(final List<IEObjectDescription> scopes, - StateGraph sg) { - - // collect transition points of this state - for (TrPoint tp : sg.getTrPoints()) { - scopes.add(EObjectDescription.create(tp.getName(), tp)); - } - - // if this state is a refined state we also add its base state transition points - if (sg.eContainer() instanceof RefinedState) { - sg = ((RefinedState) sg.eContainer()).getBase().getSubgraph(); - if (sg!=null) - for (TrPoint tp : sg.getTrPoints()) { - scopes.add(EObjectDescription.create(tp.getName(), tp)); - } - } - } - - /** - * returns a flat list of State scopes for a {@link SubStateTrPointTerminal} - * @param st - the transition endpoint or terminal - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_SubStateTrPointTerminal_state(SubStateTrPointTerminal st, EReference ref) { - return getStateScopes(st); - } - - /** - * returns a flat list of Choicepoint scopes for a {@link SubStateTrPointTerminal} - * @param ct - the transition endpoint or terminal - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_ChoicepointTerminal_cp(ChoicepointTerminal ct, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - // first state in container hierarchy - StateGraph parent = getStateGraph(ct); - - // collect choicepoints of my parent - if (parent!=null) - for (ChoicePoint cp : parent.getChPoints()) { - scopes.add(EObjectDescription.create(cp.getName(), cp)); - } - - // if my parent is a refined state we also add its base state contents - if (parent.eContainer() instanceof RefinedState) { - parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph(); - if (parent!=null) - for (ChoicePoint cp : parent.getChPoints()) { - scopes.add(EObjectDescription.create(cp.getName(), cp)); - } - } - else if (parent.eContainer() instanceof ActorClass) { - ActorClass ac = (ActorClass) parent.eContainer(); - if (ac.getBase()!=null) { - for (ChoicePoint cp : ac.getBase().getStateMachine().getChPoints()) { - scopes.add(EObjectDescription.create(cp.getName(), cp)); - } - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of Message scopes for a {@link MessageFromIf} - * @param mfi - the message from interface - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_MessageFromIf_message(MessageFromIf mfi, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - InterfaceItem item = mfi.getFrom(); - if (item!=null) { - ProtocolClass protocol = item.getProtocol(); - boolean conjugated = false; - if (item instanceof Port) - conjugated = ((Port)item).isConjugated(); - else if (item instanceof SAPRef) - conjugated = true; - for (Message msg : conjugated?protocol.getOutgoingMessages():protocol.getIncomingMessages()) { - scopes.add(EObjectDescription.create(msg.getName(), msg)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of Port scopes for a {@link MessageFromIf} - * @param mfi - the message from interface - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_MessageFromIf_port(MessageFromIf mfi, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorClass ac = getActorClass(mfi); - for (Port p : ac.getIntPorts()) { - scopes.add(EObjectDescription.create(p.getName(), p)); - } - for (ExternalPort p : ac.getExtPorts()) { - scopes.add(EObjectDescription.create(p.getIfport().getName(), p.getIfport())); - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of InterfaceItem scopes for a {@link MessageFromIf} - * @param mfi - the message from interface - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_MessageFromIf_from(MessageFromIf mfi, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorClass ac = getActorClass(mfi); - LinkedList<ActorClass> classes = getBaseClasses(ac); - LinkedList<InterfaceItem> items = new LinkedList<InterfaceItem>(); - - // for all base classes - for (ActorClass a : classes) { - // add internal ports - items.addAll(a.getIntPorts()); - - // add service implementations and saps - for (ServiceImplementation ispp : a.getServiceImplementations()) { - items.add(ispp.getSpp()); - } - items.addAll(a.getStrSAPs()); - - // add external end ports - for (ExternalPort p : a.getExtPorts()) { - items.add(p.getIfport()); - } - } - - for (InterfaceItem item : items) { - scopes.add(EObjectDescription.create(item.getName(), item)); - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of ActorRef scopes for a {@link BindingEndPoint} - * @param ep - the endpoint - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_BindingEndPoint_actorRef(BindingEndPoint ep, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorContainerClass sc = getActorContainerClass(ep); - if (sc instanceof ActorClass) { - LinkedList<ActorClass> classes = getBaseClasses((ActorClass)sc); - for (ActorClass a : classes) { - for (ActorRef ar : a.getActorRefs()) { - scopes.add(EObjectDescription.create(ar.getName(), ar)); - } - } - } - else { - for (ActorRef ar : sc.getActorRefs()) { - scopes.add(EObjectDescription.create(ar.getName(), ar)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of Port scopes for a {@link BindingEndPoint} - * @param ep - the endpoint - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_BindingEndPoint_port(BindingEndPoint ep, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorContainerClass acc = getActorContainerClass(ep); - - if (ep.getActorRef() == null){ - if (acc instanceof ActorClass) { - ActorClass ac = (ActorClass) acc; - // for all super classes (including this class) - LinkedList<ActorClass> classes = getBaseClasses(ac); - for (ActorClass a : classes) { - // collect internal and relay ports, i.e. - // structure ports not in interface (internal) - for (Port p : a.getIntPorts()) { - scopes.add(EObjectDescription.create(p.getName(), p)); - } - // interface ports not in structure (relay) - for (Port p : a.getIfPorts()) { - if (!isContained(p, a.getExtPorts())) - scopes.add(EObjectDescription.create(p.getName(), p)); - } - } - } - else { - // SubSystemClass has no internal end ports - } - } - else { - // all ports in the sub actor's interface - if (ep.getActorRef() instanceof ActorRef) { - ActorClass ac = ((ActorRef)ep.getActorRef()).getType(); - LinkedList<ActorClass> classes = getBaseClasses(ac); - for (ActorClass a : classes) { - for (Port p : a.getIfPorts()) { - scopes.add(EObjectDescription.create(p.getName(), p)); - } - } - } - else { - SubSystemClass ssc = ((SubSystemRef)ep.getActorRef()).getType(); - for (Port p : ssc.getRelayPorts()) { - scopes.add(EObjectDescription.create(p.getName(), p)); - } - } - } - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of BaseState scopes for a {@link RefinedState} - * @param rs - the refined state - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_RefinedState_base(RefinedState rs, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorClass ac = getActorClass(rs); - LinkedList<BaseState> states = new LinkedList<BaseState>(); - collectAllStates(ac.getBase(), states); - for (BaseState bs : states) { - scopes.add(EObjectDescription.create(getStatePath(bs), bs)); - } - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of Message scopes for a {@link SemanticsInRule} - * @param sr - the semantics rule for incoming messages - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_SemanticsInRule_msg(SemanticsInRule sr, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ProtocolClass pc = getProtocolClass(sr); - LinkedList<ProtocolClass> classes = getBaseClasses(pc); - for (ProtocolClass bpc : classes) { - for (Message m : bpc.getIncomingMessages()) { - scopes.add(EObjectDescription.create(m.getName(), m)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of Message scopes for a {@link SemanticsInRule} - * @param sr - the semantics rule for incoming messages - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_SemanticsOutRule_msg(SemanticsOutRule sr, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ProtocolClass pc = getProtocolClass(sr); - LinkedList<ProtocolClass> classes = getBaseClasses(pc); - for (ProtocolClass bpc : classes) { - for (Message m : bpc.getOutgoingMessages()) { - scopes.add(EObjectDescription.create(m.getName(), m)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of ActorRef scopes for a {@link SubActorSAPoint} - * @param pt - * @param ref - * @return a list of scopes - */ - public IScope scope_RefSAPoint_ref(RefSAPoint pt, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorContainerClass acc = getActorContainerClass(pt); - if (acc instanceof ActorClass) { - LinkedList<ActorClass> classes = getBaseClasses((ActorClass) acc); - for (ActorClass a : classes) { - for (ActorRef ar : a.getActorRefs()) { - scopes.add(EObjectDescription.create(ar.getName(), ar)); - } - } - } - else { - for (ActorRef ar : acc.getActorRefs()) { - scopes.add(EObjectDescription.create(ar.getName(), ar)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of SPPRef scopes for a {@link RelaySAPoint} - * @param pt - * @param ref - * @return a list of scopes - */ - public IScope scope_RelaySAPoint_relay(RelaySAPoint pt, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorClass ac = getActorClass(pt); - LinkedList<ActorClass> classes = getBaseClasses(ac); - for (ActorClass a : classes) { - for (SPPRef spp : a.getIfSPPs()) { - scopes.add(EObjectDescription.create(spp.getName(), spp)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of ActorRef scopes for a {@link SPPoint} - * @param pt - * @param ref - * @return a list of scopes - */ - public IScope scope_SPPoint_actorRef(SPPoint pt, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorContainerClass acc = getActorContainerClass(pt); - if (acc instanceof ActorClass) { - LinkedList<ActorClass> classes = getBaseClasses((ActorClass)acc); - for (ActorClass a : classes) { - for (ActorRef ar : a.getActorRefs()) { - scopes.add(EObjectDescription.create(ar.getName(), ar)); - } - } - } - else { - for (ActorRef ar : acc.getActorRefs()) { - scopes.add(EObjectDescription.create(ar.getName(), ar)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /** - * returns a flat list of SPPRef scopes for a {@link SPPoint} - * @param pt - * @param ref - * @return a list of scopes - */ - public IScope scope_SPPoint_service(SPPoint pt, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - if (pt.getRef()!=null) { - if (pt.getRef() instanceof ActorRef) { - ActorClass ac = ((ActorRef)pt.getRef()).getType(); - LinkedList<ActorClass> classes = getBaseClasses(ac); - for (ActorClass a : classes) { - for (SPPRef spp : a.getIfSPPs()) { - scopes.add(EObjectDescription.create(spp.getName(), spp)); - } - } - } - else if (pt.getRef() instanceof SubSystemRef) { - SubSystemClass ssc = ((SubSystemRef)pt.getRef()).getType(); - for (SPPRef spp : ssc.getIfSPPs()) { - scopes.add(EObjectDescription.create(spp.getName(), spp)); - } - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - public IScope scope_MessageHandler_msg(MessageHandler handler, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ProtocolClass pc = getProtocolClass(handler); - if (pc!=null) { - for (Message m : pc.getIncomingMessages()) { - scopes.add(EObjectDescription.create(m.getName(), m)); - } - for (Message m : pc.getOutgoingMessages()) { - scopes.add(EObjectDescription.create(m.getName(), m)); - } - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - - /* - * we prefer loose scoping here and rely on validation for meaningful error messages - * - * returns a flat list of ActorClass scopes for a {@link ActorRef} - * @param ar - the actor reference - * @param ref - not used - * @return a list of scopes - */ -// public IScope scope_ActorRef_type(ActorRef ar, EReference ref) { -// ActorClass ac = getActorClass(ar); -// IScope scope = delegateGetScope(ar, ref); -// return new FilteringScope(scope, new ActorRefFilter(ac)); -// } - - /** - * returns a flat list of Port scopes for a {@link ExternalPort} - * @param ar - the external port - * @param ref - not used - * @return a list of scopes - */ - public IScope scope_ExternalPort_ifport(ExternalPort ep, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - ActorClass ac = getActorClass(ep); - for (Port ip : ac.getIfPorts()) { - scopes.add(EObjectDescription.create(ip.getName(), ip)); - } - - return new SimpleScope(IScope.NULLSCOPE, scopes); - } - /** - * returns a flat list of Port scopes for a {@link ExternalPort} - * @param ar - the external port - * @param ref - not used - * @return a list of scopes - */ -// public IScope scope_ActorInstance_segments(ActorInstance ai, EReference ref) { -// final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); -// -// if (ai.getSegments().isEmpty()) { -// // context is my ActorContainerClass -// ActorContainerClass acc = getActorContainerClass(ai); -// for (ActorRef ar : acc.getActorRefs()) { -// scopes.add(EObjectDescription.create(ar.getName(), ar)); -// } -// } -// else { -// // context is actor class of last segment -// ActorClass ac = ai.getSegments().get(ai.getSegments().size()-1).getType(); -// for (ActorRef ar : ac.getActorRefs()) { -// scopes.add(EObjectDescription.create(ar.getName(), ar)); -// } -// } -// -// return new SimpleScope(IScope.NULLSCOPE, scopes); -// } - - /* - public IScope scope_ChoicePointCaseRef_case(ChoicePointCaseRef cr, EReference ref) { - final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>(); - - if (cr.getCp()!=null) { - for (ChoicePointCase cas : cr.getCp().getCases()) { - scopes.add(EObjectDescription.create(cas.getName(), cas)); - } - } - return new SimpleScope(IScope.NULLSCOPE, scopes); - }*/ -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.scoping;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorContainerClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.BaseState;
+import org.eclipse.etrice.core.room.BindingEndPoint;
+import org.eclipse.etrice.core.room.ChoicePoint;
+import org.eclipse.etrice.core.room.ChoicepointTerminal;
+import org.eclipse.etrice.core.room.ExternalPort;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.MessageHandler;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefSAPoint;
+import org.eclipse.etrice.core.room.RefinedState;
+import org.eclipse.etrice.core.room.RelaySAPoint;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.SPPoint;
+import org.eclipse.etrice.core.room.SemanticsInRule;
+import org.eclipse.etrice.core.room.SemanticsOutRule;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.StateTerminal;
+import org.eclipse.etrice.core.room.SubStateTrPointTerminal;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.core.room.SubSystemRef;
+import org.eclipse.etrice.core.room.TrPoint;
+import org.eclipse.etrice.core.room.TrPointTerminal;
+import org.eclipse.xtext.resource.EObjectDescription;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
+import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
+import org.eclipse.xtext.scoping.impl.SimpleScope;
+
+
+/**
+ * This class contains custom scoping description.
+ *
+ * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping
+ * on how and when to use it
+ *
+ */
+public class RoomScopeProvider extends AbstractDeclarativeScopeProvider {
+
+ public static final String STATE_PATH_DELIMITER = ".";
+
+ /**
+ * first container of type {@link StateGraph} ({@link State}, {@link StateMachine})
+ * @param obj
+ * @return StateGraph Container
+ */
+ private StateGraph getStateGraph(EObject obj) {
+ EObject ctx = obj.eContainer();
+ while (!(ctx instanceof StateGraph) && ctx.eContainer()!=null)
+ ctx = ctx.eContainer();
+ if (ctx instanceof StateGraph)
+ return (StateGraph) ctx;
+
+ return null;
+ }
+
+ /**
+ * first container of type {@link ActorClass}
+ * @param obj
+ * @return ActorClass container
+ */
+ private ActorClass getActorClass(EObject obj) {
+ EObject ctx = obj.eContainer();
+ while (!(ctx instanceof ActorClass) && ctx.eContainer()!=null)
+ ctx = ctx.eContainer();
+ if (ctx instanceof ActorClass)
+ return (ActorClass) ctx;
+
+ return null;
+ }
+
+ /**
+ * first container of type {@link ActorClass}
+ * @param obj
+ * @return ActorClass container
+ */
+ private ActorContainerClass getActorContainerClass(EObject obj) {
+ EObject ctx = obj.eContainer();
+ while (!(ctx instanceof ActorContainerClass) && ctx.eContainer()!=null)
+ ctx = ctx.eContainer();
+ if (ctx instanceof ActorContainerClass)
+ return (ActorContainerClass) ctx;
+
+ return null;
+ }
+
+ /**
+ * first container of type {@link ProtocolClass}
+ * @param obj
+ * @return ActorClass container
+ */
+ private ProtocolClass getProtocolClass(EObject obj) {
+ EObject ctx = obj.eContainer();
+ while (!(ctx instanceof ProtocolClass) && ctx.eContainer()!=null)
+ ctx = ctx.eContainer();
+ if (ctx instanceof ProtocolClass)
+ return (ProtocolClass) ctx;
+
+ return null;
+ }
+
+ /**
+ * check whether port is referenced by external port
+ * @param p - port to be checked
+ * @param ports - list of external ports
+ * @return true if contained
+ */
+ private boolean isContained(Port p, EList<ExternalPort> ports) {
+ for (ExternalPort port : ports) {
+ if (port.getIfport()==p)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * recursively collect all {@link BaseState}s of an actor class in a list
+ * @param ac
+ * @param states
+ */
+ private void collectAllStates(ActorClass ac,
+ LinkedList<BaseState> states) {
+ while (ac!=null) {
+ collectStates(ac.getStateMachine(), states);
+ ac = ac.getBase();
+ }
+ }
+
+ private void collectStates(StateGraph sg,
+ LinkedList<BaseState> states) {
+
+ if (sg==null)
+ return;
+
+ for (State s : sg.getStates()) {
+ if (s instanceof BaseState)
+ states.add((BaseState) s);
+ }
+ for (State s : sg.getStates()) {
+ collectStates(s.getSubgraph(), states);
+ }
+ }
+
+ /**
+ * compute the path of a {@link BaseState}
+ * @param bs
+ * @return the path
+ */
+ private String getStatePath(BaseState bs) {
+ EObject parent = bs.eContainer().eContainer();
+ if (parent instanceof BaseState)
+ return getStatePath((BaseState) parent)+STATE_PATH_DELIMITER+bs.getName();
+ else if (parent instanceof RefinedState) {
+ BaseState base = ((RefinedState) parent).getBase();
+ if (base!=null)
+ return getStatePath(base)+STATE_PATH_DELIMITER+bs.getName();
+ }
+ return bs.getName();
+ }
+
+ /**
+ * return a list of base classes of an {@link ActorClass}, parent classes first.
+ * The list includes the class itself
+ * @param ac
+ * @return
+ */
+ private LinkedList<ActorClass> getBaseClasses(ActorClass ac) {
+ LinkedList<ActorClass> classes = new LinkedList<ActorClass>();
+ if (ac!=null) {
+ classes.addFirst(ac);
+ while (ac.getBase()!=null) {
+ ac = ac.getBase();
+ classes.addFirst(ac);
+ }
+ }
+ return classes;
+ }
+
+ /**
+ * return a list of base classes of an {@link ProtocolClass}, parent classes first.
+ * The list includes the class itself
+ * @param pc
+ * @return
+ */
+ private LinkedList<ProtocolClass> getBaseClasses(ProtocolClass pc) {
+ LinkedList<ProtocolClass> classes = new LinkedList<ProtocolClass>();
+ classes.addFirst(pc);
+ while (pc.getBase()!=null) {
+ pc = pc.getBase();
+ classes.addFirst(pc);
+ }
+ return classes;
+ }
+
+ /**
+ * return the {@link BaseState} of a {@link State}
+ * @param s
+ * @return the state itself if a BaseState or the BaseState for a {@link RefinedState}
+ */
+ private BaseState getBaseState(State s) {
+ if (s instanceof BaseState)
+ return (BaseState) s;
+ else if (s instanceof RefinedState)
+ return ((RefinedState) s).getBase();
+ else
+ return null;
+ }
+
+ private IScope getStateScopes(EObject obj) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ // first state in container hierarchy
+ StateGraph parent = getStateGraph(obj);
+
+ // collect states of my parent
+ if (parent!=null) {
+ for (State s : parent.getStates()) {
+ BaseState bs = getBaseState(s);
+ scopes.add(EObjectDescription.create(bs.getName(), bs));
+ }
+
+ // if my parent is a refined state we also add its base state contents
+ if (parent.eContainer() instanceof RefinedState) {
+ parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph();
+ if (parent!=null)
+ for (State s : parent.getStates()) {
+ BaseState bs = getBaseState(s);
+ scopes.add(EObjectDescription.create(bs.getName(), bs));
+ }
+ }
+ else if (parent.eContainer() instanceof ActorClass) {
+ ActorClass ac = (ActorClass) parent.eContainer();
+ if (ac.getBase()!=null) {
+ for (State s : ac.getBase().getStateMachine().getStates()) {
+ BaseState bs = getBaseState(s);
+ scopes.add(EObjectDescription.create(bs.getName(), bs));
+ }
+ }
+ }
+ }
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of State scopes for a {@link StateTerminal}
+ * @param st - the transition endpoint or terminal
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_StateTerminal_state(StateTerminal st, EReference ref) {
+ return getStateScopes(st);
+ }
+
+ /**
+ * returns a flat list of TransitionPoint scopes for a {@link TrPointTerminal}
+ * @param ep - the transition endpoint or terminal
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_TrPointTerminal_trPoint(TrPointTerminal ep, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ StateGraph parent = getStateGraph(ep);
+ StateGraph targetStateGraph = parent;
+
+ getTrPointScopes(scopes, targetStateGraph);
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of TransitionPoint scopes for a {@link SubStateTrPointTerminal}
+ * @param ep - the transition endpoint or terminal
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_SubStateTrPointTerminal_trPoint(SubStateTrPointTerminal ep, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ StateGraph parent = getStateGraph(ep);
+ StateGraph targetStateGraph = parent;
+ if (ep.getState()!=null) {
+ targetStateGraph = ep.getState().getSubgraph(); // always a BaseState
+
+ // if one of our siblings is a RefinedState of our target we take that as target
+ for (State sibling : parent.getStates()) {
+ if (sibling instanceof RefinedState) {
+ if (((RefinedState)sibling).getBase()==ep.getState())
+ targetStateGraph = sibling.getSubgraph();
+ }
+ }
+ }
+
+ getTrPointScopes(scopes, targetStateGraph);
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ private void getTrPointScopes(final List<IEObjectDescription> scopes,
+ StateGraph sg) {
+
+ // collect transition points of this state
+ for (TrPoint tp : sg.getTrPoints()) {
+ scopes.add(EObjectDescription.create(tp.getName(), tp));
+ }
+
+ // if this state is a refined state we also add its base state transition points
+ if (sg.eContainer() instanceof RefinedState) {
+ sg = ((RefinedState) sg.eContainer()).getBase().getSubgraph();
+ if (sg!=null)
+ for (TrPoint tp : sg.getTrPoints()) {
+ scopes.add(EObjectDescription.create(tp.getName(), tp));
+ }
+ }
+ }
+
+ /**
+ * returns a flat list of State scopes for a {@link SubStateTrPointTerminal}
+ * @param st - the transition endpoint or terminal
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_SubStateTrPointTerminal_state(SubStateTrPointTerminal st, EReference ref) {
+ return getStateScopes(st);
+ }
+
+ /**
+ * returns a flat list of Choicepoint scopes for a {@link SubStateTrPointTerminal}
+ * @param ct - the transition endpoint or terminal
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_ChoicepointTerminal_cp(ChoicepointTerminal ct, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ // first state in container hierarchy
+ StateGraph parent = getStateGraph(ct);
+
+ // collect choicepoints of my parent
+ if (parent!=null)
+ for (ChoicePoint cp : parent.getChPoints()) {
+ scopes.add(EObjectDescription.create(cp.getName(), cp));
+ }
+
+ // if my parent is a refined state we also add its base state contents
+ if (parent.eContainer() instanceof RefinedState) {
+ parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph();
+ if (parent!=null)
+ for (ChoicePoint cp : parent.getChPoints()) {
+ scopes.add(EObjectDescription.create(cp.getName(), cp));
+ }
+ }
+ else if (parent.eContainer() instanceof ActorClass) {
+ ActorClass ac = (ActorClass) parent.eContainer();
+ if (ac.getBase()!=null) {
+ for (ChoicePoint cp : ac.getBase().getStateMachine().getChPoints()) {
+ scopes.add(EObjectDescription.create(cp.getName(), cp));
+ }
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of Message scopes for a {@link MessageFromIf}
+ * @param mfi - the message from interface
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_MessageFromIf_message(MessageFromIf mfi, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ InterfaceItem item = mfi.getFrom();
+ if (item!=null) {
+ ProtocolClass protocol = item.getProtocol();
+ boolean conjugated = false;
+ if (item instanceof Port)
+ conjugated = ((Port)item).isConjugated();
+ else if (item instanceof SAPRef)
+ conjugated = true;
+ for (Message msg : conjugated?protocol.getOutgoingMessages():protocol.getIncomingMessages()) {
+ scopes.add(EObjectDescription.create(msg.getName(), msg));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of Port scopes for a {@link MessageFromIf}
+ * @param mfi - the message from interface
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_MessageFromIf_port(MessageFromIf mfi, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorClass ac = getActorClass(mfi);
+ for (Port p : ac.getIntPorts()) {
+ scopes.add(EObjectDescription.create(p.getName(), p));
+ }
+ for (ExternalPort p : ac.getExtPorts()) {
+ scopes.add(EObjectDescription.create(p.getIfport().getName(), p.getIfport()));
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of InterfaceItem scopes for a {@link MessageFromIf}
+ * @param mfi - the message from interface
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_MessageFromIf_from(MessageFromIf mfi, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorClass ac = getActorClass(mfi);
+ LinkedList<ActorClass> classes = getBaseClasses(ac);
+ LinkedList<InterfaceItem> items = new LinkedList<InterfaceItem>();
+
+ // for all base classes
+ for (ActorClass a : classes) {
+ // add internal ports
+ items.addAll(a.getIntPorts());
+
+ // add service implementations and saps
+ for (ServiceImplementation ispp : a.getServiceImplementations()) {
+ items.add(ispp.getSpp());
+ }
+ items.addAll(a.getStrSAPs());
+
+ // add external end ports
+ for (ExternalPort p : a.getExtPorts()) {
+ items.add(p.getIfport());
+ }
+ }
+
+ for (InterfaceItem item : items) {
+ scopes.add(EObjectDescription.create(item.getName(), item));
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of ActorRef scopes for a {@link BindingEndPoint}
+ * @param ep - the endpoint
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_BindingEndPoint_actorRef(BindingEndPoint ep, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorContainerClass sc = getActorContainerClass(ep);
+ if (sc instanceof ActorClass) {
+ LinkedList<ActorClass> classes = getBaseClasses((ActorClass)sc);
+ for (ActorClass a : classes) {
+ for (ActorRef ar : a.getActorRefs()) {
+ scopes.add(EObjectDescription.create(ar.getName(), ar));
+ }
+ }
+ }
+ else {
+ for (ActorRef ar : sc.getActorRefs()) {
+ scopes.add(EObjectDescription.create(ar.getName(), ar));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of Port scopes for a {@link BindingEndPoint}
+ * @param ep - the endpoint
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_BindingEndPoint_port(BindingEndPoint ep, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorContainerClass acc = getActorContainerClass(ep);
+
+ if (ep.getActorRef() == null){
+ if (acc instanceof ActorClass) {
+ ActorClass ac = (ActorClass) acc;
+ // for all super classes (including this class)
+ LinkedList<ActorClass> classes = getBaseClasses(ac);
+ for (ActorClass a : classes) {
+ // collect internal and relay ports, i.e.
+ // structure ports not in interface (internal)
+ for (Port p : a.getIntPorts()) {
+ scopes.add(EObjectDescription.create(p.getName(), p));
+ }
+ // interface ports not in structure (relay)
+ for (Port p : a.getIfPorts()) {
+ if (!isContained(p, a.getExtPorts()))
+ scopes.add(EObjectDescription.create(p.getName(), p));
+ }
+ }
+ }
+ else {
+ // SubSystemClass has no internal end ports
+ }
+ }
+ else {
+ // all ports in the sub actor's interface
+ if (ep.getActorRef() instanceof ActorRef) {
+ ActorClass ac = ((ActorRef)ep.getActorRef()).getType();
+ LinkedList<ActorClass> classes = getBaseClasses(ac);
+ for (ActorClass a : classes) {
+ for (Port p : a.getIfPorts()) {
+ scopes.add(EObjectDescription.create(p.getName(), p));
+ }
+ }
+ }
+ else {
+ SubSystemClass ssc = ((SubSystemRef)ep.getActorRef()).getType();
+ for (Port p : ssc.getRelayPorts()) {
+ scopes.add(EObjectDescription.create(p.getName(), p));
+ }
+ }
+ }
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of BaseState scopes for a {@link RefinedState}
+ * @param rs - the refined state
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_RefinedState_base(RefinedState rs, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorClass ac = getActorClass(rs);
+ LinkedList<BaseState> states = new LinkedList<BaseState>();
+ collectAllStates(ac.getBase(), states);
+ for (BaseState bs : states) {
+ scopes.add(EObjectDescription.create(getStatePath(bs), bs));
+ }
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of Message scopes for a {@link SemanticsInRule}
+ * @param sr - the semantics rule for incoming messages
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_SemanticsInRule_msg(SemanticsInRule sr, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ProtocolClass pc = getProtocolClass(sr);
+ LinkedList<ProtocolClass> classes = getBaseClasses(pc);
+ for (ProtocolClass bpc : classes) {
+ for (Message m : bpc.getIncomingMessages()) {
+ scopes.add(EObjectDescription.create(m.getName(), m));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of Message scopes for a {@link SemanticsInRule}
+ * @param sr - the semantics rule for incoming messages
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_SemanticsOutRule_msg(SemanticsOutRule sr, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ProtocolClass pc = getProtocolClass(sr);
+ LinkedList<ProtocolClass> classes = getBaseClasses(pc);
+ for (ProtocolClass bpc : classes) {
+ for (Message m : bpc.getOutgoingMessages()) {
+ scopes.add(EObjectDescription.create(m.getName(), m));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of ActorRef scopes for a {@link SubActorSAPoint}
+ * @param pt
+ * @param ref
+ * @return a list of scopes
+ */
+ public IScope scope_RefSAPoint_ref(RefSAPoint pt, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorContainerClass acc = getActorContainerClass(pt);
+ if (acc instanceof ActorClass) {
+ LinkedList<ActorClass> classes = getBaseClasses((ActorClass) acc);
+ for (ActorClass a : classes) {
+ for (ActorRef ar : a.getActorRefs()) {
+ scopes.add(EObjectDescription.create(ar.getName(), ar));
+ }
+ }
+ }
+ else {
+ for (ActorRef ar : acc.getActorRefs()) {
+ scopes.add(EObjectDescription.create(ar.getName(), ar));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of SPPRef scopes for a {@link RelaySAPoint}
+ * @param pt
+ * @param ref
+ * @return a list of scopes
+ */
+ public IScope scope_RelaySAPoint_relay(RelaySAPoint pt, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorClass ac = getActorClass(pt);
+ LinkedList<ActorClass> classes = getBaseClasses(ac);
+ for (ActorClass a : classes) {
+ for (SPPRef spp : a.getIfSPPs()) {
+ scopes.add(EObjectDescription.create(spp.getName(), spp));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of ActorRef scopes for a {@link SPPoint}
+ * @param pt
+ * @param ref
+ * @return a list of scopes
+ */
+ public IScope scope_SPPoint_actorRef(SPPoint pt, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorContainerClass acc = getActorContainerClass(pt);
+ if (acc instanceof ActorClass) {
+ LinkedList<ActorClass> classes = getBaseClasses((ActorClass)acc);
+ for (ActorClass a : classes) {
+ for (ActorRef ar : a.getActorRefs()) {
+ scopes.add(EObjectDescription.create(ar.getName(), ar));
+ }
+ }
+ }
+ else {
+ for (ActorRef ar : acc.getActorRefs()) {
+ scopes.add(EObjectDescription.create(ar.getName(), ar));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /**
+ * returns a flat list of SPPRef scopes for a {@link SPPoint}
+ * @param pt
+ * @param ref
+ * @return a list of scopes
+ */
+ public IScope scope_SPPoint_service(SPPoint pt, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ if (pt.getRef()!=null) {
+ if (pt.getRef() instanceof ActorRef) {
+ ActorClass ac = ((ActorRef)pt.getRef()).getType();
+ LinkedList<ActorClass> classes = getBaseClasses(ac);
+ for (ActorClass a : classes) {
+ for (SPPRef spp : a.getIfSPPs()) {
+ scopes.add(EObjectDescription.create(spp.getName(), spp));
+ }
+ }
+ }
+ else if (pt.getRef() instanceof SubSystemRef) {
+ SubSystemClass ssc = ((SubSystemRef)pt.getRef()).getType();
+ for (SPPRef spp : ssc.getIfSPPs()) {
+ scopes.add(EObjectDescription.create(spp.getName(), spp));
+ }
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ public IScope scope_MessageHandler_msg(MessageHandler handler, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ProtocolClass pc = getProtocolClass(handler);
+ if (pc!=null) {
+ for (Message m : pc.getIncomingMessages()) {
+ scopes.add(EObjectDescription.create(m.getName(), m));
+ }
+ for (Message m : pc.getOutgoingMessages()) {
+ scopes.add(EObjectDescription.create(m.getName(), m));
+ }
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+
+ /*
+ * we prefer loose scoping here and rely on validation for meaningful error messages
+ *
+ * returns a flat list of ActorClass scopes for a {@link ActorRef}
+ * @param ar - the actor reference
+ * @param ref - not used
+ * @return a list of scopes
+ */
+// public IScope scope_ActorRef_type(ActorRef ar, EReference ref) {
+// ActorClass ac = getActorClass(ar);
+// IScope scope = delegateGetScope(ar, ref);
+// return new FilteringScope(scope, new ActorRefFilter(ac));
+// }
+
+ /**
+ * returns a flat list of Port scopes for a {@link ExternalPort}
+ * @param ar - the external port
+ * @param ref - not used
+ * @return a list of scopes
+ */
+ public IScope scope_ExternalPort_ifport(ExternalPort ep, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ ActorClass ac = getActorClass(ep);
+ for (Port ip : ac.getIfPorts()) {
+ scopes.add(EObjectDescription.create(ip.getName(), ip));
+ }
+
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }
+ /**
+ * returns a flat list of Port scopes for a {@link ExternalPort}
+ * @param ar - the external port
+ * @param ref - not used
+ * @return a list of scopes
+ */
+// public IScope scope_ActorInstance_segments(ActorInstance ai, EReference ref) {
+// final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+//
+// if (ai.getSegments().isEmpty()) {
+// // context is my ActorContainerClass
+// ActorContainerClass acc = getActorContainerClass(ai);
+// for (ActorRef ar : acc.getActorRefs()) {
+// scopes.add(EObjectDescription.create(ar.getName(), ar));
+// }
+// }
+// else {
+// // context is actor class of last segment
+// ActorClass ac = ai.getSegments().get(ai.getSegments().size()-1).getType();
+// for (ActorRef ar : ac.getActorRefs()) {
+// scopes.add(EObjectDescription.create(ar.getName(), ar));
+// }
+// }
+//
+// return new SimpleScope(IScope.NULLSCOPE, scopes);
+// }
+
+ /*
+ public IScope scope_ChoicePointCaseRef_case(ChoicePointCaseRef cr, EReference ref) {
+ final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();
+
+ if (cr.getCp()!=null) {
+ for (ChoicePointCase cas : cr.getCp().getCases()) {
+ scopes.add(EObjectDescription.create(cas.getName(), cas));
+ }
+ }
+ return new SimpleScope(IScope.NULLSCOPE, scopes);
+ }*/
+}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java index 4adecce26..33245648e 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java @@ -20,6 +20,7 @@ import org.eclipse.etrice.core.room.ActorInstancePath; import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.Binding;
import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.LayerConnection;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomClass;
@@ -124,4 +125,10 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator { if (!ValidationUtil.isValid(tp))
error(ValidationUtil.getErrorMessage(), RoomPackage.TR_POINT);
}
+
+ @Check
+ public void checkInterfaceItemUniqueName(InterfaceItem item) {
+ if (!ValidationUtil.isUniqueName(item))
+ error(ValidationUtil.getErrorMessage(), RoomPackage.INTERFACE_ITEM__NAME);
+ }
}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java index 69bc3e861..7738f9855 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java @@ -12,6 +12,8 @@ package org.eclipse.etrice.core.validation;
+import java.util.ArrayList;
+
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.ActorContainerRef;
@@ -23,6 +25,7 @@ import org.eclipse.etrice.core.room.EntryPoint; import org.eclipse.etrice.core.room.ExitPoint;
import org.eclipse.etrice.core.room.ExternalPort;
import org.eclipse.etrice.core.room.InitialTransition;
+import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.LayerConnection;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.ProtocolClass;
@@ -496,4 +499,27 @@ public class ValidationUtil { return error("entry and exit points forbidden on top level state graph");
}
+
+ public static boolean isUniqueName(InterfaceItem item) {
+ if (item.eContainer() instanceof ActorClass) {
+ ArrayList<InterfaceItem> all = new ArrayList<InterfaceItem>();
+ ActorClass ac = (ActorClass) item.eContainer();
+ while (ac.getBase()!=null) {
+ ac = ac.getBase();
+ all.addAll(ac.getIfPorts());
+ all.addAll(ac.getIntPorts());
+ all.addAll(ac.getIfSPPs());
+ all.addAll(ac.getStrSAPs());
+ }
+ for (InterfaceItem ii : all) {
+ if (ii!=item && ii.getName().equals(item.getName())) {
+ return error("name already used in base class "+((ActorClass)ii.eContainer()).getName());
+ }
+ }
+ }
+ // else
+ // we don't have to check SubSystemClasses since this is done by xtext (standard namespace)
+
+ return true;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.java/.gitignore b/plugins/org.eclipse.etrice.generator.java/.gitignore index ba077a403..092357e47 100644 --- a/plugins/org.eclipse.etrice.generator.java/.gitignore +++ b/plugins/org.eclipse.etrice.generator.java/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF index 2f18570af..a3bf59bf7 100644 --- a/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.etrice.generator.java/META-INF/MANIFEST.MF @@ -1,21 +1,21 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: eTrice Java Generator -Bundle-Vendor: eTrice (Incubation) -Bundle-Version: 0.1.0 -Bundle-SymbolicName: org.eclipse.etrice.generator.java; singleton:=true -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0";visibility:=reexport, - org.eclipse.etrice.generator;bundle-version="0.1.0", - org.eclipse.xpand;bundle-version="1.0.1";visibility:=reexport, - org.eclipse.xtend;bundle-version="1.0.1";visibility:=reexport, - org.eclipse.xtext;bundle-version="1.0.1";visibility:=reexport, - org.eclipse.emf.mwe2.launch;bundle-version="1.0.1";resolution:=optional, - org.eclipse.emf.mwe.utils;bundle-version="1.0.0";visibility:=reexport, - org.eclipse.xtend.typesystem.emf;bundle-version="1.0.1";visibility:=reexport, - org.eclipse.xtend.util.stdlib;bundle-version="1.0.1", - org.eclipse.jdt.core;bundle-version="3.6.0", - org.eclipse.core.resources;bundle-version="3.6.0", - org.eclipse.core.runtime;bundle-version="3.6.0" -Import-Package: org.apache.log4j -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eTrice Java Generator
+Bundle-Vendor: eTrice (Incubation)
+Bundle-Version: 0.1.0
+Bundle-SymbolicName: org.eclipse.etrice.generator.java; singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0";visibility:=reexport,
+ org.eclipse.etrice.generator;bundle-version="0.1.0",
+ org.eclipse.xpand;bundle-version="1.0.1";visibility:=reexport,
+ org.eclipse.xtend;bundle-version="1.0.1";visibility:=reexport,
+ org.eclipse.xtext;bundle-version="1.0.1";visibility:=reexport,
+ org.eclipse.emf.mwe2.launch;bundle-version="1.0.1";resolution:=optional,
+ org.eclipse.emf.mwe.utils;bundle-version="1.0.0";visibility:=reexport,
+ org.eclipse.xtend.typesystem.emf;bundle-version="1.0.1";visibility:=reexport,
+ org.eclipse.xtend.util.stdlib;bundle-version="1.0.1",
+ org.eclipse.jdt.core;bundle-version="3.6.0",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0"
+Import-Package: org.apache.log4j
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.etrice.generator.java/build.properties b/plugins/org.eclipse.etrice.generator.java/build.properties index 81aa74d8a..f71c22ce7 100644 --- a/plugins/org.eclipse.etrice.generator.java/build.properties +++ b/plugins/org.eclipse.etrice.generator.java/build.properties @@ -1,4 +1,4 @@ -source.. = src/ -bin.includes = META-INF/,\ - . -jre.compilation.profile = JavaSE-1.6 +source.. = src/
+bin.includes = META-INF/,\
+ .
+jre.compilation.profile = JavaSE-1.6
diff --git a/plugins/org.eclipse.etrice.generator.java/src/templates/Main.xpt b/plugins/org.eclipse.etrice.generator.java/src/templates/Main.xpt index 185e57081..a39935a27 100644 --- a/plugins/org.eclipse.etrice.generator.java/src/templates/Main.xpt +++ b/plugins/org.eclipse.etrice.generator.java/src/templates/Main.xpt @@ -1,23 +1,23 @@ -«REM» -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ -«ENDREM» -«IMPORT room»; -«IMPORT etricegen» - -«DEFINE main FOR Root-» - «EXPAND DataClass::dataClass FOR this» - «EXPAND ProtocolClass::protocolClass FOR this» - «EXPAND ActorClass::actorClass FOR this» - «EXPAND SubSystemClass::subSystemClass FOR this» - «EXPAND SubSystemRunner::subSystemRunner FOR this» -«ENDDEFINE» +«REM»
+/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+«ENDREM»
+«IMPORT room»;
+«IMPORT etricegen»
+
+«DEFINE main FOR Root-»
+ «EXPAND DataClass::dataClass FOR this»
+ «EXPAND ProtocolClass::protocolClass FOR this»
+ «EXPAND ActorClass::actorClass FOR this»
+ «EXPAND SubSystemClass::subSystemClass FOR this»
+ «EXPAND SubSystemRunner::subSystemRunner FOR this»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.etrice.generator.java/src/workflow/RoomGenerator.mwe2 b/plugins/org.eclipse.etrice.generator.java/src/workflow/RoomGenerator.mwe2 index 2f5957f50..d89ead5b5 100644 --- a/plugins/org.eclipse.etrice.generator.java/src/workflow/RoomGenerator.mwe2 +++ b/plugins/org.eclipse.etrice.generator.java/src/workflow/RoomGenerator.mwe2 @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -module workflow.RoomGenerator - -import org.eclipse.emf.mwe.utils.* - -var sourceDir = "" -var targetDir = "" -var fileEncoding = "Cp1252" - -Workflow { - - component = org.eclipse.xtext.mwe.Reader { - // lookup all resources on the classpath - // useJavaClassPath = true - - // or define search scope explicitly - path = sourceDir - useJavaClassPath=true - - // this class will be generated by the xtext generator - register = org.eclipse.etrice.core.RoomStandaloneSetup {} - load = { - slot = "model" - - // HOWTO: feed top level object into generator - // Sven Efftinge in news://news.eclipse.org:119/hlh0ju$if8$1@build.eclipse.org: - // "The new reader is based on EObjectDescriptions, which are by default only available and created for elements, which have a name." - // ==> Therefore we introduced a name for the model in Room.xtext - type = "RoomModel" - } - } - - // HOWTO: call a custom workflow component - component = org.eclipse.etrice.generator.workflow.InstanceModelCreator { - inSlot = "model" - outSlot = "instance_model" - debug = true // debug flag for verbose output - save = true // save intermediate model for debugging purposes - uri = "src-gen/tmp.rim" // name of intermediate model file - } - - component = org.eclipse.xpand2.Generator { - metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {} - expand = "templates::Main::main FOREACH instance_model" - outlet = { - path = targetDir - postprocessor = org.eclipse.xpand2.output.JavaBeautifier {} - } - fileEncoding = fileEncoding - } -} +/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+module workflow.RoomGenerator
+
+import org.eclipse.emf.mwe.utils.*
+
+var sourceDir = ""
+var targetDir = ""
+var fileEncoding = "Cp1252"
+
+Workflow {
+
+ component = org.eclipse.xtext.mwe.Reader {
+ // lookup all resources on the classpath
+ // useJavaClassPath = true
+
+ // or define search scope explicitly
+ path = sourceDir
+ useJavaClassPath=true
+
+ // this class will be generated by the xtext generator
+ register = org.eclipse.etrice.core.RoomStandaloneSetup {}
+ load = {
+ slot = "model"
+
+ // HOWTO: feed top level object into generator
+ // Sven Efftinge in news://news.eclipse.org:119/hlh0ju$if8$1@build.eclipse.org:
+ // "The new reader is based on EObjectDescriptions, which are by default only available and created for elements, which have a name."
+ // ==> Therefore we introduced a name for the model in Room.xtext
+ type = "RoomModel"
+ }
+ }
+
+ // HOWTO: call a custom workflow component
+ component = org.eclipse.etrice.generator.workflow.InstanceModelCreator {
+ inSlot = "model"
+ outSlot = "instance_model"
+ debug = true // debug flag for verbose output
+ save = true // save intermediate model for debugging purposes
+ uri = "src-gen/tmp.rim" // name of intermediate model file
+ }
+
+ component = org.eclipse.xpand2.Generator {
+ metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
+ expand = "templates::Main::main FOREACH instance_model"
+ outlet = {
+ path = targetDir
+ postprocessor = org.eclipse.xpand2.output.JavaBeautifier {}
+ }
+ fileEncoding = fileEncoding
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/.gitignore b/plugins/org.eclipse.etrice.generator/.gitignore index ba077a403..092357e47 100644 --- a/plugins/org.eclipse.etrice.generator/.gitignore +++ b/plugins/org.eclipse.etrice.generator/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.classpath b/plugins/org.eclipse.etrice.ui.behavior/.classpath index ad32c83a7..8a8f1668c 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/.classpath +++ b/plugins/org.eclipse.etrice.ui.behavior/.classpath @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.project b/plugins/org.eclipse.etrice.ui.behavior/.project index de09fb560..ee8bca729 100644 --- a/plugins/org.eclipse.etrice.ui.behavior/.project +++ b/plugins/org.eclipse.etrice.ui.behavior/.project @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.etrice.ui.behavior</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.ui.behavior</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.ui.common/.classpath b/plugins/org.eclipse.etrice.ui.common/.classpath index ad32c83a7..8a8f1668c 100644 --- a/plugins/org.eclipse.etrice.ui.common/.classpath +++ b/plugins/org.eclipse.etrice.ui.common/.classpath @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.ui.common/.project b/plugins/org.eclipse.etrice.ui.common/.project index a0274dc33..63e3c3a0b 100644 --- a/plugins/org.eclipse.etrice.ui.common/.project +++ b/plugins/org.eclipse.etrice.ui.common/.project @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.etrice.ui.common</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.ui.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.ui.structure/.gitignore b/plugins/org.eclipse.etrice.ui.structure/.gitignore index ba077a403..092357e47 100644 --- a/plugins/org.eclipse.etrice.ui.structure/.gitignore +++ b/plugins/org.eclipse.etrice.ui.structure/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF index 1b3ef155f..09523cf95 100644 --- a/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF @@ -22,4 +22,5 @@ Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0", org.eclipse.emf.transaction;bundle-version="1.4.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.etrice.ui.structure
+Export-Package: org.eclipse.etrice.ui.structure,
+ org.eclipse.etrice.ui.structure.support;x-friends:="org.eclipse.etrice.ui.structure.tests"
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java index 704d9f6f2..cc710c56a 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java @@ -12,6 +12,7 @@ package org.eclipse.etrice.ui.structure;
+import java.io.File;
import java.io.IOException;
import java.util.Collections;
@@ -48,21 +49,36 @@ public class DiagramAccess { return null;
URI uri = resource.getURI();
- if (!uri.isPlatformResource())
- return null;
- uri = uri.trimSegments(1);
- IFolder parentFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(uri.toPlatformString(true)));
-
- IFolder diagramFolder = parentFolder.getFolder(DIAGRAMS_FOLDER_NAME);
+ // TODOHRR: put common diagram access code into ui.common
+ // make abstract methods get fileEtension() and populateDiagram()
- RoomModel model = (RoomModel) sc.eContainer();
+ String modelName = ((RoomModel) sc.eContainer()).getName();
- IFile diagramFile = diagramFolder.getFile(model.getName()+"."+sc.getName()+".structure");
- URI diagURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
+ URI diagURI = null;
+ boolean exists = false;
+ if (uri.isPlatformResource()) {
+ uri = uri.trimSegments(1);
+ IFolder parentFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(uri.toPlatformString(true)));
+ IFolder diagramFolder = parentFolder.getFolder(DIAGRAMS_FOLDER_NAME);
+
+ IFile diagramFile = diagramFolder.getFile(modelName+"."+sc.getName()+".structure");
+ diagURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
+ exists = diagramFile.exists();
+ }
+ else {
+ uri = uri.trimSegments(1);
+ File diagramFile = new File(uri.toFileString());
+ diagramFile = new File(diagramFile.getParent()
+ +File.separator+DIAGRAMS_FOLDER_NAME
+ +File.separator+modelName+"."+sc.getName()+".structure");
+ diagURI = URI.createFileURI(diagramFile.getPath());
+ exists = diagramFile.exists();
+ }
+
ResourceSet rs = new ResourceSetImpl();
- if (diagramFile.exists()) {
+ if (exists) {
Resource diagRes = rs.getResource(diagURI, true);
if (diagRes.getContents().isEmpty())
return null;
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java index 6e5867d4f..7f12e59ad 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java @@ -101,11 +101,6 @@ public class PopulateDiagramCommand extends RecordingCommand { EList<? extends ActorContainerRef> subSystems = sys.getSubSystems();
addRefItems(subSystems, acShape, width, featureProvider, ifitem2anchor);
}
-
- // bindings
- for (Binding bind : sc.getBindings()) {
- addBinding(bind, featureProvider, ifitem2anchor);
- }
// layer connections
for (LayerConnection lc : sc.getConnections()) {
@@ -120,6 +115,11 @@ public class PopulateDiagramCommand extends RecordingCommand { if (base!=null)
addInheritedItems(base, acShape, ifitem2anchor, featureProvider);
}
+
+ // bindings
+ for (Binding bind : sc.getBindings()) {
+ addBinding(bind, featureProvider, ifitem2anchor);
+ }
}
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java index d4ed3000b..d76f93941 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java @@ -24,6 +24,7 @@ import org.eclipse.etrice.ui.structure.dialogs.ActorContainerRefPropertyDialog; import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateFeature;
+import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.ILayoutFeature;
import org.eclipse.graphiti.features.IMoveShapeFeature;
@@ -34,6 +35,7 @@ import org.eclipse.graphiti.features.IUpdateFeature; import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateContext;
import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.IDoubleClickContext;
import org.eclipse.graphiti.features.context.ILayoutContext;
import org.eclipse.graphiti.features.context.IMoveShapeContext;
@@ -48,6 +50,7 @@ import org.eclipse.graphiti.features.impl.AbstractCreateFeature; import org.eclipse.graphiti.features.impl.AbstractLayoutFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.features.impl.DefaultMoveShapeFeature;
+import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature;
import org.eclipse.graphiti.features.impl.Reason;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
@@ -66,6 +69,7 @@ import org.eclipse.graphiti.services.IPeCreateService; import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.ui.features.AbstractDrillDownFeature;
+import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
@@ -92,9 +96,9 @@ public class ActorContainerRefSupport { public static final int MIN_SIZE_Y = 60;
public static final int MARGIN = 20;
- private static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
- private static final IColorConstant INHERITED_COLOR = new ColorConstant(100, 100, 100);
- private static final IColorConstant BACKGROUND = new ColorConstant(200, 200, 200);
+ public static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
+ public static final IColorConstant INHERITED_COLOR = new ColorConstant(100, 100, 100);
+ public static final IColorConstant BACKGROUND = new ColorConstant(200, 200, 200);
private static class FeatureProvider extends DefaultFeatureProvider {
@@ -345,7 +349,8 @@ public class ActorContainerRefSupport { if (pes != null && pes.length == 1) {
Object bo = getBusinessObjectForPictogramElement(pes[0]);
if (bo instanceof ActorContainerRef) {
- return true;
+ EObject parent = (EObject) getBusinessObjectForPictogramElement((PictogramElement) pes[0].eContainer());
+ return !isInherited((ActorContainerRef)bo, parent);
}
}
return false;
@@ -544,6 +549,39 @@ public class ActorContainerRefSupport { }
}
+ private class RemoveFeature extends DefaultRemoveFeature {
+
+ public RemoveFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canRemove(IRemoveContext context) {
+ return false;
+ }
+ }
+
+ private class DeleteFeature extends DefaultDeleteFeature {
+
+ public DeleteFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canDelete(IDeleteContext context) {
+ Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement());
+
+ if (bo instanceof ActorContainerRef) {
+ ActorContainerRef ar = (ActorContainerRef) bo;
+ ContainerShape acShape = (ContainerShape) context.getPictogramElement().eContainer();
+ EObject parent = acShape.getLink().getBusinessObjects().get(0);
+ return !isInherited(ar, parent);
+ }
+
+ return false;
+ }
+ }
+
private class MoveShapeFeature extends DefaultMoveShapeFeature {
public MoveShapeFeature(IFeatureProvider fp) {
@@ -660,6 +698,16 @@ public class ActorContainerRefSupport { }
@Override
+ public IRemoveFeature getRemoveFeature(IRemoveContext context) {
+ return new RemoveFeature(fp);
+ }
+
+ @Override
+ public IDeleteFeature getDeleteFeature(IDeleteContext context) {
+ return new DeleteFeature(fp);
+ }
+
+ @Override
public ICustomFeature[] getCustomFeatures(ICustomContext context) {
return new ICustomFeature[] { new PropertyFeature(fp), new DrillDownFeature(fp) };
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java index c6a78575c..206a16aa4 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java @@ -19,6 +19,7 @@ import org.eclipse.etrice.ui.structure.ImageProvider; import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
+import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.IReason;
import org.eclipse.graphiti.features.IRemoveFeature;
@@ -26,6 +27,7 @@ import org.eclipse.graphiti.features.IUpdateFeature; import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
@@ -33,17 +35,20 @@ import org.eclipse.graphiti.features.context.impl.RemoveContext; import org.eclipse.graphiti.features.impl.AbstractAddFeature;
import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
+import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.features.impl.Reason;
import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeCreateService;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
@@ -61,7 +66,8 @@ import org.eclipse.etrice.core.room.SubSystemClass; public class BindingSupport {
- private static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
+ public static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
+ public static final IColorConstant INHERITED_COLOR = new ColorConstant(100, 100, 100);
class FeatureProvider extends DefaultFeatureProvider {
@@ -231,6 +237,8 @@ public class BindingSupport { IAddConnectionContext addConContext = (IAddConnectionContext) context;
Binding addedEReference = (Binding) context.getNewObject();
+ boolean inherited = isInherited(getDiagram(), addedEReference);
+
IPeCreateService peCreateService = Graphiti.getPeCreateService();
// CONNECTION WITH POLYLINE
Connection connection = peCreateService.createFreeFormConnection(getDiagram());
@@ -241,7 +249,7 @@ public class BindingSupport { IGaService gaService = Graphiti.getGaService();
Polyline polyline = gaService.createPolyline(connection);
- polyline.setForeground(manageColor(LINE_COLOR));
+ polyline.setForeground(manageColor(inherited?INHERITED_COLOR:LINE_COLOR));
// create link and wire it
link(connection, addedEReference);
@@ -293,6 +301,37 @@ public class BindingSupport { }
}
+ private class RemoveFeature extends DefaultRemoveFeature {
+
+ public RemoveFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canRemove(IRemoveContext context) {
+ return false;
+ }
+ }
+
+ private class DeleteFeature extends DefaultDeleteFeature {
+
+ public DeleteFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canDelete(IDeleteContext context) {
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(context.getPictogramElement());
+ if (bo instanceof Binding) {
+ Binding b = (Binding) bo;
+ if (isInherited(getDiagram(), b))
+ return false;
+ }
+
+ return true;
+ }
+ }
+
private IFeatureProvider fp;
public FeatureProvider(IDiagramTypeProvider dtp, IFeatureProvider fp) {
@@ -300,6 +339,11 @@ public class BindingSupport { this.fp = fp;
}
+ private boolean isInherited(Diagram diag, Binding b) {
+ ActorClass ac = (ActorClass) Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(diag.getChildren().get(0));
+ return (b.eContainer()!=ac);
+ }
+
@Override
public ICreateConnectionFeature[] getCreateConnectionFeatures() {
return new ICreateConnectionFeature[] { new CreateFeature(fp) };
@@ -314,6 +358,16 @@ public class BindingSupport { public IUpdateFeature getUpdateFeature(IUpdateContext context) {
return new UpdateFeature(fp);
}
+
+ @Override
+ public IRemoveFeature getRemoveFeature(IRemoveContext context) {
+ return new RemoveFeature(fp);
+ }
+
+ @Override
+ public IDeleteFeature getDeleteFeature(IDeleteContext context) {
+ return new DeleteFeature(fp);
+ }
}
class BehaviorProvider extends DefaultToolBehaviorProvider {
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java index 851e5c8f5..9f1902ab2 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java @@ -417,12 +417,11 @@ public class InterfaceItemSupport { if (pes != null && pes.length == 1 && pes[0] instanceof ContainerShape) {
Object bo = getBusinessObjectForPictogramElement(pes[0]);
if (bo instanceof InterfaceItem) {
- ContainerShape container = (ContainerShape)pes[0];
- bo = getBusinessObjectForPictogramElement(container);
- if (bo instanceof ActorContainerRef)
- return false;
+ ContainerShape shape = ((ContainerShape)pes[0]).getContainer();
+ InterfaceItem item = (InterfaceItem) bo;
+ Object parentBO = getBusinessObjectForPictogramElement(shape.getContainer());
- return true;
+ return !isRefItem(shape) && !isInherited(item, parentBO, shape);
}
}
return false;
@@ -436,7 +435,7 @@ public class InterfaceItemSupport { }
public boolean canRemove(IRemoveContext context) {
- return !isRefItem(context.getPictogramElement());
+ return false;
}
}
@@ -448,7 +447,11 @@ public class InterfaceItemSupport { @Override
public boolean canDelete(IDeleteContext context) {
- return !isRefItem(context.getPictogramElement());
+ ContainerShape shape = (ContainerShape) context.getPictogramElement();
+ InterfaceItem item = (InterfaceItem) getBusinessObjectForPictogramElement(shape);
+ Object parentBO = getBusinessObjectForPictogramElement(shape.getContainer());
+
+ return !isRefItem(shape) && !isInherited(item, parentBO, shape);
}
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java index 27470c9dc..1e259305a 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/LayerConnectionSupport.java @@ -19,6 +19,7 @@ import org.eclipse.etrice.ui.structure.ImageProvider; import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
+import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.IReason;
import org.eclipse.graphiti.features.IRemoveFeature;
@@ -26,6 +27,7 @@ import org.eclipse.graphiti.features.IUpdateFeature; import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
@@ -33,6 +35,7 @@ import org.eclipse.graphiti.features.context.impl.RemoveContext; import org.eclipse.graphiti.features.impl.AbstractAddFeature;
import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
+import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.features.impl.Reason;
import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
import org.eclipse.graphiti.mm.algorithms.Polyline;
@@ -40,6 +43,7 @@ import org.eclipse.graphiti.mm.pictograms.Anchor; import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.ManhattanConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.PictogramsFactory;
@@ -48,10 +52,12 @@ import org.eclipse.graphiti.services.IGaService; import org.eclipse.graphiti.services.IPeCreateService;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
+import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerRef;
import org.eclipse.etrice.core.room.LayerConnection;
import org.eclipse.etrice.core.room.RefSAPoint;
@@ -231,6 +237,37 @@ public class LayerConnectionSupport { }
+ private class RemoveFeature extends DefaultRemoveFeature {
+
+ public RemoveFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canRemove(IRemoveContext context) {
+ return false;
+ }
+ }
+
+ private class DeleteFeature extends DefaultDeleteFeature {
+
+ public DeleteFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canDelete(IDeleteContext context) {
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(context.getPictogramElement());
+ if (bo instanceof LayerConnection) {
+ LayerConnection lc = (LayerConnection) bo;
+ if (isInherited(getDiagram(), lc))
+ return false;
+ }
+
+ return true;
+ }
+ }
+
private class UpdateFeature extends AbstractUpdateFeature {
public UpdateFeature(IFeatureProvider fp) {
@@ -280,6 +317,11 @@ public class LayerConnectionSupport { this.fp = fp;
}
+ private boolean isInherited(Diagram diag, LayerConnection lc) {
+ ActorClass ac = (ActorClass) Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(diag.getChildren().get(0));
+ return (lc.eContainer()!=ac);
+ }
+
@Override
public ICreateConnectionFeature[] getCreateConnectionFeatures() {
return new ICreateConnectionFeature[] { new CreateFeature(fp) };
@@ -291,6 +333,16 @@ public class LayerConnectionSupport { }
@Override
+ public IRemoveFeature getRemoveFeature(IRemoveContext context) {
+ return new RemoveFeature(fp);
+ }
+
+ @Override
+ public IDeleteFeature getDeleteFeature(IDeleteContext context) {
+ return new DeleteFeature(fp);
+ }
+
+ @Override
public IUpdateFeature getUpdateFeature(IUpdateContext context) {
return new UpdateFeature(fp);
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java index d1f6e702b..223d1c03a 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java @@ -147,6 +147,19 @@ public class PortSupport extends InterfaceItemSupport { }
@Override
+ public boolean canExecute(ICustomContext context) {
+ if (!super.canExecute(context))
+ return false;
+
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes != null && pes.length == 1 && pes[0] instanceof ContainerShape) {
+ Object bo = getBusinessObjectForPictogramElement(pes[0]);
+ return (bo instanceof Port);
+ }
+ return false;
+ }
+
+ @Override
public void execute(ICustomContext context) {
Object bo = getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
if (bo instanceof Port) {
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java index 3db8dab8f..d5f160d8c 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java @@ -140,6 +140,19 @@ public class SPPSupport extends InterfaceItemSupport { }
@Override
+ public boolean canExecute(ICustomContext context) {
+ if (!super.canExecute(context))
+ return false;
+
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes != null && pes.length == 1 && pes[0] instanceof ContainerShape) {
+ Object bo = getBusinessObjectForPictogramElement(pes[0]);
+ return (bo instanceof SPPRef);
+ }
+ return false;
+ }
+
+ @Override
public void execute(ICustomContext context) {
SPPRef spp = (SPPRef) getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java index 0394e5cd5..0167bb4e9 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java @@ -15,8 +15,13 @@ package org.eclipse.etrice.ui.structure.support; import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
+import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.ILayoutFeature;
import org.eclipse.graphiti.features.IReason;
@@ -24,6 +29,7 @@ import org.eclipse.graphiti.features.IRemoveFeature; import org.eclipse.graphiti.features.IResizeShapeFeature;
import org.eclipse.graphiti.features.IUpdateFeature;
import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.ILayoutContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IResizeShapeContext;
@@ -32,6 +38,7 @@ import org.eclipse.graphiti.features.context.impl.RemoveContext; import org.eclipse.graphiti.features.impl.AbstractAddFeature;
import org.eclipse.graphiti.features.impl.AbstractLayoutFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
+import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature;
import org.eclipse.graphiti.features.impl.Reason;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
@@ -45,15 +52,11 @@ import org.eclipse.graphiti.services.IGaService; import org.eclipse.graphiti.services.IPeCreateService;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.StructureClass;
-
public class StructureClassSupport {
public static final int MARGIN = 40;
@@ -319,6 +322,30 @@ public class StructureClassSupport { }
}
+ private class RemoveFeature extends DefaultRemoveFeature {
+
+ public RemoveFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canRemove(IRemoveContext context) {
+ return false;
+ }
+ }
+
+ private class DeleteFeature extends DefaultDeleteFeature {
+
+ public DeleteFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canDelete(IDeleteContext context) {
+ return false;
+ }
+ }
+
private IFeatureProvider fp;
public FeatureProvider(IDiagramTypeProvider dtp, IFeatureProvider fp) {
@@ -346,6 +373,16 @@ public class StructureClassSupport { IResizeShapeContext context) {
return new ResizeFeature(fp);
}
+
+ @Override
+ public IRemoveFeature getRemoveFeature(IRemoveContext context) {
+ return new RemoveFeature(fp);
+ }
+
+ @Override
+ public IDeleteFeature getDeleteFeature(IDeleteContext context) {
+ return new DeleteFeature(fp);
+ }
}
private class BehaviorProvider extends DefaultToolBehaviorProvider {
diff --git a/runtime/org.eclipse.etrice.runtime.java/.gitignore b/runtime/org.eclipse.etrice.runtime.java/.gitignore index ba077a403..092357e47 100644 --- a/runtime/org.eclipse.etrice.runtime.java/.gitignore +++ b/runtime/org.eclipse.etrice.runtime.java/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/team/code_style.epf b/team/code_style.epf index 2e6dfebe5..7840ae48c 100644 --- a/team/code_style.epf +++ b/team/code_style.epf @@ -1,24 +1,24 @@ -#Fri Jan 28 07:47:05 CET 2011 -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.overrideannotation=true -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.formatterprofiles.version=11 -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldSuffixes= -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\r\n * Copyright (c) 2010 protos software gmbh (http\://www.protos.de).\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * CONTRIBUTORS\:\r\n * \t\tThomas Schuetz and Henrik Rentz-Reichert (initial contribution)\r\n * \r\n *******************************************************************************/\r\n</template></templates> -\!/= -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ignorelowercasenames=true -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localSuffixes= -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes= -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localPrefixes= -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentSuffixes= -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentPrefixes= -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ondemandthreshold=99 -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.gettersetter.use.is=true -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.exception.name=e -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.importorder=java;javax;org;com; -@org.eclipse.jdt.ui=3.6.0.v20100602-1600 -/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -file_export_version=3.0 -@org.eclipse.jdt.core=3.6.0.v_A58 -/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.staticondemandthreshold=99 +#Fri Jan 28 07:47:05 CET 2011
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.overrideannotation=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.formatterprofiles.version=11
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\r\n * Copyright (c) 2010 protos software gmbh (http\://www.protos.de).\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * CONTRIBUTORS\:\r\n * \t\tThomas Schuetz and Henrik Rentz-Reichert (initial contribution)\r\n * \r\n *******************************************************************************/\r\n</template></templates>
+\!/=
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ignorelowercasenames=true
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ondemandthreshold=99
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.gettersetter.use.is=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.exception.name=e
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.importorder=java;javax;org;com;
+@org.eclipse.jdt.ui=3.6.0.v20100602-1600
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
+file_export_version=3.0
+@org.eclipse.jdt.core=3.6.0.v_A58
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.staticondemandthreshold=99
diff --git a/team/codetemplates.xml b/team/codetemplates.xml index a05a467e8..c31da858b 100644 --- a/team/codetemplates.xml +++ b/team/codetemplates.xml @@ -1,31 +1,31 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/** - * ${tags} - * ${see_to_target} - */</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc) - * ${see_to_overridden} - */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/** - * @param ${param} the ${bare_field_name} to set - */</template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/******************************************************************************* - * Copyright (c) 2010 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: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ -</template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/** - * - */</template><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/** - * @return the ${bare_field_name} - */</template><template autoinsert="true" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/** - * @author ${user} - * - * ${tags} - */</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/** - * ${tags} - */</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/** - * ${tags} +<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
+ * ${tags}
+ * ${see_to_target}
+ */</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc)
+ * ${see_to_overridden}
+ */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**
+ * @param ${param} the ${bare_field_name} to set
+ */</template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+</template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
+ *
+ */</template><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
+ * @return the ${bare_field_name}
+ */</template><template autoinsert="true" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**
+ * @author ${user}
+ *
+ * ${tags}
+ */</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**
+ * ${tags}
+ */</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**
+ * ${tags}
*/</template></templates>
\ No newline at end of file diff --git a/team/etrice_project_website.epf b/team/etrice_project_website.epf index e02d3acfb..f3c2f8818 100644 --- a/team/etrice_project_website.epf +++ b/team/etrice_project_website.epf @@ -1,5 +1,5 @@ -#Fri Jan 28 09:39:16 CET 2011 -file_export_version=3.0 -@org.eclipse.team.cvs.core=3.3.300.I20100526-0800 -\!/= -/instance/org.eclipse.team.cvs.core/repositories/%extssh%__COMMITTER_NAME__@dev.eclipse.org%%cvsroot%org.eclipse/location=\:extssh\:__COMMITTER_NAME__@dev.eclipse.org\:/cvsroot/org.eclipse +#Fri Jan 28 09:39:16 CET 2011
+file_export_version=3.0
+@org.eclipse.team.cvs.core=3.3.300.I20100526-0800
+\!/=
+/instance/org.eclipse.team.cvs.core/repositories/%extssh%__COMMITTER_NAME__@dev.eclipse.org%%cvsroot%org.eclipse/location=\:extssh\:__COMMITTER_NAME__@dev.eclipse.org\:/cvsroot/org.eclipse
diff --git a/tests/org.eclipse.etrice.generator.tests/.gitignore b/tests/org.eclipse.etrice.generator.tests/.gitignore index ba077a403..092357e47 100644 --- a/tests/org.eclipse.etrice.generator.tests/.gitignore +++ b/tests/org.eclipse.etrice.generator.tests/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/tests/org.eclipse.etrice.generator.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.etrice.generator.tests/META-INF/MANIFEST.MF index 55ee4f0cf..89d867dd8 100644 --- a/tests/org.eclipse.etrice.generator.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.etrice.generator.tests/META-INF/MANIFEST.MF @@ -1,15 +1,15 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: eTrice Generator Model Tests -Bundle-SymbolicName: org.eclipse.etrice.generator.tests -Bundle-Version: 0.1.0 -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-Vendor: eTrice (Incubation) -Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0", - org.eclipse.etrice.generator;bundle-version="0.1.0", - org.junit;bundle-version="4.8.1", - org.eclipse.osgi;bundle-version="3.6.0", - org.eclipse.xtext;bundle-version="1.0.0", - org.eclipse.core.runtime;bundle-version="3.6.0" -Bundle-Activator: org.eclipse.etrice.generator.InstanceTestsActivator -Bundle-ActivationPolicy: lazy +Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eTrice Generator Model Tests
+Bundle-SymbolicName: org.eclipse.etrice.generator.tests
+Bundle-Version: 0.1.0
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: eTrice (Incubation)
+Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0",
+ org.eclipse.etrice.generator;bundle-version="0.1.0",
+ org.junit;bundle-version="4.8.1",
+ org.eclipse.osgi;bundle-version="3.6.0",
+ org.eclipse.xtext;bundle-version="1.0.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0"
+Bundle-Activator: org.eclipse.etrice.generator.InstanceTestsActivator
+Bundle-ActivationPolicy: lazy
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/.gitignore b/tests/org.eclipse.etrice.runtime.java.tests/.gitignore index ba077a403..092357e47 100644 --- a/tests/org.eclipse.etrice.runtime.java.tests/.gitignore +++ b/tests/org.eclipse.etrice.runtime.java.tests/.gitignore @@ -1 +1 @@ -bin +bin
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/.classpath b/tests/org.eclipse.etrice.ui.structure.tests/.classpath index ad32c83a7..8a8f1668c 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/.classpath +++ b/tests/org.eclipse.etrice.ui.structure.tests/.classpath @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/.project b/tests/org.eclipse.etrice.ui.structure.tests/.project index aa27fa17a..91db75bd0 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/.project +++ b/tests/org.eclipse.etrice.ui.structure.tests/.project @@ -1,28 +1,34 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.etrice.ui.structure.tests</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.ui.structure.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs index b5619aabb..7f8e6f7b4 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs +++ b/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ -#Fri Jan 28 15:16:58 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +#Fri Jan 28 15:16:58 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/build.properties b/tests/org.eclipse.etrice.ui.structure.tests/build.properties index 34d2e4d2d..41eb6ade2 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/build.properties +++ b/tests/org.eclipse.etrice.ui.structure.tests/build.properties @@ -1,4 +1,4 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room index 507e4587d..7817b1301 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room +++ b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room @@ -1,4 +1,4 @@ -RoomModel ActorClass1 { - ActorClass MyActorClass { - } -} +RoomModel ^ActorClass {
+ ActorClass MyActorClass {
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithBindings.room b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithBindings.room new file mode 100644 index 000000000..7ce1473c7 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithBindings.room @@ -0,0 +1,34 @@ +RoomModel ActorClassWithBindings {
+ ProtocolClass MyProtocol {
+ incoming {
+ Message in1 ()
+ Message in2 ()
+ }
+ outgoing {
+ Message out1 ()
+ }
+ }
+
+ ActorClass SubActor {
+ Interface {
+ Port fct: MyProtocol
+ }
+ }
+
+ ActorClass MyActorClass {
+ Interface {
+ Port ip : MyProtocol
+ Port xp : MyProtocol
+ }
+ Structure {
+ conjugated Port sp : MyProtocol
+ external Port xp
+
+ ActorRef sub_a : SubActor
+ ActorRef sub_b : SubActor
+
+ Binding ip and sub_a.fct
+ Binding sp and sub_b.fct
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithInheritance.room b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithInheritance.room new file mode 100644 index 000000000..60d214912 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithInheritance.room @@ -0,0 +1,57 @@ +RoomModel ActorClassWithInheritance {
+ ProtocolClass MyProtocol {
+ incoming {
+ Message in1 ()
+ Message in2 ()
+ }
+ outgoing {
+ Message out1 ()
+ }
+ }
+
+ ProtocolClass MyControl {
+ incoming {
+ Message in1 ()
+ }
+ outgoing {
+ Message out1 ()
+ }
+ }
+
+ ActorClass SubActor {
+ Interface {
+ Port fct: MyProtocol
+ Port ctl: MyControl
+ }
+ }
+
+ ActorClass MyBaseClass {
+ Interface {
+ Port ip : MyProtocol
+ }
+ Structure {
+ ActorRef sub_a : SubActor
+
+ Binding ip and sub_a.fct
+ }
+ }
+
+ ActorClass MyActorClass extends MyBaseClass {
+ Interface {
+ Port p : MyProtocol
+ }
+ Structure {
+ conjugated Port ctl : MyControl
+ conjugated Port sp1 : MyProtocol
+ conjugated Port sp2 : MyProtocol
+ external Port p
+
+ ActorRef sub_b : SubActor
+ ActorRef sub_c : SubActor
+
+ Binding ctl and sub_a.ctl
+ Binding sp1 and sub_b.fct
+ Binding sp2 and sub_c.fct
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithPorts.room b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithPorts.room new file mode 100644 index 000000000..e3c5ed6d3 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithPorts.room @@ -0,0 +1,22 @@ +RoomModel ActorClassWithPorts {
+ ProtocolClass MyProtocol {
+ incoming {
+ Message in1 ()
+ Message in2 ()
+ }
+ outgoing {
+ Message out1 ()
+ }
+ }
+
+ ActorClass MyActorClass {
+ Interface {
+ Port ip : MyProtocol
+ Port xp : MyProtocol
+ }
+ Structure {
+ conjugated Port sp : MyProtocol
+ external Port xp
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithReferences.room b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithReferences.room new file mode 100644 index 000000000..e94bda656 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClassWithReferences.room @@ -0,0 +1,31 @@ +RoomModel ActorClassWithReferences {
+ ProtocolClass MyProtocol {
+ incoming {
+ Message in1 ()
+ Message in2 ()
+ }
+ outgoing {
+ Message out1 ()
+ }
+ }
+
+ ActorClass SubActor {
+ Interface {
+ Port fct: MyProtocol
+ }
+ }
+
+ ActorClass MyActorClass {
+ Interface {
+ Port ip : MyProtocol
+ Port xp : MyProtocol
+ }
+ Structure {
+ conjugated Port sp : MyProtocol
+ external Port xp
+
+ ActorRef sub_a : SubActor
+ ActorRef sub_b : SubActor
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/org.eclipse.etrice.ui.structure.tests.launch b/tests/org.eclipse.etrice.ui.structure.tests/org.eclipse.etrice.ui.structure.tests.launch new file mode 100644 index 000000000..29c0acdb2 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/org.eclipse.etrice.ui.structure.tests.launch @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="false"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.etrice.ui.structure.tests"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.etrice.ui.structure.tests"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.etrice.ui.structure.tests"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
+<booleanAttribute key="run_in_ui_thread" value="true"/>
+<stringAttribute key="selected_target_plugins" value="org.eclipse.ui.workbench@default:default,org.eclipse.equinox.p2.discovery.compatibility@default:default,org.eclipse.emf.mapping.ui@default:default,org.eclipse.graphiti.doc@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.xsd.example@default:default,org.eclipse.emf.validation.ui@default:default,org.eclipse.jface@default:default,org.eclipse.compare@default:default,org.eclipse.cvs@default:default,org.eclipse.pde.runtime@default:default,org.eclipse.core.resources.win32.x86@default:false,org.eclipse.ui.ide.application@default:default,org.apache.batik.util@default:default,org.eclipse.rcp@default:default,org.eclipse.draw2d@default:default,org.eclipse.pde.ua.core@default:default,org.eclipse.gef@default:default,org.eclipse.equinox.security.win32.x86@default:false,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.jdt.junit.core@default:default,net.sourceforge.lpg.lpgjavaruntime@default:default,org.eclipse.xsd.cheatsheets@default:default,org.w3c.dom.smil@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.apache.batik.dom.svg@default:default,org.eclipse.xsd.edit@default:default,org.eclipse.help@default:default,org.eclipse.ant.ui@default:default,org.apache.axis@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.emf.exporter@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.xtext.ecore@default:default,org.eclipse.ui.forms@default:default,org.eclipse.equinox.common@2:true,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.emf.java@default:default,org.eclipse.update.ui@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.pde@default:default,org.eclipse.pde.doc.user@default:default,org.apache.batik.pdf@default:default,org.eclipse.xtext.xtend@default:default,org.eclipse.platform@default:default,javax.servlet.jsp@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.objectweb.asm@default:default,org.eclipse.emf.transaction@default:default,org.eclipse.pde.build@default:default,org.apache.commons.logging*1.1.1.v201005080502@default:default,org.eclipse.emf.databinding.edit@default:default,com.google.collect*1.0.0.v201003051000@default:default,org.eclipse.core.net.win32.x86@default:false,org.eclipse.core.runtime@default:true,org.eclipse.pde.core@default:default,org.eclipse.epp.mpc.help.ui@default:default,org.eclipse.emf.transaction.doc@default:default,org.eclipse.emf.workspace@default:default,org.eclipse.xtend.typesystem.xsd.ui@default:default,org.eclipse.platform.doc.user@default:default,org.eclipse.xtend.profiler@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.emf.mapping.xsd2ecore.editor@default:default,org.eclipse.xtext.ui@default:default,org.eclipse.emf.ecore.edit@default:default,org.hamcrest.core@default:default,org.eclipse.xtend@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.update.configurator@3:true,org.eclipse.ui.editors@default:default,org.apache.log4j*1.2.15.v200910021404@default:default,org.eclipse.graphiti.mm@default:default,org.eclipse.emf.examples.library.editor@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.emf.compare.match@default:default,org.aopalliance@default:default,org.eclipse.compare.core@default:default,org.mortbay.jetty.util@default:default,org.antlr.runtime@default:default,org.eclipse.xtend.typesystem.xsd@default:default,org.eclipse.gef.examples.ui.pde@default:default,org.eclipse.emf.mwe.doc@default:default,org.apache.commons.discovery@default:default,org.eclipse.emf.importer.ecore@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.emf.common.ui@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.draw2d.doc.isv@default:default,com.jcraft.jsch@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.emf.doc@default:default,org.eclipse.xsd.editor@default:default,org.eclipse.team.core@default:default,org.apache.lucene.analysis@default:default,org.eclipse.emf.compare.diff@default:default,org.mozilla.javascript@default:default,org.eclipse.jsch.core@default:default,org.eclipse.emf.mapping.ecore2xml.ui@default:default,org.eclipse.emf.mapping.ecore@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.pde.ui@default:default,org.sat4j.pb@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,javax.mail@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.ant.core@default:default,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.xsd.example.installer@default:default,javax.wsdl@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.xtend.typesystem.uml2@default:default,org.apache.batik.css@default:default,org.eclipse.ui@default:default,org.polarion.eclipse.team.svn.connector@default:default,org.eclipse.core.commands@default:default,org.eclipse.xpand.doc@default:default,org.eclipse.debug.ui@default:default,org.eclipse.xtend.shared.ui@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.help.base@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.emf.workspace.ui@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.update.core@default:default,org.easymock@default:default,org.eclipse.jdt.debug.ui@default:default,org.eclipse.pde.api.tools.ui@default:default,org.jdom@default:default,org.eclipse.xtext.xtext.ui.examples@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.emf.example.installer@default:default,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.xtext.xbase.ui@default:default,org.eclipse.pde.ds.ui@default:default,org.apache.lucene@default:default,org.eclipse.xtext.util@default:default,org.eclipse.xsd.ecore.converter@default:default,org.eclipse.platform.doc.isv@default:default,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.core.expressions@default:default,org.eclipse.graphiti@default:default,org.apache.batik.xml@default:default,org.eclipse.xtext.common.types.ui@default:default,org.eclipse.swt@default:default,org.eclipse.equinox.security.ui@default:default,org.eclipse.xpand.ui@default:default,org.eclipse.emf.mapping.ecore2ecore@default:default,org.eclipse.emf.mapping@default:default,org.eclipse.emf.transaction.examples@default:default,org.eclipse.xsd.doc@default:default,org.eclipse.equinox.security@default:default,org.eclipse.emf.exporter.html@default:default,org.eclipse.emf.mapping.xsd2ecore@default:default,org.eclipse.sdk@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.xtext.junit@default:default,org.apache.batik.parser@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.app@default:default,org.eclipse.team.svn@default:default,org.eclipse.emf.mwe.core@default:default,org.eclipse.emf.importer@default:default,org.eclipse.xpand.examples@default:default,org.apache.xml.resolver@default:default,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.eclipse.team.cvs.ui@default:default,org.eclipse.emf.mapping.ecore2xml@default:default,org.eclipse.emf.examples@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.apache.xerces@default:default,org.eclipse.xpand.activities@default:default,org.eclipse.emf.mapping.ecore2ecore.editor@default:default,org.eclipse.gef.doc.isv@default:default,org.apache.commons.lang*2.4.0.v201005080502@default:default,org.eclipse.emf.transaction.ui@default:default,org.eclipse.xtend.typesystem.emf@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.emf.examples.generator.validator@default:default,org.eclipse.equinox.p2.ui.discovery@default:default,org.eclipse.osgi@-1:true,org.eclipse.help.ui@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.emf.java.edit@default:default,org.eclipse.xsd@default:default,org.eclipse.ui.presentations.r21@default:default,org.eclipse.emf.codegen@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.xtend.ui@default:default,javax.xml@default:default,org.eclipse.uml2.common.edit@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.help.webapp@default:default,org.eclipse.emf.importer.rose@default:default,org.eclipse.pde.ua.ui@default:default,org.eclipse.xpand.incremental@default:default,org.eclipse.emf@default:default,javax.xml.bind@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.emf.converter@default:default,org.apache.jasper@default:default,org.eclipse.ui.win32@default:false,org.eclipse.ui.ide@default:default,java_cup.runtime@default:default,javax.xml.soap@default:default,org.eclipse.equinox.util@default:default,org.eclipse.emf.ant@default:default,org.apache.ant@default:default,org.eclipse.pde.ui.templates@default:default,org.eclipse.graphiti.examples.tutorial@default:default,org.eclipse.emf.codegen.ui@default:default,org.eclipse.core.filesystem.win32.x86@default:false,org.eclipse.team.cvs.core@default:default,org.eclipse.xsd.ecore.importer@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.xtend.typesystem.uml2.ui@default:default,org.eclipse.team.svn.help@default:default,org.sat4j.core@default:default,org.eclipse.compare.win32@default:default,org.eclipse.xtend.typesystem.emf.ui@default:default,org.eclipse.equinox.ds@default:true,org.apache.batik.dom@default:default,org.apache.batik.ext.awt@default:default,org.eclipse.xtext.common.types@default:default,org.apache.commons.lang*2.3.0.v201005080501@default:default,org.eclipse.ui.views.log@default:default,org.eclipse.emf.ecore.editor@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.xsd.ecore.exporter@default:default,org.junit*3.8.2.v3_8_2_v20100427-1100@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.emf.mwe.ui@default:default,org.apache.commons.httpclient@default:default,org.eclipse.pde.ds.core@default:default,org.eclipse.equinox.http.registry@default:default,com.ibm.icu@default:default,org.apache.log4j*1.2.15.v201005080500@default:default,org.eclipse.ui.navigator@default:default,org.w3c.dom.events@default:default,org.eclipse.pde.junit.runtime@default:default,javax.servlet@default:default,org.eclipse.xtext.ui.ecore@default:default,org.eclipse.emf.compare@default:default,org.eclipse.xsd.mapping@default:default,org.junit4@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.uml2.common@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.emf.workspace.doc@default:default,org.eclipse.emf.common@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.xtext.xbase@default:default,org.eclipse.core.databinding@default:default,org.eclipse.ecf@default:default,org.eclipse.core.net@default:default,org.apache.commons.cli@default:default,org.eclipse.core.resources@default:default,org.apache.batik.bridge@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.emf.codegen.ecore.ui@default:default,org.eclipse.ui.console@default:default,org.eclipse.xsd.mapping.editor@default:default,org.eclipse.xtext.ui.shared@default:default,javax.xml.rpc@default:default,org.eclipse.epp.mpc.ui@default:default,org.apache.bcel@default:default,org.apache.xml.serializer@default:default,org.eclipse.xtext@default:default,org.eclipse.pde.api.tools@default:default,org.eclipse.update.scheduler@default:default,org.apache.batik.util.gui@default:default,org.apache.commons.logging*1.0.4.v201005080501@default:default,org.polarion.eclipse.team.svn.connector.javahl16@default:default,org.eclipse.uml2.uml.resources@default:default,com.google.collect*0.8.0.v201008251220@default:default,org.eclipse.uml2.uml.edit@default:default,org.apache.commons.codec@default:default,org.apache.ws.commons.util@default:default,org.eclipse.team.cvs.ssh2@default:default,org.eclipse.emf.codegen.ecore@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.emf.java.editor@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.ant.launching@default:default,org.eclipse.emf.mapping.ecore.editor@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.xpand@default:default,org.eclipse.emf.mwe2.runtime@default:default,org.apache.batik.transcoder@default:default,org.eclipse.xtend.util.stdlib@default:default,org.eclipse.emf.mwe.ui.simpleEditor@default:default,org.eclipse.xtend.check.ui@default:default,org.w3c.dom.svg@default:default,org.eclipse.core.boot@default:default,org.eclipse.team.ui@default:default,org.eclipse.help.appserver@default:default,org.eclipse.uml2.codegen.ecore@default:default,org.eclipse.pde.launching@default:default,org.eclipse.emf.mwe2.language@default:default,org.eclipse.xtext.xtext.ui@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.h2@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.emf.cheatsheets@default:default,org.apache.xalan@default:default,javax.activation@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.emf.examples.library@default:default,org.eclipse.ui.views@default:default,org.eclipse.xtext.builder@default:default,org.eclipse.emf.mwe.activities@default:default,org.eclipse.ui.browser@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.jface.text@default:default,org.eclipse.emf.mwe2.launch@default:default,org.eclipse.graphiti.ui@default:default,org.eclipse.team.svn.ui@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.xtext.generator@default:default,org.eclipse.graphiti.pattern@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.swt.win32.win32.x86@default:false,org.eclipse.equinox.launcher.win32.win32.x86@default:false,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.update.core.win32@default:false,org.eclipse.ui.cheatsheets@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.externaltools@default:default,org.eclipse.emf.compare.ui@default:default,org.eclipse.emf.generic.editor@default:default,de.itemis.xtext.antlr@default:default,org.eclipse.equinox.p2.repository@default:default,org.apache.commons.el@default:default,org.apache.xmlrpc@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.discovery@default:default,org.eclipse.search@default:default,org.eclipse.equinox.event@default:default,org.eclipse.team.svn.core@default:default,org.eclipse.xtext.logging@default:false,org.eclipse.debug.core@default:default,com.google.inject@default:default,org.eclipse.xtext.ui.junit@default:default,org.eclipse.osgi.util@default:default,org.eclipse.uml2.uml@default:default,org.eclipse.emf.databinding@default:default,org.eclipse.xtext.doc@default:default,org.eclipse.ui.net@default:default,org.eclipse.epp.mpc.core@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.emf.mwe2.language.ui@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.osgi.services@default:default,org.eclipse.equinox.p2.updatechecker@default:default,lpg.runtime.java@default:default,org.eclipse.core.variables@default:default,org.eclipse.emf.validation@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.compare.doc@default:default,org.eclipse.graphiti.examples.common@default:default,org.eclipse.emf.importer.java@default:default,org.eclipse.emf.compare.epatch@default:default,org.eclipse.emf.ecore.change.edit@default:default,org.eclipse.jgit@default:default,org.mortbay.jetty.server@default:default,org.eclipse.uml2.uml.ecore.importer@default:default,org.eclipse.ui.intro@default:default,org.eclipse.emf.edit@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.w3c.css.sac@default:default,org.eclipse.emf.examples.library.edit@default:default,org.antlr.gen@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.emf.validation.ui.ide@default:default,org.eclipse.jdt.core@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ui.navigator.resources@default:default,org.apache.batik.svggen@default:default,org.polarion.eclipse.team.svn.connector.svnkit16@default:default,org.eclipse.emf.mwe.utils@default:default,org.eclipse.xtext.activities@default:default,org.eclipse.emf.activities@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.emf.edit.ui@default:default,org.eclipse.text@default:default,org.eclipse.emf.compare.diff.edit@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.etrice.ui.common@default:default,org.eclipse.graphiti.pattern@default:default,org.eclipse.graphiti.mm@default:default,org.eclipse.etrice.core.room.ui@default:default,org.eclipse.graphiti.examples.common@default:default,org.eclipse.etrice.generator.tests@default:default,org.eclipse.etrice.modellib@default:default,org.eclipse.etrice.ui.structure.tests@default:default,org.eclipse.graphiti.ui@default:default,org.eclipse.etrice.generator.java@default:default,org.eclipse.graphiti@default:default,org.eclipse.etrice.integration.tests@default:default,org.eclipse.etrice.generator@default:default,org.eclipse.etrice.example@default:default,org.eclipse.etrice.ui.behavior@default:default,org.eclipse.etrice.core.room@default:default,org.eclipse.graphiti.examples.tutorial@default:default,org.eclipse.xtext.ui@default:default,org.eclipse.etrice.ui.structure@default:default"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="true"/>
+</launchConfiguration>
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java index 3eb3852eb..a9f5b1037 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java @@ -1,22 +1,22 @@ -package org.eclipse.etrice.ui.structure; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class StructureTestActivator extends Plugin implements BundleActivator { - - private static StructureTestActivator instance = null; - - public static StructureTestActivator getInstance() { - return instance; - } - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - - instance = this; - } - -} +package org.eclipse.etrice.ui.structure;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class StructureTestActivator extends Plugin implements BundleActivator {
+
+ private static StructureTestActivator instance = null;
+
+ public static StructureTestActivator getInstance() {
+ return instance;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ instance = this;
+ }
+
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/ActorClassWithBindings.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/ActorClassWithBindings.java new file mode 100644 index 000000000..6ab9450b2 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/ActorClassWithBindings.java @@ -0,0 +1,102 @@ +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ActorClassWithBindings extends TestBase {
+
+ private ActorClass ac = null;
+
+ @Before
+ public void setUp() {
+ loadModelFile();
+
+ assertEquals("models read", 1, getModels().size());
+ assertEquals("actor classes in our model", 2, getModels().get(0).getActorClasses().size());
+
+ for (ActorClass a : getModels().get(0).getActorClasses()) {
+ if (a.getName().equals("MyActorClass")) {
+ ac = a;
+ break;
+ }
+ }
+ assertNotNull("ActorClass expected", ac);
+ }
+
+ @After
+ public void tearDown() {
+ removeDiagramsDirectory();
+ }
+
+ @Override
+ protected String getModelFileName() {
+ return "ActorClassWithBindings.room";
+ }
+
+ @Test
+ public void checkReferences() {
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+ ContainerShape shape = (ContainerShape) diagram.getChildren().get(0);
+ assertEquals("actor class child shapes", 5, shape.getChildren().size());
+
+ int nRefs = 0;
+ for (Shape childShape : shape.getChildren()) {
+ EObject[] bos = Graphiti.getLinkService()
+ .getAllBusinessObjectsForLinkedPictogramElement(childShape);
+ assertEquals("business objects", 1, bos.length);
+ if (!(bos[0] instanceof Port)) {
+ assertTrue("bo is actor ref", bos[0] instanceof ActorRef);
+ nRefs++;
+ }
+ }
+ assertEquals("number of actor references", 2, nRefs);
+ }
+
+ @Test
+ public void checkBindings() {
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+ assertEquals("bindings", 2, diagram.getConnections().size());
+
+ for (Connection conn : diagram.getConnections()) {
+ EObject[] bos = Graphiti.getLinkService().getAllBusinessObjectsForLinkedPictogramElement(conn);
+ assertEquals("business objects", 1, bos.length);
+ assertTrue("binding", bos[0] instanceof Binding);
+
+ Binding b = (Binding) bos[0];
+
+ // the first port is part of the only MyActor instance
+ List<PictogramElement> pes = Graphiti.getLinkService().getPictogramElements(diagram, b.getEndpoint1().getPort());
+ assertEquals("instances of first port", 1, pes.size());
+
+ // the second port is part of SubActor which has two instances
+ pes = Graphiti.getLinkService().getPictogramElements(diagram, b.getEndpoint2().getPort());
+ assertEquals("instances of second port", 2, pes.size());
+ assertNull("first ref", b.getEndpoint1().getActorRef());
+
+ // the second ref is represented once in the diagram
+ assertNotNull("second ref", b.getEndpoint2().getActorRef());
+ pes = Graphiti.getLinkService().getPictogramElements(diagram, ((ActorRef)b.getEndpoint2().getActorRef()));
+ assertEquals("instances of second ref", 1, pes.size());
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java index 4122efd28..d4b015aa0 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java @@ -1,47 +1,53 @@ -package org.eclipse.etrice.ui.structure.commands; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.etrice.core.room.ActorClass; -import org.eclipse.etrice.ui.structure.DiagramAccess; -import org.eclipse.graphiti.mm.pictograms.ContainerShape; -import org.eclipse.graphiti.mm.pictograms.Diagram; -import org.eclipse.graphiti.mm.pictograms.Shape; -import org.eclipse.graphiti.services.Graphiti; -import org.junit.Before; -import org.junit.Test; - -public class TestActorClass extends TestBase { - - @Before - public void setUp() { - loadModelFile(); - } - - @Override - protected String getModelFileName() { - return "ActorClass.room"; - } - - @Test - public void checkModel() { - assertEquals("models read", 1, getModels().size()); - assertEquals("actor classes in our model", 1, getModels().get(0).getActorClasses().size()); - } - - @Test - public void testActorClass() { - ActorClass ac = getModels().get(0).getActorClasses().get(0); - Diagram diagram = DiagramAccess.getDiagram(ac); - - assertEquals("diagram children", 1, diagram.getChildren().size()); - - Shape shape = diagram.getChildren().get(0); - assertTrue("top level shape is container shape", shape instanceof ContainerShape); - - EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(shape); - assertTrue("top level business object is ActorClass", bo instanceof ActorClass); - } -} +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestActorClass extends TestBase {
+
+ @Before
+ public void setUp() {
+ loadModelFile();
+ }
+
+ @After
+ public void tearDown() {
+ removeDiagramsDirectory();
+ }
+
+ @Override
+ protected String getModelFileName() {
+ return "ActorClass.room";
+ }
+
+ @Test
+ public void checkModel() {
+ assertEquals("models read", 1, getModels().size());
+ assertEquals("actor classes in our model", 1, getModels().get(0).getActorClasses().size());
+ }
+
+ @Test
+ public void testActorClass() {
+ ActorClass ac = getModels().get(0).getActorClasses().get(0);
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+
+ assertEquals("diagram children", 1, diagram.getChildren().size());
+
+ Shape shape = diagram.getChildren().get(0);
+ assertTrue("top level shape is container shape", shape instanceof ContainerShape);
+
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(shape);
+ assertTrue("top level business object is ActorClass", bo instanceof ActorClass);
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java new file mode 100644 index 000000000..876a41498 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java @@ -0,0 +1,167 @@ +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.etrice.ui.structure.support.ActorContainerRefSupport;
+import org.eclipse.etrice.ui.structure.support.BindingSupport;
+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
+import org.eclipse.graphiti.mm.algorithms.Rectangle;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.algorithms.styles.Color;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.util.IColorConstant;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestActorClassWithInheritance extends TestBase {
+
+ private ActorClass ac = null;
+
+ @Before
+ public void setUp() {
+ loadModelFile();
+
+ assertEquals("models read", 1, getModels().size());
+ assertEquals("actor classes in our model", 3, getModels().get(0).getActorClasses().size());
+
+ for (ActorClass a : getModels().get(0).getActorClasses()) {
+ if (a.getName().equals("MyActorClass")) {
+ ac = a;
+ break;
+ }
+ }
+ assertNotNull("ActorClass expected", ac);
+ }
+
+ @After
+ public void tearDown() {
+ removeDiagramsDirectory();
+ }
+
+ @Override
+ protected String getModelFileName() {
+ return "ActorClassWithInheritance.room";
+ }
+
+ private boolean isEqual(Color c, IColorConstant cc) {
+ if (c.getRed()!=cc.getRed())
+ return false;
+ if (c.getGreen()!=cc.getGreen())
+ return false;
+ if (c.getBlue()!=cc.getBlue())
+ return false;
+ return true;
+ }
+
+ @Test
+ public void checkReferences() {
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+ ContainerShape shape = (ContainerShape) diagram.getChildren().get(0);
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(shape);
+ assertTrue("bo is ActorClass", bo instanceof ActorClass);
+
+ // re-assign this because the old Java object is another instance since it comes from another resource
+ ac = (ActorClass) bo;
+
+ assertEquals("actor class child shapes", 8, shape.getChildren().size());
+
+ int nRefs = 0;
+ for (Shape childShape : shape.getChildren()) {
+ EObject[] bos = Graphiti.getLinkService()
+ .getAllBusinessObjectsForLinkedPictogramElement(childShape);
+ assertEquals("business objects", 1, bos.length);
+ if (!(bos[0] instanceof Port)) {
+ assertTrue("bo is actor ref", bos[0] instanceof ActorRef);
+ nRefs++;
+
+ ActorRef ar = (ActorRef) bos[0];
+ boolean inherited = (ar.eContainer()!=ac);
+
+ assertNotNull("ga is there (invisible rectangle)", childShape.getGraphicsAlgorithm());
+ assertTrue("ga is invisible rectangle", childShape.getGraphicsAlgorithm() instanceof Rectangle);
+ assertFalse("ga is invisible", childShape.getGraphicsAlgorithm().getFilled());
+ assertFalse("ga is invisible", childShape.getGraphicsAlgorithm().getLineVisible());
+ assertEquals("border rect", 1, childShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().size());
+ GraphicsAlgorithm borderRect = childShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0);
+ if (inherited)
+ assertTrue("border rect background", isEqual(borderRect.getForeground(), ActorContainerRefSupport.INHERITED_COLOR));
+ else
+ assertTrue("border rect background", isEqual(borderRect.getForeground(), ActorContainerRefSupport.LINE_COLOR));
+
+ // ports of actor refs
+ assertEquals("grand child shapes", 3, ((ContainerShape)childShape).getChildren().size());
+ for (Shape grandChildShape : ((ContainerShape)childShape).getChildren()) {
+ // skip the actor ref label
+ if (grandChildShape.getGraphicsAlgorithm() instanceof Text)
+ continue;
+
+ bos = Graphiti.getLinkService()
+ .getAllBusinessObjectsForLinkedPictogramElement(grandChildShape);
+ assertEquals("business objects", 1, bos.length);
+ assertTrue("bo is port", bos[0] instanceof Port);
+ }
+ }
+ }
+ assertEquals("number of actor references", 3, nRefs);
+ }
+
+ @Test
+ public void checkBindings() {
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+ ContainerShape shape = (ContainerShape) diagram.getChildren().get(0);
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(shape);
+ assertTrue("bo is ActorClass", bo instanceof ActorClass);
+
+ // re-assign this because the old Java object is another instance since it comes from another resource
+ ac = (ActorClass) bo;
+
+ assertEquals("bindings", 4, diagram.getConnections().size());
+
+ for (Connection conn : diagram.getConnections()) {
+ EObject[] bos = Graphiti.getLinkService().getAllBusinessObjectsForLinkedPictogramElement(conn);
+ assertEquals("business objects", 1, bos.length);
+ assertTrue("binding", bos[0] instanceof Binding);
+
+ Binding b = (Binding) bos[0];
+ boolean inherited = (b.eContainer()!=ac);
+
+ if (inherited)
+ assertTrue("border rect background", isEqual(conn.getGraphicsAlgorithm().getForeground(), BindingSupport.INHERITED_COLOR));
+ else
+ assertTrue("border rect background", isEqual(conn.getGraphicsAlgorithm().getForeground(), BindingSupport.LINE_COLOR));
+
+ // the first port is part of the only MyActor instance
+ List<PictogramElement> pes = Graphiti.getLinkService().getPictogramElements(diagram, b.getEndpoint1().getPort());
+ assertEquals("instances of first port", 1, pes.size());
+
+ // the second port is part of SubActor which has three instances
+ pes = Graphiti.getLinkService().getPictogramElements(diagram, b.getEndpoint2().getPort());
+ assertEquals("instances of second port", 3, pes.size());
+ assertNull("first ref", b.getEndpoint1().getActorRef());
+
+ // the second ref is represented once in the diagram
+ assertNotNull("second ref", b.getEndpoint2().getActorRef());
+ pes = Graphiti.getLinkService().getPictogramElements(diagram, ((ActorRef)b.getEndpoint2().getActorRef()));
+ assertEquals("instances of second ref", 1, pes.size());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithPorts.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithPorts.java new file mode 100644 index 000000000..3a8f3251d --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithPorts.java @@ -0,0 +1,37 @@ +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.junit.Test;
+
+public class TestActorClassWithPorts extends TestActorClass {
+
+ @Test
+ public void checkPorts() {
+ ActorClass ac = getModels().get(0).getActorClasses().get(0);
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+ ContainerShape shape = (ContainerShape) diagram.getChildren().get(0);
+ assertEquals("actor class child shapes", 3, shape.getChildren().size());
+
+ for (Shape childShape : shape.getChildren()) {
+ EObject[] bos = Graphiti.getLinkService()
+ .getAllBusinessObjectsForLinkedPictogramElement(childShape);
+ assertEquals("business objects", 1, bos.length);
+ assertTrue("bo is port", bos[0] instanceof Port);
+ }
+ }
+
+ @Override
+ protected String getModelFileName() {
+ return "ActorClassWithPorts.room";
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java new file mode 100644 index 000000000..00820df8e --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java @@ -0,0 +1,83 @@ +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorRef;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestActorClassWithReferences extends TestBase {
+
+ private ActorClass ac = null;
+
+ @Before
+ public void setUp() {
+ loadModelFile();
+
+ assertEquals("models read", 1, getModels().size());
+ assertEquals("actor classes in our model", 2, getModels().get(0).getActorClasses().size());
+
+ for (ActorClass a : getModels().get(0).getActorClasses()) {
+ if (a.getName().equals("MyActorClass")) {
+ ac = a;
+ break;
+ }
+ }
+ assertNotNull("ActorClass expected", ac);
+ }
+
+ @After
+ public void tearDown() {
+ removeDiagramsDirectory();
+ }
+
+ @Override
+ protected String getModelFileName() {
+ return "ActorClassWithReferences.room";
+ }
+
+ @Test
+ public void checkReferences() {
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+ ContainerShape shape = (ContainerShape) diagram.getChildren().get(0);
+ assertEquals("actor class child shapes", 5, shape.getChildren().size());
+
+ int nRefs = 0;
+ for (Shape childShape : shape.getChildren()) {
+ EObject[] bos = Graphiti.getLinkService()
+ .getAllBusinessObjectsForLinkedPictogramElement(childShape);
+ assertEquals("business objects", 1, bos.length);
+ if (!(bos[0] instanceof Port)) {
+ assertTrue("bo is actor ref", bos[0] instanceof ActorRef);
+ nRefs++;
+
+ // ports of actor refs
+ assertEquals("grand child shapes", 2, ((ContainerShape)childShape).getChildren().size());
+ for (Shape grandChildShape : ((ContainerShape)childShape).getChildren()) {
+ // skip the actor ref label
+ if (grandChildShape.getGraphicsAlgorithm() instanceof Text)
+ continue;
+
+ bos = Graphiti.getLinkService()
+ .getAllBusinessObjectsForLinkedPictogramElement(grandChildShape);
+ assertEquals("business objects", 1, bos.length);
+ assertTrue("bo is port", bos[0] instanceof Port);
+ }
+ }
+ }
+ assertEquals("number of actor references", 2, nRefs);
+ }
+
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java index ce0818de8..9fba7087b 100644 --- a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java @@ -1,52 +1,65 @@ -package org.eclipse.etrice.ui.structure.commands; - -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.URL; -import java.util.LinkedList; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.etrice.core.room.RoomModel; -import org.eclipse.etrice.ui.structure.StructureTestActivator; -import org.eclipse.xtext.resource.XtextResource; -import org.eclipse.xtext.resource.XtextResourceSet; - -public abstract class TestBase { - - private String basePath; - private LinkedList<RoomModel> models = new LinkedList<RoomModel>(); - - protected void loadModelFile() { - try { - URL modelsDir = StructureTestActivator.getInstance().getBundle().getEntry("models"); - URL fileURL = FileLocator.toFileURL(modelsDir); - basePath = fileURL.getFile(); - } catch (IOException e) { - e.printStackTrace(); - } - - loadModels(getModelFileName()); - } - - private void loadModels(String modelName) { - XtextResourceSet rs = new XtextResourceSet(); - rs.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); - String path = basePath + modelName; - URI uri = URI.createFileURI(path); - Resource resource = rs.getResource(uri, true); - Object root = resource.getContents().get(0); - if (root instanceof RoomModel) - models.add((RoomModel) root); - else - fail("File contains no RoomModel as root object"); - } - - public LinkedList<RoomModel> getModels() { - return models; - } - - protected abstract String getModelFileName(); -} +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.LinkedList;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.ui.structure.StructureTestActivator;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.resource.XtextResourceSet;
+
+public abstract class TestBase {
+
+ private String basePath;
+ private LinkedList<RoomModel> models = new LinkedList<RoomModel>();
+
+ protected void loadModelFile() {
+ try {
+ URL modelsDir = StructureTestActivator.getInstance().getBundle().getEntry("models");
+ URL fileURL = FileLocator.toFileURL(modelsDir);
+ basePath = fileURL.getFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ loadModels(getModelFileName());
+ }
+
+ protected void removeDiagramsDirectory() {
+ File diagDir = new File(basePath+File.separator+"diagrams");
+ if (diagDir.isDirectory()) {
+ File[] files = diagDir.listFiles();
+ if (files!=null)
+ for (int i = 0; i < files.length; i++) {
+ files[i].delete();
+ }
+ diagDir.delete();
+ }
+ }
+
+ private void loadModels(String modelName) {
+ XtextResourceSet rs = new XtextResourceSet();
+ rs.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
+ String path = basePath + modelName;
+ URI uri = URI.createFileURI(path);
+ Resource resource = rs.getResource(uri, true);
+ Object root = resource.getContents().get(0);
+ if (root instanceof RoomModel)
+ models.add((RoomModel) root);
+ else
+ fail("File contains no RoomModel as root object");
+ }
+
+ public LinkedList<RoomModel> getModels() {
+ return models;
+ }
+
+ protected abstract String getModelFileName();
+}
|