carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/editor/DiagramInitializer.xpt
author cawthron
Fri, 04 Dec 2009 11:06:59 -0600
changeset 422 033392511bf7
permissions -rw-r--r--
add files for RCL_2_2

/*
 * Copyright (c) 2007 Borland Software Corporation
 * 
 * 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:
 *    bblajer (Borland) - initial API and implementation
 */

«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::GenModelUtils»
«EXTENSION xpt::diagram::parts::NotationModelRefresher»
«EXTENSION xpt::diagram::parts::LinkNotationModelRefresher»
«EXTENSION xpt::diagram::LinkFinder»

«DEFINE DiagramInitializer FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedClassComment»
private static class DiagramInitializer {
	«EXPAND xpt::Common::generatedMemberComment»
	private void initDiagramContents(org.eclipse.gmf.runtime.notation.Diagram diagram) {
«IF getAllInitableContainers().size() > 0-»
		create«getUniqueIdentifier()»Children(diagram);
«ENDIF-»
«IF links.size() > 0-»
		myViewService = new org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.NaiveViewService(diagram);
		create«getUniqueIdentifier()»ChildLinks(diagram);
«ENDIF-»
	}

«LET getAllInitableContainers() AS containers2Generate-»
«FOREACH containers2Generate AS nextContainer-»
«EXPAND createChildren FOR nextContainer-»
	«IF nextContainer.needsNotationModelRefresher()-»
«EXPAND getSemanticChildNodes FOR nextContainer-»
«EXPAND getCreateNotationalChildNodeCommand FOR nextContainer-»
	«ENDIF-»
«ENDFOREACH-»
«ENDLET-»

«IF links.size() > 0-»
	«LET getLinkContainersWithAncestors() AS linkContainersWithAncestors»
	«FOREACH linkContainersWithAncestors AS nextContainer-»
	«EXPAND createChildLinks(linkContainersWithAncestors) FOR nextContainer-»
		«IF nextContainer.containedLinks().size() > 0-»
	«EXPAND getSemanticChildLinks FOR nextContainer-»
	«EXPAND getCreateNotationalChildLinkCommand FOR nextContainer-»
		«ENDIF-»
	«ENDFOREACH-»
	«ENDLET-»
«ENDIF-»
	«EXPAND viewService-»
	«EXPAND xpt::diagram::parts::semanticChildren::getPhantomNodesIterator-»
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE createChildren FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void create«getUniqueIdentifier()»Children(org.eclipse.gmf.runtime.notation.View viewObject) {
	«EXPAND createChildrenOfCompartments-»
	«IF needsNotationModelRefresher()-»
	java.util.List semanticChildren = get«getUniqueIdentifier()»SemanticChildNodes(viewObject);
	for(java.util.Iterator it = semanticChildren.iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor nextDescriptor = (org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor) it.next();
		org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand createCommand = getCreate«getUniqueIdentifier()»NotationalChildNodeCommand(viewObject, nextDescriptor);
		if (createCommand != null && createCommand.canExecute()) {
			createCommand.execute();
		«LET getInitableGrandChildren() AS initableGrandChildren-»
		«IF initableGrandChildren.size() > 0-»
			org.eclipse.gmf.runtime.notation.View nextChild = createCommand.getCreatedView();
			int childVisualID = nextDescriptor.getVisualID();
			switch (childVisualID) {
			«EXPAND createGrandChildren("nextChild") FOREACH initableGrandChildren-»
			}
		«ENDIF-»
		«ENDLET-»
		}
	}
	«ENDIF-»
}
«ENDDEFINE»

«DEFINE createChildrenOfCompartments FOR gmfgen::GenContainerBase»«ENDDEFINE»

«DEFINE createChildrenOfCompartments FOR gmfgen::GenNode-»
«LET getInitableCompartments() AS initableCompartments-»
«IF initableCompartments.size() > 0-»
	for(java.util.Iterator it = viewObject.getChildren().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View next = (org.eclipse.gmf.runtime.notation.View) it.next();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(next);
		switch (visualID) {
		«EXPAND createGrandChildren("next") FOREACH initableCompartments-»
		}
	}
«ENDIF-»
«ENDLET-»
«ENDDEFINE»

«DEFINE createGrandChildren(String viewCode) FOR gmfgen::GenContainerBase-»
case «getEditPartQualifiedClassName()».VISUAL_ID:
	create«getUniqueIdentifier()»Children(«viewCode»);
	break;
«ENDDEFINE»

«DEFINE getSemanticChildNodes FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private java.util.List get«getUniqueIdentifier()»SemanticChildNodes(org.eclipse.gmf.runtime.notation.View parentView) {
	«EXPAND xpt::diagram::parts::semanticChildren::semanticChildren("parentView")-»
}
«ENDDEFINE»

«DEFINE getCreateNotationalChildNodeCommand FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand getCreate«getUniqueIdentifier()»NotationalChildNodeCommand(org.eclipse.gmf.runtime.notation.View parentView, org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor descriptor) {
	«EXPAND xpt::commands::createNotationalElementCommand::createNotationalNodeCommand("parentView")-»
}
«ENDDEFINE»

«DEFINE createChildLinks(Collection[gmfgen::GenCommonBase] allContainersWithAncestors) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void create«getUniqueIdentifier()»ChildLinks(org.eclipse.gmf.runtime.notation.View viewObject) {
«IF containedLinks().size() > 0-»
	java.util.List semanticChildLinks = get«getUniqueIdentifier()»SemanticChildLinks(viewObject);
	for(java.util.Iterator it = semanticChildLinks.iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor nextDescriptor = (org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor) it.next();
		org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand createCommand = getCreate«getUniqueIdentifier()»NotationalChildLinkCommand(viewObject, nextDescriptor);
		if (createCommand != null && createCommand.canExecute()) {
			createCommand.execute();
		}
	}
«ENDIF-»
		«LET getContainedContainers().select(e| allContainersWithAncestors.contains(e)) AS containedLinkContainers-»
		«LET containedLinkContainers.typeSelect(gmfgen::GenLink) AS linkContainersContainedInSourceEdges-»
		«LET (Collection[gmfgen::GenCommonBase]) containedLinkContainers.without(linkContainersContainedInSourceEdges) AS linkContainersContainedInChildren-»
		«IF linkContainersContainedInChildren.size() > 0-»
	for(java.util.Iterator it = viewObject.getChildren().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View next = (org.eclipse.gmf.runtime.notation.View) it.next();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(next);
		switch (visualID) {
		«EXPAND createGrandChildLinks FOREACH linkContainersContainedInChildren-»
		}
	}
		«ENDIF-»
		«IF linkContainersContainedInSourceEdges.size() > 0-»
	for(java.util.Iterator it = viewObject.getSourceEdges().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View next = (org.eclipse.gmf.runtime.notation.View) it.next();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(next);
		switch (visualID) {
		«EXPAND createGrandChildLinks FOREACH linkContainersContainedInSourceEdges-»
		}
	}
		«ENDIF-»
		«ENDLET-»
		«ENDLET-»
		«ENDLET-»
}
«ENDDEFINE»

«DEFINE createGrandChildLinks FOR gmfgen::GenCommonBase-»
case «getEditPartQualifiedClassName()».VISUAL_ID:
	create«getUniqueIdentifier()»ChildLinks(next);
	break;
«ENDDEFINE»

«DEFINE getSemanticChildLinks FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
private java.util.List get«getUniqueIdentifier()»SemanticChildLinks(org.eclipse.gmf.runtime.notation.View parentView) {
	«EXPAND xpt::diagram::parts::semanticChildLinks::semanticChildLinks("parentView")-»
}
«ENDDEFINE»

«DEFINE getCreateNotationalChildLinkCommand FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand getCreate«getUniqueIdentifier()»NotationalChildLinkCommand(org.eclipse.gmf.runtime.notation.View parentView, org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor linkDescriptor) {
	«EXPAND xpt::commands::createNotationalElementCommand::createNotationalEdgeCommand("parentView.getDiagram()")-»
}
«ENDDEFINE»

«DEFINE viewService FOR gmfgen::GenDiagram-»
«IF links.size() > 0-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.IViewService myViewService;

«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.IViewService getViewService() {
	return myViewService;
}
«ENDIF-»
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»