• R/O
  • SSH
  • HTTPS

rgss-lib: Commit


Commit MetaInfo

Revisão451 (tree)
Hora2012-07-30 23:34:34
Autoryf30

Mensagem de Log

グラマー作成中

Mudança Sumário

Diff

--- trunk/eclipse/projects/jp.sf.rgsslib.tools.rgptkool.system.editor/src/jp/sf/rgsslib/tools/rgptkool/system/editor/generator/SystemDSLUtils.java (revision 450)
+++ trunk/eclipse/projects/jp.sf.rgsslib.tools.rgptkool.system.editor/src/jp/sf/rgsslib/tools/rgptkool/system/editor/generator/SystemDSLUtils.java (revision 451)
@@ -3,7 +3,9 @@
33 import java.io.FileInputStream;
44 import java.io.IOException;
55 import java.util.ArrayList;
6+import java.util.HashMap;
67 import java.util.List;
8+import java.util.Map;
79
810 import jp.fs.rgsslib.tools.rpgtkool.common.CommonUtils;
911 import jp.sf.rgsslib.tools.j2rlib.vxace.RGSSProxyFacade;
@@ -46,76 +48,121 @@
4648 }
4749 return proxyFacade.createSystem();
4850 }
49-
51+
5052 // 変数の情報
51- private static List<String> getVariables(SystemDSLModel dsl,
52- List<String> variables) {
53- for (VariableInfo variableInfo : dsl.getVariable().getVariables()) {
54- if (variableInfo.getName() != null)
55- variables.add(variableInfo.getName());
53+ private static Map<Integer,String> getVariablesInternal(Resource resource) {
54+ Map<Integer,String> variables = new HashMap<Integer,String>();
55+ int count = 0;
56+ if (resource.getURI().segmentCount() > 1) {
57+ String projectName = resource.getURI().segment(1);
58+ if (projectName != null) {
59+ System systemData = getSystemData(projectName);
60+ for (String name : systemData.getVariables()) {
61+ variables.put(count,name);
62+ count++;
63+ }
64+ }
5665 }
57- return variables;
58- }
5966
60- private static List<String> getVariables(System systemData,
61- List<String> variables) {
62- for (String variable : systemData.getVariables()) {
63- if (variable != null)
64- variables.add(variable);
67+ EObject object = CommonUtils.getSystemDSLModel(resource);
68+ if (object instanceof SystemDSLModel) {
69+ SystemDSLModel dsl = (SystemDSLModel) object;
70+ for (VariableInfo info : dsl.getVariable().getVariables()) {
71+ if (info.getName() != null) {
72+ if (info.getId() > 0) {
73+ count = info.getId();
74+ }
75+ variables.put(count,info.getName());
76+ count++;
77+ }
78+ }
6579 }
6680 return variables;
6781 }
6882
83+ /**
84+ * コンテンツアシスト用に、null の入らない名前のリストを返す。
85+ * @param resource
86+ * @return
87+ */
6988 public static List<String> getVariables(Resource resource) {
70- List<String> variables = new ArrayList<String>();
71-
72- EObject object = CommonUtils.getSystemDSLModel(resource);
73- if (object instanceof SystemDSLModel) {
74- getVariables((SystemDSLModel) object, variables);
89+ List<String> list = new ArrayList<String>();
90+ for(String name : getVariablesInternal(resource).values()) {
91+ if (name != null)
92+ list.add(name);
7593 }
94+ return list;
95+ }
96+ /**
97+ * データ生成用に、名前からIDを取るためのマップを返す。
98+ * @param resource
99+ * @return
100+ */
101+ public static Map<String,Integer> getVariablesMap(Resource resource) {
102+ Map<String,Integer> map = new HashMap<String,Integer>();
103+ for(Map.Entry<Integer, String> et : getVariablesInternal(resource).entrySet()) {
104+ if (et.getValue() != null) {
105+ map.put(et.getValue(), et.getKey());
106+ }
107+ }
108+ return map;
109+ }
76110
111+ // スイッチの情報
112+ private static Map<Integer,String> getSwitchesInternal(Resource resource) {
113+ Map<Integer,String> switches = new HashMap<Integer,String>();
114+ int count = 0;
77115 if (resource.getURI().segmentCount() > 1) {
78116 String projectName = resource.getURI().segment(1);
79117 if (projectName != null) {
80- getVariables(getSystemData(projectName), variables);
118+ System systemData = getSystemData(projectName);
119+ for (String name : systemData.getSwitches()) {
120+ switches.put(count,name);
121+ count++;
122+ }
81123 }
82124 }
83- return variables;
84- }
85125
86- // スイッチの情報
87- private static List<String> getSwitches(SystemDSLModel dsl,
88- List<String> switches) {
89- for (SwitchInfo switchInfo : dsl.getSwitch().getSwitches()) {
90- if (switchInfo.getName() != null)
91- switches.add(switchInfo.getName());
126+ EObject object = CommonUtils.getSystemDSLModel(resource);
127+ if (object instanceof SystemDSLModel) {
128+ SystemDSLModel dsl = (SystemDSLModel) object;
129+ for (SwitchInfo info : dsl.getSwitch().getSwitches()) {
130+ if (info.getName() != null) {
131+ if (info.getId() > 0) {
132+ count = info.getId();
133+ }
134+ switches.put(count,info.getName());
135+ count++;
136+ }
137+ }
92138 }
93139 return switches;
94140 }
95-
96- private static List<String> getSwitches(System systemData,
97- List<String> switches) {
98- for (String _switch : systemData.getSwitches()) {
99- if (_switch != null)
100- switches.add(_switch);
141+ /**
142+ * コンテンツアシスト用に、null の入らない名前のリストを返す。
143+ * @param resource
144+ * @return
145+ */
146+ public static List<String> getSwitches(Resource resource) {
147+ List<String> list = new ArrayList<String>();
148+ for(String name : getSwitchesInternal(resource).values()) {
149+ if (name != null)
150+ list.add(name);
101151 }
102- return switches;
152+ return list;
103153 }
104-
105- public static List<String> getSwitches(Resource resource) {
106- List<String> switches = new ArrayList<String>();
107-
108- EObject object = CommonUtils.getSystemDSLModel(resource);
109- if (object instanceof SystemDSLModel) {
110- getSwitches((SystemDSLModel) object, switches);
111- }
112-
113- if (resource.getURI().segmentCount() > 1) {
114- String projectName = resource.getURI().segment(1);
115- if (projectName != null) {
116- getSwitches(getSystemData(projectName), switches);
154+ /**
155+ * データ生成用に、名前からIDを取るためのマップを返す。
156+ * @param resource
157+ * @return
158+ */
159+ public static Map<String,Integer> getSwitchesMap(Resource resource) {
160+ Map<String,Integer> map = new HashMap<String,Integer>();
161+ for(Map.Entry<Integer, String> et : getSwitchesInternal(resource).entrySet()) {
162+ if (et.getValue() != null) {
163+ map.put(et.getValue(), et.getKey());
117164 }
118165 }
119- return switches;
166+ return map;
120167 }
121168 }
Show on old repository browser