KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > scheduler > CmsSchedulerList


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/scheduler/CmsSchedulerList.java,v $
3  * Date : $Date: 2006/03/27 14:52:59 $
4  * Version: $Revision: 1.27 $
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.tools.scheduler;
33
34 import org.opencms.configuration.CmsSystemConfiguration;
35 import org.opencms.i18n.CmsMessageContainer;
36 import org.opencms.jsp.CmsJspActionElement;
37 import org.opencms.main.CmsException;
38 import org.opencms.main.CmsRuntimeException;
39 import org.opencms.main.OpenCms;
40 import org.opencms.scheduler.CmsScheduledJobInfo;
41 import org.opencms.security.CmsRoleViolationException;
42 import org.opencms.workplace.CmsDialog;
43 import org.opencms.workplace.list.A_CmsListDialog;
44 import org.opencms.workplace.list.CmsListColumnAlignEnum;
45 import org.opencms.workplace.list.CmsListColumnDefinition;
46 import org.opencms.workplace.list.CmsListDateMacroFormatter;
47 import org.opencms.workplace.list.CmsListDefaultAction;
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.CmsListItemDefaultComparator;
52 import org.opencms.workplace.list.CmsListItemDetails;
53 import org.opencms.workplace.list.CmsListItemDetailsFormatter;
54 import org.opencms.workplace.list.CmsListMetadata;
55 import org.opencms.workplace.list.CmsListMultiAction;
56 import org.opencms.workplace.list.CmsListOrderEnum;
57
58 import java.io.IOException JavaDoc;
59 import java.util.ArrayList JavaDoc;
60 import java.util.HashMap JavaDoc;
61 import java.util.Iterator JavaDoc;
62 import java.util.List JavaDoc;
63 import java.util.Map JavaDoc;
64
65 import javax.servlet.ServletException JavaDoc;
66 import javax.servlet.http.HttpServletRequest JavaDoc;
67 import javax.servlet.http.HttpServletResponse JavaDoc;
68 import javax.servlet.jsp.PageContext JavaDoc;
69
70 /**
71  * Main scheduled jobs management list view.<p>
72  *
73  * Defines the list columns and possible actions for scheduled jobs.<p>
74  *
75  * @author Michael Moossen
76  * @author Andreas Zahner
77  *
78  * @version $Revision: 1.27 $
79  *
80  * @since 6.0.0
81  */

82 public class CmsSchedulerList extends A_CmsListDialog {
83
84     /** List action activate. */
85     public static final String JavaDoc LIST_ACTION_ACTIVATE = "aa";
86
87     /** List action copy. */
88     public static final String JavaDoc LIST_ACTION_COPY = "ac";
89
90     /** List action deactivate. */
91     public static final String JavaDoc LIST_ACTION_DEACTIVATE = "at";
92
93     /** List action delete. */
94     public static final String JavaDoc LIST_ACTION_DELETE = "ad";
95
96     /** List action edit. */
97     public static final String JavaDoc LIST_ACTION_EDIT = "ae";
98
99     /** List column activate. */
100     public static final String JavaDoc LIST_COLUMN_ACTIVATE = "ca";
101
102     /** List column class. */
103     public static final String JavaDoc LIST_COLUMN_CLASS = "cs";
104
105     /** List column copy. */
106     public static final String JavaDoc LIST_COLUMN_COPY = "cc";
107
108     /** List column delete. */
109     public static final String JavaDoc LIST_COLUMN_DELETE = "cd";
110
111     /** List column edit. */
112     public static final String JavaDoc LIST_COLUMN_EDIT = "ce";
113
114     /** List column last execution. */
115     public static final String JavaDoc LIST_COLUMN_LASTEXE = "cl";
116
117     /** List column name. */
118     public static final String JavaDoc LIST_COLUMN_NAME = "cn";
119
120     /** List column next execution. */
121     public static final String JavaDoc LIST_COLUMN_NEXTEXE = "cx";
122
123     /** List action edit. */
124     public static final String JavaDoc LIST_DEFACTION_EDIT = "de";
125
126     /** List detail context info. */
127     public static final String JavaDoc LIST_DETAIL_CONTEXTINFO = "dc";
128
129     /** List detail parameter. */
130     public static final String JavaDoc LIST_DETAIL_PARAMETER = "dp";
131
132     /** List ID. */
133     public static final String JavaDoc LIST_ID = "lj";
134
135     /** List action multi activate. */
136     public static final String JavaDoc LIST_MACTION_ACTIVATE = "ma";
137
138     /** List action multi deactivate. */
139     public static final String JavaDoc LIST_MACTION_DEACTIVATE = "mc";
140
141     /** List action multi delete. */
142     public static final String JavaDoc LIST_MACTION_DELETE = "md";
143
144     /** Path to the list buttons. */
145     public static final String JavaDoc PATH_BUTTONS = "tools/scheduler/buttons/";
146
147     /**
148      * Public constructor.<p>
149      *
150      * @param jsp an initialized JSP action element
151      */

152     public CmsSchedulerList(CmsJspActionElement jsp) {
153
154         super(
155             jsp,
156             LIST_ID,
157             new CmsMessageContainer(Messages.get(), Messages.GUI_JOBS_LIST_NAME_0),
158             LIST_COLUMN_NAME,
159             CmsListOrderEnum.ORDER_ASCENDING,
160             LIST_COLUMN_NAME);
161     }
162
163     /**
164      * Public constructor with JSP variables.<p>
165      *
166      * @param context the JSP page context
167      * @param req the JSP request
168      * @param res the JSP response
169      */

170     public CmsSchedulerList(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
171
172         this(new CmsJspActionElement(context, req, res));
173     }
174
175     /**
176      * This method should handle every defined list multi action,
177      * by comparing <code>{@link #getParamListAction()}</code> with the id
178      * of the action to execute.<p>
179      *
180      * @throws CmsRuntimeException to signal that an action is not supported
181      *
182      */

183     public void executeListMultiActions() throws CmsRuntimeException {
184
185         CmsListItem listItem = null;
186         if (getParamListAction().equals(LIST_MACTION_DELETE)) {
187             // execute the delete multiaction
188
List JavaDoc removedItems = new ArrayList JavaDoc();
189             try {
190                 Iterator JavaDoc itItems = getSelectedItems().iterator();
191                 while (itItems.hasNext()) {
192                     listItem = (CmsListItem)itItems.next();
193                     OpenCms.getScheduleManager().unscheduleJob(getCms(), listItem.getId());
194                     removedItems.add(listItem.getId());
195                 }
196                 // update the XML configuration
197
writeConfiguration(false);
198             } catch (CmsException e) {
199                 throw new CmsRuntimeException(Messages.get().container(
200                     Messages.ERR_UNSCHEDULE_JOB_1,
201                     (listItem == null) ? (Object JavaDoc)"?" : new Integer JavaDoc(listItem.getId())), e);
202             } finally {
203                 getList().removeAllItems(removedItems, getLocale());
204             }
205         } else if (getParamListAction().equals(LIST_MACTION_ACTIVATE)
206             || getParamListAction().equals(LIST_MACTION_DEACTIVATE)) {
207             // execute the activate or deactivate multiaction
208
try {
209                 Iterator JavaDoc itItems = getSelectedItems().iterator();
210                 boolean activate = getParamListAction().equals(LIST_MACTION_ACTIVATE);
211                 while (itItems.hasNext()) {
212                     // toggle the active state of the selected item(s)
213
listItem = (CmsListItem)itItems.next();
214                     CmsScheduledJobInfo job = (CmsScheduledJobInfo)OpenCms.getScheduleManager().getJob(listItem.getId()).clone();
215                     job.setActive(activate);
216                     OpenCms.getScheduleManager().scheduleJob(getCms(), job);
217                 }
218                 // update the XML configuration
219
writeConfiguration(true);
220             } catch (CmsException e) {
221                 throw new CmsRuntimeException(Messages.get().container(
222                     Messages.ERR_SCHEDULE_JOB_1,
223                     (listItem == null) ? (Object JavaDoc)"?" : new Integer JavaDoc(listItem.getId())), e);
224             }
225         } else {
226             throwListUnsupportedActionException();
227         }
228         listSave();
229     }
230
231     /**
232      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
233      */

234     public void executeListSingleActions() throws IOException JavaDoc, ServletException JavaDoc {
235
236         if (getParamListAction().equals(LIST_ACTION_EDIT) || getParamListAction().equals(LIST_DEFACTION_EDIT)) {
237             // edit a job from the list
238
String JavaDoc jobId = getSelectedItem().getId();
239             // forward to the edit job screen with additional parameters
240
Map JavaDoc params = new HashMap JavaDoc();
241             params.put(CmsEditScheduledJobInfoDialog.PARAM_JOBID, jobId);
242             // set action parameter to initial dialog call
243
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
244             getToolManager().jspForwardTool(this, "/scheduler/edit", params);
245         } else if (getParamListAction().equals(LIST_ACTION_COPY)) {
246             // copy a job from the list
247
String JavaDoc jobId = getSelectedItem().getId();
248             // forward to the edit job screen with additional parameters
249
Map JavaDoc params = new HashMap JavaDoc();
250             params.put(CmsEditScheduledJobInfoDialog.PARAM_JOBID, jobId);
251             // set action parameter to copy job action
252
params.put(CmsDialog.PARAM_ACTION, CmsEditScheduledJobInfoDialog.DIALOG_COPYJOB);
253             getToolManager().jspForwardTool(this, "/scheduler/new", params);
254         } else if (getParamListAction().equals(LIST_ACTION_ACTIVATE)) {
255             // activate a job from the list
256
String JavaDoc jobId = getSelectedItem().getId();
257             CmsScheduledJobInfo job = (CmsScheduledJobInfo)OpenCms.getScheduleManager().getJob(jobId).clone();
258             job.setActive(true);
259             try {
260                 OpenCms.getScheduleManager().scheduleJob(getCms(), job);
261                 // update the XML configuration
262
writeConfiguration(true);
263             } catch (CmsException e) {
264                 // should never happen
265
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_SCHEDULE_JOB_1, jobId), e);
266             }
267         } else if (getParamListAction().equals(LIST_ACTION_DEACTIVATE)) {
268             // deactivate a job from the list
269
String JavaDoc jobId = getSelectedItem().getId();
270             CmsScheduledJobInfo job = (CmsScheduledJobInfo)OpenCms.getScheduleManager().getJob(jobId).clone();
271             job.setActive(false);
272             try {
273                 OpenCms.getScheduleManager().scheduleJob(getCms(), job);
274                 // update the XML configuration
275
writeConfiguration(true);
276             } catch (CmsException e) {
277                 // should never happen
278
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNSCHEDULE_JOB_1, jobId), e);
279             }
280         } else if (getParamListAction().equals(LIST_ACTION_DELETE)) {
281             // delete a job from the list
282
String JavaDoc jobId = getSelectedItem().getId();
283             try {
284                 OpenCms.getScheduleManager().unscheduleJob(getCms(), jobId);
285                 // update the XML configuration
286
writeConfiguration(false);
287                 getList().removeItem(jobId, getLocale());
288             } catch (CmsRoleViolationException e) {
289                 // should never happen
290
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_JOB_1, jobId), e);
291             }
292         } else {
293             throwListUnsupportedActionException();
294         }
295         listSave();
296     }
297
298     /**
299      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
300      */

301     protected void fillDetails(String JavaDoc detailId) {
302
303         // get all scheduled jobs from manager
304
Iterator JavaDoc i = getList().getAllContent().iterator();
305         while (i.hasNext()) {
306             CmsListItem item = (CmsListItem)i.next();
307             CmsScheduledJobInfo job = OpenCms.getScheduleManager().getJob(item.getId());
308             if (detailId.equals(LIST_DETAIL_CONTEXTINFO)) {
309                 // job details: context info
310
item.set(LIST_DETAIL_CONTEXTINFO, job.getContextInfo());
311             } else if (detailId.equals(LIST_DETAIL_PARAMETER)) {
312                 // job details: parameter
313
StringBuffer JavaDoc params = new StringBuffer JavaDoc(32);
314                 Iterator JavaDoc paramIt = job.getParameters().keySet().iterator();
315                 while (paramIt.hasNext()) {
316                     String JavaDoc param = (String JavaDoc)paramIt.next();
317                     String JavaDoc value = (String JavaDoc)job.getParameters().get(param);
318                     params.append(param).append("=");
319                     params.append(value).append("<br>");
320                 }
321                 item.set(LIST_DETAIL_PARAMETER, params);
322             } else {
323                 continue;
324             }
325         }
326     }
327
328     /**
329      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
330      */

331     protected List JavaDoc getListItems() {
332
333         List JavaDoc items = new ArrayList JavaDoc();
334
335         // get all scheduled jobs from manager
336
Iterator JavaDoc i = OpenCms.getScheduleManager().getJobs().iterator();
337         while (i.hasNext()) {
338             CmsScheduledJobInfo job = (CmsScheduledJobInfo)i.next();
339             CmsListItem item = getList().newItem(job.getId().toString());
340             // set the contents of the columns
341
item.set(LIST_COLUMN_NAME, job.getJobName());
342             item.set(LIST_COLUMN_CLASS, job.getClassName());
343             item.set(LIST_COLUMN_LASTEXE, job.getExecutionTimePrevious());
344             item.set(LIST_COLUMN_NEXTEXE, job.getExecutionTimeNext());
345             items.add(item);
346         }
347
348         return items;
349     }
350
351     /**
352      * @see org.opencms.workplace.CmsWorkplace#initMessages()
353      */

354     protected void initMessages() {
355
356         // add specific messages
357
addMessages(Messages.get().getBundleName());
358         // add default messages
359
super.initMessages();
360     }
361
362     /**
363      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
364      */

365     protected void setColumns(CmsListMetadata metadata) {
366
367         // add column for edit action
368
CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
369         editCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_EDIT_0));
370         editCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_EDIT_HELP_0));
371         editCol.setWidth("20");
372         editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
373         editCol.setSorteable(false);
374         // create default edit action for edit column: edit job
375
CmsListDirectAction editColAction = new CmsListDirectAction(LIST_ACTION_EDIT);
376         editColAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_NAME_0));
377         editColAction.setIconPath(PATH_BUTTONS + "edit.png");
378         editColAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_HELP_0));
379         editColAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_CONF_0));
380         // set action for the edit column
381
editCol.addDirectAction(editColAction);
382         metadata.addColumn(editCol);
383
384         // add column for activate/deactivate action
385
CmsListColumnDefinition activateCol = new CmsListColumnDefinition(LIST_COLUMN_ACTIVATE);
386         activateCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_ACTIVE_0));
387         activateCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_ACTIVE_HELP_0));
388         activateCol.setWidth("20");
389         activateCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
390         activateCol.setListItemComparator(new CmsListItemActionIconComparator());
391
392         // direct action: activate job
393
CmsListDirectAction jobActAction = new CmsListDirectAction(LIST_ACTION_ACTIVATE) {
394
395             /**
396              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
397              */

398             public boolean isVisible() {
399
400                 if (getItem() != null) {
401                     String JavaDoc jobId = getItem().getId();
402                     CmsScheduledJobInfo job = OpenCms.getScheduleManager().getJob(jobId);
403                     return !job.isActive();
404                 }
405                 return super.isVisible();
406             }
407         };
408         jobActAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_ACTIVATE_NAME_0));
409         jobActAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_ACTIVATE_CONF_0));
410         jobActAction.setIconPath(ICON_INACTIVE);
411         jobActAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_ACTIVATE_HELP_0));
412         activateCol.addDirectAction(jobActAction);
413
414         // direct action: deactivate job
415
CmsListDirectAction jobDeactAction = new CmsListDirectAction(LIST_ACTION_DEACTIVATE) {
416
417             /**
418              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
419              */

420             public boolean isVisible() {
421
422                 if (getItem() != null) {
423                     String JavaDoc jobId = getItem().getId();
424                     CmsScheduledJobInfo job = OpenCms.getScheduleManager().getJob(jobId);
425                     return job.isActive();
426                 }
427                 return super.isVisible();
428             }
429         };
430         jobDeactAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DEACTIVATE_NAME_0));
431         jobDeactAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DEACTIVATE_CONF_0));
432         jobDeactAction.setIconPath(ICON_ACTIVE);
433         jobDeactAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DEACTIVATE_HELP_0));
434         activateCol.addDirectAction(jobDeactAction);
435
436         metadata.addColumn(activateCol);
437
438         // add column for copy action
439
CmsListColumnDefinition copyCol = new CmsListColumnDefinition(LIST_COLUMN_COPY);
440         copyCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_COPY_0));
441         copyCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_COPY_HELP_0));
442         copyCol.setWidth("20");
443         copyCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
444         copyCol.setListItemComparator(null);
445         // direct action: copy job
446
CmsListDirectAction copyJob = new CmsListDirectAction(LIST_ACTION_COPY);
447         copyJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_COPY_NAME_0));
448         copyJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_COPY_CONF_0));
449         copyJob.setIconPath(PATH_BUTTONS + "copy.png");
450         copyJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_COPY_HELP_0));
451         copyCol.addDirectAction(copyJob);
452         metadata.addColumn(copyCol);
453
454         // add column for delete action
455
CmsListColumnDefinition delCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
456         delCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_DELETE_0));
457         delCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_DELETE_HELP_0));
458         delCol.setWidth("20");
459         delCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
460         delCol.setListItemComparator(null);
461         // direct action: delete job
462
CmsListDirectAction delJob = new CmsListDirectAction(LIST_ACTION_DELETE);
463         delJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DELETE_NAME_0));
464         delJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DELETE_CONF_0));
465         delJob.setIconPath(ICON_DELETE);
466         delJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DELETE_HELP_0));
467         delCol.addDirectAction(delJob);
468         metadata.addColumn(delCol);
469
470         // add column for name
471
CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
472         nameCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_NAME_0));
473         nameCol.setWidth("30%");
474         nameCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
475         nameCol.setListItemComparator(new CmsListItemDefaultComparator());
476         // create default edit action for name column: edit job
477
CmsListDefaultAction nameColAction = new CmsListDefaultAction(LIST_DEFACTION_EDIT);
478         nameColAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_NAME_0));
479         nameColAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_HELP_0));
480         nameColAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_CONF_0));
481         // set action for the name column
482
nameCol.addDefaultAction(nameColAction);
483         metadata.addColumn(nameCol);
484
485         // add column for class
486
CmsListColumnDefinition classCol = new CmsListColumnDefinition(LIST_COLUMN_CLASS);
487         classCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_CLASS_0));
488         classCol.setWidth("20%");
489         classCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
490         classCol.setListItemComparator(new CmsListItemDefaultComparator());
491         metadata.addColumn(classCol);
492
493         // add column for last execution time
494
CmsListColumnDefinition lastExecCol = new CmsListColumnDefinition(LIST_COLUMN_LASTEXE);
495         lastExecCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_LASTEXE_0));
496         lastExecCol.setWidth("25%");
497         lastExecCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
498         lastExecCol.setListItemComparator(new CmsListItemDefaultComparator());
499         // create date formatter for last execution time
500
lastExecCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
501         metadata.addColumn(lastExecCol);
502
503         // add column for next execution time
504
CmsListColumnDefinition nextExecCol = new CmsListColumnDefinition(LIST_COLUMN_NEXTEXE);
505         nextExecCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_NEXTEXE_0));
506         nextExecCol.setWidth("25%");
507         nextExecCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
508         nextExecCol.setListItemComparator(new CmsListItemDefaultComparator());
509         // create date formatter for next execution time
510
nextExecCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
511         metadata.addColumn(nextExecCol);
512     }
513
514     /**
515      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
516      */

517     protected void setIndependentActions(CmsListMetadata metadata) {
518
519         // add independent job context info button
520
CmsListItemDetails jobsContextInfoDetails = new CmsListItemDetails(LIST_DETAIL_CONTEXTINFO);
521         jobsContextInfoDetails.setAtColumn(LIST_COLUMN_NAME);
522         jobsContextInfoDetails.setVisible(false);
523         jobsContextInfoDetails.setShowActionName(Messages.get().container(
524             Messages.GUI_JOBS_DETAIL_SHOW_CONTEXTINFO_NAME_0));
525         jobsContextInfoDetails.setShowActionHelpText(Messages.get().container(
526             Messages.GUI_JOBS_DETAIL_SHOW_CONTEXTINFO_HELP_0));
527         jobsContextInfoDetails.setHideActionName(Messages.get().container(
528             Messages.GUI_JOBS_DETAIL_HIDE_CONTEXTINFO_NAME_0));
529         jobsContextInfoDetails.setHideActionHelpText(Messages.get().container(
530             Messages.GUI_JOBS_DETAIL_HIDE_CONTEXTINFO_HELP_0));
531         // create formatter to display context info
532
CmsContextInfoDetailsFormatter contextFormatter = new CmsContextInfoDetailsFormatter();
533         contextFormatter.setUserMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_USER_0));
534         contextFormatter.setProjectMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_PROJECT_0));
535         contextFormatter.setLocaleMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_LOCALE_0));
536         contextFormatter.setRootSiteMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_ROOTSITE_0));
537         contextFormatter.setEncodingMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_ENCODING_0));
538         contextFormatter.setRemoteAddrMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_REMADR_0));
539         contextFormatter.setRequestedURIMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_REQURI_0));
540         jobsContextInfoDetails.setFormatter(contextFormatter);
541         // add context info item detail to meta data
542
metadata.addItemDetails(jobsContextInfoDetails);
543
544         // add independent job parameter button
545
CmsListItemDetails jobsParameterDetails = new CmsListItemDetails(LIST_DETAIL_PARAMETER);
546         jobsParameterDetails.setAtColumn(LIST_COLUMN_NAME);
547         jobsParameterDetails.setVisible(false);
548         jobsParameterDetails.setShowActionName(Messages.get().container(Messages.GUI_JOBS_DETAIL_SHOW_PARAMETER_NAME_0));
549         jobsParameterDetails.setShowActionHelpText(Messages.get().container(
550             Messages.GUI_JOBS_DETAIL_SHOW_PARAMETER_HELP_0));
551         jobsParameterDetails.setHideActionName(Messages.get().container(Messages.GUI_JOBS_DETAIL_HIDE_PARAMETER_NAME_0));
552         jobsParameterDetails.setHideActionHelpText(Messages.get().container(
553             Messages.GUI_JOBS_DETAIL_HIDE_PARAMETER_HELP_0));
554         // create formatter to display parameters
555
jobsParameterDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
556             Messages.GUI_JOBS_DETAIL_PARAMETER_FORMAT_0)));
557         // add parameter item to metadata
558
metadata.addItemDetails(jobsParameterDetails);
559     }
560
561     /**
562      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
563      */

564     protected void setMultiActions(CmsListMetadata metadata) {
565
566         // add the activate job multi action
567
CmsListMultiAction activateJob = new CmsListMultiAction(LIST_MACTION_ACTIVATE);
568         activateJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MACTIVATE_NAME_0));
569         activateJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MACTIVATE_CONF_0));
570         activateJob.setIconPath(ICON_MULTI_ACTIVATE);
571         activateJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MACTIVATE_HELP_0));
572         metadata.addMultiAction(activateJob);
573
574         // add the deactivate job multi action
575
CmsListMultiAction deactivateJob = new CmsListMultiAction(LIST_MACTION_DEACTIVATE);
576         deactivateJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDEACTIVATE_NAME_0));
577         deactivateJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDEACTIVATE_CONF_0));
578         deactivateJob.setIconPath(ICON_MULTI_DEACTIVATE);
579         deactivateJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDEACTIVATE_HELP_0));
580         metadata.addMultiAction(deactivateJob);
581
582         // add the delete job multi action
583
CmsListMultiAction deleteJobs = new CmsListMultiAction(LIST_MACTION_DELETE);
584         deleteJobs.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDELETE_NAME_0));
585         deleteJobs.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDELETE_CONF_0));
586         deleteJobs.setIconPath(ICON_MULTI_DELETE);
587         deleteJobs.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDELETE_HELP_0));
588         metadata.addMultiAction(deleteJobs);
589     }
590
591     /**
592      * Writes the updated scheduled job info back to the XML configuration file and refreshes the complete list.<p>
593      *
594      * @param refresh if true, the list items are refreshed
595      */

596     protected void writeConfiguration(boolean refresh) {
597
598         // update the XML configuration
599
OpenCms.writeConfiguration(CmsSystemConfiguration.class);
600         if (refresh) {
601             refreshList();
602         }
603     }
604 }
Popular Tags