Source Code Cross Referenced for ModelUtil.java in  » Workflow-Engines » osbl-1_0 » model » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » osbl 1_0 » model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package model;
004:
005:        import java.util.ArrayList;
006:        import java.util.Iterator;
007:        import java.util.List;
008:
009:        import logging.LoggingPlugin;
010:        import newprocess.Element;
011:
012:        import org.eclipse.core.resources.IFile;
013:        import org.eclipse.core.resources.IFolder;
014:        import org.eclipse.core.resources.IProject;
015:        import org.eclipse.core.resources.IResource;
016:        import org.eclipse.core.resources.ResourcesPlugin;
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.ILog;
019:        import org.eclipse.core.runtime.IStatus;
020:        import org.eclipse.core.runtime.Status;
021:        import org.eclipse.gef.EditPart;
022:        import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
023:        import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
024:        import org.eclipse.gmf.runtime.notation.Diagram;
025:        import org.eclipse.gmf.runtime.notation.Node;
026:
027:        /**
028:         * @author sh
029:         *
030:         */
031:        public class ModelUtil {
032:
033:            /**
034:             * Helper method to return the locations of the given files.
035:             * 
036:             * @param files a list of files
037:             * @return modelList a list containing the location of all files
038:             */
039:            private static List<String> getModelFilePaths(List<IFile> files) {
040:                List<String> modelList = new ArrayList<String>();
041:                for (Iterator<IFile> iterator = files.iterator(); iterator
042:                        .hasNext();) {
043:                    IFile file = (IFile) iterator.next();
044:                    String path = file.getLocation().toString();
045:                    modelList.add(path);
046:                }
047:                return modelList;
048:            }
049:
050:            /**
051:             * get all Meta Model Files (*.ecore) in the workspace.
052:             * Just opened projects are considered.
053:             * 
054:             * @return modelList a list containing all Meta Model Files of the workspace 
055:             */
056:            public static List<String> getMetaModelFiles() {
057:                List<IFile> modelFiles = scanWorkspace("ecore");
058:                return getModelFilePaths(modelFiles);
059:            }
060:
061:            /**
062:             * Scans the whole workspace for files with the given file extension.
063:             * Just opened projects are considered.
064:             * 
065:             * @param fileExtension the file ending of the wanted files
066:             * @return matches a list containing all found files
067:             */
068:            public static List<IFile> scanWorkspace(String fileExtension) {
069:                try {
070:                    List<IFile> matches = new ArrayList<IFile>();
071:
072:                    // scan the whole workspace for opened projects 
073:                    IProject[] projects = ResourcesPlugin.getWorkspace()
074:                            .getRoot().getProjects();
075:                    for (IProject project : projects) {
076:
077:                        // just search if if the current project is open
078:                        if (!project.isAccessible())
079:                            continue;
080:
081:                        // get the content of the current project and scan for the wanted files
082:                        IResource[] members = project.members();
083:                        for (IResource resource : members) {
084:
085:                            if (resource instanceof  IFile) {
086:                                if (((IFile) resource).getFileExtension() != null
087:                                        && ((IFile) resource)
088:                                                .getFileExtension().equals(
089:                                                        fileExtension)) {
090:                                    matches.add((IFile) resource);
091:                                }
092:                            }
093:
094:                            // scan recursivly all subfolders
095:                            else if (resource instanceof  IFolder)
096:                                matches.addAll(search(((IFolder) resource),
097:                                        fileExtension));
098:                        }
099:                    }
100:
101:                    return matches;
102:                } catch (IllegalStateException e1) {
103:                    String message = " You are not running under Eclipse but "
104:                            + "instead under just a standard java application";
105:                    ILog logger = LoggingPlugin.getDefault().getLog();
106:                    String symName = LoggingPlugin.getDefault().getBundle()
107:                            .getSymbolicName();
108:                    logger.log(new Status(IStatus.ERROR, symName, 0, message,
109:                            e1));
110:                    throw new RuntimeException(message, e1);
111:                    // TODO: finding the Meta Model without running under Eclipse.
112:                } catch (CoreException e) {
113:                    return null;
114:                }
115:            }
116:
117:            /**
118:             * Searches for files with the given file extension starting at
119:             * the given folder.
120:             * 
121:             * @param folder the folder to start
122:             * @param ending the file extension of the file to search
123:             * @return matches a list containing all found files
124:             */
125:            public static List<IFile> search(IFolder folder, String ending) {
126:                List<IFile> matches = new ArrayList<IFile>();
127:                if (folder != null) {
128:                    IResource[] members;
129:                    try {
130:                        members = folder.members();
131:                    } catch (CoreException e) {
132:                        String message = e.getMessage();
133:                        ILog logger = LoggingPlugin.getDefault().getLog();
134:                        String symName = LoggingPlugin.getDefault().getBundle()
135:                                .getSymbolicName();
136:                        logger.log(new Status(IStatus.ERROR, symName, 0,
137:                                message, e));
138:                        throw new RuntimeException(e);
139:                    }
140:
141:                    for (int i = 0; i < members.length; i++) {
142:                        IResource resource = members[i];
143:                        if (resource instanceof  IFile) {
144:                            if (((IFile) resource).getFileExtension() != null
145:                                    && ((IFile) resource).getFileExtension()
146:                                            .equals(ending)) {
147:                                matches.add((IFile) resource);
148:                            }
149:                        } else if (resource instanceof  IFolder) {
150:                            matches.addAll(search((IFolder) resource, ending));
151:                        }
152:                    }
153:                }
154:                return matches;
155:            }
156:
157:            /**
158:             * get all Model Files (*.concept) in the workspace.
159:             * Just opened projects are considered.
160:             * 
161:             * @return modelList a list containing all Model Files of the workspace
162:             */
163:            public static List<String> getModelFiles() {
164:                List<IFile> modelFiles = scanWorkspace("concept");
165:                return getModelFilePaths(modelFiles);
166:            }
167:
168:            /**
169:             * get the implementation property of a model element.
170:             * 
171:             * @param editPart the EditPart containing the 
172:             * 				implementation property
173:             * @return implementation the implementation property
174:             */
175:            public static String getModelImplProperty(EditPart editPart) {
176:                String implementation = null;
177:                if (editPart instanceof  DiagramEditPart)
178:                    implementation = ((newprocess.Process) ((Diagram) editPart
179:                            .getModel()).getElement()).getImplementation();
180:                else if (editPart instanceof  ShapeNodeEditPart)
181:                    implementation = ((Element) ((Node) editPart.getModel())
182:                            .getElement()).getImplementation();
183:                return implementation;
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.