Source Code Cross Referenced for Link.java in  » Web-Framework » Millstone » org » millstone » base » ui » 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 » Web Framework » Millstone » org.millstone.base.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* *************************************************************************
002:         
003:                                        Millstone(TM) 
004:                           Open Sourced User Interface Library for
005:                               Internet Development with Java
006:
007:                     Millstone is a registered trademark of IT Mill Ltd
008:                          Copyright (C) 2000-2005 IT Mill Ltd
009:                             
010:         *************************************************************************
011:
012:           This library is free software; you can redistribute it and/or
013:           modify it under the terms of the GNU Lesser General Public
014:           license version 2.1 as published by the Free Software Foundation.
015:
016:           This library is distributed in the hope that it will be useful,
017:           but WITHOUT ANY WARRANTY; without even the implied warranty of
018:           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:           Lesser General Public License for more details.
020:
021:           You should have received a copy of the GNU Lesser General Public
022:           License along with this library; if not, write to the Free Software
023:           Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         *************************************************************************
026:           
027:           For more information, contact:
028:           
029:           IT Mill Ltd                           phone: +358 2 4802 7180
030:           Ruukinkatu 2-4                        fax:  +358 2 4802 7181
031:           20540, Turku                          email: info@itmill.com
032:           Finland                               company www: www.itmill.com
033:           
034:           Primary source for MillStone information and releases: www.millstone.org
035:
036:         ********************************************************************** */
037:
038:        package org.millstone.base.ui;
039:
040:        import org.millstone.base.terminal.PaintTarget;
041:        import org.millstone.base.terminal.PaintException;
042:        import org.millstone.base.terminal.Resource;
043:
044:        /** Link component.
045:         *  Link is used to create external or internal URL links.
046:         *
047:         *  Internal links can be used to create action items, which
048:         *  change the state to application to one of the predefined states.
049:         *  For example, a link can be created for existing MenuTree items.
050:         *
051:         * @author IT Mill Ltd.
052:         * @version 3.1.1
053:         * @since 3.0
054:         */
055:        public class Link extends AbstractComponent {
056:
057:            /* Target window border type constant: No window border */
058:            public static final int TARGET_BORDER_NONE = Window.BORDER_NONE;
059:            /* Target window border type constant: Minimal window border */
060:            public static final int TARGET_BORDER_MINIMAL = Window.BORDER_MINIMAL;
061:            /* Target window border type constant: Default window border */
062:            public static final int TARGET_BORDER_DEFAULT = Window.BORDER_DEFAULT;
063:
064:            private Resource resource = null;
065:            private Window window = null;
066:            private String targetName;
067:            private int targetBorder = TARGET_BORDER_DEFAULT;
068:            private int targetWidth = -1;
069:            private int targetHeight = -1;
070:
071:            /** Creates a new link. */
072:            public Link() {
073:
074:            }
075:
076:            /** Creates a new link to a window. */
077:            public Link(Window window) {
078:
079:                // Set the link caption to match window caption
080:                setCaption(window.getCaption());
081:
082:                // Set the target
083:                setTargetName(window.getName());
084:
085:                setTargetName(window.getName());
086:                setTargetWidth(window.getWidth());
087:                setTargetHeight(window.getHeight());
088:                setTargetBorder(window.getBorder());
089:            }
090:
091:            /** Creates a new instance of Link */
092:            public Link(String caption, Resource resource) {
093:                setCaption(caption);
094:                this .resource = resource;
095:            }
096:
097:            /** Creates a new instance of Link that opens a new window. 
098:             * 
099:             * 
100:             * @param caption Link text.
101:             * @param targetName The name of the target window where the link 
102:             * opens to. Empty name of null implies that
103:             * the target is opened to the window containing the link.
104:             * @param width Width of the target window.
105:             * @param height Height of the target window.
106:             * @param border Borget style of the target window.
107:             * 
108:             */
109:            public Link(String caption, Resource resource, String targetName,
110:                    int width, int height, int border) {
111:                setCaption(caption);
112:                this .resource = resource;
113:                setTargetName(targetName);
114:                setTargetWidth(width);
115:                setTargetHeight(height);
116:                setTargetBorder(border);
117:            }
118:
119:            /** Get component UIDL tag.
120:             *  @return Component UIDL tag as string.
121:             */
122:            public String getTag() {
123:                return "link";
124:            }
125:
126:            /** Paint the content of this component.
127:             * @param event PaintEvent.
128:             * @throws PaintException The paint operation failed.
129:             */
130:            public void paintContent(PaintTarget target) throws PaintException {
131:
132:                if (window != null)
133:                    target.addAttribute("src", window.getURL().toString());
134:                else if (resource != null)
135:                    target.addAttribute("src", resource);
136:                else
137:                    return;
138:
139:                // Target window name
140:                String name = getTargetName();
141:                if (name != null && name.length() > 0)
142:                    target.addAttribute("name", name);
143:
144:                // Target window size
145:                if (getTargetWidth() >= 0)
146:                    target.addAttribute("width", getTargetWidth());
147:                if (getTargetHeight() >= 0)
148:                    target.addAttribute("height", getTargetHeight());
149:
150:                // Target window border
151:                switch (getTargetBorder()) {
152:                case TARGET_BORDER_MINIMAL:
153:                    target.addAttribute("border", "minimal");
154:                    break;
155:                case TARGET_BORDER_NONE:
156:                    target.addAttribute("border", "none");
157:                    break;
158:                }
159:            }
160:
161:            /** Returns the target window border.
162:             * @return int
163:             */
164:            public int getTargetBorder() {
165:                return targetBorder;
166:            }
167:
168:            /** Returns the target window height or -1 if not set.
169:             * @return int
170:             */
171:            public int getTargetHeight() {
172:                return targetHeight < 0 ? -1 : targetHeight;
173:            }
174:
175:            /** Returns the target window name. Empty name of null implies that
176:             * the target is opened to the window containing the link.
177:             * @return String
178:             */
179:            public String getTargetName() {
180:                return targetName;
181:            }
182:
183:            /** Returns the target window width or -1 if not set.
184:             * @return int
185:             */
186:            public int getTargetWidth() {
187:                return targetWidth < 0 ? -1 : targetWidth;
188:            }
189:
190:            /** Sets the border of the target window.
191:             * @param targetBorder The targetBorder to set
192:             */
193:            public void setTargetBorder(int targetBorder) {
194:                if (targetBorder == TARGET_BORDER_DEFAULT
195:                        || targetBorder == TARGET_BORDER_MINIMAL
196:                        || targetBorder == TARGET_BORDER_NONE)
197:                    this .targetBorder = targetBorder;
198:            }
199:
200:            /** Sets the target window height.
201:             * @param targetHeight The targetHeight to set
202:             */
203:            public void setTargetHeight(int targetHeight) {
204:                this .targetHeight = targetHeight;
205:            }
206:
207:            /** Sets the target window name.
208:             * @param targetName The targetName to set
209:             */
210:            public void setTargetName(String targetName) {
211:                this .targetName = targetName;
212:            }
213:
214:            /** Sets the target window width.
215:             * @param targetWidth The targetWidth to set
216:             */
217:            public void setTargetWidth(int targetWidth) {
218:                this .targetWidth = targetWidth;
219:            }
220:
221:            /** Returns the resource this link opens.
222:             * @return Resource
223:             */
224:            public Resource getResource() {
225:                return resource;
226:            }
227:
228:            /** Returns the window this link opens.
229:             * @return Window
230:             */
231:            public Window getWindow() {
232:                return window;
233:            }
234:
235:            /** Sets the resource this link opens.
236:             * @param resource The resource to set
237:             */
238:            public void setResource(Resource resource) {
239:                this .resource = resource;
240:                if (resource != null)
241:                    window = null;
242:            }
243:
244:            /** Sets the window this link opens.
245:             * @param window The window to set
246:             */
247:            public void setWindow(Window window) {
248:                this.window = window;
249:                if (window != null)
250:                    this.resource = null;
251:            }
252:
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.