Bonjour à tous,
J'utilise Visual Editor et je viens de découvrir la vue VE Model : XMI View qui permet d'afficher ma Visual Class java sous forme XML.
Voici à quoi ressemble ma classe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.Rectangle; import javax.swing.JLabel; public class Frame extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JButton jButton = null; private JLabel jLabel = null; /** * This is the default constructor */ public Frame() { super(); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(300, 200); this.setContentPane(getJContentPane()); this.setTitle("JFrame"); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jLabel = new JLabel(); jLabel.setBounds(new Rectangle(157, 104, 38, 16)); jLabel.setText("JLabel"); jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getJButton(), null); jContentPane.add(jLabel, null); } return jContentPane; } /** * This method initializes jButton * * @return javax.swing.JButton */ private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setBounds(new Rectangle(64, 25, 34, 10)); } return jButton; } }
Et voici la tête du fichier XML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 <?xml version="1.0" encoding="UTF-8" ?> - <org.eclipse.ve.internal.jcm:BeanSubclassComposition xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:_-javaprim="java:/" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:java.awt="java:/java.awt" xmlns:java.lang="java:/java.lang" xmlns:javax.swing="java:/javax.swing" xmlns:org.eclipse.jem.internal.instantiation="http:///org/eclipse/jem/internal/instantiation.ecore" xmlns:org.eclipse.ve.internal.cdm="http:///org/eclipse/ve/internal/cdm.ecore" xmlns:org.eclipse.ve.internal.jcm="http:///org/eclipse/ve/internal/jcm.ecore"> <diagrams id="org.eclipse.ve.internal.cdm.primarydiagram" visualInfos="//@annotations.0/@visualInfos.0 //@annotations.1/@visualInfos.0" /> - <annotations xsi:type="org.eclipse.ve.internal.cdm:AnnotationEMF" annotates="//@members.0"> <keyedValues xsi:type="ecore:EStringToStringMapEntry" key="org.eclipse.ve.internal.cde.core.nameincomposition" value="jContentPane" /> - <visualInfos diagram="//@diagrams.0"> <keyedValues xsi:type="org.eclipse.ve.internal.cdm:KeyedBoolean" key="org.eclipse.ve.internal.cdm.model.visualconstraintkey" value="true" /> </visualInfos> </annotations> - <annotations xsi:type="org.eclipse.ve.internal.cdm:AnnotationEMF" annotates="this"> - <visualInfos diagram="//@diagrams.0"> <keyedValues xsi:type="org.eclipse.ve.internal.cdm:KeyedBoolean" key="org.eclipse.ve.internal.cdm.model.visualconstraintkey" value="true" /> </visualInfos> </annotations> + <annotations xsi:type="org.eclipse.ve.internal.cdm:AnnotationEMF" annotates="//@members.1"> <keyedValues xsi:type="ecore:EStringToStringMapEntry" key="org.eclipse.ve.internal.cde.core.nameincomposition" value="jButton" /> </annotations> - <annotations xsi:type="org.eclipse.ve.internal.cdm:AnnotationEMF" annotates="//@members.2"> <keyedValues xsi:type="ecore:EStringToStringMapEntry" key="org.eclipse.ve.internal.cde.core.nameincomposition" value="jLabel" /> </annotations> - <members xsi:type="javax.swing:JPanel"> - <allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation"> <expression xsi:type="org.eclipse.jem.internal.instantiation:PTClassInstanceCreation" type="javax.swing.JPanel" /> </allocation> <layout xsi:nil="true" /> - <components component="//@members.1"> <constraint xsi:nil="true" /> </components> - <components component="//@members.2"> <constraint xsi:nil="true" /> </components> </members> <members xsi:type="javax.swing:JButton" bounds="//@methods.2/@properties.0" /> <members xsi:type="javax.swing:JLabel" bounds="//@methods.0/@properties.1" text="//@methods.0/@properties.0" /> <thisPart xsi:type="_-javaprim:Frame" xmi:id="this" size="//@methods.1/@properties.0" title="//@methods.1/@properties.1" contentPane="//@members.0" /> - <methods name="getJContentPane" initializes="//@members.0 //@members.2" return="//@members.0"> - <properties xsi:type="java.lang:String"> <allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation" initString=""JLabel"" /> </properties> - <properties xsi:type="java.awt:Rectangle"> - <allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation"> - <expression xsi:type="org.eclipse.jem.internal.instantiation:PTClassInstanceCreation" type="java.awt.Rectangle"> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="157" /> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="104" /> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="38" /> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="16" /> </expression> </allocation> </properties> </methods> - <methods name="initialize" initializes="this"> - <properties xsi:type="java.awt:Dimension"> <allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation" initString="new java.awt.Dimension(300,200)" /> </properties> - <properties xsi:type="java.lang:String"> - <allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation"> <expression xsi:type="org.eclipse.jem.internal.instantiation:PTStringLiteral" escapedValue=""JFrame"" /> </allocation> </properties> </methods> - <methods name="getJButton" initializes="//@members.1" return="//@members.1"> - <properties xsi:type="java.awt:Rectangle"> - <allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation"> - <expression xsi:type="org.eclipse.jem.internal.instantiation:PTClassInstanceCreation" type="java.awt.Rectangle"> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="64" /> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="25" /> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="34" /> <arguments xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral" token="10" /> </expression> </allocation> </properties> </methods> </org.eclipse.ve.internal.jcm:BeanSubclassComposition>
Ce que je souhaiterais, c'est que Visual Editor puisse, à partir d'un fichier XML (valide bien sûr) comme celui ci-dessus, reconstruire ma classe java et afficher son aperçu dans la fenêtre d'édition.
Donc je me demandais si VE serait capable de parser ce fichier pour reconstruire une classe ou alors si il existerait d'autres méthodes pour le faire.
Merci d'avance pour l'aide que vous pourrez m'apporter.
Nicolas.
Partager