Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 47037 Details for
Bug 145884
creating command handlers to manipulate tasks list elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
latest patch
commandspatch.txt (text/plain), 37.33 KB, created by
Izzet Safer
on 2006-07-30 19:50:36 EDT
(
hide
)
Description:
latest patch
Filename:
MIME Type:
Creator:
Izzet Safer
Created:
2006-07-30 19:50:36 EDT
Size:
37.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.tasks.core >Index: src/org/eclipse/mylar/tasks/core/TaskList.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.core/src/org/eclipse/mylar/tasks/core/TaskList.java,v >retrieving revision 1.2 >diff -u -r1.2 TaskList.java >--- src/org/eclipse/mylar/tasks/core/TaskList.java 27 Jul 2006 19:39:50 -0000 1.2 >+++ src/org/eclipse/mylar/tasks/core/TaskList.java 30 Jul 2006 23:43:01 -0000 >@@ -422,8 +422,43 @@ > } > > public ITask getTask(String handleIdentifier) { >- return tasks.get(handleIdentifier); >+ return tasks.get(handleIdentifier); > } >+ >+ //IZZET >+ /** Acts as getTask for regular tasks. If the task with >+ * given handle is not found, then look for subTasks >+ */ >+ public ITask findTask(String handleIdentifier) { >+ ITask task = getTask(handleIdentifier); >+ if (task != null) return task; >+ >+ foundTask = null; >+ findSubtask(getAllTasks(), handleIdentifier); >+ return foundTask; >+ } >+ >+ //this shouldn't be used other than findTask and findSubtask >+ private ITask foundTask = null; >+ >+ /** Temporary solution to find a subtask. Looks for infinite depth. >+ * If the taskHandle matches a task rather than a subTask, >+ * that's a valid match too >+ * >+ * @param tasks Collection of tasks to be looked for their children >+ * @param taskHandle >+ */ >+ private void findSubtask(Collection<ITask> tasks, String taskHandle) { >+ for (ITask t : tasks) { >+ if (foundTask != null) return; >+ if (t.getHandleIdentifier().equals(taskHandle)) { >+ foundTask = t; >+ continue; >+ } >+ else findSubtask(t.getChildren(), taskHandle); >+ } >+ } >+ //IZZET > > public AbstractTaskContainer getContainerForHandle(String categoryHandle) { > for (AbstractTaskContainer cat : categories) { >@@ -547,4 +582,4 @@ > } > } > } >-} >+} >\ No newline at end of file >#P org.eclipse.mylar.tasks.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/plugin.xml,v >retrieving revision 1.144 >diff -u -r1.144 plugin.xml >--- plugin.xml 30 Jul 2006 02:04:53 -0000 1.144 >+++ plugin.xml 30 Jul 2006 23:43:02 -0000 >@@ -473,7 +473,132 @@ > type="task"/> > </extension>--> > >+ <extension point="org.eclipse.ui.handlers"> >+ <handler >+ commandId="org.eclipse.mylar.tasklist.commands.addNewLocalTask" >+ class="org.eclipse.mylar.internal.tasks.ui.commands.NewLocalTaskHandler"> >+ </handler> >+ >+ <handler >+ commandId="org.eclipse.mylar.tasklist.commands.addNewLocalSubTask" >+ class="org.eclipse.mylar.internal.tasks.ui.commands.NewLocalSubTaskHandler"> >+ </handler> >+ >+ <handler >+ commandId="org.eclipse.mylar.tasklist.commands.activateTask" >+ class="org.eclipse.mylar.internal.tasks.ui.commands.TaskActivateHandler"> >+ </handler> >+ >+ <handler >+ commandId="org.eclipse.mylar.tasklist.commands.deactivateTask" >+ class="org.eclipse.mylar.internal.tasks.ui.commands.TaskDeactivateHandler"> >+ </handler> >+ >+ <handler >+ commandId="org.eclipse.mylar.tasklist.commands.completeTask" >+ class="org.eclipse.mylar.internal.tasks.ui.commands.MarkTaskCompleteHandler"> >+ </handler> >+ >+ <handler >+ commandId="org.eclipse.mylar.tasklist.commands.incompleteTask" >+ class="org.eclipse.mylar.internal.tasks.ui.commands.MarkTaskIncompleteHandler"> >+ </handler> >+ </extension> > >+ <extension point="org.eclipse.ui.commands"> >+ <command >+ description="Add new Mylar Task" >+ id="org.eclipse.mylar.tasklist.commands.addNewLocalTask" >+ name="Add new Mylar Task"> >+ <commandParameter >+ id="taskName" >+ name="Task Name" >+ optional="false"/> >+ <commandParameter >+ id="taskHandle" >+ name="Unique Task Handle" >+ optional="true"/> >+ <commandParameter >+ id="categoryName" >+ name="Category Name" >+ optional="true"/> >+ <commandParameter >+ id="activateTask" >+ name="Boolean parameter to activate the task" >+ optional="true"/> >+ <commandParameter >+ id="resetContext" >+ name="Boolean parameter to delete the context of the existing task" >+ optional="true"/> >+ </command> >+ >+ <command >+ description="Add new Mylar Subtask" >+ id="org.eclipse.mylar.tasklist.commands.addNewLocalSubTask" >+ name="Add new Mylar Subtask"> >+ <commandParameter >+ id="taskName" >+ name="Subtask Name" >+ optional="false"/> >+ <commandParameter >+ id="taskHandle" >+ name="Unique Task Handle" >+ optional="true"/> >+ <commandParameter >+ id="parentHandle" >+ name="Handle to parent task" >+ optional="false"/> >+ <commandParameter >+ id="activateTask" >+ name="Boolean parameter to activate the subtask" >+ optional="true"/> >+ <commandParameter >+ id="resetContext" >+ name="Boolean parameter to delete the context of the existing subtask" >+ optional="true"/> >+ </command> >+ >+ <command >+ description="Activate a Mylar task" >+ id="org.eclipse.mylar.tasklist.commands.activateTask" >+ name="Activate a Mylar task"> >+ <commandParameter >+ id="taskHandle" >+ name="Unique Task Handle" >+ optional="false"/> >+ </command> >+ >+ <command >+ description="Deactivate a Mylar task" >+ id="org.eclipse.mylar.tasklist.commands.deactivateTask" >+ name="Deactivate a Mylar task"> >+ <commandParameter >+ id="taskHandle" >+ name="Unique Task Handle" >+ optional="false"/> >+ </command> >+ >+ <command >+ description="Mark Complete a Mylar task" >+ id="org.eclipse.mylar.tasklist.commands.completeTask" >+ name="Complete a Mylar task"> >+ <commandParameter >+ id="taskHandle" >+ name="Unique Task Handle" >+ optional="false"/> >+ </command> >+ >+ <command >+ description="Mark Incomplete a Mylar task" >+ id="org.eclipse.mylar.tasklist.commands.incompleteTask" >+ name="Incomplete a Mylar task"> >+ <commandParameter >+ id="taskHandle" >+ name="Unique Task Handle" >+ optional="false"/> >+ </command> >+ </extension> >+ > </plugin> > > >@@ -486,4 +611,4 @@ > class="org.eclipse.mylar.tasklist.ui.actions.GoIntoAction" > icon="icons/etool16/go-into.gif" > enablesFor="1"/> >---> >+--> >\ No newline at end of file >Index: src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskIncompleteAction.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskIncompleteAction.java,v >retrieving revision 1.1 >diff -u -r1.1 MarkTaskIncompleteAction.java >--- src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskIncompleteAction.java 14 Jul 2006 15:39:08 -0000 1.1 >+++ src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskIncompleteAction.java 30 Jul 2006 23:43:02 -0000 >@@ -19,7 +19,7 @@ > import org.eclipse.mylar.tasks.ui.TasksUiPlugin; > > /** >- * @author Mik Kersten and Ken Sueda >+ * @author Mik Kersten, Ken Sueda and Izzet Safer > */ > public class MarkTaskIncompleteAction extends Action { > >@@ -27,6 +27,10 @@ > > private final TaskListView view; > >+ public MarkTaskIncompleteAction() { >+ this(TaskListView.getFromActivePerspective()); >+ } >+ > public MarkTaskIncompleteAction(TaskListView view) { > this.view = view; > setText("Mark Incomplete"); >@@ -39,8 +43,16 @@ > public void run() { > for (Object selectedObject : ((IStructuredSelection) this.view.getViewer().getSelection()).toList()) { > if (selectedObject instanceof ITask) { >- TasksUiPlugin.getTaskListManager().getTaskList().markComplete(((ITask) selectedObject), false); >+ markIncomplete((ITask) selectedObject); > } > } > } >+ >+ public void run(ITask task) { >+ markIncomplete(task); >+ } >+ >+ private void markIncomplete(ITask task) { >+ TasksUiPlugin.getTaskListManager().getTaskList().markComplete(task, false); >+ } > } >Index: src/org/eclipse/mylar/internal/tasks/ui/actions/NewCategoryAction.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/actions/NewCategoryAction.java,v >retrieving revision 1.1 >diff -u -r1.1 NewCategoryAction.java >--- src/org/eclipse/mylar/internal/tasks/ui/actions/NewCategoryAction.java 14 Jul 2006 15:39:07 -0000 1.1 >+++ src/org/eclipse/mylar/internal/tasks/ui/actions/NewCategoryAction.java 30 Jul 2006 23:43:02 -0000 >@@ -21,7 +21,7 @@ > import org.eclipse.ui.PlatformUI; > > /** >- * @author Mik Kersten and Ken Sueda >+ * @author Mik Kersten, Ken Sueda and Izzet Safer > */ > public class NewCategoryAction extends Action { > >@@ -43,9 +43,17 @@ > "Enter name", "Enter a name for the Category: ", "", null); > int dialogResult = dialog.open(); > if (dialogResult == Window.OK) { >- TaskCategory cat = new TaskCategory(dialog.getValue(), TasksUiPlugin.getTaskListManager().getTaskList()); >- TasksUiPlugin.getTaskListManager().getTaskList().addCategory(cat); >- this.view.getViewer().refresh(); >+ addCategory(dialog.getValue()); > } > } >+ >+ public void run(String categoryName) { >+ addCategory(categoryName); >+ } >+ >+ private void addCategory(String categoryName) { >+ TaskCategory cat = new TaskCategory(categoryName, TasksUiPlugin.getTaskListManager().getTaskList()); >+ TasksUiPlugin.getTaskListManager().getTaskList().addCategory(cat); >+ this.view.getViewer().refresh(); >+ } > } >Index: src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalTaskAction.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalTaskAction.java,v >retrieving revision 1.1 >diff -u -r1.1 NewLocalTaskAction.java >--- src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalTaskAction.java 14 Jul 2006 15:39:08 -0000 1.1 >+++ src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalTaskAction.java 30 Jul 2006 23:43:02 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil; > import org.eclipse.mylar.internal.tasks.ui.views.TaskInputDialog; > import org.eclipse.mylar.internal.tasks.ui.views.TaskListView; >+import org.eclipse.mylar.tasks.core.AbstractTaskContainer; > import org.eclipse.mylar.tasks.core.ITask; > import org.eclipse.mylar.tasks.core.Task; > import org.eclipse.mylar.tasks.core.TaskCategory; >@@ -28,16 +29,16 @@ > import org.eclipse.swt.widgets.Display; > > /** >- * @author Mik Kersten >+ * @author Mik Kersten and Izzet Safer > */ > public class NewLocalTaskAction extends Action { > >- public static final String DESCRIPTION_DEFAULT = "new task"; >+ public static final String DESCRIPTION_DEFAULT = "New Task"; > > public static final String ID = "org.eclipse.mylar.tasklist.actions.create.task"; > > private final TaskListView view; >- >+ > public NewLocalTaskAction() { > this(null); > } >@@ -52,48 +53,85 @@ > > @Override > public void run() { >- Task newTask = new Task(TasksUiPlugin.getTaskListManager().genUniqueTaskHandle(), DESCRIPTION_DEFAULT, true); >- >- Calendar reminderCalendar = GregorianCalendar.getInstance(); >- TasksUiPlugin.getTaskListManager().setScheduledToday(reminderCalendar); >- TasksUiPlugin.getTaskListManager().setReminder(newTask, reminderCalendar.getTime()); >- >+ String taskHandle = TasksUiPlugin.getTaskListManager().genUniqueTaskHandle(); >+ AbstractTaskContainer category = null; >+ boolean showWarning = false; >+ > Object selectedObject = null; > if (view != null) { > selectedObject = ((IStructuredSelection) view.getViewer().getSelection()).getFirstElement(); > } >+ > if (selectedObject instanceof TaskCategory) { >- TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, (TaskCategory) selectedObject); >+ category = (TaskCategory) selectedObject; > } else if (selectedObject instanceof ITask) { > ITask task = (ITask) selectedObject; > if (task.getContainer() instanceof TaskCategory) { >- TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, >- (TaskCategory) task.getContainer()); >+ category = (TaskCategory) task.getContainer(); > } else if (view.getDrilledIntoCategory() instanceof TaskCategory) { >- TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, >- (TaskCategory) view.getDrilledIntoCategory()); >+ category = (TaskCategory) view.getDrilledIntoCategory(); > } else { >- TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, >- TasksUiPlugin.getTaskListManager().getTaskList().getRootCategory()); >+ category = TasksUiPlugin.getTaskListManager().getTaskList().getRootCategory(); > } > } else if (view != null && view.getDrilledIntoCategory() instanceof TaskCategory) { >- TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, >- (TaskCategory) view.getDrilledIntoCategory()); >+ category = (TaskCategory) view.getDrilledIntoCategory(); > } else { > if (view != null && view.getDrilledIntoCategory() != null) { >- MessageDialog.openInformation(Display.getCurrent().getActiveShell(), TasksUiPlugin.TITLE_DIALOG, >- "The new task has been added to the root of the list, since tasks can not be added to a query."); >+ showWarning = true; > } >- TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, >- TasksUiPlugin.getTaskListManager().getTaskList().getRootCategory()); >+ category = TasksUiPlugin.getTaskListManager().getTaskList().getRootCategory(); > } >- TaskUiUtil.openEditor(newTask, true); >+ >+ addNewLocalTask(taskHandle, DESCRIPTION_DEFAULT, category, true, showWarning); >+ } >+ >+ public ITask run(String taskHandle, String taskName, String categoryName) { >+ if (taskHandle == null || taskHandle.equals("")) >+ taskHandle = TasksUiPlugin.getTaskListManager().genUniqueTaskHandle(); > >- if (view != null) { >- view.getViewer().refresh(); >- view.setInRenameAction(true); >- view.getViewer().editElement(newTask, 4); >- view.setInRenameAction(false); >+ AbstractTaskContainer category = null; >+ if (categoryName == null || categoryName.equals("")) { >+ category = TasksUiPlugin.getTaskListManager().getTaskList().getRootCategory(); >+ } >+ else { >+ category = TasksUiPlugin.getTaskListManager().getTaskList().getContainerForHandle(categoryName); >+ if (category == null) { >+ // the category is not found, create it by calling NewCategoryAction >+ NewCategoryAction action = new NewCategoryAction(TaskListView.getFromActivePerspective()); >+ action.run(categoryName); >+ category = TasksUiPlugin.getTaskListManager().getTaskList().getContainerForHandle(categoryName); >+ if (category == null) category = TasksUiPlugin.getTaskListManager().getTaskList().getRootCategory(); >+ } > } >+ >+ return addNewLocalTask(taskHandle, taskName, category, false, false); > } >+ >+ private ITask addNewLocalTask(String taskHandle, String taskName, AbstractTaskContainer category, boolean edit, boolean showWarning) { >+ ITask newTask = new Task(taskHandle, taskName, true); >+// newTask.setUrl(getDefaultIssueURL()); >+ >+ Calendar reminderCalendar = GregorianCalendar.getInstance(); >+ TasksUiPlugin.getTaskListManager().setScheduledToday(reminderCalendar); >+ TasksUiPlugin.getTaskListManager().setReminder(newTask, reminderCalendar.getTime()); >+ >+ if (showWarning) { >+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), TasksUiPlugin.TITLE_DIALOG, >+ "The new task has been added to the root of the list, since tasks can not be added to a query."); >+ } >+ TasksUiPlugin.getTaskListManager().getTaskList().addTask(newTask, category); >+ >+ if (edit) TaskUiUtil.openEditor(newTask, true); >+ >+ if (view != null) { >+ view.getViewer().refresh(); >+ >+ if (edit) { >+ view.setInRenameAction(true); >+ view.getViewer().editElement(newTask, 4); >+ view.setInRenameAction(false); >+ } >+ } >+ return newTask; >+ } > } >Index: src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskCompleteAction.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskCompleteAction.java,v >retrieving revision 1.1 >diff -u -r1.1 MarkTaskCompleteAction.java >--- src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskCompleteAction.java 14 Jul 2006 15:39:07 -0000 1.1 >+++ src/org/eclipse/mylar/internal/tasks/ui/actions/MarkTaskCompleteAction.java 30 Jul 2006 23:43:02 -0000 >@@ -19,13 +19,17 @@ > import org.eclipse.mylar.tasks.ui.TasksUiPlugin; > > /** >- * @author Mik Kersten >+ * @author Mik Kersten and Izzet Safer > */ > public class MarkTaskCompleteAction extends Action { > > public static final String ID = "org.eclipse.mylar.tasklist.actions.mark.completed"; > > private final TaskListView view; >+ >+ public MarkTaskCompleteAction() { >+ this(TaskListView.getFromActivePerspective()); >+ } > > public MarkTaskCompleteAction(TaskListView view) { > this.view = view; >@@ -39,8 +43,16 @@ > public void run() { > for (Object selectedObject : ((IStructuredSelection) this.view.getViewer().getSelection()).toList()) { > if (selectedObject instanceof ITask) { >- TasksUiPlugin.getTaskListManager().getTaskList().markComplete(((ITask) selectedObject), true); >+ markComplete((ITask) selectedObject); > } > } > } >+ >+ public void run(ITask task) { >+ markComplete(task); >+ } >+ >+ private void markComplete(ITask task) { >+ TasksUiPlugin.getTaskListManager().getTaskList().markComplete(task, true); >+ } > } >Index: src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalSubTaskHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalSubTaskHandler.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalSubTaskHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalSubTaskHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,97 @@ >+package org.eclipse.mylar.internal.tasks.ui.commands; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.mylar.context.core.ContextCorePlugin; >+import org.eclipse.mylar.internal.tasks.ui.actions.MarkTaskIncompleteAction; >+import org.eclipse.mylar.internal.tasks.ui.actions.NewLocalSubTaskAction; >+import org.eclipse.mylar.internal.tasks.ui.actions.TaskActivateAction; >+import org.eclipse.mylar.internal.tasks.ui.actions.TaskDeactivateAction; >+import org.eclipse.mylar.internal.tasks.ui.views.TaskListView; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class NewLocalSubTaskHandler extends AbstractHandler { >+ >+ private static final String PARAMETER_TASK_NAME_ID = "taskName"; //$NON-NLS-1$ >+ private static final String PARAMETER_TASK_HANDLE_ID = "taskHandle"; //$NON-NLS-1$ >+ private static final String PARAMETER_PARENT_HANDLE_ID = "parentHandle"; //$NON-NLS-1$ >+ private static final String PARAMETER_ACTIVATE_TASK_ID = "activateTask"; //$NON-NLS-1$ >+ private static final String PARAMETER_RESET_CONTEXT_ID = "resetContext"; //$NON-NLS-1$ >+ >+ private static final boolean activateTaskDefault = true; >+ private static final boolean resetContextDefault = true; >+ >+ private NewLocalSubTaskAction newAction = null; >+ private TaskActivateAction activateAction = null; >+ private TaskDeactivateAction deactivateAction = null; >+ private MarkTaskIncompleteAction incompleteAction = null; >+ >+ public NewLocalSubTaskHandler () { >+ newAction = new NewLocalSubTaskAction(); >+ activateAction = new TaskActivateAction(); >+ deactivateAction = new TaskDeactivateAction(); >+ incompleteAction = new MarkTaskIncompleteAction(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ Object returnValue = null; >+ >+ final String taskName = event.getParameter(PARAMETER_TASK_NAME_ID); >+ // if task handle is not null and a task with that handle already exists, >+ // that task will be used and no new task will be created >+ final String taskHandle = event.getParameter(PARAMETER_TASK_HANDLE_ID); >+ >+ final String parentHandle = event.getParameter(PARAMETER_PARENT_HANDLE_ID); >+ >+ final boolean activateTask = event.getParameter(PARAMETER_ACTIVATE_TASK_ID) == null ? activateTaskDefault >+ : Boolean.parseBoolean(event.getParameter(PARAMETER_ACTIVATE_TASK_ID)); >+ >+ // delete the context associated with the task if an existing task is used >+ final boolean resetContext = event.getParameter(PARAMETER_RESET_CONTEXT_ID) == null ? resetContextDefault >+ : Boolean.parseBoolean(event.getParameter(PARAMETER_RESET_CONTEXT_ID)); >+ >+ if (taskName == null || parentHandle == null) { >+ return returnValue; >+ } else { >+ >+ /* >+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), TasksUiPlugin.TITLE_DIALOG, >+ "New Subtask with " + taskHandle + ", " + parentHandle); >+ */ >+ >+ ITask newSubTask = null; >+ if (taskHandle != null) { >+ newSubTask = TasksUiPlugin.getTaskListManager().getTaskList().findTask((String)taskHandle); >+ if (newSubTask != null && resetContext) { >+ //TODO: do this using ContextClearAction >+ ContextCorePlugin.getContextManager().deleteContext(newSubTask.getHandleIdentifier()); >+ //TODO: call DeleteAction to delete the subtasks of this task, or just >+ //delete subtasks' context >+ newSubTask.getChildren().clear(); >+ incompleteAction.run(newSubTask); >+ } >+ } >+ >+ if (newSubTask == null) { >+ newSubTask = newAction.run(taskHandle == null ? "" : taskHandle, >+ taskName, parentHandle); >+ } >+ >+ returnValue = (newSubTask == null) ? null : newSubTask.getHandleIdentifier(); >+ >+ if (activateTask) activateAction.run(newSubTask); >+ else deactivateAction.run(newSubTask); >+ } >+ >+ try { >+ TaskListView.getFromActivePerspective().getViewer().refresh(); >+ } catch (Exception ex) {} >+ >+ return returnValue; >+ } >+} >Index: src/org/eclipse/mylar/internal/tasks/ui/commands/TaskActivateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/commands/TaskActivateHandler.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/commands/TaskActivateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/commands/TaskActivateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+package org.eclipse.mylar.internal.tasks.ui.commands; >+ >+ >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.mylar.internal.tasks.ui.actions.TaskActivateAction; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class TaskActivateHandler extends AbstractHandler { >+ >+ private static final String PARAMETER_TASK_HANDLE_ID = "taskHandle"; //$NON-NLS-1$ >+ >+ private TaskActivateAction activateAction = null; >+ >+ public TaskActivateHandler() { >+ activateAction = new TaskActivateAction(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ String taskHandle = event.getParameter(PARAMETER_TASK_HANDLE_ID); >+ >+ if (taskHandle == null) { >+ return null; >+ } >+ >+ ITask task = TasksUiPlugin.getTaskListManager().getTaskList().findTask((String)taskHandle); >+ if (task != null) { >+ activateAction.run(task); >+ } >+ >+ return Boolean.TRUE; >+ } >+} >Index: src/org/eclipse/mylar/internal/tasks/ui/commands/TaskDeactivateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/commands/TaskDeactivateHandler.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/commands/TaskDeactivateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/commands/TaskDeactivateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+package org.eclipse.mylar.internal.tasks.ui.commands; >+ >+ >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.mylar.internal.tasks.ui.actions.TaskDeactivateAction; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class TaskDeactivateHandler extends AbstractHandler { >+ >+ private static final String PARAMETER_TASK_HANDLE_ID = "taskHandle"; //$NON-NLS-1$ >+ >+ private TaskDeactivateAction deactivateAction = null; >+ >+ public TaskDeactivateHandler() { >+ deactivateAction = new TaskDeactivateAction(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ String taskHandle = event.getParameter(PARAMETER_TASK_HANDLE_ID); >+ >+ if (taskHandle == null) { >+ return null; >+ } >+ >+ ITask task = TasksUiPlugin.getTaskListManager().getTaskList().findTask((String)taskHandle); >+ if (task != null) { >+ deactivateAction.run(task); >+ } >+ >+ return Boolean.TRUE; >+ } >+} >Index: src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskIncompleteHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskIncompleteHandler.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskIncompleteHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskIncompleteHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+package org.eclipse.mylar.internal.tasks.ui.commands; >+ >+ >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.mylar.internal.tasks.ui.actions.MarkTaskIncompleteAction; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class MarkTaskIncompleteHandler extends AbstractHandler { >+ >+ private static final String PARAMETER_TASK_HANDLE_ID = "taskHandle"; //$NON-NLS-1$ >+ >+ private MarkTaskIncompleteAction incompleteAction = null; >+ >+ public MarkTaskIncompleteHandler() { >+ incompleteAction = new MarkTaskIncompleteAction(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ String taskHandle = event.getParameter(PARAMETER_TASK_HANDLE_ID); >+ >+ if (taskHandle == null) { >+ return null; >+ } >+ >+ ITask task = TasksUiPlugin.getTaskListManager().getTaskList().findTask((String)taskHandle); >+ if (task != null) { >+ incompleteAction.run(task); >+ } >+ >+ return Boolean.TRUE; >+ } >+} >Index: src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalSubTaskAction.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalSubTaskAction.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalSubTaskAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/actions/NewLocalSubTaskAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.tasks.ui.actions; >+ >+import java.util.Calendar; >+import java.util.GregorianCalendar; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.mylar.internal.tasks.ui.TaskListImages; >+import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil; >+import org.eclipse.mylar.internal.tasks.ui.views.TaskInputDialog; >+import org.eclipse.mylar.internal.tasks.ui.views.TaskListView; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.core.Task; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+import org.eclipse.swt.widgets.Display; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class NewLocalSubTaskAction extends Action { >+ >+ public static final String DESCRIPTION_DEFAULT = "New Subtask"; >+ >+ public static final String ID = "org.eclipse.mylar.tasklist.actions.create.subtask"; >+ >+ private final TaskListView view; >+ >+ public NewLocalSubTaskAction() { >+ this(null); >+ } >+ >+ public NewLocalSubTaskAction(TaskListView view) { >+ this.view = view; >+ setText(TaskInputDialog.LABEL_SHELL); //TODO form to be done >+ setToolTipText(TaskInputDialog.LABEL_SHELL); //TODO form to be done >+ setId(ID); >+ setImageDescriptor(TaskListImages.TASK_NEW); >+ } >+ >+ @Override >+ public void run() { >+ String taskHandle = TasksUiPlugin.getTaskListManager().genUniqueTaskHandle(); >+ ITask parentTask = null; >+ >+ Object selectedObject = null; >+ if (view != null) { >+ selectedObject = ((IStructuredSelection) view.getViewer().getSelection()).getFirstElement(); >+ } >+ >+ if (selectedObject instanceof ITask) { >+ parentTask = (ITask) selectedObject; >+ } else { >+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), TasksUiPlugin.TITLE_DIALOG, >+ "The new subtask cannot be added, please choose a task."); >+ return; >+ } >+ >+ addNewLocalSubTask(taskHandle, DESCRIPTION_DEFAULT, parentTask, true); >+ } >+ >+ public ITask run(String taskHandle, String taskName, String parentHandle) { >+ if (taskHandle == null || taskHandle.equals("")) >+ taskHandle = TasksUiPlugin.getTaskListManager().genUniqueTaskHandle(); >+ >+ if (parentHandle == null || parentHandle.equals("")) return null; >+ >+ ITask parentTask = TasksUiPlugin.getTaskListManager().getTaskList().findTask(parentHandle); >+ if (parentTask == null) return null; >+ >+ return addNewLocalSubTask(taskHandle, taskName, parentTask, false); >+ } >+ >+ private ITask addNewLocalSubTask(String taskHandle, String taskName, ITask parentTask, boolean edit) { >+ ITask newSubTask = new Task(taskHandle, taskName, true); >+// newTask.setUrl(getDefaultIssueURL()); >+ >+ Calendar reminderCalendar = GregorianCalendar.getInstance(); >+ TasksUiPlugin.getTaskListManager().setScheduledToday(reminderCalendar); >+ TasksUiPlugin.getTaskListManager().setReminder(newSubTask, reminderCalendar.getTime()); >+ >+ parentTask.addSubTask(newSubTask); >+ >+ if (edit) TaskUiUtil.openEditor(newSubTask, true); >+ >+ if (view != null) { >+ view.getViewer().refresh(); >+ >+ if (edit) { >+ view.setInRenameAction(true); >+ view.getViewer().editElement(newSubTask, 4); >+ view.setInRenameAction(false); >+ } >+ } >+ >+ return newSubTask; >+ } >+} >Index: src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskCompleteHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskCompleteHandler.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskCompleteHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/commands/MarkTaskCompleteHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+package org.eclipse.mylar.internal.tasks.ui.commands; >+ >+ >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.mylar.internal.tasks.ui.actions.MarkTaskCompleteAction; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class MarkTaskCompleteHandler extends AbstractHandler { >+ >+ private static final String PARAMETER_TASK_HANDLE_ID = "taskHandle"; //$NON-NLS-1$ >+ >+ private MarkTaskCompleteAction completeAction = null; >+ >+ public MarkTaskCompleteHandler() { >+ completeAction = new MarkTaskCompleteAction(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ String taskHandle = event.getParameter(PARAMETER_TASK_HANDLE_ID); >+ >+ if (taskHandle == null) { >+ return null; >+ } >+ >+ ITask task = TasksUiPlugin.getTaskListManager().getTaskList().findTask((String)taskHandle); >+ if (task != null) { >+ completeAction.run(task); >+ } >+ >+ return Boolean.TRUE; >+ } >+} >Index: src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalTaskHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalTaskHandler.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalTaskHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/commands/NewLocalTaskHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+package org.eclipse.mylar.internal.tasks.ui.commands; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.mylar.context.core.ContextCorePlugin; >+import org.eclipse.mylar.internal.tasks.ui.actions.MarkTaskIncompleteAction; >+import org.eclipse.mylar.internal.tasks.ui.actions.NewLocalTaskAction; >+import org.eclipse.mylar.internal.tasks.ui.actions.TaskActivateAction; >+import org.eclipse.mylar.internal.tasks.ui.actions.TaskDeactivateAction; >+import org.eclipse.mylar.internal.tasks.ui.views.TaskListView; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Izzet Safer >+ */ >+public class NewLocalTaskHandler extends AbstractHandler { >+ >+ private static final String PARAMETER_TASK_NAME_ID = "taskName"; //$NON-NLS-1$ >+ private static final String PARAMETER_TASK_HANDLE_ID = "taskHandle"; //$NON-NLS-1$ >+ private static final String PARAMETER_CATEGORY_NAME_ID = "categoryName"; //$NON-NLS-1$ >+ private static final String PARAMETER_ACTIVATE_TASK_ID = "activateTask"; //$NON-NLS-1$ >+ private static final String PARAMETER_RESET_CONTEXT_ID = "resetContext"; //$NON-NLS-1$ >+ >+ private static final boolean activateTaskDefault = true; >+ private static final boolean resetContextDefault = true; >+ >+ private NewLocalTaskAction newAction = null; >+ private TaskActivateAction activateAction = null; >+ private TaskDeactivateAction deactivateAction = null; >+ private MarkTaskIncompleteAction incompleteAction = null; >+ >+ public NewLocalTaskHandler () { >+ newAction = new NewLocalTaskAction(); >+ activateAction = new TaskActivateAction(); >+ deactivateAction = new TaskDeactivateAction(); >+ incompleteAction = new MarkTaskIncompleteAction(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ Object returnValue = null; >+ >+ final String taskName = event.getParameter(PARAMETER_TASK_NAME_ID); >+ // if task handle is not null and a task with that handle already exists, >+ // that task will be used and no new task will be created >+ final String taskHandle = event.getParameter(PARAMETER_TASK_HANDLE_ID); >+ >+ // will use root when null >+ final String categoryName = event.getParameter(PARAMETER_CATEGORY_NAME_ID); >+ >+ final boolean activateTask = event.getParameter(PARAMETER_ACTIVATE_TASK_ID) == null ? activateTaskDefault >+ : Boolean.parseBoolean(event.getParameter(PARAMETER_ACTIVATE_TASK_ID)); >+ >+ // delete the context associated with the task if an existing task is used >+ final boolean resetContext = event.getParameter(PARAMETER_RESET_CONTEXT_ID) == null ? resetContextDefault >+ : Boolean.parseBoolean(event.getParameter(PARAMETER_RESET_CONTEXT_ID)); >+ >+ if (taskName == null) { >+ return returnValue; >+ } else { >+ ITask newTask = null; >+ if (taskHandle != null) { >+ newTask = TasksUiPlugin.getTaskListManager().getTaskList().findTask((String)taskHandle); >+ if (newTask != null && resetContext) { >+ //TODO: do this using ContextClearAction >+ ContextCorePlugin.getContextManager().deleteContext(newTask.getHandleIdentifier()); >+ //TODO: call DeleteAction to delete the subtasks of this task, or just >+ //delete subtasks' context >+ newTask.getChildren().clear(); >+ incompleteAction.run(newTask); >+ } >+ } >+ >+ if (newTask == null) { >+ newTask = newAction.run(taskHandle == null ? "" : taskHandle, >+ taskName, categoryName == null ? "" : categoryName); >+ } >+ >+ returnValue = (newTask == null) ? null : newTask.getHandleIdentifier(); >+ >+ if (activateTask) activateAction.run(newTask); >+ else deactivateAction.run(newTask); >+ } >+ >+ try { >+ TaskListView.getFromActivePerspective().getViewer().refresh(); >+ } catch (Exception ex) {} >+ >+ return returnValue; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 145884
:
44854
|
44873
|
44963
| 47037