• R/O
  • SSH
  • HTTPS

rgss-lib: Commit


Commit MetaInfo

Revisão448 (tree)
Hora2012-07-27 00:13:15
Autoryf30

Mensagem de Log

グラマー作成中

Mudança Sumário

Diff

--- trunk/eclipse/projects/jp.sf.rgsslib.tools.rpgtkool.common/src/jp/fs/rgsslib/tools/rpgtkool/common/CommonUtils.java (nonexistent)
+++ trunk/eclipse/projects/jp.sf.rgsslib.tools.rpgtkool.common/src/jp/fs/rgsslib/tools/rpgtkool/common/CommonUtils.java (revision 448)
@@ -0,0 +1,37 @@
1+package jp.fs.rgsslib.tools.rpgtkool.common;
2+
3+import org.eclipse.core.resources.IProject;
4+import org.eclipse.core.resources.ResourcesPlugin;
5+import org.eclipse.core.runtime.Path;
6+import org.eclipse.emf.common.util.URI;
7+import org.eclipse.emf.ecore.EObject;
8+import org.eclipse.emf.ecore.resource.Resource;
9+import org.eclipse.emf.ecore.resource.ResourceSet;
10+
11+public class CommonUtils {
12+ private static final String SYSTEM_DSL_PATH[] = new String[]{"src/system.sysinfo","system.sysinfo"};
13+
14+ public static EObject getSystemDSLModel(Resource resource) {
15+ return getDSLModel(resource, SYSTEM_DSL_PATH);
16+ }
17+
18+ private static EObject getDSLModel(Resource resource, String[] paths) {
19+ if (resource.getURI().segmentCount() > 1) {
20+ return getDSLModel(resource.getResourceSet(), resource.getURI().segment(1), paths);
21+ }
22+ return null;
23+ }
24+
25+ private static EObject getDSLModel(ResourceSet resourceSet, String projectName, String[] paths) {
26+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
27+ for (String path : paths) {
28+ if (project.getFile(new Path(path)).exists()) {
29+ URI uri = URI.createPlatformResourceURI(projectName+"/"+path,true);
30+ Resource resource = resourceSet.getResource(uri,true);
31+ return resource.getAllContents().next();
32+ }
33+ }
34+ return null;
35+ }
36+
37+}
Show on old repository browser