Source Code Cross Referenced for EnvEntryList.java in  » Workflow-Engines » osbl-1_0 » gui » section » 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 » gui.section 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package gui.section;
004:
005:        import gui.actions.RefactorEnvEntryAction;
006:
007:        import java.util.HashMap;
008:        import java.util.HashSet;
009:        import java.util.Iterator;
010:        import java.util.Map;
011:        import java.util.Set;
012:        import java.util.Vector;
013:
014:        import org.eclipse.emf.common.util.EList;
015:        import org.eclipse.gef.EditPart;
016:
017:        import core.Util;
018:        import diagram.commands.ConfigureCommand;
019:        import diagram.commands.DeleteCommand;
020:        import diagram.commands.ReadCommand;
021:        import diagram.commands.WriteCommand;
022:        import diagram.section.EnvEntry;
023:
024:        /**
025:         * Class that plays the role of the domain model in the EnvEntrySheetPage.
026:         * 
027:         * @author sh
028:         */
029:        public class EnvEntryList {
030:            private Vector<EnvEntry> envEntries = new Vector<EnvEntry>();
031:            private Set<IEnvEntryViewer> changeListeners = new HashSet<IEnvEntryViewer>();
032:            private EditPart selectedEditPart;
033:            Map<EnvEntry, newprocess.EnvEntry> entryMap = new HashMap<EnvEntry, newprocess.EnvEntry>();
034:            public static final String STANDARD_TEXT = "(standard)";
035:
036:            /**
037:             * Constructor
038:             */
039:            public EnvEntryList(EditPart selectedEditPart) {
040:                super ();
041:                this .selectedEditPart = selectedEditPart;
042:                this .initData();
043:            }
044:
045:            /**
046:             * Return the collection of EnvEntries.
047:             */
048:            public Vector<EnvEntry> getEnvEntries() {
049:                return envEntries;
050:            }
051:
052:            /**
053:             * initialize some default entries. 
054:             */
055:            private void initData() {
056:                // get the EMF model data
057:                ReadCommand readCommand = new ReadCommand();
058:                EList<newprocess.EnvEntry> entries = readCommand
059:                        .getValues(selectedEditPart);
060:
061:                if (entries == null || entries.isEmpty())
062:                    return;
063:
064:                // clear the hashmap
065:                entryMap.clear();
066:
067:                // create the table model EnvEntry Objects
068:                EnvEntry exampleEnvEntry = null;
069:                for (Iterator<newprocess.EnvEntry> iter = entries.iterator(); iter
070:                        .hasNext();) {
071:                    newprocess.EnvEntry element = (newprocess.EnvEntry) iter
072:                            .next();
073:                    exampleEnvEntry = new EnvEntry(element.getName());
074:                    exampleEnvEntry.setName(element.getName());
075:                    exampleEnvEntry.setType(element.getType());
076:                    exampleEnvEntry.setValue(element.getValue());
077:                    envEntries.add(exampleEnvEntry);
078:                    entryMap.put(exampleEnvEntry, element);
079:                }
080:            };
081:
082:            /**
083:             * Add a new table model EnvEntry and an EMF model EnvEntry.
084:             */
085:            public void addEnvEntry() {
086:                // create the table model EnvEntry Object
087:                EnvEntry envEntry = new EnvEntry(EnvEntryList.STANDARD_TEXT);
088:                envEntries.add(envEntries.size(), envEntry);
089:
090:                // create the EMF model EnvEntry Object
091:                ConfigureCommand confCom = new ConfigureCommand();
092:                newprocess.EnvEntry modelEntry = confCom
093:                        .executeConfigureElementCommand(selectedEditPart,
094:                                envEntry);
095:
096:                // add both to the hasmap
097:                entryMap.put(envEntry, modelEntry);
098:
099:                Iterator<IEnvEntryViewer> iterator = changeListeners.iterator();
100:                while (iterator.hasNext()) {
101:                    ((IEnvEntryViewer) iterator.next()).addEnvEntry(envEntry);
102:                }
103:            }
104:
105:            /**
106:             * Removes a table model EnvEntry and an EMF model EnvEntry Object.
107:             * It also checks if EnvEntry source code exist. If so the
108:             * source will be removed if confirmed.
109:             * 
110:             * @param envEntry
111:             */
112:            public void removeEnvEntry(EnvEntry envEntry) {
113:                // check if a standard text entry is in the collection
114:                deleteDummies();
115:
116:                // removes the table EnvEntry Object from the view
117:                envEntries.remove(envEntry);
118:
119:                // fetch the EMF Model Entry of the concerning table model Entry Object
120:                newprocess.EnvEntry modelEntry = entryMap.get(envEntry);
121:
122:                DeleteCommand deleteCommand = new DeleteCommand();
123:                deleteCommand
124:                        .executeRemoveCommand(selectedEditPart, modelEntry);
125:
126:                // remove the env entry source
127:                Util.removeEnvEntrySource(selectedEditPart, envEntry);
128:
129:                Iterator<IEnvEntryViewer> iterator = changeListeners.iterator();
130:                while (iterator.hasNext())
131:                    ((IEnvEntryViewer) iterator.next())
132:                            .removeEnvEntry(envEntry);
133:            }
134:
135:            /**
136:             * Refactors the table model EnvEntry,the EMF model EnvEntry 
137:             * and finally the source code.
138:             * 
139:             * @param envEntry the selected EnvEntry
140:             */
141:            public void refactorEnvEntry(EnvEntry envEntry) {
142:                // check if a standard text entry is in the collection
143:                deleteDummies();
144:
145:                // invoke the refactoring
146:                //new RefactorEnvEntryAction(selectedEditPart, envEntry).run();
147:                RefactorEnvEntryAction refAction = new RefactorEnvEntryAction(
148:                        selectedEditPart, envEntry, changeListeners);
149:                refAction.run();
150:
151:                // the model update will be executed by the model change object in the EnventryDelegate 
152:            }
153:
154:            /**
155:             * does the changes in the model.
156:             * 
157:             * @param envEntry
158:             */
159:            public void envEntryChanged(EnvEntry envEntry) {
160:                // check if a standard text entry is in the collection
161:                deleteDummies();
162:
163:                // fetch the EMF Model Entry of the concerning table model Entry
164:                newprocess.EnvEntry modelEntry = entryMap.get(envEntry);
165:
166:                // set the name, value and type attributs
167:                WriteCommand writeCommand = new WriteCommand();
168:                if (!envEntry.getName().equals(STANDARD_TEXT)) {
169:                    writeCommand.executeWriteCommand(selectedEditPart,
170:                            modelEntry, envEntry);
171:                }
172:
173:                // update the table view
174:                Iterator<IEnvEntryViewer> iterator = changeListeners.iterator();
175:                while (iterator.hasNext())
176:                    ((IEnvEntryViewer) iterator.next())
177:                            .updateEnvEntry(envEntry);
178:            }
179:
180:            /**
181:             * delete the dummies in the TableViewer.
182:             */
183:            private void deleteDummies() {
184:                Vector<EnvEntry> v = new Vector<EnvEntry>();
185:                for (Iterator<EnvEntry> iter = envEntries.iterator(); iter
186:                        .hasNext();) {
187:                    EnvEntry element = (EnvEntry) iter.next();
188:                    if (element.getName().equals(STANDARD_TEXT)) {
189:                        v.add(element);
190:                    }
191:                }
192:                envEntries.removeAll(v);
193:            }
194:
195:            /**
196:             * @param viewer
197:             */
198:            public void removeChangeListener(IEnvEntryViewer viewer) {
199:                changeListeners.remove(viewer);
200:            }
201:
202:            /**
203:             * @param viewer
204:             */
205:            public void addChangeListener(IEnvEntryViewer viewer) {
206:                changeListeners.add(viewer);
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.