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


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsPublishResourcesList.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:25 $
004:         * Version: $Revision: 1.8 $
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.commons;
033:
034:        import org.opencms.db.CmsPublishList;
035:        import org.opencms.db.CmsUserSettings;
036:        import org.opencms.file.CmsObject;
037:        import org.opencms.file.CmsResource;
038:        import org.opencms.file.CmsResourceFilter;
039:        import org.opencms.file.CmsVfsResourceNotFoundException;
040:        import org.opencms.i18n.CmsMessageContainer;
041:        import org.opencms.jsp.CmsJspActionElement;
042:        import org.opencms.main.CmsException;
043:        import org.opencms.main.CmsIllegalStateException;
044:        import org.opencms.main.CmsLog;
045:        import org.opencms.main.OpenCms;
046:        import org.opencms.relations.CmsRelation;
047:        import org.opencms.relations.CmsRelationFilter;
048:        import org.opencms.util.CmsStringUtil;
049:        import org.opencms.workplace.CmsWorkplace;
050:        import org.opencms.workplace.explorer.CmsResourceUtil;
051:        import org.opencms.workplace.list.A_CmsListDialog;
052:        import org.opencms.workplace.list.A_CmsListExplorerDialog;
053:        import org.opencms.workplace.list.A_CmsListIndependentJsAction;
054:        import org.opencms.workplace.list.A_CmsListResourceCollector;
055:        import org.opencms.workplace.list.CmsListColumnDefinition;
056:        import org.opencms.workplace.list.CmsListDirectAction;
057:        import org.opencms.workplace.list.CmsListExplorerColumn;
058:        import org.opencms.workplace.list.CmsListIndependentAction;
059:        import org.opencms.workplace.list.CmsListItem;
060:        import org.opencms.workplace.list.CmsListItemDetails;
061:        import org.opencms.workplace.list.CmsListMetadata;
062:        import org.opencms.workplace.list.CmsListResourceProjStateAction;
063:        import org.opencms.workplace.list.I_CmsListAction;
064:        import org.opencms.workplace.list.I_CmsListFormatter;
065:        import org.opencms.workplace.list.I_CmsListResourceCollector;
066:
067:        import java.util.ArrayList;
068:        import java.util.Iterator;
069:        import java.util.List;
070:        import java.util.Locale;
071:        import java.util.Map;
072:        import java.util.zip.DataFormatException;
073:
074:        import org.apache.commons.logging.Log;
075:
076:        /**
077:         * List for resources that can be published.<p>
078:         * 
079:         * @author Michael Moossen  
080:         * 
081:         * @version $Revision: 1.8 $ 
082:         * 
083:         * @since 6.5.5 
084:         */
085:        public class CmsPublishResourcesList extends A_CmsListExplorerDialog {
086:
087:            /** list action id constant. */
088:            public static final String LIST_DETAIL_RELATIONS = "dr";
089:
090:            /** list action id constant. */
091:            public static final String LIST_DETAIL_RELATIONS_HIDE = "drh";
092:
093:            /** list action id constant. */
094:            public static final String LIST_DETAIL_RELATIONS_SHOW = "drs";
095:
096:            /** list id constant. */
097:            public static final String LIST_ID = "pr";
098:
099:            /** List column id constant. */
100:            protected static final String LIST_COLUMN_IS_RELATED = "ecir";
101:
102:            /** The log object for this class. */
103:            protected static final Log LOG = CmsLog
104:                    .getLog(CmsPublishResourcesList.class);
105:
106:            /** The publish list created for that list. */
107:            protected CmsPublishList m_publishList;
108:
109:            /** Indicates if the related resources should be included. */
110:            protected boolean m_publishRelated;
111:
112:            /** The internal collector instance. */
113:            private I_CmsListResourceCollector m_collector;
114:
115:            /**
116:             * Public constructor.<p>
117:             * 
118:             * @param jsp an initialized JSP action element
119:             * @param relativeTo the 'relative to' path, this only affects the generation of the path for the resource
120:             * @param publishRelated indicates if the related resources should be included
121:             */
122:            public CmsPublishResourcesList(CmsJspActionElement jsp,
123:                    String relativeTo, boolean publishRelated) {
124:
125:                super (jsp, LIST_ID, Messages.get().container(
126:                        Messages.GUI_PUBLISH_RESOURCES_LIST_NAME_0));
127:
128:                // prevent paging
129:                getList().setMaxItemsPerPage(Integer.MAX_VALUE);
130:
131:                // set the right resource util parameters
132:                CmsResourceUtil resUtil = getResourceUtil();
133:                resUtil.setAbbrevLength(50);
134:                resUtil.setRelativeTo(getCms().getRequestContext().addSiteRoot(
135:                        relativeTo));
136:                resUtil.setSiteMode(CmsResourceUtil.SITE_MODE_MATCHING);
137:
138:                m_publishRelated = publishRelated;
139:            }
140:
141:            /**
142:             * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
143:             */
144:            public void executeListMultiActions() {
145:
146:                throwListUnsupportedActionException();
147:            }
148:
149:            /**
150:             * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
151:             */
152:            public void executeListSingleActions() {
153:
154:                throwListUnsupportedActionException();
155:            }
156:
157:            /**
158:             * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getCollector()
159:             */
160:            public I_CmsListResourceCollector getCollector() {
161:
162:                if (m_collector == null) {
163:                    m_collector = new A_CmsListResourceCollector(this ) {
164:
165:                        /** Parameter of the default collector name. */
166:                        private static final String COLLECTOR_NAME = "publishResources";
167:
168:                        /**
169:                         * @see org.opencms.file.collectors.I_CmsResourceCollector#getCollectorNames()
170:                         */
171:                        public List getCollectorNames() {
172:
173:                            List names = new ArrayList();
174:                            names.add(COLLECTOR_NAME);
175:                            return names;
176:                        }
177:
178:                        /**
179:                         * @see org.opencms.workplace.list.A_CmsListResourceCollector#getResources(org.opencms.file.CmsObject, java.util.Map)
180:                         */
181:                        public List getResources(CmsObject cms, Map params) {
182:
183:                            if (m_publishRelated
184:                                    && getSettings().getPublishList()
185:                                            .isDirectPublish()) {
186:                                try {
187:                                    CmsPublishList relatedPL = OpenCms
188:                                            .getPublishManager()
189:                                            .getRelatedResourcesToPublish(
190:                                                    cms,
191:                                                    getSettings()
192:                                                            .getPublishList());
193:                                    CmsPublishList mergedPL = OpenCms
194:                                            .getPublishManager()
195:                                            .mergePublishLists(
196:                                                    cms,
197:                                                    getSettings()
198:                                                            .getPublishList(),
199:                                                    relatedPL);
200:                                    m_publishList = mergedPL;
201:                                } catch (CmsException e) {
202:                                    if (LOG.isErrorEnabled()) {
203:                                        LOG
204:                                                .error(
205:                                                        e
206:                                                                .getLocalizedMessage(getLocale()),
207:                                                        e);
208:                                    }
209:                                }
210:                            } else {
211:                                m_publishList = getSettings().getPublishList();
212:                            }
213:                            return m_publishList.getAllResources();
214:                        }
215:
216:                        /**
217:                         * @see org.opencms.workplace.list.A_CmsListResourceCollector#setAdditionalColumns(org.opencms.workplace.list.CmsListItem, org.opencms.workplace.explorer.CmsResourceUtil)
218:                         */
219:                        protected void setAdditionalColumns(CmsListItem item,
220:                                CmsResourceUtil resUtil) {
221:
222:                            item.set(LIST_COLUMN_IS_RELATED, Boolean
223:                                    .valueOf(!getSettings().getPublishList()
224:                                            .getAllResources().contains(
225:                                                    resUtil.getResource())));
226:                        }
227:                    };
228:                }
229:                return m_collector;
230:            }
231:
232:            /**
233:             * Returns the publish list created for that list.<p>
234:             *
235:             * @return the publish list created for that list
236:             */
237:            public CmsPublishList getPublishList() {
238:
239:                return m_publishList;
240:            }
241:
242:            /**
243:             * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
244:             */
245:            protected void fillDetails(String detailId) {
246:
247:                CmsObject cms;
248:                try {
249:                    cms = OpenCms.initCmsObject(getCms());
250:                } catch (CmsException e) {
251:                    cms = getCms();
252:                }
253:
254:                // check if progress should be set in the thread
255:                CmsProgressThread thread = null;
256:                int progressOffset = 0;
257:                if (Thread.currentThread() instanceof  CmsProgressThread) {
258:                    thread = (CmsProgressThread) Thread.currentThread();
259:                    progressOffset = thread.getProgress();
260:                }
261:
262:                List publishResources = getSettings().getPublishList()
263:                        .getAllResources();
264:
265:                // get content
266:                List resourceNames = new ArrayList(getList().getAllContent());
267:                Iterator itResourceNames = resourceNames.iterator();
268:                int count = 0;
269:                while (itResourceNames.hasNext()) {
270:                    // set progress in thread
271:                    count++;
272:                    if (thread != null) {
273:                        if (thread.isInterrupted()) {
274:                            throw new CmsIllegalStateException(
275:                                    org.opencms.workplace.commons.Messages
276:                                            .get()
277:                                            .container(
278:                                                    org.opencms.workplace.commons.Messages.ERR_PROGRESS_INTERRUPTED_0));
279:                        }
280:                        thread.setProgress((count * 10 / resourceNames.size())
281:                                + progressOffset);
282:                        thread
283:                                .setDescription(org.opencms.workplace.commons.Messages
284:                                        .get()
285:                                        .getBundle(thread.getLocale())
286:                                        .key(
287:                                                org.opencms.workplace.commons.Messages.GUI_PROGRESS_PUBLISH_STEP3_2,
288:                                                new Integer(count),
289:                                                new Integer(resourceNames
290:                                                        .size())));
291:                    }
292:
293:                    CmsListItem item = (CmsListItem) itResourceNames.next();
294:                    try {
295:                        if (detailId.equals(LIST_DETAIL_RELATIONS)) {
296:                            List relatedResources = new ArrayList();
297:                            CmsResource resource = getResourceUtil(item)
298:                                    .getResource();
299:
300:                            String rightSite = OpenCms.getSiteManager()
301:                                    .getSiteRoot(resource.getRootPath());
302:                            if (rightSite == null) {
303:                                rightSite = "";
304:                            }
305:                            String oldSite = cms.getRequestContext()
306:                                    .getSiteRoot();
307:                            try {
308:                                cms.getRequestContext().setSiteRoot(rightSite);
309:                                // get and iterate over all related resources
310:                                Iterator itRelations = cms
311:                                        .getRelationsForResource(
312:                                                cms.getSitePath(resource),
313:                                                CmsRelationFilter.TARGETS
314:                                                        .filterStrong())
315:                                        .iterator();
316:                                while (itRelations.hasNext()) {
317:                                    CmsRelation relation = (CmsRelation) itRelations
318:                                            .next();
319:                                    CmsResource target = null;
320:                                    try {
321:                                        target = relation.getTarget(cms,
322:                                                CmsResourceFilter.ALL);
323:                                    } catch (CmsVfsResourceNotFoundException e) {
324:                                        // target not found, ignore, will come later in the link check dialog
325:                                    }
326:                                    // just add resources that may come in question
327:                                    if ((target != null)
328:                                            && !publishResources
329:                                                    .contains(target)
330:                                            && !target.getState().isUnchanged()) {
331:                                        String relationName = target
332:                                                .getRootPath();
333:                                        if (relationName.startsWith(cms
334:                                                .getRequestContext()
335:                                                .getSiteRoot())) {
336:                                            // same site
337:                                            relationName = cms
338:                                                    .getSitePath(target);
339:                                            relationName = CmsStringUtil
340:                                                    .formatResourceName(
341:                                                            relationName, 50);
342:                                        } else {
343:                                            // other site
344:                                            String site = OpenCms
345:                                                    .getSiteManager()
346:                                                    .getSiteRoot(relationName);
347:                                            String siteName = site;
348:                                            if (site != null) {
349:                                                relationName = relationName
350:                                                        .substring(site
351:                                                                .length());
352:                                                siteName = OpenCms
353:                                                        .getSiteManager()
354:                                                        .getSiteForSiteRoot(
355:                                                                site)
356:                                                        .getTitle();
357:                                            } else {
358:                                                siteName = "/";
359:                                            }
360:                                            relationName = CmsStringUtil
361:                                                    .formatResourceName(
362:                                                            relationName, 50);
363:                                            relationName = key(
364:                                                    Messages.GUI_DELETE_SITE_RELATION_2,
365:                                                    new Object[] { siteName,
366:                                                            relationName });
367:                                        }
368:                                        if (!cms.getLock(target).isLockableBy(
369:                                                cms.getRequestContext()
370:                                                        .currentUser())) {
371:                                            // mark not lockable resources
372:                                            relationName = relationName + "*";
373:                                        } else if (m_publishRelated) {
374:                                            // mark related resources to be published
375:                                            relationName = relationName + "!";
376:                                        }
377:                                        if (!resourceNames
378:                                                .contains(relationName)) {
379:                                            relatedResources.add(relationName);
380:                                        }
381:                                    }
382:                                }
383:                                if (((Boolean) item.get(LIST_COLUMN_IS_RELATED))
384:                                        .booleanValue()) {
385:                                    // mark the reverse references
386:                                    itRelations = cms.getRelationsForResource(
387:                                            cms.getSitePath(resource),
388:                                            CmsRelationFilter.SOURCES
389:                                                    .filterStrong()).iterator();
390:                                    while (itRelations.hasNext()) {
391:                                        CmsRelation relation = (CmsRelation) itRelations
392:                                                .next();
393:                                        CmsResource source = null;
394:                                        try {
395:                                            source = relation.getSource(cms,
396:                                                    CmsResourceFilter.ALL);
397:                                        } catch (CmsVfsResourceNotFoundException e) {
398:                                            // source not found, ignore, will come later in the link check dialog
399:                                        }
400:                                        // just add resources that may come in question
401:                                        if ((source != null)
402:                                                && publishResources
403:                                                        .contains(source)) {
404:                                            String relationName = source
405:                                                    .getRootPath();
406:                                            if (relationName.startsWith(cms
407:                                                    .getRequestContext()
408:                                                    .getSiteRoot())) {
409:                                                // same site
410:                                                relationName = cms
411:                                                        .getSitePath(source);
412:                                                relationName = CmsStringUtil
413:                                                        .formatResourceName(
414:                                                                relationName,
415:                                                                50);
416:                                            } else {
417:                                                // other site
418:                                                String site = OpenCms
419:                                                        .getSiteManager()
420:                                                        .getSiteRoot(
421:                                                                relationName);
422:                                                String siteName = site;
423:                                                if (site != null) {
424:                                                    relationName = relationName
425:                                                            .substring(site
426:                                                                    .length());
427:                                                    siteName = OpenCms
428:                                                            .getSiteManager()
429:                                                            .getSiteForSiteRoot(
430:                                                                    site)
431:                                                            .getTitle();
432:                                                } else {
433:                                                    siteName = "/";
434:                                                }
435:                                                relationName = CmsStringUtil
436:                                                        .formatResourceName(
437:                                                                relationName,
438:                                                                50);
439:                                                relationName = key(
440:                                                        Messages.GUI_DELETE_SITE_RELATION_2,
441:                                                        new Object[] {
442:                                                                siteName,
443:                                                                relationName });
444:                                            }
445:                                            // mark as reverse reference
446:                                            relationName = relationName + "$";
447:                                            if (!resourceNames
448:                                                    .contains(relationName)) {
449:                                                relatedResources
450:                                                        .add(relationName);
451:                                            }
452:                                        }
453:                                    }
454:                                }
455:                            } finally {
456:                                cms.getRequestContext().setSiteRoot(oldSite);
457:                            }
458:                            if (!relatedResources.isEmpty()) {
459:                                item.set(detailId, relatedResources);
460:                            }
461:                        } else {
462:                            continue;
463:                        }
464:                    } catch (CmsException e) {
465:                        // should never happen, log exception
466:                        if (LOG.isErrorEnabled()) {
467:                            LOG.error(e.getLocalizedMessage(), e);
468:                        }
469:                        item.set(detailId, e.getLocalizedMessage());
470:                    }
471:                }
472:            }
473:
474:            /**
475:             * @see org.opencms.workplace.list.A_CmsListExplorerDialog#isColumnVisible(int)
476:             */
477:            protected boolean isColumnVisible(int colFlag) {
478:
479:                boolean isVisible = (colFlag == CmsUserSettings.FILELIST_TITLE);
480:                isVisible = isVisible
481:                        || (colFlag == LIST_COLUMN_TYPEICON.hashCode());
482:                isVisible = isVisible
483:                        || (colFlag == LIST_COLUMN_LOCKICON.hashCode());
484:                isVisible = isVisible
485:                        || (colFlag == LIST_COLUMN_PROJSTATEICON.hashCode());
486:                isVisible = isVisible
487:                        || (colFlag == LIST_COLUMN_NAME.hashCode());
488:                isVisible = isVisible
489:                        || ((colFlag == LIST_COLUMN_SITE.hashCode()) && (OpenCms
490:                                .getSiteManager().getSites().size() > 1));
491:                return isVisible;
492:            }
493:
494:            /**
495:             * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
496:             */
497:            protected void setColumns(CmsListMetadata metadata) {
498:
499:                super .setColumns(metadata);
500:
501:                Iterator it = metadata.getColumnDefinitions().iterator();
502:                while (it.hasNext()) {
503:                    CmsListColumnDefinition colDefinition = (CmsListColumnDefinition) it
504:                            .next();
505:                    colDefinition.setSorteable(false);
506:                    if (colDefinition.getId().equals(LIST_COLUMN_NAME)) {
507:                        colDefinition.removeDefaultAction(LIST_DEFACTION_OPEN);
508:                        colDefinition.setWidth("60%");
509:                    } else if (colDefinition.getId().equals(
510:                            LIST_COLUMN_PROJSTATEICON)) {
511:                        colDefinition
512:                                .removeDirectAction(LIST_ACTION_PROJSTATEICON);
513:                        // add resource state icon action
514:                        CmsListDirectAction resourceProjStateAction = new CmsListResourceProjStateAction(
515:                                LIST_ACTION_PROJSTATEICON) {
516:
517:                            /**
518:                             * @see org.opencms.workplace.list.CmsListResourceProjStateAction#getIconPath()
519:                             */
520:                            public String getIconPath() {
521:
522:                                if (((Boolean) getItem().get(
523:                                        LIST_COLUMN_IS_RELATED)).booleanValue()) {
524:                                    return "explorer/related_resource.png";
525:                                }
526:                                return super .getIconPath();
527:                            }
528:
529:                            /**
530:                             * @see org.opencms.workplace.list.CmsListResourceProjStateAction#getName()
531:                             */
532:                            public CmsMessageContainer getName() {
533:
534:                                if (((Boolean) getItem().get(
535:                                        LIST_COLUMN_IS_RELATED)).booleanValue()) {
536:                                    return Messages
537:                                            .get()
538:                                            .container(
539:                                                    Messages.GUI_PUBLISH_RELATED_RESOURCE_0);
540:                                }
541:                                return super .getName();
542:                            }
543:                        };
544:                        resourceProjStateAction.setEnabled(false);
545:                        colDefinition.addDirectAction(resourceProjStateAction);
546:                    }
547:                }
548:
549:                CmsListColumnDefinition relatedCol = new CmsListExplorerColumn(
550:                        LIST_COLUMN_IS_RELATED);
551:                relatedCol
552:                        .setName(org.opencms.workplace.explorer.Messages
553:                                .get()
554:                                .container(
555:                                        org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0));
556:                relatedCol.setVisible(false);
557:                relatedCol.setPrintable(false);
558:                metadata.addColumn(relatedCol);
559:            }
560:
561:            /**
562:             * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
563:             */
564:            protected void setIndependentActions(CmsListMetadata metadata) {
565:
566:                /**
567:                 * Class to render a javascript driven detail action button.<p>
568:                 */
569:                abstract class DetailsJsAction extends
570:                        A_CmsListIndependentJsAction {
571:
572:                    /**
573:                     * Default constructor.<p>
574:                     * 
575:                     * @param id the action id
576:                     */
577:                    public DetailsJsAction(String id) {
578:
579:                        super (id);
580:                    }
581:
582:                    /**
583:                     * @see org.opencms.workplace.list.CmsListIndependentAction#buttonHtml(org.opencms.workplace.CmsWorkplace)
584:                     */
585:                    public String buttonHtml(CmsWorkplace wp) {
586:
587:                        StringBuffer html = new StringBuffer(1024);
588:                        html.append("\t<span id='");
589:                        html.append(getId());
590:                        html.append("' class=\"link");
591:                        html.append("\"");
592:                        html.append(" onClick=\"");
593:                        html.append(resolveOnClic(wp));
594:                        html.append("\"");
595:                        html.append(">");
596:                        html.append("<img src='");
597:                        html.append(CmsWorkplace.getSkinUri());
598:                        html.append(getIconPath());
599:                        html.append("'");
600:                        html.append(" alt='");
601:                        html.append(getName().key(wp.getLocale()));
602:                        html.append("'");
603:                        html.append(" title='");
604:                        html.append(getName().key(wp.getLocale()));
605:                        html.append("'");
606:                        html.append(">");
607:                        html.append("&nbsp;");
608:                        html.append("<a href='#'>");
609:                        html.append(getName().key(wp.getLocale()));
610:                        html.append("</a>");
611:                        html.append("</span>");
612:                        return html.toString();
613:                    }
614:                }
615:
616:                I_CmsListAction hideAction = new DetailsJsAction(
617:                        LIST_DETAIL_RELATIONS_HIDE) {
618:
619:                    /**
620:                     * @see org.opencms.workplace.list.A_CmsListIndependentJsAction#jsCode(CmsWorkplace)
621:                     */
622:                    public String jsCode(CmsWorkplace wp) {
623:
624:                        return "javascript:showRelatedResources(false);";
625:                    }
626:                };
627:                hideAction.setIconPath(A_CmsListDialog.ICON_DETAILS_HIDE);
628:                hideAction
629:                        .setName(Messages
630:                                .get()
631:                                .container(
632:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_NAME_0));
633:                hideAction
634:                        .setHelpText(Messages
635:                                .get()
636:                                .container(
637:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_HELP_0));
638:                metadata.addIndependentAction(hideAction);
639:
640:                I_CmsListAction showAction = new DetailsJsAction(
641:                        LIST_DETAIL_RELATIONS_SHOW) {
642:
643:                    /**
644:                     * @see org.opencms.workplace.list.A_CmsListIndependentJsAction#jsCode(CmsWorkplace)
645:                     */
646:                    public String jsCode(CmsWorkplace wp) {
647:
648:                        return "javascript:showRelatedResources(true);";
649:                    }
650:                };
651:                showAction.setIconPath(A_CmsListDialog.ICON_DETAILS_SHOW);
652:                showAction
653:                        .setName(Messages
654:                                .get()
655:                                .container(
656:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_NAME_0));
657:                showAction
658:                        .setHelpText(Messages
659:                                .get()
660:                                .container(
661:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_HELP_0));
662:                metadata.addIndependentAction(showAction);
663:
664:                // create list item detail
665:                CmsListItemDetails relationsDetails = new CmsListItemDetails(
666:                        LIST_DETAIL_RELATIONS) {
667:
668:                    /**
669:                     * @see org.opencms.workplace.list.CmsListItemDetails#getAction()
670:                     */
671:                    public I_CmsListAction getAction() {
672:
673:                        return new CmsListIndependentAction("hide") {
674:
675:                            /**
676:                             * @see org.opencms.workplace.list.CmsListIndependentAction#buttonHtml(org.opencms.workplace.CmsWorkplace)
677:                             */
678:                            public String buttonHtml(CmsWorkplace wp) {
679:
680:                                return "";
681:                            }
682:                        };
683:                    }
684:                };
685:                relationsDetails.setAtColumn(LIST_COLUMN_NAME);
686:                relationsDetails.setVisible(true);
687:                relationsDetails.setFormatter(new I_CmsListFormatter() {
688:
689:                    public String format(Object data, Locale locale) {
690:
691:                        if (!(data instanceof  List)) {
692:                            return new DataFormatException()
693:                                    .getLocalizedMessage();
694:                        }
695:                        StringBuffer html = new StringBuffer(512);
696:                        Iterator itResourceNames = ((List) data).iterator();
697:                        if (itResourceNames.hasNext()) {
698:                            html
699:                                    .append("<table border='0' cellspacing='0' cellpadding='0'>\n");
700:                        }
701:                        while (itResourceNames.hasNext()) {
702:                            String resName = (String) itResourceNames.next();
703:                            html.append("\t<tr>\n");
704:                            html
705:                                    .append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
706:                            html.append("\t\t\t");
707:                            if (resName.endsWith("*")) {
708:                                // resource is not lockable, and will not be published
709:                                resName = resName.substring(0,
710:                                        resName.length() - 1);
711:                                html.append("<font color='red' />");
712:                                html
713:                                        .append(Messages
714:                                                .get()
715:                                                .getBundle(locale)
716:                                                .key(
717:                                                        Messages.GUI_PUBLISH_DETAIL_RELATED_LOCKED_RESOURCE_0));
718:                                html.append("</font/>");
719:                            } else if (resName.endsWith("!")) {
720:                                // resource will be published
721:                                resName = resName.substring(0,
722:                                        resName.length() - 1);
723:                                html
724:                                        .append(Messages
725:                                                .get()
726:                                                .getBundle(locale)
727:                                                .key(
728:                                                        Messages.GUI_PUBLISH_DETAIL_RELATED_RESOURCE_0));
729:                            } else if (resName.endsWith("$")) {
730:                                // reverse reference
731:                                resName = resName.substring(0,
732:                                        resName.length() - 1);
733:                                html
734:                                        .append(Messages
735:                                                .get()
736:                                                .getBundle(locale)
737:                                                .key(
738:                                                        Messages.GUI_PUBLISH_DETAIL_REVERSE_REFERENCE_0));
739:                            } else {
740:                                // resource will not be published
741:                                html.append("<font color='red' />");
742:                                html
743:                                        .append(Messages
744:                                                .get()
745:                                                .getBundle(locale)
746:                                                .key(
747:                                                        Messages.GUI_PUBLISH_DETAIL_RELATED_RESOURCE_NO_0));
748:                                html.append("</font/>");
749:                            }
750:                            html.append("&nbsp;:&nbsp;\n");
751:                            html.append("\t\t</td>\n");
752:                            html
753:                                    .append("\t\t<td class='listdetailitem' style='white-space:normal;'>\n");
754:                            html.append("\t\t\t");
755:                            html.append(resName);
756:                            html.append("\n");
757:                            html.append("\t\t</td>\n");
758:                            html.append("\t</tr>\n");
759:                        }
760:                        if (html.length() > 0) {
761:                            html.append("</table>\n");
762:                        }
763:                        return html.toString();
764:                    }
765:
766:                });
767:                relationsDetails
768:                        .setShowActionName(Messages
769:                                .get()
770:                                .container(
771:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_NAME_0));
772:                relationsDetails
773:                        .setShowActionHelpText(Messages
774:                                .get()
775:                                .container(
776:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_HELP_0));
777:                relationsDetails
778:                        .setHideActionName(Messages
779:                                .get()
780:                                .container(
781:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_NAME_0));
782:                relationsDetails
783:                        .setHideActionHelpText(Messages
784:                                .get()
785:                                .container(
786:                                        Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_HELP_0));
787:
788:                // add resources info item detail to meta data
789:                metadata.addItemDetails(relationsDetails);
790:            }
791:
792:            /**
793:             * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
794:             */
795:            protected void setMultiActions(CmsListMetadata metadata) {
796:
797:                // no LMAs, and remove default search action
798:                metadata.setSearchAction(null);
799:            }
800:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.