author | terytkon |
Wed, 02 Jun 2010 10:50:41 +0300 | |
changeset 1 | fe41c66bacc7 |
parent 0 | 30eb2d538f02 |
permissions | -rw-r--r-- |
0
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
1 |
/* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
3 |
* All rights reserved. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
8 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
9 |
* Initial Contributors: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
11 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
12 |
* Contributors: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
13 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
14 |
* Description: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
15 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
16 |
*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
17 |
package gcmodel.util; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
18 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
19 |
import gcmodel.GcmodelPackage; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
20 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
21 |
import org.eclipse.emf.ecore.EClass; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
22 |
import org.eclipse.emf.ecore.ENamedElement; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
23 |
import org.eclipse.emf.ecore.EStructuralFeature; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
24 |
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
25 |
import org.eclipse.emf.ecore.util.ExtendedMetaData; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
26 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
27 |
public class XMLCustomizerGC { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
28 |
/** |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
29 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
30 |
*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
31 |
public class Frame |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
32 |
{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
33 |
ENamedElement elementEMF=null; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
34 |
String nameXML=null; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
35 |
int presentationXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
36 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
37 |
public Frame(ENamedElement elementEMF,String nameXML,int presentationXML){ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
38 |
this.elementEMF = elementEMF; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
39 |
this.nameXML = nameXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
40 |
this.presentationXML = presentationXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
41 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
42 |
public ENamedElement getElementEMF() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
43 |
return elementEMF; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
44 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
45 |
public void setElementEMF(ENamedElement elementEMF) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
46 |
this.elementEMF = elementEMF; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
47 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
48 |
public String getNameXML() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
49 |
return nameXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
50 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
51 |
public void setNameXML(String nameXML) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
52 |
this.nameXML = nameXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
53 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
54 |
public int getPresentationXML() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
55 |
return presentationXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
56 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
57 |
public void setPresentationXML(int presentationXML) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
58 |
this.presentationXML = presentationXML; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
59 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
60 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
61 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
62 |
//XMLCustomization body |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
63 |
//map for ConfigurationML |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
64 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
65 |
ExtendedMetaData extendedMetaData = null; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
66 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
67 |
public static final int SAVE = 0; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
68 |
public static final int LOAD = 1; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
69 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
70 |
GcmodelPackage gcpackage = GcmodelPackage.eINSTANCE; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
71 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
72 |
//input data |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
73 |
Frame[] frames = new Frame[] |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
74 |
{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
75 |
//configuration element, its attributes and elements |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
76 |
new Frame(gcpackage.getFile(), "file",ExtendedMetaData.ELEMENT_FEATURE), |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
77 |
new Frame(gcpackage.getFile_Name(), "name",ExtendedMetaData.ATTRIBUTE_FEATURE), |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
78 |
new Frame(gcpackage.getFile_Settings(),"setting",ExtendedMetaData.ELEMENT_WILDCARD_FEATURE), |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
79 |
new Frame(gcpackage.getSetting_Ref(),"ref",ExtendedMetaData.ATTRIBUTE_FEATURE) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
80 |
}; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
81 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
82 |
public ExtendedMetaData getExtendedMetaData() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
83 |
if(extendedMetaData==null) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
84 |
setExtendedMetaData(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
85 |
return extendedMetaData; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
86 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
87 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
88 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
89 |
private void setExtendedMetaData() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
90 |
extendedMetaData = new BasicExtendedMetaData(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
91 |
extendedMetaData.putPackage(gcpackage.getNsURI(), gcpackage); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
92 |
//extendedMetaData.setNamespace(confMLPackage.getConfiguration_Feature(),confMLPackage.getNsURI()); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
93 |
for (int i = 0; i < frames.length; i++) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
94 |
if(frames[i].getElementEMF() instanceof EClass){ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
95 |
extendedMetaData.setName((EClass)(frames[i].getElementEMF()), frames[i].getNameXML()); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
96 |
extendedMetaData.setContentKind((EClass)(frames[i].getElementEMF()), frames[i].getPresentationXML()); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
97 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
98 |
else if(frames[i].getElementEMF() instanceof EStructuralFeature){ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
99 |
extendedMetaData.setName((EStructuralFeature)(frames[i].getElementEMF()), frames[i].getNameXML()); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
100 |
extendedMetaData.setFeatureKind((EStructuralFeature)(frames[i].getElementEMF()), frames[i].getPresentationXML()); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
101 |
if(frames[i].getPresentationXML()==ExtendedMetaData.ELEMENT_WILDCARD_FEATURE) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
102 |
extendedMetaData.setNamespace((EStructuralFeature)(frames[i].getElementEMF()),gcpackage.getNsURI()); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
103 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
104 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
105 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
106 |
} |