Source Code Cross Referenced for PropertyPanel.java in  » Content-Management-System » harmonise » org » openharmonise » him » metadata » swing » 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.swing 
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:
020:        package org.openharmonise.him.metadata.swing;
021:
022:        import java.awt.*;
023:
024:        import javax.swing.*;
025:        import javax.swing.border.*;
026:
027:        import org.openharmonise.commons.xml.namespace.*;
028:        import org.openharmonise.him.metadata.range.swing.*;
029:        import org.openharmonise.vfs.metadata.*;
030:
031:        /**
032:         * @author Matthew Large
033:         *
034:         */
035:        public class PropertyPanel extends JPanel implements  LayoutManager {
036:
037:            private PropertyInstance m_propertyInstance = null;
038:            private String m_sName = null;
039:
040:            private boolean m_bResizeWidth = true;
041:
042:            private HelpIcon m_helpIcon = null;
043:
044:            private JLabel m_titleLabel = null;
045:
046:            /**
047:             * 
048:             */
049:            public PropertyPanel(PropertyInstance propertyInstance,
050:                    boolean bResizeWidth) {
051:                super ();
052:                this .m_propertyInstance = propertyInstance;
053:                this .m_bResizeWidth = bResizeWidth;
054:                this .setup();
055:            }
056:
057:            /**
058:             * 
059:             */
060:            public PropertyPanel(String sName, boolean bResizeWidth) {
061:                super ();
062:                this .m_sName = sName;
063:                this .m_bResizeWidth = bResizeWidth;
064:                this .setup();
065:            }
066:
067:            public Property getProperty() {
068:                Property prop = null;
069:
070:                if (this .m_propertyInstance != null
071:                        && this .m_propertyInstance.getDefinition() != null) {
072:                    prop = this .m_propertyInstance.getDefinition();
073:                }
074:
075:                return prop;
076:            }
077:
078:            /**
079:             * @param arg0
080:             */
081:            private PropertyPanel(boolean arg0) {
082:                super (arg0);
083:            }
084:
085:            /**
086:             * @param arg0
087:             */
088:            private PropertyPanel(LayoutManager arg0) {
089:                super (arg0);
090:            }
091:
092:            /**
093:             * @param arg0
094:             * @param arg1
095:             */
096:            private PropertyPanel(LayoutManager arg0, boolean arg1) {
097:                super (arg0, arg1);
098:            }
099:
100:            private void setup() {
101:                this .setLayout(this );
102:
103:                TitledBorder border = null;
104:
105:                if (this .m_propertyInstance != null) {
106:                    if (this .m_propertyInstance.getNamespaceURI().equals(
107:                            NamespaceType.OHRM.getURI())
108:                            && this .m_propertyInstance.getName()
109:                                    .equals("title")) {
110:                        this .m_titleLabel = new JLabel("Title");
111:                    } else {
112:                        this .m_titleLabel = new JLabel(this .m_propertyInstance
113:                                .getDefinition().getDisplayName());
114:                    }
115:                } else if (this .m_sName != null) {
116:                    this .m_titleLabel = new JLabel(this .m_sName);
117:                }
118:                String fontName = "Dialog";
119:                int fontSize = 13;
120:                Font font = new Font(fontName, Font.BOLD, fontSize);
121:                this .m_titleLabel.setFont(font);
122:                this .add(m_titleLabel);
123:
124:                if (this .m_propertyInstance != null
125:                        && this .m_propertyInstance.getDefinition() != null) {
126:                    if (this .m_propertyInstance.getName().equals("domain")) {
127:                        this .m_helpIcon = new HelpIcon(
128:                                "Domain",
129:                                "Domain is used to restrict a Property's use (and occurrence) to a particular set of Collections or Resources, for example you could restrict the Property \"Location\" to the Resources within the Collection \"Case Study\" and restrict the number of locations to \"one\". This would mean that when tagging a Case Study document the vocabularies within Location (e.g. South East, Midlands etc.) would be available to the user and that they need to define one Location.");
130:                        this .add(m_helpIcon);
131:                    } else if (this .m_propertyInstance.getName()
132:                            .equals("range")) {
133:                        this .m_helpIcon = new HelpIcon("Range",
134:                                "The Range of a Property is description of its allowable Values.");
135:                        this .add(m_helpIcon);
136:                    } else {
137:                        this .m_helpIcon = new HelpIcon(this .m_propertyInstance
138:                                .getDefinition());
139:                        this .add(m_helpIcon);
140:                    }
141:                }
142:            }
143:
144:            /* (non-Javadoc)
145:             * @see java.awt.Component#getPreferredSize()
146:             */
147:            public Dimension getPreferredSize() {
148:                int nHeight = 0;
149:                int nCount = this .getComponentCount();
150:                int nWidth = 0;
151:                for (int i = 0; i < nCount; i++) {
152:                    Component comp = this .getComponent(i);
153:                    int nDepth = comp.getLocation().y
154:                            + comp.getPreferredSize().height;
155:                    int nCurrWidth = comp.getLocation().x
156:                            + comp.getPreferredSize().width;
157:                    if (nDepth > nHeight) {
158:                        nHeight = nDepth;
159:                    }
160:                    if (nCurrWidth > nWidth) {
161:                        nWidth = nCurrWidth;
162:                    }
163:                }
164:
165:                if (this .m_bResizeWidth) {
166:                    return new Dimension(this .getParent().getWidth() - 20,
167:                            nHeight + 5);
168:                } else {
169:                    return new Dimension(nWidth, nHeight + 5);
170:                }
171:            }
172:
173:            /* (non-Javadoc)
174:             * @see java.awt.Component#setEnabled(boolean)
175:             */
176:            public void setEnabled(boolean bEnabled) {
177:                for (int i = 0; i < this .getComponentCount(); i++) {
178:                    Component comp = this .getComponent(i);
179:                    comp.setEnabled(bEnabled);
180:                }
181:                super .setEnabled(bEnabled);
182:            }
183:
184:            public AbstractRangeDisplay getRangeDisplay() {
185:                for (int i = 0; i < this .getComponentCount(); i++) {
186:                    Component comp = this .getComponent(i);
187:                    if (comp instanceof  AbstractRangeDisplay) {
188:                        return (AbstractRangeDisplay) comp;
189:                    }
190:                }
191:                return null;
192:            }
193:
194:            /* (non-Javadoc)
195:             * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
196:             */
197:            public void layoutContainer(Container arg0) {
198:                int nHeight = 35;
199:                for (int i = 0; i < this .getComponentCount(); i++) {
200:                    Component comp = this .getComponent(i);
201:                    if (comp instanceof  AbstractRangeDisplay) {
202:                        comp.setSize(comp.getPreferredSize());
203:                        comp.setLocation(5, nHeight);
204:                    } else if (comp instanceof  HelpIcon) {
205:                        comp.setSize(20, 20);
206:                        comp
207:                                .setLocation(this .m_titleLabel
208:                                        .getPreferredSize().width + 15, 10);
209:                    } else if (comp == this .m_titleLabel) {
210:                        comp.setSize(
211:                                this .m_titleLabel.getPreferredSize().width, 30);
212:                        comp.setLocation(5, 5);
213:                    }
214:                }
215:            }
216:
217:            /* (non-Javadoc)
218:             * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
219:             */
220:            public void removeLayoutComponent(Component arg0) {
221:            }
222:
223:            /* (non-Javadoc)
224:             * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
225:             */
226:            public void addLayoutComponent(String arg0, Component arg1) {
227:            }
228:
229:            /* (non-Javadoc)
230:             * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
231:             */
232:            public Dimension minimumLayoutSize(Container arg0) {
233:                return this .getPreferredSize();
234:            }
235:
236:            /* (non-Javadoc)
237:             * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
238:             */
239:            public Dimension preferredLayoutSize(Container arg0) {
240:                return this.getPreferredSize();
241:            }
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.