Source Code Cross Referenced for AssociationPropertiesDialog.java in  » UML » MetaBoss » com » metaboss » applications » designstudio » propertiesdialogs » 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 » UML » MetaBoss » com.metaboss.applications.designstudio.propertiesdialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.applications.designstudio.propertiesdialogs;
016:
017:        import java.awt.Dimension;
018:        import java.awt.event.ItemEvent;
019:        import java.awt.event.ItemListener;
020:
021:        import javax.swing.JComboBox;
022:        import javax.swing.JPanel;
023:        import javax.swing.JTextArea;
024:        import javax.swing.JTextField;
025:
026:        import com.metaboss.applications.designstudio.BaseUserObject;
027:        import com.metaboss.applications.designstudio.userobjects.AggregationTypeItem;
028:        import com.metaboss.applications.designstudio.userobjects.AssociationRoleCardinalityItem;
029:        import com.metaboss.applications.designstudio.userobjects.EntityItem;
030:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
031:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
032:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AggregationType;
033:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Association;
034:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
035:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRoleCardinality;
036:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRoleClass;
037:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
038:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
039:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SystemImplementationModelPackage;
040:
041:        /*	Association properties tuning dialog	*/
042:
043:        public class AssociationPropertiesDialog extends
044:                ModelElementPropertiesDialog {
045:            private boolean mLoading = true;
046:            private Entity mOldRoleAEntity = null;
047:            private Entity mOldRoleBEntity = null;
048:            // UI constrols
049:            private JPanel mRoleAPanel = new JPanel();
050:            private JPanel mRoleBPanel = new JPanel();
051:            // properties
052:            private JTextArea mDescriptionField = new JTextArea(8, 40);
053:            // RoleA
054:            private JTextField mRoleANameField = new JTextField();
055:            private JTextField mRoleAPluralNameField = new JTextField();
056:            private JComboBox mRoleAEntityField = new JComboBox();
057:            private JComboBox mRoleAStereotypeField = new JComboBox();
058:            private JComboBox mRoleACardinalityField = new JComboBox();
059:            private JTextArea mRoleADescriptionField = new JTextArea(8, 40);
060:            // RoleB
061:            private JTextField mRoleBNameField = new JTextField();
062:            private JTextField mRoleBPluralNameField = new JTextField();
063:            private JComboBox mRoleBEntityField = new JComboBox();
064:            private JComboBox mRoleBStereotypeField = new JComboBox();
065:            private JComboBox mRoleBCardinalityField = new JComboBox();
066:            private JTextArea mRoleBDescriptionField = new JTextArea(8, 40);
067:
068:            public AssociationPropertiesDialog() {
069:                super ("Association", new Dimension(400, 370));
070:
071:                mRoleAPanel.setLayout(mClientGridBagLayout);
072:                mRoleBPanel.setLayout(mClientGridBagLayout);
073:
074:                AggregationTypeItem
075:                        .loadBoxWithAggregationTypes(mRoleAStereotypeField);
076:                AggregationTypeItem
077:                        .loadBoxWithAggregationTypes(mRoleBStereotypeField);
078:                AssociationRoleCardinalityItem
079:                        .loadBoxWithCardinalities(mRoleACardinalityField);
080:                AssociationRoleCardinalityItem
081:                        .loadBoxWithCardinalities(mRoleBCardinalityField);
082:
083:                // properties		
084:                addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
085:                addTextArea(mPropertiesPanel, "Description: ",
086:                        mDescriptionField, 2, false);
087:                // RoleA
088:                addComboBox(mRoleAPanel, "Entity: ", mRoleAEntityField, 1, true);
089:                addTextField(mRoleAPanel, "Name: ", mRoleANameField, 2, true);
090:                addTextField(mRoleAPanel, "Plural Name: ",
091:                        mRoleAPluralNameField, 3, true);
092:                addComboBox(mRoleAPanel, "Aggregation Type: ",
093:                        mRoleAStereotypeField, 4, false);
094:                addComboBox(mRoleAPanel, "Cardinality: ",
095:                        mRoleACardinalityField, 5, false);
096:                addTextArea(mRoleAPanel, "Description: ",
097:                        mRoleADescriptionField, 6, false);
098:                // RoleB
099:                addComboBox(mRoleBPanel, "Entity: ", mRoleBEntityField, 1, true);
100:                addTextField(mRoleBPanel, "Name: ", mRoleBNameField, 2, true);
101:                addTextField(mRoleBPanel, "Plural Name: ",
102:                        mRoleBPluralNameField, 3, true);
103:                addComboBox(mRoleBPanel, "Aggregation Type: ",
104:                        mRoleBStereotypeField, 4, false);
105:                addComboBox(mRoleBPanel, "Cardinality: ",
106:                        mRoleBCardinalityField, 5, false);
107:                addTextArea(mRoleBPanel, "Description: ",
108:                        mRoleBDescriptionField, 6, false);
109:
110:                mTabControl.insertTab("Role A", null, mRoleAPanel, null, 1);
111:                mTabControl.insertTab("Role B", null, mRoleBPanel, null, 2);
112:
113:                mRoleAEntityField.addItemListener(new ItemListener() {
114:                    public void itemStateChanged(ItemEvent e) {
115:                        processRoleAEntityChange();
116:                    }
117:                });
118:                mRoleBEntityField.addItemListener(new ItemListener() {
119:                    public void itemStateChanged(ItemEvent e) {
120:                        processRoleBEntityChange();
121:                    }
122:                });
123:            }
124:
125:            // load Association properties
126:            public void loadProperties(ModelElement pObject) throws Exception {
127:                if (pObject != null && pObject instanceof  Association) {
128:                    Association lAssociation = (Association) pObject;
129:                    loadBoxesWithEntities(lAssociation.getDomain());
130:
131:                    //properties
132:                    mNameField.setText(lAssociation.getName());
133:                    mDescriptionField.setText(lAssociation.getDescription());
134:
135:                    java.util.List lList = lAssociation.getRoles();
136:                    AssociationRole lRoleA = (lList != null && lList.size() > 0) ? (AssociationRole) lList
137:                            .get(0)
138:                            : null;
139:                    AssociationRole lRoleB = (lList != null && lList.size() > 1) ? (AssociationRole) lList
140:                            .get(1)
141:                            : null;
142:
143:                    //rolea
144:                    if (lRoleA != null) {
145:                        mRoleANameField.setText(lRoleA.getName());
146:                        mRoleAPluralNameField.setText(lRoleA.getPluralName());
147:                        mRoleAEntityField.setSelectedIndex(EntityItem
148:                                .findEntityItemIndex(mRoleAEntityField, lRoleA
149:                                        .getEntity()));
150:                        mRoleAStereotypeField
151:                                .setSelectedIndex(AggregationTypeItem
152:                                        .findAggregationTypeItemIndex(
153:                                                mRoleAStereotypeField, lRoleA
154:                                                        .getAggregationType()));
155:                        mRoleACardinalityField
156:                                .setSelectedIndex(AssociationRoleCardinalityItem
157:                                        .findCardinalityItemIndex(
158:                                                mRoleACardinalityField, lRoleA
159:                                                        .getCardinality()));
160:                        mRoleADescriptionField.setText(lRoleA.getDescription());
161:                    }
162:                    //roleb
163:                    if (lRoleB != null) {
164:                        mRoleBNameField.setText(lRoleB.getName());
165:                        mRoleBPluralNameField.setText(lRoleB.getPluralName());
166:                        mRoleBEntityField.setSelectedIndex(EntityItem
167:                                .findEntityItemIndex(mRoleBEntityField, lRoleB
168:                                        .getEntity()));
169:                        mRoleBStereotypeField
170:                                .setSelectedIndex(AggregationTypeItem
171:                                        .findAggregationTypeItemIndex(
172:                                                mRoleBStereotypeField, lRoleB
173:                                                        .getAggregationType()));
174:                        mRoleBCardinalityField
175:                                .setSelectedIndex(AssociationRoleCardinalityItem
176:                                        .findCardinalityItemIndex(
177:                                                mRoleBCardinalityField, lRoleB
178:                                                        .getCardinality()));
179:                        mRoleBDescriptionField.setText(lRoleB.getDescription());
180:                    }
181:                }
182:                super .loadProperties(pObject);
183:
184:                mOldRoleAEntity = getRoleEntity(mRoleAEntityField);
185:                mOldRoleBEntity = getRoleEntity(mRoleBEntityField);
186:                mLoading = false;
187:            }
188:
189:            // save association proeprties
190:            public void saveProperties(ModelElement pObject) throws Exception {
191:                super .saveProperties(pObject);
192:                if (pObject != null && pObject instanceof  Association) {
193:                    Association lAssociation = (Association) pObject;
194:                    MetaBossModelPackage lPackage = BaseUserObject
195:                            .getObjectPackage(lAssociation);
196:
197:                    lAssociation.setName(mNameField.getText());
198:                    lAssociation.setDescription(mDescriptionField.getText());
199:
200:                    java.util.List lList = lAssociation.getRoles();
201:                    AssociationRole lRoleA = (lList != null && lList.size() > 0) ? (AssociationRole) lList
202:                            .get(0)
203:                            : null;
204:                    AssociationRole lRoleB = (lList != null && lList.size() > 1) ? (AssociationRole) lList
205:                            .get(1)
206:                            : null;
207:
208:                    if (lRoleA == null) {
209:                        lRoleA = createAssociationRole(lPackage);
210:                        lAssociation.getRoles().add(lRoleA);
211:                    }
212:                    if (lRoleB == null) {
213:                        lRoleB = createAssociationRole(lPackage);
214:                        lAssociation.getRoles().add(lRoleB);
215:                    }
216:
217:                    //rolea
218:                    if (lRoleA != null) {
219:                        lRoleA.setEntity(getRoleEntity(mRoleAEntityField));
220:                        lRoleA.setName(mRoleANameField.getText());
221:                        lRoleA.setPluralName(mRoleAPluralNameField.getText());
222:                        lRoleA
223:                                .setAggregationType((AggregationType) mRoleAStereotypeField
224:                                        .getSelectedItem());
225:                        lRoleA
226:                                .setCardinality((AssociationRoleCardinality) mRoleACardinalityField
227:                                        .getSelectedItem());
228:                        lRoleA.setDescription(mRoleADescriptionField.getText());
229:                    }
230:                    //roleb
231:                    if (lRoleB != null) {
232:                        lRoleB.setEntity(getRoleEntity(mRoleBEntityField));
233:                        lRoleB.setName(mRoleBNameField.getText());
234:                        lRoleB.setPluralName(mRoleBPluralNameField.getText());
235:                        lRoleB
236:                                .setAggregationType((AggregationType) mRoleBStereotypeField
237:                                        .getSelectedItem());
238:                        lRoleB
239:                                .setCardinality((AssociationRoleCardinality) mRoleBCardinalityField
240:                                        .getSelectedItem());
241:                        lRoleB.setDescription(mRoleBDescriptionField.getText());
242:                    }
243:                }
244:                super .saveProperties(pObject);
245:            }
246:
247:            // load Entities Boxes
248:            private void loadBoxesWithEntities(Domain pDomain) {
249:                EntityItem
250:                        .loadBoxWithEntities(mRoleAEntityField, pDomain, true);
251:                EntityItem
252:                        .loadBoxWithEntities(mRoleBEntityField, pDomain, true);
253:            }
254:
255:            // create new AssociationRole
256:            private AssociationRole createAssociationRole(
257:                    MetaBossModelPackage pPackage) {
258:                SystemImplementationModelPackage lSystemImplementationModelPackage = pPackage
259:                        .getEnterpriseModel().getSystemImplementationModel();
260:                AssociationRoleClass lClass = lSystemImplementationModelPackage
261:                        .getAssociationRole();
262:                return lClass.createAssociationRole();
263:            }
264:
265:            // provcess roleA Entity change
266:            private void processRoleAEntityChange() {
267:                if (mLoading)
268:                    return;
269:
270:                Entity lNewEnitity = getRoleEntity(mRoleAEntityField);
271:                if (lNewEnitity != null) {
272:                    if (mOldRoleAEntity != null) {
273:                        if (mRoleANameField.getText().equals(
274:                                mOldRoleAEntity.getName()))
275:                            mRoleANameField.setText(lNewEnitity.getName());
276:                        if (mRoleAPluralNameField.getText().equals(
277:                                mOldRoleAEntity.getName()))
278:                            mRoleAPluralNameField
279:                                    .setText(lNewEnitity.getName());
280:                    } else {
281:                        if (mRoleANameField.getText().length() == 0)
282:                            mRoleANameField.setText(lNewEnitity.getName());
283:                        if (mRoleAPluralNameField.getText().length() == 0)
284:                            mRoleAPluralNameField
285:                                    .setText(lNewEnitity.getName());
286:                    }
287:                }
288:                mOldRoleAEntity = lNewEnitity;
289:            }
290:
291:            // provcess roleB Entity change
292:            private void processRoleBEntityChange() {
293:                if (mLoading)
294:                    return;
295:
296:                Entity lNewEnitity = getRoleEntity(mRoleBEntityField);
297:                if (lNewEnitity != null) {
298:                    if (mOldRoleBEntity != null) {
299:                        if (mRoleBNameField.getText().equals(
300:                                mOldRoleBEntity.getName()))
301:                            mRoleBNameField.setText(lNewEnitity.getName());
302:                        if (mRoleBPluralNameField.getText().equals(
303:                                mOldRoleBEntity.getName()))
304:                            mRoleBPluralNameField
305:                                    .setText(lNewEnitity.getName());
306:                    } else {
307:                        if (mRoleBNameField.getText().length() == 0)
308:                            mRoleBNameField.setText(lNewEnitity.getName());
309:                        if (mRoleBPluralNameField.getText().length() == 0)
310:                            mRoleBPluralNameField
311:                                    .setText(lNewEnitity.getName());
312:                    }
313:                }
314:                mOldRoleBEntity = lNewEnitity;
315:            }
316:
317:            private Entity getRoleEntity(JComboBox pBox) {
318:                EntityItem lItem = (EntityItem) pBox.getSelectedItem();
319:                if (lItem != null)
320:                    return lItem.mEntity;
321:                else
322:                    return null;
323:            }
324:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.