Source Code Cross Referenced for RelatedEventValueDisplay.java in  » Content-Management-System » harmonise » org » openharmonise » him » metadata » range » swing » relatedevents » 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 » Content Management System » harmonise » org.openharmonise.him.metadata.range.swing.relatedevents 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.him.metadata.range.swing.relatedevents;
020:
021:        import java.awt.*;
022:        import java.beans.*;
023:        import java.util.*;
024:        import java.util.List;
025:
026:        import javax.swing.*;
027:        import javax.swing.tree.*;
028:
029:        import org.openharmonise.him.*;
030:        import org.openharmonise.him.metadata.range.swing.*;
031:        import org.openharmonise.vfs.*;
032:        import org.openharmonise.vfs.metadata.*;
033:        import org.openharmonise.vfs.metadata.range.*;
034:        import org.openharmonise.vfs.metadata.value.*;
035:        import org.openharmonise.vfs.servers.ServerList;
036:
037:        /**
038:         *
039:         * @author Michael Bell
040:         * @version $Revision: 1.1 $
041:         *
042:         */
043:        public class RelatedEventValueDisplay extends AbstractRangeDisplay
044:                implements  RangeDisplay, LayoutManager, PropertyChangeListener {
045:
046:            private RelatedEventText m_eventText = null;
047:            private RelatedEventRelationship m_eventType = null;
048:            private RelatedEventRelationship m_place = null;
049:            private RelatedEventRelationship m_people = null;
050:            ArrayList m_propDisplays = new ArrayList(3);
051:            protected int m_nHeight = 300;
052:
053:            private HashMap m_pathOrderMapping = new HashMap();
054:
055:            private SortedSet m_propPanels = new TreeSet();
056:
057:            private int m_nNextOrderVal = 1;
058:
059:            private PropertyValue m_propValue = null;
060:
061:            private RelatedEventRangeDisplay m_display = null;
062:
063:            private RelatedEventApproxDate m_startDate = null;
064:            private RelatedEventApproxDate m_endDate = null;
065:            private int m_nWidth = 300;
066:            protected static int m_nSpace = 10;
067:
068:            public static final String PROPERTY_METADATA_CHANGE = "MetadataChanged";
069:
070:            /**
071:             * @param display
072:             * @param instance
073:             * @param value
074:             */
075:            public RelatedEventValueDisplay(RelatedEventRangeDisplay display,
076:                    PropertyInstance propInstance, PropertyValue propValue) {
077:                super (propInstance);
078:                this .m_display = display;
079:                this .m_propValue = propValue;
080:                this .setup();
081:            }
082:
083:            /**
084:             * 
085:             */
086:            private void setup() {
087:                this .setLayout(this );
088:
089:                PropertyRange propRange = (PropertyRange) this 
090:                        .getPropertyInstance().getDefinition().getRange();
091:                List aHREFs = propRange.getHREFs();
092:                AbstractVirtualFileSystem vfs = ServerList.getInstance()
093:                        .getHarmoniseServer().getVFS();
094:
095:                Iterator itor = aHREFs.iterator();
096:                while (itor.hasNext()) {
097:                    String sGroupPath = (String) itor.next();
098:                    VirtualFile vfPropGroup = vfs.getVirtualFile(sGroupPath)
099:                            .getResource();
100:                    if (vfPropGroup != null) {
101:                        int nCount = 1;
102:                        Iterator itor2 = vfPropGroup.getChildren().iterator();
103:                        while (itor2.hasNext()) {
104:                            String sPath = (String) itor2.next();
105:                            this .m_pathOrderMapping.put(sPath, new Integer(
106:                                    nCount));
107:                            nCount++;
108:                        }
109:                        this .m_nNextOrderVal = nCount;
110:                    }
111:                }
112:
113:            }
114:
115:            /**
116:             * @param propInstance
117:             */
118:            public RelatedEventValueDisplay(PropertyInstance propInstance) {
119:                super (propInstance);
120:            }
121:
122:            /* (non-Javadoc)
123:             * @see java.awt.Component#isValid()
124:             */
125:            public boolean isMetadataValid() {
126:                boolean bIsValid = false;
127:
128:                //need to call for each component so any changes to
129:                //display are made
130:                boolean bStartValid = m_startDate.isMetadataValid();
131:                boolean bEndValid = m_endDate.isMetadataValid();
132:                boolean bPeople = m_people.isMetadataValid();
133:                boolean bPlace = m_place.isMetadataValid();
134:                boolean bType = m_eventType.isMetadataValid();
135:                boolean bText = m_eventText.isMetadataValid();
136:
137:                bIsValid = (bStartValid && bEndValid && bPeople && bPlace
138:                        && bType && bText);
139:
140:                return bIsValid;
141:            }
142:
143:            /* (non-Javadoc)
144:             * @see com.simulacramedia.contentmanager.metadata.range.swing.RangeDisplay#getPanel()
145:             */
146:            public JPanel getPanel() {
147:                PropertyRange range = (PropertyRange) this 
148:                        .getPropertyInstance().getDefinition().getRange();
149:
150:                List props = range.getProperties();
151:
152:                Iterator itor = props.iterator();
153:
154:                List propInstances = this .m_propValue.getValue();
155:
156:                ArrayList aFillingPropInstances = new ArrayList();
157:                aFillingPropInstances.addAll(propInstances);
158:
159:                while (itor.hasNext()) {
160:                    Property prop = (Property) itor.next();
161:
162:                    String sPropName = prop.getName();
163:
164:                    PropertyInstance propInst = getPropertyInstance(prop);
165:
166:                    if (propInst == null) {
167:                        propInst = new PropertyInstance(prop.getNamespace(),
168:                                prop.getName());
169:                        aFillingPropInstances.add(propInst);
170:
171:                        if (getPropertyInstance().getVirtualFile() == null) {
172:                            throw new NullPointerException();
173:                        }
174:
175:                        propInst.setVirtualFile(this .getPropertyInstance()
176:                                .getVirtualFile());
177:                    }
178:
179:                    if (sPropName.equals("event_start_date")) {
180:                        m_startDate = new RelatedEventApproxDate(propInst);
181:                        m_startDate.addPropertyChangeListener(this );
182:                        this .add(m_startDate);
183:                    } else if (sPropName.equals("event_end_date")) {
184:                        m_endDate = new RelatedEventApproxDate(propInst);
185:                        m_endDate.addPropertyChangeListener(this );
186:                        this .add(m_endDate);
187:                    } else if (sPropName.equals("event_people")) {
188:                        m_people = new RelatedEventRelationship(propInst);
189:                        m_people
190:                                .setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
191:                        m_people.setSelectedLeafOnly(true);
192:                        this .add(m_people);
193:                    } else if (sPropName.equals("event_place")) {
194:                        m_place = new RelatedEventRelationship(propInst);
195:                        m_place
196:                                .setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
197:                        m_place.setSelectedLeafOnly(true);
198:                        this .add(m_place);
199:                    } else if (sPropName.equals("event_type")) {
200:                        m_eventType = new RelatedEventRelationship(propInst);
201:                        m_eventType.setSelectedLeafOnly(true);
202:                        m_eventType.setMaxOccurs(1);
203:                        m_eventType.setMinOccurs(1);
204:                        m_eventType.addPropertyChangeListener(this );
205:                        this .add(m_eventType);
206:
207:                    } else if (sPropName.equals("event_text")) {
208:                        m_eventText = new RelatedEventText(propInst);
209:                        m_eventText.addPropertyChangeListener(this );
210:                        this .add(m_eventText);
211:                    }
212:
213:                }
214:
215:                if (aFillingPropInstances.size() > propInstances.size()) {
216:                    this .m_propValue.setValue(aFillingPropInstances);
217:                }
218:
219:                this .setBorder(BorderFactory.createRaisedBevelBorder());
220:
221:                return this ;
222:            }
223:
224:            /**
225:             * @param prop
226:             * @return
227:             */
228:            private PropertyInstance getPropertyInstance(Property prop) {
229:                PropertyInstance propInst = null;
230:
231:                List propInstances = this .m_propValue.getValue();
232:
233:                Iterator iter = propInstances.iterator();
234:
235:                while (iter.hasNext()) {
236:                    PropertyInstance propInstTemp = (PropertyInstance) iter
237:                            .next();
238:                    if (prop.getName().equals(propInstTemp.getName())
239:                            && prop.getNamespace().equals(
240:                                    propInstTemp.getNamespaceURI())) {
241:                        propInst = propInstTemp;
242:                    }
243:                }
244:
245:                return propInst;
246:            }
247:
248:            /* (non-Javadoc)
249:             * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
250:             */
251:            public void removeLayoutComponent(Component comp) {
252:            }
253:
254:            /* (non-Javadoc)
255:             * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
256:             */
257:            public void layoutContainer(Container parent) {
258:                this .setSize(this .getPreferredSize());
259:
260:                m_nWidth = 10;
261:
262:                m_startDate.setSize(m_startDate.getPreferredSize().width,
263:                        m_startDate.getPreferredSize().height);
264:                m_startDate.setLocation(m_nWidth, 10);
265:                m_nWidth = m_nWidth + m_startDate.getPreferredSize().width
266:                        + m_nSpace;
267:
268:                m_endDate.setSize(m_endDate.getPreferredSize().width, m_endDate
269:                        .getPreferredSize().height);
270:                m_endDate.setLocation(m_nWidth, 10);
271:
272:                m_nWidth = m_nWidth + m_endDate.getPreferredSize().width
273:                        + m_nSpace;
274:
275:                m_eventType.setSize(m_eventType.getPreferredSize());
276:                m_eventType.setLocation(m_nWidth, 10);
277:
278:                m_nWidth = m_nWidth + m_eventType.getPreferredSize().width
279:                        + m_nSpace;
280:
281:                m_eventText.setSize(m_eventText.getPreferredSize());
282:                m_eventText.setLocation(m_nWidth, 10);
283:
284:                m_nWidth = m_nWidth + m_eventText.getPreferredSize().width
285:                        + m_nSpace;
286:
287:                m_people.setSize(m_people.getPreferredSize());
288:                m_people.setLocation(m_nWidth, 10);
289:
290:                m_nWidth = m_nWidth + m_people.getPreferredSize().width
291:                        + m_nSpace;
292:
293:                m_place.setSize(m_place.getPreferredSize());
294:                m_place.setLocation(m_nWidth, 10);
295:
296:                m_nWidth = m_nWidth + m_place.getPreferredSize().width
297:                        + m_nSpace;
298:
299:                m_nHeight = m_startDate.getSize().height + 20;
300:
301:                m_nWidth = m_nWidth + 20;
302:
303:                this .repaint();
304:
305:            }
306:
307:            /* (non-Javadoc)
308:             * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
309:             */
310:            public void addLayoutComponent(String name, Component comp) {
311:            }
312:
313:            /* (non-Javadoc)
314:             * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
315:             */
316:            public Dimension minimumLayoutSize(Container arg0) {
317:                return this .getPreferredSize();
318:            }
319:
320:            /* (non-Javadoc)
321:             * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
322:             */
323:            public Dimension preferredLayoutSize(Container arg0) {
324:                return this .getPreferredSize();
325:            }
326:
327:            /* (non-Javadoc)
328:             * @see java.awt.Component#getPreferredSize()
329:             */
330:            public Dimension getPreferredSize() {
331:                return new Dimension(m_nWidth, this .m_nHeight);
332:            }
333:
334:            Dimension getDateSize() {
335:                return m_startDate.getPreferredSize();
336:            }
337:
338:            Dimension getRelationshipSize() {
339:                return m_place.getPreferredSize();
340:            }
341:
342:            Dimension getTextSize() {
343:                return m_eventText.getPreferredSize();
344:            }
345:
346:            public PropertyValue getValue() {
347:                return this .m_propValue;
348:            }
349:
350:            /* (non-Javadoc)
351:             * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
352:             */
353:            public void propertyChange(PropertyChangeEvent evt) {
354:                if (evt.getPropertyName() == RelatedEventValueDisplay.PROPERTY_METADATA_CHANGE) {
355:                    this.validateTab();
356:                }
357:
358:            }
359:
360:        }
w___w___w.j___a___v___a__2__s___.__c__o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.