carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/diagram/parts/EditPartFactory.xpt
/*
* 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::Common»
«DEFINE EditPartFactory FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen»
package «editPartsPackageName»;
«EXPAND xpt::Common::generatedClassComment»
public class «editPartFactoryClassName» «EXPAND supertypes» {
«EXPAND externalNodeLabels-»
«EXPAND createEditPart-»
«EXPAND createUnrecognizedEditPart-»
«EXPAND additions-»
}
«ENDDEFINE»
«DEFINE supertypes FOR gmfgen::GenDiagram»implements org.eclipse.gef.EditPartFactory«ENDDEFINE»
«DEFINE externalNodeLabels FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
public static final String EXTERNAL_NODE_LABELS_LAYER = "External Node Labels"; «EXPAND xpt::Common::nonNLS»
«ENDDEFINE»
«DEFINE createEditPart FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
public org.eclipse.gef.EditPart createEditPart(org.eclipse.gef.EditPart context, Object model) {
if (model instanceof org.eclipse.gmf.runtime.notation.View) {
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) model;
String modelID = «EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(view);
if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(modelID)) {
«IF containsShortcutsTo.size() > 0-»
if («getDiagramEditorUtilQualifiedClassName()».isKnownShortcutModelID(modelID)) {
org.eclipse.gmf.runtime.lite.shortcuts.IShortcutProvider shortcutProvider = org.eclipse.gmf.runtime.lite.shortcuts.ShortcutProvidersRegistry.INSTANCE.getShortcutProvider(modelID);
if (shortcutProvider != null) {
return shortcutProvider.createShortcutEditPart(context, view);
}
}
«ENDIF-»
return null;
}
int viewVisualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(view);
switch (viewVisualID) {
«EXPAND doCreate FOREACH getAllContainers()-»
«EXPAND doCreate FOREACH links-»
}
}
return createUnrecognizedEditPart(context, model);
}
«ENDDEFINE»
«DEFINE createUnrecognizedEditPart FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gef.EditPart createUnrecognizedEditPart(org.eclipse.gef.EditPart context, Object model) {
// Handle creation of unrecognized child node EditParts here
return null;
}
«ENDDEFINE»
«DEFINE doCreate FOR gmfgen::GenCommonBase-»
«EXPAND caseVisualID-»
«EXPAND doCreate FOREACH getAllLabels()-»
«ENDDEFINE»
«DEFINE caseVisualID FOR gmfgen::GenCommonBase-»
case «EXPAND xpt::editor::VisualIDRegistry::visualID»:
return new «getEditPartQualifiedClassName()»(«EXPAND cast»view);
«ENDDEFINE»
«DEFINE cast FOR gmfgen::GenCommonBase»«ENDDEFINE»
«DEFINE cast FOR gmfgen::GenDiagram»(org.eclipse.gmf.runtime.notation.Diagram) «ENDDEFINE»
«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»