Source Code Cross Referenced for CmsTool.java in  » Content-Management-System » opencms » org » opencms » workplace » tools » 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 » opencms » org.opencms.workplace.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/tools/CmsTool.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:31 $
004:         * Version: $Revision: 1.27 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
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:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.workplace.tools;
033:
034:        import org.opencms.main.OpenCms;
035:        import org.opencms.workplace.CmsWorkplace;
036:
037:        import java.util.Iterator;
038:        import java.util.List;
039:
040:        /**
041:         * Implementation of an administration tool.<p>
042:         * 
043:         * An admin tool can be a link to itself through 
044:         * the <code>{@link #buttonHtml(CmsWorkplace)}</code> method,
045:         * as also a group of <code>{@link CmsToolGroup}</code>s through the 
046:         * <code>{@link #groupHtml(CmsWorkplace)}</code> method.<p>
047:         * 
048:         * @author Michael Moossen 
049:         *  
050:         * @version $Revision: 1.27 $ 
051:         * 
052:         * @since 6.0.0 
053:         */
054:        public class CmsTool {
055:
056:            /** Sub-tools container. */
057:            private final CmsIdentifiableObjectContainer m_container = new CmsIdentifiableObjectContainer(
058:                    true, true);
059:
060:            /** Handler that represents this tool. */
061:            private I_CmsToolHandler m_handler;
062:
063:            /** Dhtml id, from name. */
064:            private final String m_id;
065:
066:            /**
067:             * Default Constructor.<p> 
068:             * 
069:             * @param id a unique id
070:             * @param handler the handler that represents this tool
071:             */
072:            public CmsTool(String id, I_CmsToolHandler handler) {
073:
074:                m_id = id;
075:                m_handler = handler;
076:
077:            }
078:
079:            /**
080:             * Adds a group.<p>
081:             * 
082:             * @param group the group
083:             * 
084:             * @see org.opencms.workplace.tools.I_CmsIdentifiableObjectContainer#addIdentifiableObject(String, Object)
085:             */
086:            public void addToolGroup(CmsToolGroup group) {
087:
088:                m_container.addIdentifiableObject(group.getName(), group);
089:            }
090:
091:            /**
092:             * Adds a group at the given position.<p>
093:             * 
094:             * @param group the group
095:             * @param position the position
096:             * 
097:             * @see org.opencms.workplace.tools.I_CmsIdentifiableObjectContainer#addIdentifiableObject(String, Object, float)
098:             */
099:            public void addToolGroup(CmsToolGroup group, float position) {
100:
101:                m_container.addIdentifiableObject(group.getName(), group,
102:                        position);
103:            }
104:
105:            /**
106:             * Returns the necessary html code for a link to this tool.<p>
107:             * 
108:             * @param wp the jsp page to write the code to
109:             * 
110:             * @return html code
111:             */
112:            public String buttonHtml(CmsWorkplace wp) {
113:
114:                if (!m_handler.isVisible(wp)) {
115:                    return "";
116:                }
117:                String link = CmsToolManager.linkForToolPath(wp.getJsp(),
118:                        getHandler().getPath(), getHandler().getParameters(wp));
119:                String onClic = "openPage('" + link + "');";
120:                return A_CmsHtmlIconButton.defaultButtonHtml(
121:                        CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT, getId(),
122:                        m_handler.getShortName(),
123:                        m_handler.isEnabled(wp) ? m_handler.getHelpText()
124:                                : m_handler.getDisabledHelpText(), m_handler
125:                                .isEnabled(wp), m_handler.getIconPath(),
126:                        m_handler.getConfirmationMessage(), onClic);
127:            }
128:
129:            /**
130:             * Compares two tools by name.<p>
131:             * 
132:             * @param obj the other tool
133:             * 
134:             * @return <code>true</code> if the tools have the same name
135:             */
136:            public boolean equals(Object obj) {
137:
138:                if (obj == this ) {
139:                    return true;
140:                }
141:                if (obj instanceof  CmsTool) {
142:                    return ((CmsTool) obj).m_id.equals(m_id);
143:                }
144:                return false;
145:            }
146:
147:            /**
148:             * Returns the handler.<p>
149:             *
150:             * @return the handler
151:             */
152:            public I_CmsToolHandler getHandler() {
153:
154:                return m_handler;
155:            }
156:
157:            /**
158:             * Returns the dhtml unique id.<p>
159:             *
160:             * @return the dhtml unique id
161:             */
162:            public String getId() {
163:
164:                return m_id;
165:            }
166:
167:            /**
168:             * Returns the requested group.<p>
169:             * 
170:             * @param name the name of the group
171:             * 
172:             * @return the group
173:             * 
174:             * @see org.opencms.workplace.tools.I_CmsIdentifiableObjectContainer#getObject(String)
175:             */
176:            public CmsToolGroup getToolGroup(String name) {
177:
178:                return (CmsToolGroup) m_container.getObject(name);
179:            }
180:
181:            /**
182:             * Retuns a list of groups.<p>
183:             * 
184:             * @return a list of <code>{@link CmsToolGroup}</code>
185:             */
186:            public List getToolGroups() {
187:
188:                return m_container.elementList();
189:            }
190:
191:            /**
192:             * Returns the necessary html code for the tool subgroups.<p>
193:             * 
194:             * @param wp the jsp page to write the code to
195:             * 
196:             * @return html code
197:             */
198:            public String groupHtml(CmsWorkplace wp) {
199:
200:                List subTools = OpenCms.getWorkplaceManager().getToolManager()
201:                        .getToolsForPath(wp, getHandler().getPath(), false);
202:                Iterator itSubTools = subTools.iterator();
203:                m_container.clear();
204:                while (itSubTools.hasNext()) {
205:                    CmsTool subTool = (CmsTool) itSubTools.next();
206:                    // locate group
207:                    CmsToolGroup group = null;
208:                    String groupName = CmsToolMacroResolver.resolveMacros(
209:                            subTool.getHandler().getGroup(), wp);
210:
211:                    // in the parent tool
212:                    group = getToolGroup(groupName);
213:                    if (group == null) {
214:                        // if does not exist, create it
215:                        String gid = "group" + getToolGroups().size();
216:                        group = new CmsToolGroup(gid, groupName);
217:                        addToolGroup(group, subTool.getHandler().getPosition());
218:                    }
219:
220:                    // add to group
221:                    group.addAdminTool(subTool, subTool.getHandler()
222:                            .getPosition());
223:
224:                }
225:
226:                StringBuffer html = new StringBuffer(512);
227:                Iterator itHtml = getToolGroups().iterator();
228:                while (itHtml.hasNext()) {
229:                    CmsToolGroup group = (CmsToolGroup) itHtml.next();
230:                    html.append(group.groupHtml(wp));
231:                }
232:                return CmsToolMacroResolver.resolveMacros(html.toString(), wp);
233:            }
234:
235:            /**
236:             * @see java.lang.Object#hashCode()
237:             */
238:            public int hashCode() {
239:
240:                return m_handler.getName().hashCode();
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.