/*
* (c) 2011 - 2013 University of Mannheim: Software Engineering Group
*/
package de.uni_mannheim.informatik.swt.models.plm.diagram.navigator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.ICommonContentProvider;
/**
* @generated
*/
public class PLMNavigatorContentProvider implements ICommonContentProvider {
/**
* @generated
*/
private static final Object[] EMPTY_ARRAY = new Object[0];
/**
* @generated
*/
private Viewer myViewer;
/**
* @generated
*/
private AdapterFactoryEditingDomain myEditingDomain;
/**
* @generated
*/
private WorkspaceSynchronizer myWorkspaceSynchronizer;
/**
* @generated
*/
private Runnable myViewerRefreshRunnable;
/**
* @generated
*/
@SuppressWarnings({ "unchecked", "serial", "rawtypes" })
public PLMNavigatorContentProvider() {
TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
.createEditingDomain();
myEditingDomain = (AdapterFactoryEditingDomain) editingDomain;
myEditingDomain.setResourceToReadOnlyMap(new HashMap() {
public Object get(Object key) {
if (!containsKey(key)) {
put(key, Boolean.TRUE);
}
return super.get(key);
}
});
myViewerRefreshRunnable = new Runnable() {
public void run() {
if (myViewer != null) {
myViewer.refresh();
}
}
};
myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain,
new WorkspaceSynchronizer.Delegate() {
public void dispose() {
}
public boolean handleResourceChanged(final Resource resource) {
unloadAllResources();
asyncRefresh();
return true;
}
public boolean handleResourceDeleted(Resource resource) {
unloadAllResources();
asyncRefresh();
return true;
}
public boolean handleResourceMoved(Resource resource,
final URI newURI) {
unloadAllResources();
asyncRefresh();
return true;
}
});
}
/**
* @generated
*/
public void dispose() {
myWorkspaceSynchronizer.dispose();
myWorkspaceSynchronizer = null;
myViewerRefreshRunnable = null;
myViewer = null;
unloadAllResources();
((TransactionalEditingDomain) myEditingDomain).dispose();
myEditingDomain = null;
}
/**
* @generated
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
myViewer = viewer;
}
/**
* @generated
*/
void unloadAllResources() {
for (Resource nextResource : myEditingDomain.getResourceSet()
.getResources()) {
nextResource.unload();
}
}
/**
* @generated
*/
void asyncRefresh() {
if (myViewer != null && !myViewer.getControl().isDisposed()) {
myViewer.getControl().getDisplay()
.asyncExec(myViewerRefreshRunnable);
}
}
/**
* @generated
*/
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
/**
* @generated
*/
public void restoreState(IMemento aMemento) {
}
/**
* @generated
*/
public void saveState(IMemento aMemento) {
}
/**
* @generated
*/
public void init(ICommonContentExtensionSite aConfig) {
}
/**
* @generated
*/
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IFile) {
IFile file = (IFile) parentElement;
URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
.toString(), true);
Resource resource = myEditingDomain.getResourceSet().getResource(
fileURI, true);
ArrayList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem> result = new ArrayList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem>();
ArrayList<View> topViews = new ArrayList<View>(resource
.getContents().size());
for (EObject o : resource.getContents()) {
if (o instanceof View) {
topViews.add((View) o);
}
}
result.addAll(createNavigatorItems(
selectViewsByType(
topViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.DomainEditPart.MODEL_ID),
file, false));
return result.toArray();
}
if (parentElement instanceof de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup) {
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup group = (de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup) parentElement;
return group.getChildren();
}
if (parentElement instanceof de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem) {
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem navigatorItem = (de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem) parentElement;
if (navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) {
return EMPTY_ARRAY;
}
return getViewChildren(navigatorItem.getView(), parentElement);
}
return EMPTY_ARRAY;
}
/**
* @generated
*/
private Object[] getViewChildren(View view, Object parentElement) {
switch (de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getVisualID(view)) {
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.DomainEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Diagram sv = (Diagram) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Ontologies = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Domain_1000_Ontologies,
"icons/ontology16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.OntologyEditPart.VISUAL_ID));
Ontologies.addChildren(createNavigatorItems(connectedViews,
Ontologies, false));
result.add(Ontologies);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.OntologyEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Ontology_2003_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Models = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Ontology_2003_Models,
"icons/model16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.OntologyOntologyModelCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelEditPart.VISUAL_ID));
Models.addChildren(createNavigatorItems(connectedViews, Models,
false));
result.add(LMLVisualizers);
result.add(Models);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Model_3059_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Entities = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Model_3059_Entities,
"icons/clabject16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Connections = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Model_3059_Connections,
"icons/connection16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Generalizations = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Model_3059_Generalizations,
"icons/inheritance16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup SetRelationships = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Model_3059_SetRelationships,
"icons/setRelationship16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Entity2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEntityContentsCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Connection2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionConnectionAttributesCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.AttributeEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.LMLVisualizer2EditPart.VISUAL_ID));
LMLVisualizers.addChildren(createNavigatorItems(connectedViews,
LMLVisualizers, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Entity2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEntityContentsCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEditPart.VISUAL_ID));
Entities.addChildren(createNavigatorItems(connectedViews, Entities,
false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Entity2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEntityContentsCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Connection2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionConnectionContentsCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEditPart.VISUAL_ID));
Entities.addChildren(createNavigatorItems(connectedViews, Entities,
false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionEditPart.VISUAL_ID));
Connections.addChildren(createNavigatorItems(connectedViews,
Connections, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.GeneralizationEditPart.VISUAL_ID));
Generalizations.addChildren(createNavigatorItems(connectedViews,
Generalizations, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ComplementEditPart.VISUAL_ID));
SetRelationships.addChildren(createNavigatorItems(connectedViews,
SetRelationships, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EqualityEditPart.VISUAL_ID));
SetRelationships.addChildren(createNavigatorItems(connectedViews,
SetRelationships, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ModelDomainElementsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.InversionEditPart.VISUAL_ID));
SetRelationships.addChildren(createNavigatorItems(connectedViews,
SetRelationships, false));
result.add(LMLVisualizers);
result.add(Entities);
result.add(Connections);
result.add(Generalizations);
result.add(SetRelationships);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Connection_3060_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Attributes = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Connection_3060_Attributes,
"icons/field16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionConnectionAttributesCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.AttributeEditPart.VISUAL_ID));
Attributes.addChildren(createNavigatorItems(connectedViews,
Attributes, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionConnectionContentsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Connection2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionConnectionAttributesCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.AttributeEditPart.VISUAL_ID));
Attributes.addChildren(createNavigatorItems(connectedViews,
Attributes, false));
result.add(LMLVisualizers);
result.add(Attributes);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ComplementEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Complement_3063_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
result.add(LMLVisualizers);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EqualityEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Equality_3064_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
result.add(LMLVisualizers);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.InversionEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Inversion_3065_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
result.add(LMLVisualizers);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.GeneralizationEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Generalization_3072_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
result.add(LMLVisualizers);
return result.toArray();
}
case de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEditPart.VISUAL_ID: {
LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem> result = new LinkedList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem>();
Node sv = (Node) view;
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup LMLVisualizers = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Entity_3085_LMLVisualizers,
"icons/LMLVisualizer16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Attributes = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Entity_3085_Attributes,
"icons/field16.gif", parentElement); //$NON-NLS-1$
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup Methods = new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorGroup(
de.uni_mannheim.informatik.swt.models.plm.diagram.part.Messages.NavigatorGroupName_Entity_3085_Methods,
"icons/method16.gif", parentElement); //$NON-NLS-1$
Collection<View> connectedViews;
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEntityAttributesCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Attribute2EditPart.VISUAL_ID));
Attributes.addChildren(createNavigatorItems(connectedViews,
Attributes, false));
connectedViews = getChildrenByType(
Collections.singleton(sv),
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEntityContentsCompartmentEditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.Connection2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionConnectionMethodsCompartment2EditPart.VISUAL_ID));
connectedViews = getChildrenByType(
connectedViews,
de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getType(de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.MethodEditPart.VISUAL_ID));
Methods.addChildren(createNavigatorItems(connectedViews, Methods,
false));
result.add(LMLVisualizers);
result.add(Attributes);
result.add(Methods);
return result.toArray();
}
}
return EMPTY_ARRAY;
}
/**
* @generated
*/
private Collection<View> getLinksSourceByType(Collection<Edge> edges,
String type) {
LinkedList<View> result = new LinkedList<View>();
for (Edge nextEdge : edges) {
View nextEdgeSource = nextEdge.getSource();
if (type.equals(nextEdgeSource.getType())
&& isOwnView(nextEdgeSource)) {
result.add(nextEdgeSource);
}
}
return result;
}
/**
* @generated
*/
private Collection<View> getLinksTargetByType(Collection<Edge> edges,
String type) {
LinkedList<View> result = new LinkedList<View>();
for (Edge nextEdge : edges) {
View nextEdgeTarget = nextEdge.getTarget();
if (type.equals(nextEdgeTarget.getType())
&& isOwnView(nextEdgeTarget)) {
result.add(nextEdgeTarget);
}
}
return result;
}
/**
* @generated
*/
private Collection<View> getOutgoingLinksByType(
Collection<? extends View> nodes, String type) {
LinkedList<View> result = new LinkedList<View>();
for (View nextNode : nodes) {
result.addAll(selectViewsByType(nextNode.getSourceEdges(), type));
}
return result;
}
/**
* @generated
*/
private Collection<View> getIncomingLinksByType(
Collection<? extends View> nodes, String type) {
LinkedList<View> result = new LinkedList<View>();
for (View nextNode : nodes) {
result.addAll(selectViewsByType(nextNode.getTargetEdges(), type));
}
return result;
}
/**
* @generated
*/
private Collection<View> getChildrenByType(
Collection<? extends View> nodes, String type) {
LinkedList<View> result = new LinkedList<View>();
for (View nextNode : nodes) {
result.addAll(selectViewsByType(nextNode.getChildren(), type));
}
return result;
}
/**
* @generated
*/
private Collection<View> getDiagramLinksByType(
Collection<Diagram> diagrams, String type) {
ArrayList<View> result = new ArrayList<View>();
for (Diagram nextDiagram : diagrams) {
result.addAll(selectViewsByType(nextDiagram.getEdges(), type));
}
return result;
}
// TODO refactor as static method
/**
* @generated
*/
private Collection<View> selectViewsByType(Collection<View> views,
String type) {
ArrayList<View> result = new ArrayList<View>();
for (View nextView : views) {
if (type.equals(nextView.getType()) && isOwnView(nextView)) {
result.add(nextView);
}
}
return result;
}
/**
* @generated
*/
private boolean isOwnView(View view) {
return de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.DomainEditPart.MODEL_ID
.equals(de.uni_mannheim.informatik.swt.models.plm.diagram.part.PLMVisualIDRegistry
.getModelID(view));
}
/**
* @generated
*/
private Collection<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem> createNavigatorItems(
Collection<View> views, Object parent, boolean isLeafs) {
ArrayList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem> result = new ArrayList<de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem>(
views.size());
for (View nextView : views) {
result.add(new de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMNavigatorItem(
nextView, parent, isLeafs));
}
return result;
}
/**
* @generated
*/
public Object getParent(Object element) {
if (element instanceof de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem) {
de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem abstractNavigatorItem = (de.uni_mannheim.informatik.swt.models.plm.diagram.navigator.PLMAbstractNavigatorItem) element;
return abstractNavigatorItem.getParent();
}
return null;
}
/**
* @generated
*/
public boolean hasChildren(Object element) {
return element instanceof IFile || getChildren(element).length > 0;
}
}