KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > list > CmsListMetadata


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/CmsListMetadata.java,v $
3  * Date : $Date: 2006/10/17 12:16:56 $
4  * Version: $Revision: 1.23 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.list;
33
34 import org.opencms.main.CmsIllegalStateException;
35 import org.opencms.util.CmsIdentifiableObjectContainer;
36 import org.opencms.util.CmsStringUtil;
37 import org.opencms.workplace.CmsWorkplace;
38
39 import java.util.Iterator JavaDoc;
40 import java.util.List JavaDoc;
41 import java.util.Locale JavaDoc;
42 import java.util.Set JavaDoc;
43 import java.util.TreeSet JavaDoc;
44
45 /**
46  * This is class contains all the information for defining a whole html list.<p>
47  *
48  * @author Michael Moossen
49  *
50  * @version $Revision: 1.23 $
51  *
52  * @since 6.0.0
53  */

54 public class CmsListMetadata {
55
56     /** the html id for the input element of the search bar. */
57     public static final String JavaDoc SEARCH_BAR_INPUT_ID = "listSearchFilter";
58     
59     /** Container for column definitions. */
60     private CmsIdentifiableObjectContainer m_columns = new CmsIdentifiableObjectContainer(true, false);
61
62     /** Container for of independent actions. */
63     private CmsIdentifiableObjectContainer m_indepActions = new CmsIdentifiableObjectContainer(true, false);
64
65     /** Container for item detail definitions. */
66     private CmsIdentifiableObjectContainer m_itemDetails = new CmsIdentifiableObjectContainer(true, false);
67
68     /** The id of the list. */
69     private String JavaDoc m_listId;
70
71     /** Container for multi actions. */
72     private CmsIdentifiableObjectContainer m_multiActions = new CmsIdentifiableObjectContainer(true, false);
73
74     /** Search action. */
75     private CmsListSearchAction m_searchAction;
76
77     /** <code>true</code> if this metadata object should not be cached.<p>. */
78     private boolean m_volatile = false;
79
80     /**
81      * Default Constructor.<p>
82      *
83      * @param listId the id of the list
84      */

85     public CmsListMetadata(String JavaDoc listId) {
86
87         m_listId = listId;
88     }
89
90     /**
91      * Adds a new column definition at the end.<p>
92      *
93      * By default a column is printable if it is the first column in the list,
94      * or if it is sorteable.<p>
95      *
96      * If you want to override this behaviour, use the
97      * {@link CmsListColumnDefinition#setPrintable(boolean)}
98      * method after calling this one.
99      *
100      * @param listColumn the column definition
101      *
102      * @see CmsIdentifiableObjectContainer
103      */

104     public void addColumn(CmsListColumnDefinition listColumn) {
105
106         setListIdForColumn(listColumn);
107         if (m_columns.elementList().isEmpty()) {
108             listColumn.setPrintable(true);
109         } else {
110             listColumn.setPrintable(listColumn.isSorteable());
111         }
112         m_columns.addIdentifiableObject(listColumn.getId(), listColumn);
113     }
114
115     /**
116      * Adds a new column definition at the given position.<p>
117      *
118      * By default a column is printable if it is the first column in the list,
119      * or if it is sorteable.<p>
120      *
121      * If you want to override this behaviour, use the
122      * {@link CmsListColumnDefinition#setPrintable(boolean)}
123      * method after calling this one.
124      *
125      * @param listColumn the column definition
126      * @param position the position
127      *
128      * @see CmsIdentifiableObjectContainer
129      */

130     public void addColumn(CmsListColumnDefinition listColumn, int position) {
131
132         setListIdForColumn(listColumn);
133         if (m_columns.elementList().isEmpty()) {
134             listColumn.setPrintable(true);
135         } else {
136             listColumn.setPrintable(listColumn.isSorteable());
137         }
138         m_columns.addIdentifiableObject(listColumn.getId(), listColumn, position);
139     }
140
141     /**
142      * Adds a list item independent action.<p>
143      *
144      * @param action the action
145      */

146     public void addIndependentAction(I_CmsListAction action) {
147
148         action.setListId(getListId());
149         m_indepActions.addIdentifiableObject(action.getId(), action);
150     }
151
152     /**
153      * Adds a new item detail definition at the end.<p>
154      *
155      * @param itemDetail the item detail definition
156      *
157      * @see CmsIdentifiableObjectContainer
158      */

159     public void addItemDetails(CmsListItemDetails itemDetail) {
160
161         itemDetail.setListId(getListId());
162         m_itemDetails.addIdentifiableObject(itemDetail.getId(), itemDetail);
163     }
164
165     /**
166      * Adds a new item detail definition at the given position.<p>
167      *
168      * @param itemDetail the item detail definition
169      * @param position the position
170      *
171      * @see CmsIdentifiableObjectContainer
172      */

173     public void addItemDetails(CmsListItemDetails itemDetail, int position) {
174
175         itemDetail.setListId(getListId());
176         m_itemDetails.addIdentifiableObject(itemDetail.getId(), itemDetail, position);
177     }
178
179     /**
180      * Adds an action applicable to more than one list item at once.<p>
181      *
182      * It will be executed with a list of <code>{@link CmsListItem}</code>s.<p>
183      *
184      * @param multiAction the action
185      */

186     public void addMultiAction(CmsListMultiAction multiAction) {
187
188         multiAction.setListId(getListId());
189         m_multiActions.addIdentifiableObject(multiAction.getId(), multiAction);
190     }
191
192     /**
193      * Generates the csv output for an empty table.<p>
194      *
195      * @return csv output
196      */

197     public String JavaDoc csvEmptyList() {
198
199         StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
200         html.append("\n");
201         return html.toString();
202     }
203
204     /**
205      * Returns the csv output for the header of the list.<p>
206      *
207      * @param wp the workplace instance
208      *
209      * @return csv output
210      */

211     public String JavaDoc csvHeader(CmsWorkplace wp) {
212
213         StringBuffer JavaDoc csv = new StringBuffer JavaDoc(1024);
214         Iterator JavaDoc itCols = m_columns.elementList().iterator();
215         while (itCols.hasNext()) {
216             CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
217             if (!col.isVisible()) {
218                 continue;
219             }
220             csv.append(col.csvHeader(wp));
221             csv.append("\t");
222         }
223         csv.append("\n\n");
224         return csv.toString();
225     }
226
227     /**
228      * Returns the csv output for a list item.<p>
229      *
230      * @param item the list item to render
231      * @param wp the workplace context
232      *
233      * @return csv output
234      */

235     public String JavaDoc csvItem(CmsListItem item, CmsWorkplace wp) {
236
237         StringBuffer JavaDoc csv = new StringBuffer JavaDoc(1024);
238         Iterator JavaDoc itCols = m_columns.elementList().iterator();
239         while (itCols.hasNext()) {
240             CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
241             if (!col.isVisible()) {
242                 continue;
243             }
244             csv.append(col.csvCell(item, wp));
245             csv.append("\t");
246         }
247         csv.append("\n");
248         return csv.toString();
249     }
250
251     /**
252      * Returns a column definition object for a given column id.<p>
253      *
254      * @param columnId the column id
255      *
256      * @return the column definition, or <code>null</code> if not present
257      */

258     public CmsListColumnDefinition getColumnDefinition(String JavaDoc columnId) {
259
260         return (CmsListColumnDefinition)m_columns.getObject(columnId);
261     }
262
263     /**
264      * Returns all columns definitions.<p>
265      *
266      * @return a list of <code>{@link CmsListColumnDefinition}</code>s.
267      */

268     public List JavaDoc getColumnDefinitions() {
269
270         return m_columns.elementList();
271     }
272
273     /**
274      * Returns an independent action object for a given id.<p>
275      *
276      * @param actionId the id
277      *
278      * @return the independent action, or <code>null</code> if not present
279      */

280     public I_CmsListAction getIndependentAction(String JavaDoc actionId) {
281
282         return (I_CmsListAction)m_indepActions.getObject(actionId);
283     }
284
285     /**
286      * Returns the list of independent actions.<p>
287      *
288      * @return a list of <code>{@link I_CmsListAction}</code>s
289      */

290     public List JavaDoc getIndependentActions() {
291
292         return m_indepActions.elementList();
293     }
294
295     /**
296      * Returns the item details definition object for a given id.<p>
297      *
298      * @param itemDetailId the id
299      *
300      * @return the item details definition, or <code>null</code> if not present
301      */

302     public CmsListItemDetails getItemDetailDefinition(String JavaDoc itemDetailId) {
303
304         return (CmsListItemDetails)m_itemDetails.getObject(itemDetailId);
305     }
306
307     /**
308      * Returns all detail definitions.<p>
309      *
310      * @return a list of <code>{@link CmsListItemDetails}</code>.
311      */

312     public List JavaDoc getItemDetailDefinitions() {
313
314         return m_itemDetails.elementList();
315     }
316
317     /**
318      * Returns the id of the list.<p>
319      *
320      * @return the id of list
321      */

322     public String JavaDoc getListId() {
323
324         return m_listId;
325     }
326
327     /**
328      * Returns a multi action object for a given id.<p>
329      *
330      * @param actionId the id
331      *
332      * @return the multi action, or <code>null</code> if not present
333      */

334     public CmsListMultiAction getMultiAction(String JavaDoc actionId) {
335
336         return (CmsListMultiAction)m_multiActions.getObject(actionId);
337     }
338
339     /**
340      * Returns the list of multi actions.<p>
341      *
342      * @return a list of <code>{@link CmsListMultiAction}</code>s
343      */

344     public List JavaDoc getMultiActions() {
345
346         return m_multiActions.elementList();
347     }
348
349     /**
350      * Returns the search action.<p>
351      *
352      * @return the search action
353      */

354     public CmsListSearchAction getSearchAction() {
355
356         return m_searchAction;
357     }
358
359     /**
360      * Returns the total number of displayed columns.<p>
361      *
362      * @return the total number of displayed columns
363      */

364     public int getWidth() {
365
366         return m_columns.elementList().size() + (hasCheckMultiActions() ? 1 : 0);
367     }
368
369     /**
370      * Returns <code>true</code> if the list definition contains an action.<p>
371      *
372      * @return <code>true</code> if the list definition contains an action
373      */

374     public boolean hasActions() {
375
376         return !m_indepActions.elementList().isEmpty();
377     }
378
379     /**
380      * Returns <code>true</code> if at least 'check' multiaction has been set.<p>
381      *
382      * @return <code>true</code> if at least 'check' multiaction has been set
383      */

384     public boolean hasCheckMultiActions() {
385
386         Iterator JavaDoc it = m_multiActions.elementList().iterator();
387         while (it.hasNext()) {
388             CmsListMultiAction action = (CmsListMultiAction)it.next();
389             if (!(action instanceof CmsListRadioMultiAction)) {
390                 return true;
391             }
392         }
393         return false;
394     }
395
396     /**
397      * Returns <code>true</code> if the list definition contains a multi action.<p>
398      *
399      * @return <code>true</code> if the list definition contains a multi action
400      */

401     public boolean hasMultiActions() {
402
403         return !m_multiActions.elementList().isEmpty();
404     }
405
406     /**
407      * Returns <code>true</code> if any column definition contains a single action.<p>
408      *
409      * @return <code>true</code> if any column definition contains a single action
410      */

411     public boolean hasSingleActions() {
412
413         Iterator JavaDoc itCols = m_columns.elementList().iterator();
414         while (itCols.hasNext()) {
415             CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
416             if (!col.getDefaultActions().isEmpty() || !col.getDirectActions().isEmpty()) {
417                 return true;
418             }
419         }
420         return false;
421     }
422
423     /**
424      * Returns the html code for the action bar.<p>
425      *
426      * @param wp the workplace context
427      *
428      * @return html code
429      */

430     public String JavaDoc htmlActionBar(CmsWorkplace wp) {
431
432         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
433         html.append("<td class='misc'>\n");
434         html.append("\t<div>\n");
435         Iterator JavaDoc itDetails = m_itemDetails.elementList().iterator();
436         while (itDetails.hasNext()) {
437             I_CmsListAction detailAction = ((CmsListItemDetails)itDetails.next()).getAction();
438             html.append("\t\t");
439             html.append(detailAction.buttonHtml(wp));
440             if (itDetails.hasNext()) {
441                 html.append("&nbsp;&nbsp;");
442             }
443             html.append("\n");
444         }
445         Iterator JavaDoc itActions = m_indepActions.elementList().iterator();
446         while (itActions.hasNext()) {
447             I_CmsListAction indepAction = (I_CmsListAction)itActions.next();
448             html.append("\t\t");
449             html.append("&nbsp;&nbsp;");
450             html.append(indepAction.buttonHtml(wp));
451             html.append("\n");
452         }
453         html.append("\t</div>\n");
454         html.append("</td>\n");
455         return html.toString();
456     }
457
458     /**
459      * Generates the hml code for an empty table.<p>
460      *
461      * @param locale for localization
462      *
463      * @return html code
464      */

465     public String JavaDoc htmlEmptyTable(Locale JavaDoc locale) {
466
467         StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
468         html.append("<tr class='oddrowbg'>\n");
469         html.append("\t<td align='center' colspan='");
470         html.append(getWidth());
471         html.append("'>\n");
472         html.append(Messages.get().getBundle(locale).key(Messages.GUI_LIST_EMPTY_0));
473         html.append("\t</td>\n");
474         html.append("</tr>\n");
475         return html.toString();
476     }
477
478     /**
479      * Returns the html code for the header of the list.<p>
480      *
481      * @param list the list to generate the code for
482      * @param wp the workplace instance
483      *
484      * @return html code
485      */

486     public String JavaDoc htmlHeader(CmsHtmlList list, CmsWorkplace wp) {
487
488         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
489         html.append("<tr>\n");
490         Iterator JavaDoc itCols = m_columns.elementList().iterator();
491         while (itCols.hasNext()) {
492             CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
493             if (!list.isPrintable() || col.isPrintable()) {
494                 html.append(col.htmlHeader(list, wp));
495             }
496         }
497         if (!list.isPrintable() && hasCheckMultiActions()) {
498             html.append("\t<th width='0' class='select'>\n");
499             html.append("\t\t<input type='checkbox' class='checkbox' name='listSelectAll' value='true' onClick=\"listSelect('");
500             html.append(list.getId());
501             html.append("')\">\n");
502             html.append("\t</th>\n");
503         }
504         html.append("</tr>\n");
505         return html.toString();
506     }
507
508     /**
509      * Returns the html code for a list item.<p>
510      *
511      * @param item the list item to render
512      * @param wp the workplace context
513      * @param odd if the position is odd or even
514      * @param isPrintable if the list is to be printed
515      *
516      * @return html code
517      */

518     public String JavaDoc htmlItem(CmsListItem item, CmsWorkplace wp, boolean odd, boolean isPrintable) {
519
520         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
521         html.append("<tr ");
522         if (!isPrintable) {
523             html.append("class='");
524             html.append(odd ? "oddrowbg" : "evenrowbg");
525             html.append("'");
526         }
527         html.append(">\n");
528         Iterator JavaDoc itCols = m_columns.elementList().iterator();
529         int width = 0;
530         while (itCols.hasNext()) {
531             CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
532             if (!col.isVisible() || (isPrintable && !col.isPrintable())) {
533                 continue;
534             }
535             width++;
536             StringBuffer JavaDoc style = new StringBuffer JavaDoc(64);
537             html.append("<td");
538             CmsListColumnAlignEnum align = col.getAlign();
539             if (align != CmsListColumnAlignEnum.ALIGN_LEFT && CmsStringUtil.isNotEmpty(align.toString())) {
540                 style.append("text-align: ");
541                 style.append(col.getAlign());
542                 style.append("; ");
543             }
544             if (col.isTextWrapping()) {
545                 style.append("white-space: normal;");
546             }
547             if (isPrintable) {
548                 style.append("border-top: 1px solid black;");
549             }
550             if (style.length() > 0) {
551                 html.append(" style='");
552                 html.append(style);
553                 html.append("'");
554             }
555             html.append(">\n");
556             html.append(col.htmlCell(item, wp, isPrintable));
557             html.append("</td>\n");
558         }
559         if (!isPrintable && hasCheckMultiActions()) {
560             width++;
561             html.append("\t<td class='select' align='center'>\n");
562             html.append("\t\t<input type='checkbox' class='checkbox' name='listMultiAction' value='");
563             html.append(item.getId());
564             html.append("'>\n");
565             html.append("\t</td>\n");
566         }
567         html.append("</tr>\n");
568
569         Iterator JavaDoc itDet = m_itemDetails.elementList().iterator();
570         while (itDet.hasNext()) {
571             CmsListItemDetails lid = (CmsListItemDetails)itDet.next();
572             if (lid.isVisible()
573                 && item.get(lid.getId()) != null
574                 && CmsStringUtil.isNotEmptyOrWhitespaceOnly(item.get(lid.getId()).toString())) {
575                 int padCols = 0;
576                 itCols = m_columns.elementList().iterator();
577                 while (itCols.hasNext()) {
578                     CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
579                     if (!col.isVisible() || (isPrintable && !col.isPrintable())) {
580                         continue;
581                     }
582                     if (col.getId().equals(lid.getAtColumn())) {
583                         break;
584                     }
585                     padCols++;
586                 }
587                 int spanCols = width - padCols;
588
589                 html.append("<tr ");
590                 if (!isPrintable) {
591                     html.append("class='");
592                     html.append(odd ? "oddrowbg" : "evenrowbg");
593                     html.append("'");
594                 }
595                 html.append(">\n");
596                 if (padCols > 0) {
597                     html.append("<td colspan='");
598                     html.append(padCols);
599                     html.append("'>&nbsp;</td>\n");
600                 }
601                 html.append("<td colspan='");
602                 html.append(spanCols);
603                 html.append("' style='padding-left: 20px; white-space:normal;'>\n");
604                 html.append(lid.htmlCell(item, wp, isPrintable));
605                 html.append("\n</td>\n");
606                 html.append("\n");
607                 html.append("</tr>\n");
608             }
609         }
610         return html.toString();
611     }
612
613     /**
614      * Returns the html code for the multi action bar.<p>
615      *
616      * @param wp the workplace context
617      *
618      * @return html code
619      */

620     public String JavaDoc htmlMultiActionBar(CmsWorkplace wp) {
621
622         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
623         html.append("<td class='misc'>\n");
624         html.append("\t<div>\n");
625         Iterator JavaDoc itActions = m_multiActions.elementList().iterator();
626         while (itActions.hasNext()) {
627             CmsListMultiAction multiAction = (CmsListMultiAction)itActions.next();
628             html.append("\t\t");
629             html.append(multiAction.buttonHtml(wp));
630             if (itActions.hasNext()) {
631                 html.append("&nbsp;&nbsp;");
632             }
633             html.append("\n");
634         }
635         html.append("\t</div>\n");
636         html.append("</td>\n");
637         return html.toString();
638     }
639
640     /**
641      * Generates the html code for the search bar.<p>
642      *
643      * @param wp the workplace context
644      *
645      * @return html code
646      */

647     public String JavaDoc htmlSearchBar(CmsWorkplace wp) {
648
649         if (!isSearchable()) {
650             return "";
651         }
652         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
653         html.append("<td class='main'>\n");
654         html.append("\t<div>\n");
655         html.append("\t\t<input type='text' name='listSearchFilter' id='" + SEARCH_BAR_INPUT_ID + "' value='' size='20' maxlength='245' style='vertical-align: bottom;'>\n");
656         html.append(m_searchAction.buttonHtml(wp));
657         I_CmsListAction showAllAction = m_searchAction.getShowAllAction();
658         if (showAllAction != null) {
659             html.append("&nbsp;&nbsp;");
660             html.append(showAllAction.buttonHtml(wp));
661         }
662         html.append("\t</div>\n");
663         html.append("</td>\n");
664         return html.toString();
665     }
666
667     /**
668      * Returns <code>true</code> if the list is searchable.<p>
669      *
670      * @return <code>true</code> if the list is searchable
671      */

672     public boolean isSearchable() {
673
674         return m_searchAction != null;
675     }
676
677     /**
678      * Returns <code>true</code> if any column is sorteable.<p>
679      *
680      * @return <code>true</code> if any column is sorteable
681      */

682     public boolean isSorteable() {
683
684         Iterator JavaDoc itCols = m_columns.elementList().iterator();
685         while (itCols.hasNext()) {
686             CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
687             if (col.isSorteable()) {
688                 return true;
689             }
690         }
691         return false;
692     }
693
694     /**
695      * Returns <code>true</code> if this metadata object should not be cached.<p>
696      *
697      * @return <code>true</code> if this metadata object should not be cached.<p>
698      */

699     public boolean isVolatile() {
700
701         return m_volatile;
702     }
703
704     /**
705      * Sets the search action.<p>
706      *
707      * @param searchAction the search action to set
708      */

709     public void setSearchAction(CmsListSearchAction searchAction) {
710
711         m_searchAction = searchAction;
712         m_searchAction.setListId(getListId());
713     }
714
715     /**
716      * Sets the volatile flag.<p>
717      *
718      * @param volatileFlag the volatile flag to set
719      */

720     public void setVolatile(boolean volatileFlag) {
721
722         m_volatile = volatileFlag;
723     }
724
725     /**
726      * Toggles the given item detail state from visible to hidden or
727      * from hidden to visible.<p>
728      *
729      * @param itemDetailId the item detail id
730      */

731     public void toogleDetailState(String JavaDoc itemDetailId) {
732
733         CmsListItemDetails lid = (CmsListItemDetails)m_itemDetails.getObject(itemDetailId);
734         lid.setVisible(!lid.isVisible());
735     }
736
737     /**
738      * Throws a runtime exception if there are 2 identical ids.<p>
739      *
740      * This includes:<p>
741      * <ul>
742      * <li><code>{@link CmsListIndependentAction}</code>s</li>
743      * <li><code>{@link CmsListMultiAction}</code>s</li>
744      * <li><code>{@link CmsListItemDetails}</code></li>
745      * <li><code>{@link CmsListColumnDefinition}</code>s</li>
746      * <li><code>{@link CmsListDefaultAction}</code>s</li>
747      * <li><code>{@link CmsListDirectAction}</code>s</li>
748      * </ul>
749      */

750     /*package*/void checkIds() {
751
752         Set JavaDoc ids = new TreeSet JavaDoc();
753         // indep actions
754
Iterator JavaDoc itIndepActions = getIndependentActions().iterator();
755         while (itIndepActions.hasNext()) {
756             String JavaDoc id = ((CmsListIndependentAction)itIndepActions.next()).getId();
757             if (ids.contains(id)) {
758                 throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, id));
759             }
760             ids.add(id);
761         }
762         // multi actions
763
Iterator JavaDoc itMultiActions = getMultiActions().iterator();
764         while (itMultiActions.hasNext()) {
765             String JavaDoc id = ((CmsListMultiAction)itMultiActions.next()).getId();
766             if (ids.contains(id)) {
767                 throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, id));
768             }
769             ids.add(id);
770         }
771         // details
772
Iterator JavaDoc itItemDetails = getItemDetailDefinitions().iterator();
773         while (itItemDetails.hasNext()) {
774             String JavaDoc id = ((CmsListItemDetails)itItemDetails.next()).getId();
775             if (ids.contains(id)) {
776                 throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, id));
777             }
778             ids.add(id);
779         }
780         // columns
781
Iterator JavaDoc itColumns = getColumnDefinitions().iterator();
782         while (itColumns.hasNext()) {
783             CmsListColumnDefinition col = (CmsListColumnDefinition)itColumns.next();
784             if (ids.contains(col.getId())) {
785                 throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, col.getId()));
786             }
787             ids.add(col.getId());
788             // default actions
789
Iterator JavaDoc itDefaultActions = col.getDefaultActions().iterator();
790             while (itDefaultActions.hasNext()) {
791                 CmsListDefaultAction action = (CmsListDefaultAction)itDefaultActions.next();
792                 if (ids.contains(action.getId())) {
793                     throw new CmsIllegalStateException(Messages.get().container(
794                         Messages.ERR_DUPLICATED_ID_1,
795                         action.getId()));
796                 }
797                 ids.add(action.getId());
798             }
799             // direct actions
800
Iterator JavaDoc itDirectActions = col.getDirectActions().iterator();
801             while (itDirectActions.hasNext()) {
802                 CmsListDirectAction action = (CmsListDirectAction)itDirectActions.next();
803                 if (ids.contains(action.getId())) {
804                     throw new CmsIllegalStateException(Messages.get().container(
805                         Messages.ERR_DUPLICATED_ID_1,
806                         action.getId()));
807                 }
808                 ids.add(action.getId());
809             }
810         }
811     }
812
813     /**
814      * Sets the list id for all column single actions.<p>
815      *
816      * @param col the column to set the list id for
817      */

818     private void setListIdForColumn(CmsListColumnDefinition col) {
819
820         col.setListId(getListId());
821         // default actions
822
Iterator JavaDoc itDefaultActions = col.getDefaultActions().iterator();
823         while (itDefaultActions.hasNext()) {
824             ((CmsListDefaultAction)itDefaultActions.next()).setListId(getListId());
825         }
826         // direct actions
827
Iterator JavaDoc itDirectActions = col.getDirectActions().iterator();
828         while (itDirectActions.hasNext()) {
829             ((CmsListDirectAction)itDirectActions.next()).setListId(getListId());
830         }
831     }
832 }
Popular Tags