001: /*
002: * TaskTableActions.java
003: *
004: * Created on May 18, 2005, 10:52 AM
005: *
006: * To change this template, choose Tools | Options and locate the template under
007: * the Source Creation and Management node. Right-click the template and choose
008: * Open. You can then make changes to the template in the Source Editor.
009: */
010:
011: package com.sun.portal.app.sharedtasks.faces.beans;
012:
013: import com.sun.web.ui.component.Checkbox;
014: import com.sun.web.ui.model.Option;
015:
016: import com.sun.portal.app.sharedtasks.util.SharedConstants;
017: import com.sun.portal.app.sharedtasks.util.SharedTaskException;
018: import com.sun.portal.app.sharedtasks.faces.models.TaskModel;
019:
020: import java.util.ArrayList;
021: import java.util.ResourceBundle;
022:
023: import com.sun.portal.log.common.PortalLogger;
024: import java.util.logging.Logger;
025: import java.util.logging.Level;
026:
027: /**
028: * This class provides functionality for table actions.
029: */
030: public class TaskTableActions {
031:
032: private TaskUserSessionBackingBean userSession;
033: private TaskTableContainer parent;
034:
035: private static Logger logger = PortalLogger
036: .getLogger(TaskTableActions.class);
037:
038: /** Default constructor. */
039: public TaskTableActions(TaskUserSessionBackingBean userSession,
040: TaskTableContainer parent) {
041: this .userSession = userSession;
042: this .parent = parent;
043: }
044:
045: // Action button methods
046:
047: /** Action 1 event. */
048: public void deleteTaskAction() {
049: parent.setRefreshData();
050:
051: ArrayList selected = Checkbox.getSelected("selectGroup");
052:
053: for (int i = 0; i < selected.size(); i++) {
054: String idrid = (String) selected.get(i);
055: int separatorIndex = idrid
056: .indexOf(SharedConstants.ID_RID_SEPARATOR);
057:
058: String taskId = idrid.substring(0, separatorIndex);
059: String taskRid = idrid.substring(separatorIndex + 1);
060:
061: TaskModel model = new TaskModel(userSession);
062:
063: model.getTask().setId(taskId);
064:
065: if (taskRid != null && !taskRid.equals("null")) {
066: model.getTask().setRid(taskRid);
067: }
068:
069: try {
070: model.delete();
071: this .userSession.deleteTaskFromSearchDatabase(model);
072: } catch (SharedTaskException e) {
073: logger.log(Level.SEVERE, "Error deleting task id ["
074: + taskId + "], rid [" + taskRid + "]", e);
075: parent.getParent().setException(e);
076: }
077: }
078: }
079:
080: /** Get action menu options. */
081: public Option[] getActionOptions() {
082: ResourceBundle bundle = userSession.getResourceBundle();
083:
084: Option[] actionOptions = {
085: new Option(SharedConstants.VIEW_CTX_DAY, bundle
086: .getString(SharedConstants.KEY_ACTION_DAYVIEW)),
087: new Option(SharedConstants.VIEW_CTX_WEEK, bundle
088: .getString(SharedConstants.KEY_ACTION_WEEKVIEW)),
089: new Option(
090: SharedConstants.VIEW_CTX_MONTH,
091: bundle
092: .getString(SharedConstants.KEY_ACTION_MONTHVIEW)) };
093:
094: return actionOptions;
095: }
096:
097: /** Set disabled value for table actions. */
098: public boolean getDisabled() {
099: // If there is at least one checkbox selection, actions are enabled.
100: return (Checkbox.getSelected("selectGroup") == null);
101: }
102:
103: public void switchViewContext() {
104: parent.setRefreshData();
105: }
106:
107: }
|