blob: 2b5f72ca57b8d5197725687f01edba0b9807fc04 [file] [log] [blame]
/*
* Copyright (c) 2006, 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:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
import "http://www.eclipse.org/gmf/2006/GraphicalDefinition";
import "http://www.eclipse.org/emf/2002/Ecore";
String compilationUnitName(gmfgraph::FigureDescriptor figure) :
figure.name.toFirstUpper()
;
Boolean hasSourceDecoration(gmfgraph::PolylineConnection figure) :
null != figure.sourceDecoration
;
List[String] requiredBundles(List[String] referencedBundles) :
isFullRuntime() /*&& usesLabelOrPolyline) || usesMapMode()*/ ?
{"org.eclipse.core.runtime","org.eclipse.draw2d", "org.eclipse.gmf.runtime.draw2d.ui"}.union(referencedBundles).toList().purgeDups() :
{"org.eclipse.core.runtime","org.eclipse.draw2d"}.union(referencedBundles).toList().purgeDups()
;
String additionalStaticFields() :
GLOBALVAR outputStaticFields
;
EBoolean hasTargetDecoration(gmfgraph::PolylineConnection figure) :
null != figure.targetDecoration
;
cached boolean isFullRuntime() :
internalCheckRuntimeToken() != null ? internalCheckRuntimeToken().toLowerCase() == "full" : true
;
private String internalCheckRuntimeToken() : GLOBALVAR runtimeToken;
boolean needsField(gmfgraph::RealFigure figure) :
// XXX consider adding generation option "fields for all figures"
figure.descriptor != null && figure.descriptor.accessors.figure.contains(figure)
;
String figureVariableName(gmfgraph::RealFigure figure, EInt count) :
needsField(figure)
? figureFieldName(figure)
: ( figure.name != null && figure.name.trim().length() > 0
? figure.name.toFirstLower() + count
: variableNameStem(figure) + count )
;
String nameStem(FigureRef fig) : variableNameStem(fig.figure);
String nameStem(Figure fig) : variableNameStem(fig);
// actually, should be smth like fig.eClass().name
private String variableNameStem(Figure fig) : "fig";
private String variableNameStem(RealFigure fig) : "fig";
private String variableNameStem(Shape fig) : "shape";
private String variableNameStem(Rectangle fig) : "rect";
private String variableNameStem(RoundedRectangle fig) : "rrect";
private String variableNameStem(Ellipse fig) : "elli";
private String variableNameStem(Polyline fig) : "polyline";
private String variableNameStem(Label fig) : "l";
private String variableNameStem(DecorationFigure fig) : "dec";
private String variableNameStem(ConnectionFigure fig) : "conn";
// assert needsField() == true
String figureFieldName(gmfgraph::RealFigure figure) :
figureFieldName(figure.descriptor.accessors.select(a | (figure == a.figure)))
;
private String figureFieldName(List[ChildAccess] aaa) :
aaa.collect(x | figureFieldName(x)).toList().first()
;
String figureFieldName(gmfgraph::ChildAccess childAccess) :
"f" + (childAccess.accessor.startsWith("get") && childAccess.accessor.length() > 3 ? childAccess.accessor.subString(3) : childAccess.accessor)
;
String borderLayoutConstant(gmfgraph::BorderLayoutData layoutData) :
switch (layoutData.alignment) {
case Alignment::BEGINNING : ( layoutData.vertical ? "TOP" : "LEFT" )
case Alignment::END : ( layoutData.vertical ? "BOTTOM" : "RIGHT" )
default : "CENTER"
}
;
cached List[gmfgraph::CustomBorder] getBordersInUse() : {} ;
cached List[FigureAccessor] allCustomAccessors(FigureDescriptor fd) :
filterCustom( { fd.actualFigure } ).customChildren
;
// all CustimFigures in the hierarchy of each figure
private List[CustomFigure] filterCustom(List[Figure] figures) :
figures.isEmpty() ? {}
: figures.typeSelect(CustomFigure).union(filterCustom(figures.typeSelect(RealFigure).children))
;
EString messageFormat(EString pattern, List[Object] argument) :
JAVA java.text.MessageFormat.format(java.lang.String, java.lang.Object.List)
;