KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > commons > CmsHistoryList


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsHistoryList.java,v $
3  * Date : $Date: 2006/10/09 09:44:09 $
4  * Version: $Revision: 1.6 $
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.commons;
33
34 import org.opencms.file.CmsBackupProject;
35 import org.opencms.file.CmsBackupResource;
36 import org.opencms.file.CmsBackupResourceHandler;
37 import org.opencms.file.CmsFile;
38 import org.opencms.file.CmsObject;
39 import org.opencms.file.CmsResource;
40 import org.opencms.file.CmsResourceFilter;
41 import org.opencms.jsp.CmsJspActionElement;
42 import org.opencms.main.CmsException;
43 import org.opencms.main.CmsLog;
44 import org.opencms.main.CmsRuntimeException;
45 import org.opencms.workplace.list.A_CmsListDialog;
46 import org.opencms.workplace.list.CmsListColumnAlignEnum;
47 import org.opencms.workplace.list.CmsListColumnDefinition;
48 import org.opencms.workplace.list.CmsListDirectAction;
49 import org.opencms.workplace.list.CmsListItem;
50 import org.opencms.workplace.list.CmsListItemActionIconComparator;
51 import org.opencms.workplace.list.CmsListItemDetails;
52 import org.opencms.workplace.list.CmsListItemDetailsFormatter;
53 import org.opencms.workplace.list.CmsListItemSelectionAction;
54 import org.opencms.workplace.list.CmsListMetadata;
55 import org.opencms.workplace.list.CmsListOrderEnum;
56 import org.opencms.workplace.list.CmsListRadioMultiAction;
57 import org.opencms.workplace.list.CmsListResourceIconAction;
58 import org.opencms.workplace.tools.CmsToolDialog;
59
60 import java.io.IOException JavaDoc;
61 import java.util.ArrayList JavaDoc;
62 import java.util.Arrays JavaDoc;
63 import java.util.HashMap JavaDoc;
64 import java.util.Iterator JavaDoc;
65 import java.util.List JavaDoc;
66 import java.util.Map JavaDoc;
67
68 import javax.servlet.ServletException JavaDoc;
69 import javax.servlet.http.HttpServletRequest JavaDoc;
70 import javax.servlet.http.HttpServletResponse JavaDoc;
71 import javax.servlet.jsp.PageContext JavaDoc;
72
73 import org.apache.commons.logging.Log;
74
75 /**
76  * Displays the history of a file.<p>
77  *
78  * @author Jan Baudisch
79  * @author Armen Markarian
80  *
81  * @version $Revision: 1.6 $
82  *
83  * @since 6.0.2
84  */

85 public class CmsHistoryList extends A_CmsListDialog {
86
87     /**
88      * Wrapper class for the version which is either an integer or the string "offline".<p>
89      */

90     public static class CmsVersionWrapper implements Comparable JavaDoc {
91         
92         private Object JavaDoc m_version;
93         
94         /**
95          * Constructs a new version wrapper.<p>
96          * @param version the version of the file
97          */

98         public CmsVersionWrapper(Object JavaDoc version) {
99             
100             m_version = version;
101         }
102         
103         /**
104          *
105          * @see java.lang.Comparable#compareTo(java.lang.Object)
106          */

107         public int compareTo(Object JavaDoc o) {
108             
109             CmsVersionWrapper version = (CmsVersionWrapper)o;
110             if (String JavaDoc.class.equals(version.getVersion().getClass()) && Integer JavaDoc.class.equals(getVersion().getClass())) {
111                 return -1;
112             } else if (Integer JavaDoc.class.equals(version.getVersion().getClass()) && String JavaDoc.class.equals(getVersion().getClass())) {
113                 return 1;
114             } else {
115                 return ((Comparable JavaDoc)m_version).compareTo(version.getVersion());
116             }
117         }
118         
119         /**
120          * Returns the version of the file.<p>
121          * @return the version of the file
122          */

123         public Object JavaDoc getVersion() {
124             
125             return m_version;
126         }
127         
128         /**
129          *
130          * @see java.lang.Object#toString()
131          */

132         public String JavaDoc toString() {
133             
134             return m_version.toString();
135         }
136         
137     }
138     
139     /** list item detail id constant. */
140     public static final String JavaDoc GUI_LIST_HISTORY_DETAIL_PROJECT_0 = "lhdp";
141     /** List action export. */
142     public static final String JavaDoc LIST_ACTION_RESTORE = "ar";
143     /** list action id constant. */
144     public static final String JavaDoc LIST_ACTION_VIEW = "av";
145     
146     /** list column id constant. */
147     public static final String JavaDoc LIST_COLUMN_BACKUP_TAG = "cbt";
148
149     /** list column id constant. */
150     public static final String JavaDoc LIST_COLUMN_DATE_LAST_MODIFIED = "cm";
151
152     /** list column id constant. */
153     public static final String JavaDoc LIST_COLUMN_DATE_PUBLISHED = "cdp";
154
155     /** list column id constant. */
156     public static final String JavaDoc LIST_COLUMN_FILE_TYPE = "ct";
157
158     /** list column id constant. */
159     public static final String JavaDoc LIST_COLUMN_ICON = "ci";
160     
161     /** list column id constant. */
162     public static final String JavaDoc LIST_COLUMN_RESOURCE_PATH = "crp";
163
164     /** List column delete. */
165     public static final String JavaDoc LIST_COLUMN_RESTORE = "cr";
166
167     /** list column id constant. */
168     public static final String JavaDoc LIST_COLUMN_SEL1 = "cs1";
169     
170     /** list column id constant. */
171     public static final String JavaDoc LIST_COLUMN_SEL2 = "cs2";
172
173     /** list column id constant. */
174     public static final String JavaDoc LIST_COLUMN_SIZE = "cs";
175
176     /** List column export. */
177     public static final String JavaDoc LIST_COLUMN_USER = "cu";
178     
179     /** list column id constant. */
180     public static final String JavaDoc LIST_COLUMN_VERSION = "cv";
181
182     /** List column export. */
183     public static final String JavaDoc LIST_COLUMN_VIEW = "cp";
184
185     /** list id constant. */
186     public static final String JavaDoc LIST_ID = "him";
187     
188     /** list multi action id constant. */
189     private static final String JavaDoc LIST_MACTION_COMPARE = "mc";
190
191     /** list independent action id constant. */
192     public static final String JavaDoc LIST_RACTION_SEL1 = "rs1";
193
194     /** list independent action id constant. */
195     public static final String JavaDoc LIST_RACTION_SEL2 = "rs2";
196
197     /** The log object for this class. */
198     private static final Log LOG = CmsLog.getLog(CmsHistoryList.class);
199
200     /** constant for the offline project.<p> */
201     public static final String JavaDoc OFFLINE_PROJECT = "offline";
202
203     /** parameter for the path of the first resource. */
204     public static final String JavaDoc PARAM_PATH_1 = "path1";
205
206     /** parameter for the path of the second resource. */
207     public static final String JavaDoc PARAM_PATH_2 = "path2";
208
209     /** parameter for the version of the first resource. */
210     public static final String JavaDoc PARAM_TAGID_1 = "tagid1";
211
212     /** parameter for the tag id of the second resource. */
213     public static final String JavaDoc PARAM_TAGID_2 = "tagid2";
214
215     /** parameter for the version of the first resource. */
216     public static final String JavaDoc PARAM_VERSION_1 = "version1";
217     
218     /** parameter for the version of the second resource. */
219     public static final String JavaDoc PARAM_VERSION_2 = "version2";
220     
221     /** Path to the list buttons. */
222     public static final String JavaDoc PATH_BUTTONS = "buttons/";
223     
224     /**
225      * Public constructor.<p>
226      *
227      * @param jsp an initialized JSP action element
228      */

229     public CmsHistoryList(CmsJspActionElement jsp) {
230
231         super(jsp, LIST_ID, Messages.get().container(Messages.GUI_HISTORY_0),
232             LIST_COLUMN_VERSION, CmsListOrderEnum.ORDER_DESCENDING, null);
233     }
234
235     /**
236      * Public constructor with JSP variables.<p>
237      *
238      * @param context the JSP page context
239      * @param req the JSP request
240      * @param res the JSP response
241      */

242     public CmsHistoryList(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
243
244         this(new CmsJspActionElement(context, req, res));
245     }
246
247     /**
248      * Returns the link to a backup file.<p>
249      *
250      * @param resourcePath the path of the file
251      * @param versionId the version of the file
252      * @return the link to a backup file
253      */

254     public static String JavaDoc getBackupLink(String JavaDoc resourcePath, String JavaDoc versionId) {
255         StringBuffer JavaDoc link = new StringBuffer JavaDoc();
256         link.append(CmsBackupResourceHandler.BACKUP_HANDLER);
257         link.append(resourcePath);
258         link.append('?');
259         link.append(CmsBackupResourceHandler.PARAM_VERSIONID);
260         link.append('=');
261         link.append(versionId);
262         return link.toString();
263     }
264     
265     /**
266      * Returns the user last modified of a backup resource.<p>
267      *
268      * @param cms the cms object
269      * @param file the file to use
270      * @return the user last modified of a backup resource
271      * @throws CmsException if something goes wrong
272      */

273     public static String JavaDoc readUserNameOfBackupFile(CmsObject cms, CmsFile file) throws CmsException {
274         String JavaDoc userName;
275         try {
276             userName = cms.readUser(file.getUserLastModified()).getName();
277         } catch (CmsException e) {
278             if (file instanceof CmsBackupResource) {
279                 userName = ((CmsBackupResource)file).getLastModifiedByName();
280             } else {
281                 throw e;
282             }
283         }
284         return userName;
285     }
286     
287     /**
288      * @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart()
289      */

290     protected String JavaDoc defaultActionHtmlStart() {
291
292         return getList().listJs(getLocale()) + dialogContentStart(getParamTitle());
293     }
294
295     /**
296      * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
297      */

298     public void executeListMultiActions() throws IOException JavaDoc, ServletException JavaDoc {
299
300         if (getParamListAction().equals(LIST_MACTION_COMPARE)) {
301             CmsListItem item1 = (CmsListItem)getSelectedItems().get(0);
302             CmsListItem item2 = (CmsListItem)getSelectedItems().get(1);
303             Map JavaDoc params = new HashMap JavaDoc();
304             if (((Comparable JavaDoc)item2.get(LIST_COLUMN_VERSION)).compareTo(item1.get(LIST_COLUMN_VERSION)) > 0) {
305                 params.put(PARAM_TAGID_1, item1.getId());
306                 params.put(PARAM_TAGID_2, item2.getId());
307                 params.put(PARAM_VERSION_1, item1.get(LIST_COLUMN_VERSION));
308                 params.put(PARAM_VERSION_2, item2.get(LIST_COLUMN_VERSION));
309                 params.put(PARAM_PATH_1, item1.get(LIST_COLUMN_RESOURCE_PATH));
310                 params.put(PARAM_PATH_2, item2.get(LIST_COLUMN_RESOURCE_PATH));
311             } else {
312                 params.put(PARAM_TAGID_1, item2.getId());
313                 params.put(PARAM_TAGID_2, item1.getId());
314                 params.put(PARAM_VERSION_1, item2.get(LIST_COLUMN_VERSION));
315                 params.put(PARAM_VERSION_2, item1.get(LIST_COLUMN_VERSION));
316                 params.put(PARAM_PATH_1, item2.get(LIST_COLUMN_RESOURCE_PATH));
317                 params.put(PARAM_PATH_2, item1.get(LIST_COLUMN_RESOURCE_PATH));
318             }
319             params.put(PARAM_ACTION, DIALOG_INITIAL);
320             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
321             params.put(PARAM_RESOURCE, getParamResource());
322             getToolManager().jspForwardTool(this, "/history/comparison", params);
323         }
324         refreshList();
325     }
326     
327     /**
328      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
329      */

330     public void executeListSingleActions() throws IOException JavaDoc, ServletException JavaDoc {
331
332         if (getParamListAction().equals(LIST_ACTION_RESTORE)) {
333             try {
334                 performRestoreOperation();
335                 Map JavaDoc params = new HashMap JavaDoc();
336                 params.put(PARAM_ACTION, DIALOG_INITIAL);
337                 getToolManager().jspForwardPage(this, "/system/workplace/views/explorer/explorer_files.jsp", params);
338             } catch (CmsException e) {
339                 LOG.error(e.getMessage(), e);
340                 throw new CmsRuntimeException(e.getMessageContainer());
341             }
342         }
343         refreshList();
344     }
345
346     /**
347      * Fills details of the project into the given item. <p>
348      *
349      * @param item the list item to fill
350      *
351      * @param detailId the id for the detail to fill
352      *
353      */

354     private void fillDetailProject(CmsListItem item, String JavaDoc detailId) {
355
356         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
357
358         // search /read for the corresponding backup project: it's tag id transmitted from getListItems()
359
// in a hidden column
360
Object JavaDoc tagIdObj = item.get(LIST_COLUMN_BACKUP_TAG);
361         if (tagIdObj != null) {
362             // it is null if the offline version with changes is shown here: now backup project available then
363

364             int tagId = ((Integer JavaDoc)tagIdObj).intValue();
365             try {
366                 CmsBackupProject project = getCms().readBackupProject(tagId);
367                 // output of project info
368
html.append(project.getName()).append("<br/>").append(project.getDescription());
369             } catch (CmsException cmse) {
370                 html.append(cmse.getMessageContainer().key(this.getLocale()));
371             }
372         }
373         item.set(detailId, html.toString());
374     }
375
376     /**
377      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
378      */

379     protected void fillDetails(String JavaDoc detailId) {
380
381         // get content
382
List JavaDoc items = getList().getAllContent();
383         Iterator JavaDoc itItems = items.iterator();
384         CmsListItem item;
385         while (itItems.hasNext()) {
386             item = (CmsListItem)itItems.next();
387             if (detailId.equals(GUI_LIST_HISTORY_DETAIL_PROJECT_0)) {
388                 fillDetailProject(item, detailId);
389             }
390         }
391     }
392
393     /**
394      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
395      */

396     protected List JavaDoc getListItems() throws CmsException {
397         
398         List JavaDoc result = new ArrayList JavaDoc();
399         List JavaDoc backupFileHeaders = getCms().readAllBackupFileHeaders(getParamResource());
400         Iterator JavaDoc i = backupFileHeaders.iterator();
401         while (i.hasNext()) {
402             CmsBackupResource file = (CmsBackupResource)i.next();
403             // the tagId for the Backup project
404
int tagId = file.getTagId();
405             //String version = .toString();
406
CmsBackupProject project = getCms().readBackupProject(tagId);
407             String JavaDoc versionId = new Integer JavaDoc(project.getVersionId()).toString();
408             String JavaDoc filetype = String.valueOf(file.getTypeId());
409             String JavaDoc dateLastModified = getMessages().getDateTime(file.getDateLastModified());
410             String JavaDoc datePublished = getMessages().getDateTime(project.getPublishingDate());
411             CmsListItem item = getList().newItem(versionId);
412             //version
413
item.set(LIST_COLUMN_VERSION, new CmsVersionWrapper(new Integer JavaDoc(file.getVersionId())));
414             // filename
415
item.set(LIST_COLUMN_DATE_PUBLISHED, datePublished);
416             // nicename
417
item.set(LIST_COLUMN_DATE_LAST_MODIFIED, dateLastModified);
418             // group
419
item.set(LIST_COLUMN_FILE_TYPE, filetype);
420             // user
421
item.set(LIST_COLUMN_USER, readUserNameOfBackupFile(getCms(), file));
422             // path
423
item.set(LIST_COLUMN_RESOURCE_PATH, file.getRootPath());
424             // size
425
item.set(LIST_COLUMN_SIZE, new Integer JavaDoc(file.getLength()).toString());
426             result.add(item);
427             // invisible backup tag (for reading backup project in fillDetails)
428
item.set(LIST_COLUMN_BACKUP_TAG, new Integer JavaDoc(tagId));
429         }
430         CmsFile offlineFile = getCms().readFile(getParamResource(), CmsResourceFilter.IGNORE_EXPIRATION);
431         
432         // display offline version, if state is not unchanged
433
if (offlineFile.getState() != CmsResource.STATE_UNCHANGED) {
434             CmsListItem item = getList().newItem("-1");
435             //version
436
item.set(LIST_COLUMN_VERSION, new CmsVersionWrapper(OFFLINE_PROJECT));
437             // filename
438
item.set(LIST_COLUMN_DATE_PUBLISHED, "-");
439             // nicename
440
item.set(LIST_COLUMN_DATE_LAST_MODIFIED, getMessages().getDateTime(offlineFile.getDateLastModified()));
441             // group
442
item.set(LIST_COLUMN_FILE_TYPE, String.valueOf(offlineFile.getTypeId()));
443             // user
444
item.set(LIST_COLUMN_USER, getCms().readUser(offlineFile.getUserLastModified()).getName());
445             // size
446
item.set(LIST_COLUMN_SIZE, new Integer JavaDoc(offlineFile.getLength()).toString());
447             // path
448
item.set(LIST_COLUMN_RESOURCE_PATH, offlineFile.getRootPath());
449             result.add(item);
450         }
451         getList().getMetadata().getColumnDefinition(LIST_COLUMN_SEL1).setVisible(result.size() > 1);
452         getList().getMetadata().getColumnDefinition(LIST_COLUMN_SEL2).setVisible(result.size() > 1);
453         return result;
454     }
455
456     /**
457      * Restores a backed up resource version.<p>
458      *
459      * @throws CmsException if something goes wrong
460      */

461     protected void performRestoreOperation() throws CmsException {
462
463         int tagId = Integer.parseInt(((CmsListItem)getSelectedItems().get(0)).getId());
464         String JavaDoc resourcename = getCms().getSitePath(getCms().readResource(getParamResource()));
465         checkLock(getParamResource());
466         getCms().restoreResourceBackup(resourcename, tagId);
467     }
468     
469     /**
470      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
471      */

472     protected void setColumns(CmsListMetadata metadata) {
473         
474         CmsListColumnDefinition previewCol = new CmsListColumnDefinition(LIST_COLUMN_VIEW);
475         previewCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_VIEW_0));
476         previewCol.setWidth("20");
477         previewCol.setVisible(false);
478         previewCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
479         previewCol.setSorteable(false);
480         
481         // create column for icon
482
CmsListColumnDefinition restoreCol = new CmsListColumnDefinition(LIST_COLUMN_RESTORE);
483         restoreCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_RESTORE_0));
484         restoreCol.setWidth("20");
485         restoreCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
486         restoreCol.setListItemComparator(new CmsListItemActionIconComparator());
487         restoreCol.setSorteable(false);
488
489         // add icon action
490
CmsListDirectAction restoreAction = new CmsListDirectAction(LIST_ACTION_RESTORE) {
491             // do not show icon for offline version
492
public boolean isVisible() {
493                 return !"-1".equals(getItem().getId().toString());
494             }
495         };
496         restoreAction.setName(Messages.get().container(Messages.GUI_HISTORY_RESTORE_VERSION_0));
497         restoreAction.setIconPath("tools/ex_history/buttons/restore.png");
498         restoreAction.setConfirmationMessage(Messages.get().container(Messages.GUI_HISTORY_CONFIRMATION_0));
499         restoreAction.setEnabled(true);
500         
501         restoreCol.addDirectAction(restoreAction);
502         // add it to the list definition
503
metadata.addColumn(restoreCol);
504         
505         // create column for icon
506
CmsListColumnDefinition iconCol = new CmsListColumnDefinition(LIST_COLUMN_ICON);
507         iconCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_VIEW_0));
508         iconCol.setWidth("20");
509         iconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
510         iconCol.setListItemComparator(new CmsListItemActionIconComparator());
511
512         // add icon action
513
CmsListDirectAction fileAction = new CmsListResourceIconAction(LIST_ACTION_VIEW, LIST_COLUMN_FILE_TYPE, getCms()) {
514             public String JavaDoc defButtonHtml(CmsJspActionElement jsp, String JavaDoc id, String JavaDoc helpId, String JavaDoc name, String JavaDoc helpText,
515                 boolean enabled, String JavaDoc iconPath, String JavaDoc confirmationMessage, String JavaDoc onClick, boolean singleHelp) {
516                 StringBuffer JavaDoc jsCode = new StringBuffer JavaDoc(512);
517                 jsCode.append("window.open('");
518                 String JavaDoc versionId = getItem().getId().toString();
519                 if ("-1".equals(versionId)) {
520                     // offline version
521
jsCode.append(jsp.link(jsp.getRequestContext().removeSiteRoot(getItem().get(LIST_COLUMN_RESOURCE_PATH).toString())));
522                 } else {
523                     jsCode.append(jsp.link(getBackupLink(getItem().get(LIST_COLUMN_RESOURCE_PATH).toString(),
524                         versionId)));
525                 }
526                 jsCode.append("','version','scrollbars=yes, resizable=yes, width=800, height=600')");
527                 return super.defButtonHtml(jsp, id, helpId, name, helpText, enabled,
528                     iconPath, confirmationMessage, jsCode.toString(), singleHelp);
529             }
530         };
531         fileAction.setName(Messages.get().container(Messages.GUI_HISTORY_PREVIEW_0));
532         fileAction.setEnabled(true);
533         iconCol.addDirectAction(fileAction);
534         // add it to the list definition
535
metadata.addColumn(iconCol);
536         iconCol.setPrintable(false);
537         
538         // add column for version
539
CmsListColumnDefinition versionCol = new CmsListColumnDefinition(LIST_COLUMN_VERSION);
540         versionCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_VERSION_0));
541         versionCol.setWidth("5%");
542         versionCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
543         metadata.addColumn(versionCol);
544
545         // add column for file type
546
CmsListColumnDefinition groupCol = new CmsListColumnDefinition(LIST_COLUMN_FILE_TYPE);
547         groupCol.setVisible(false);
548         metadata.addColumn(groupCol);
549         
550         // add column for resource path
551
CmsListColumnDefinition pathCol = new CmsListColumnDefinition(LIST_COLUMN_RESOURCE_PATH);
552         pathCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_RESOURCE_PATH_0));
553         pathCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
554         pathCol.setWidth("20%");
555         metadata.addColumn(pathCol);
556         
557         // add column for date published
558
CmsListColumnDefinition datePublishedCol = new CmsListColumnDefinition(LIST_COLUMN_DATE_PUBLISHED);
559         datePublishedCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_DATE_PUBLISHED_0));
560         datePublishedCol.setWidth("20%");
561         datePublishedCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
562         metadata.addColumn(datePublishedCol);
563
564         // add column for date last modified
565
CmsListColumnDefinition nicenameCol = new CmsListColumnDefinition(LIST_COLUMN_DATE_LAST_MODIFIED);
566         nicenameCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_DATE_LAST_MODIFIED_0));
567         nicenameCol.setWidth("20%");
568         nicenameCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
569         metadata.addColumn(nicenameCol);
570         
571         // add column for user modified
572
CmsListColumnDefinition userCol = new CmsListColumnDefinition(LIST_COLUMN_USER);
573         userCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_USER_0));
574         userCol.setWidth("12%");
575         userCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
576         metadata.addColumn(userCol);
577         
578         // add column for date last modified
579
CmsListColumnDefinition sizeCol = new CmsListColumnDefinition(LIST_COLUMN_SIZE);
580         sizeCol.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_SIZE_0));
581         sizeCol.setWidth("13%");
582         sizeCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
583         metadata.addColumn(sizeCol);
584
585         // create column for radio button 1
586
CmsListColumnDefinition radioSel1Col = new CmsListColumnDefinition(LIST_COLUMN_SEL1);
587         radioSel1Col.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_VERSION1_0));
588         radioSel1Col.setWidth("20");
589         radioSel1Col.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
590         radioSel1Col.setSorteable(false);
591         // add item selection action
592
CmsListItemSelectionAction sel1Action = new CmsListItemSelectionAction(LIST_RACTION_SEL1, LIST_MACTION_COMPARE);
593         sel1Action.setName(Messages.get().container(Messages.GUI_HISTORY_FIRST_VERSION_0));
594         sel1Action.setEnabled(true);
595         radioSel1Col.addDirectAction(sel1Action);
596         metadata.addColumn(radioSel1Col);
597
598         // create column for radio button 2
599
CmsListColumnDefinition radioSel2Col = new CmsListColumnDefinition(LIST_COLUMN_SEL2);
600         radioSel2Col.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_VERSION2_0));
601         radioSel2Col.setWidth("20");
602         radioSel2Col.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
603         radioSel2Col.setSorteable(false);
604         
605         // add item selection action
606
CmsListItemSelectionAction sel2Action = new CmsListItemSelectionAction(LIST_RACTION_SEL2, LIST_MACTION_COMPARE);
607         sel2Action.setName(Messages.get().container(Messages.GUI_HISTORY_SECOND_VERSION_0));
608         sel2Action.setEnabled(true);
609         radioSel2Col.addDirectAction(sel2Action);
610         metadata.addColumn(radioSel2Col);
611
612         // create invisible backup tag column to allow fillDetails to be able to read the proper
613
// backup project
614
CmsListColumnDefinition backupTagCol = new CmsListColumnDefinition(LIST_COLUMN_BACKUP_TAG);
615         //radioSel2Col.setName(Messages.get().container(Messages.GUI_HISTORY_COLS_VERSION2_0));
616
//radioSel2Col.setWidth("20");
617
//radioSel2Col.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
618
backupTagCol.setSorteable(false);
619         backupTagCol.setVisible(false);
620         metadata.addColumn(backupTagCol);
621     }
622     
623     /**
624      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
625      */

626     protected void setIndependentActions(CmsListMetadata metadata) {
627         // add index source details
628
CmsListItemDetails indexDetails = new CmsListItemDetails(GUI_LIST_HISTORY_DETAIL_PROJECT_0);
629         indexDetails.setAtColumn(LIST_COLUMN_VERSION);
630         indexDetails.setVisible(false);
631         indexDetails.setShowActionName(Messages.get().container(Messages.GUI_LIST_HISTORY_DETAIL_PROJECT_NAME_SHOW_0));
632         indexDetails.setShowActionHelpText(Messages.get().container(
633             Messages.GUI_LIST_HISTORY_DETAIL_PROJECT_SHOW_HELP_0));
634         indexDetails.setHideActionName(Messages.get().container(Messages.GUI_LIST_HISTORY_DETAIL_PROJECT_NAME_HIDE_0));
635         indexDetails.setHideActionHelpText(Messages.get().container(
636             Messages.GUI_LIST_HISTORY_DETAIL_PROJECT_HIDE_HELP_0));
637         indexDetails.setName(Messages.get().container(Messages.GUI_LIST_HISTORY_DETAIL_PROJECT_INFO_0));
638         indexDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
639             Messages.GUI_LIST_HISTORY_DETAIL_PROJECT_INFO_0)));
640         metadata.addItemDetails(indexDetails);
641     }
642
643     /**
644      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
645      */

646     protected void setMultiActions(CmsListMetadata metadata) {
647
648         // add compare action
649
CmsListRadioMultiAction compareAction = new CmsListRadioMultiAction(
650             LIST_MACTION_COMPARE,
651             Arrays.asList(new String JavaDoc[] {LIST_RACTION_SEL1, LIST_RACTION_SEL2}));
652         compareAction.setName(Messages.get().container(Messages.GUI_HISTORY_COMPARE_0));
653         compareAction.setIconPath("tools/ex_history/buttons/compare.png");
654         metadata.addMultiAction(compareAction);
655     }
656 }
Popular Tags