Skip to content

Commit

Permalink
Composite structure diagram: rework
Browse files Browse the repository at this point in the history
- Connector creation
- Drop of element from model (only children could be dropped for
  the Structured classifier on which the diagram was created)
- fill selection windows for the add tool
- Interface realization is display twice
- Usage is not displayed
- display only once component child
- drop interface in diagram
- display connector between interface (provided and required interface)
- display empty diagram message
- display connector when interface layer is disable
  • Loading branch information
fbats committed Sep 7, 2015
1 parent 16bb5fc commit 9aae821
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 89 deletions.
27 changes: 11 additions & 16 deletions plugins/org.obeonetwork.dsl.uml2.design/description/uml2.odesign

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery;
import org.eclipse.sirius.diagram.business.internal.helper.task.operations.CreateViewTask;
import org.eclipse.sirius.diagram.business.internal.metamodel.spec.DNodeContainerSpec;
import org.eclipse.sirius.diagram.business.internal.metamodel.spec.DNodeSpec;
import org.eclipse.sirius.diagram.description.AbstractNodeMapping;
import org.eclipse.sirius.diagram.description.DiagramElementMapping;
import org.eclipse.sirius.diagram.description.tool.CreateView;
Expand Down Expand Up @@ -537,6 +538,35 @@ public boolean inactive(Element element) {
return false;
}

/**
* Check if a diagram is empty.
*
* @param diagram
* diagram to check
* @return true if no element is present in diagram
*/
public boolean isDiagramEmpty(DDiagram diagram) {
final List<EObject> elements = new ArrayList<EObject>();
for (final EObject object : diagram.getDiagramElements()) {
if (!(object instanceof DSemanticDiagram)){
if (object instanceof DNodeSpec){
// ignore empty diagram image
if (!((DNodeSpec)object).getActualMapping().getName()
.equals("Empty Diagram")) { //$NON-NLS-1$
elements.add(object);
}
}else{
elements.add(object);
}
}
}

if (elements.size() == 0) {
return true;
}
return false;
}

/**
* States if the given object is related to the context {@link Classifier}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.Usage;
import org.obeonetwork.dsl.uml2.design.internal.services.ConnectorServices;
import org.obeonetwork.dsl.uml2.design.internal.services.DependencyServices;
import org.obeonetwork.dsl.uml2.design.internal.services.ElementServices;
import org.obeonetwork.dsl.uml2.design.internal.services.LogServices;
import org.obeonetwork.dsl.uml2.design.internal.services.NodeInverseRefsServices;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

/**
* A set of services to handle the Component diagram.
*
Expand Down Expand Up @@ -237,46 +234,8 @@ public Usage createHelperUsage(EObject context, Interface contract) {
* @return needed clients to handle is the diagram ui
*/
public List<NamedElement> getClient(Dependency dependency) {
final List<NamedElement> result = new ArrayList<NamedElement>();
final List<NamedElement> clients = Lists.newArrayList(Iterables.filter(dependency.getClients(),
new Predicate<EObject>() {
public boolean apply(EObject input) {
return !(input instanceof Connector);
}
}));
if (clients.size() == 1) {
result.addAll(clients);
return result;
}
for (final NamedElement client : clients) {
if (client instanceof Property) {
final Property property = (Property)client;
if (property instanceof Port) {
final Port port = (Port)property;
if (port.getType() != null) {
if (port.eContainer() instanceof StructuredClassifier
&& port.getType().equals(port.eContainer())) {
// when the port type is the container type, add directly the container.
result.add(port.getType());
} else if (port.isConjugated()) {
// if conjugated add the port type and the port.
result.add(port);
result.add(port.getType());
} else {
// Else add the port
result.add(port);
}
} else {
// Else add the port
result.add(port);
}
} else {
// Else add the property
result.add(property);
}
}
}
return result;

return DependencyServices.INSTANCE.getClient(dependency);
}

/**
Expand Down
Loading

0 comments on commit 9aae821

Please sign in to comment.