carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/diagram/parts/CompartmentEditPart.xpt
author cawthron
Fri, 04 Dec 2009 12:29:56 -0600
changeset 779 4870ed7d9d38
parent 422 033392511bf7
permissions -rw-r--r--
remove .branch.txt

/*
 * 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"»

«DEFINE CompartmentEditPart FOR gmfgen::GenCompartment-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen»
package «getDiagram().editPartsPackageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «editPartClassName» «EXPAND supertypes» {
	«EXPAND xpt::diagram::parts::Common::visualIDConstant-»

	«EXPAND xpt::diagram::parts::Common::ctors-»
	«EXPAND xpt::diagram::parts::Common::notSelectable-»
	«EXPAND getModelChildren-»
	«EXPAND xpt::diagram::parts::Common::declareViewCode-»
	«EXPAND createEditPolicies-»

	«EXPAND createSelectionHandles-»
	«EXPAND xpt::diagram::parts::requests::performRequest-»
	«EXPAND getTitleName-»
	«EXPAND createFigure-»
	«EXPAND xpt::diagram::parts::Common::getAdapter-»
	«EXPAND xpt::diagram::parts::Common::contentPane-»
	«EXPAND setupCompartmentHolder-»
	«EXPAND xpt::diagram::parts::Common::activate-»
	«EXPAND xpt::diagram::parts::Common::deactivate-»
	«EXPAND xpt::diagram::parts::Common::getTransactionalUpdateManager-»
	«EXPAND xpt::diagram::parts::NotationModelRefresher::all-»
	«EXPAND xpt::diagram::parts::refresh::refresher-»
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE supertypes FOR gmfgen::GenCompartment»extends org.eclipse.gef.editparts.AbstractGraphicalEditPart implements org.eclipse.gmf.runtime.lite.edit.parts.update.IUpdatableEditPart«ENDDEFINE»

«DEFINE getModelChildren FOR gmfgen::GenCompartment-»
«EXPAND xpt::Common::generatedMemberComment»
protected java.util.List getModelChildren() {
	org.eclipse.gmf.runtime.notation.DrawerStyle style = (org.eclipse.gmf.runtime.notation.DrawerStyle) «EXPAND xpt::diagram::parts::Common::getViewCode».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle());
	if (style != null && style.isCollapsed()) {
		return java.util.Collections.EMPTY_LIST;
	}
	return «EXPAND xpt::diagram::parts::Common::getViewCode».getVisibleChildren();
}
«ENDDEFINE»

«DEFINE createEditPolicies FOR gmfgen::GenCompartment-»
«EXPAND xpt::Common::generatedMemberComment»
protected void createEditPolicies() {
	installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, new «EXPAND xpt::diagram::policies::LayoutEditPolicy::qualifiedClassName»());
	«EXPAND xpt::diagram::parts::Common::behaviour-»
	«EXPAND xpt::diagram::parts::NotationModelRefresher::installClause-»
}
«ENDDEFINE»

«DEFINE createSelectionHandles FOR gmfgen::GenCompartment-»
«EXPAND xpt::Common::generatedMemberComment("Returns the selection handles that should be contributed to the parent when it becomes selected.")»
public java.util.List createSelectionHandles() {
«IF canCollapse-»
	return java.util.Collections.singletonList(new org.eclipse.gmf.runtime.lite.handles.CompartmentCollapseHandle(this, getTitleName()));
«ELSE-»
	return java.util.Collections.singletonList(new org.eclipse.gmf.runtime.lite.handles.CompartmentNameHandle(this, getTitleName()));
«ENDIF-»
}
«ENDDEFINE»

«DEFINE getTitleName FOR gmfgen::GenCompartment-»
«EXPAND xpt::Common::generatedMemberComment»
protected String getTitleName() {
«IF needsTitle-»
	return "«title»";	«EXPAND xpt::Common::nonNLS»
«ELSE-»
	return "";	«EXPAND xpt::Common::nonNLS»
«ENDIF-»
}
«ENDDEFINE»

«DEFINE createFigure FOR gmfgen::GenCompartment-»
«EXPAND xpt::Common::generatedMemberComment»
public org.eclipse.draw2d.IFigure createFigure() {
	org.eclipse.draw2d.Figure result = new org.eclipse.gmf.runtime.lite.figures.CompartmentFigure();
	result.setLayoutManager(new org.eclipse.draw2d.StackLayout());
	org.eclipse.draw2d.ScrollPane scrollPane = new org.eclipse.draw2d.ScrollPane();
	result.add(scrollPane);
«IF listLayout-»
		org.eclipse.draw2d.Viewport viewport = new org.eclipse.draw2d.Viewport();
		contentPane = new org.eclipse.draw2d.Figure();
		contentPane.setLayoutManager(new org.eclipse.draw2d.ToolbarLayout());
«ELSE-»
		org.eclipse.draw2d.Viewport viewport = new org.eclipse.draw2d.FreeformViewport();
		contentPane = new org.eclipse.draw2d.FreeformLayer();
		contentPane.setLayoutManager(new org.eclipse.draw2d.FreeformLayout());
«ENDIF-»
	viewport.setContents(contentPane);
	scrollPane.setViewport(viewport);
	return result;
}
«ENDDEFINE»

«DEFINE setupCompartmentHolder FOR gmfgen::GenCompartment-»
«EXPAND setupCompartmentHolder FOR viewmap-»
«ENDDEFINE»

«DEFINE setupCompartmentHolder FOR gmfgen::Viewmap»«ENDDEFINE»

«DEFINE setupCompartmentHolder FOR gmfgen::ParentAssignedViewmap-»
«EXPAND xpt::Common::generatedMemberComment»
public void setupCompartmentHolder(org.eclipse.draw2d.IFigure shape) {
	if (shape.getLayoutManager() == null) {
		shape.setLayoutManager(new org.eclipse.draw2d.StackLayout());
	}
}
«ENDDEFINE»

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