|
|
Re: How to add attributes to an abstract component [message #757587 is a reply to message #757586] |
Sat, 19 November 2011 22:05 |
Jens Missing name Messages: 27 Registered: November 2011 |
Junior Member |
|
|
hi Christian,
sorry I didn't get that: "your component eclass gets a name and a properties
so this happens automatically"
I wanted to do something like this. Could you give me an example please.
def setProperties(Component c) '''
«IF (c.properties.colspan != null)»
«c.name»Constraint.gridwidth = «c.properties.colspan»;
«ENDIF»
«IF (c.properties.rowspan != null)»
«c.name»Constraint.gridheight = «c.properties.rowspan»;
«ENDIF»
«IF (c.properties.alignment != null)»
«c.name»Constraint.fill = «c.name»Constraint«c.properties.alignment»;
«ENDIF»
'''
so that I don't have to do it for all my components:..
def dispatch compile (Button b, Panel p) '''
JButton «b.name» = new JButton("«b.text»");
«IF (b.actionmessage!=null)»
«b.name».addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"«b.actionmessage»");
}});
«ENDIF»
«IF (b.properties != null)»
GridBagConstraints «b.name»Constraint = new GridBagConstraints();
«b.name»Constraint.gridx = «b.properties.position.gridX»;
«b.name»Constraint.gridy = «b.properties.position.gridY»;
«p.name».add(«b.name», «b.name»Constraint);
«IF (b.properties.colspan != null)»
«b.name»Constraint.gridwidth = «b.properties.colspan»;
«ENDIF»
«IF (b.properties.rowspan != null)»
«b.name»Constraint.gridheight = «b.properties.rowspan»;
«ENDIF»
«IF (b.properties.alignment != null)»
«b.name»Constraint.fill = «b.name»Constraint«b.properties.alignment»;
«ENDIF»
«ELSE»
«p.name».add(«b.name»);
«ENDIF»
«p.name».add(«b.name»);
'''
def setProperties(Component c) '''
«c.eClass.» ?????????
'''
regards,
jens
[Updated on: Sat, 19 November 2011 22:09] Report message to a moderator
|
|
|
Re: How to add attributes to an abstract component [message #757588 is a reply to message #757587] |
Sat, 19 November 2011 22:08 |
|
Hi,
as i said: this works with the grammar you shared!!!!!
here is the metamodel generated
<eClassifiers xsi:type="ecore:EClass" name="Component">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="properties" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03629 seconds