diff options
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
15 files changed, 784 insertions, 153 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java index 9b021668a..3d051e7ca 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java @@ -104,4 +104,16 @@ public interface ITask extends Serializable, ITaskListElement { public abstract void setEndDate(String date); public abstract String getEndDateString(); + + public abstract void setReminderDate(Date date); + + public abstract void setReminderDate(String date); + + public abstract Date getReminderDate(); + + public abstract String getReminderDateString(boolean forDisplay); + + public abstract boolean hasBeenReminded(); + + public abstract void setReminded(boolean reminded); }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java index c1c28a475..9328fbad0 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java @@ -27,6 +27,9 @@ import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.mylar.core.MylarPlugin; import org.eclipse.mylar.tasklist.internal.TaskListExternalizer; +import org.eclipse.mylar.tasklist.report.internal.ReminderRequiredCollector; +import org.eclipse.mylar.tasklist.report.internal.TaskReportGenerator; +import org.eclipse.mylar.tasklist.ui.TasksReminderDialog; import org.eclipse.mylar.tasklist.ui.views.TaskListView; import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.events.ShellListener; @@ -72,6 +75,7 @@ public class MylarTasklistPlugin extends AbstractUIPlugin { public static final String FILTER_INCOMPLETE_MODE = "org.eclipse.mylar.tasklist.filter.incomplete"; public static final String SAVE_TASKLIST_MODE = "org.eclipse.mylar.tasklist.save.mode"; public static final String PREVIOUS_SAVE_DATE = "org.eclipse.mylar.tasklist.save.last"; + public static final String REMINDER_CHECK = "org.eclipse.mylar.tasklist.reminder.check"; private ResourceBundle resourceBundle; private static Date lastSave = null; @@ -197,6 +201,24 @@ public class MylarTasklistPlugin extends AbstractUIPlugin { } } + private void checkReminders() { + if (getPrefs().getBoolean(REMINDER_CHECK)) { + getPrefs().setValue(REMINDER_CHECK, false); + final TaskReportGenerator parser = new TaskReportGenerator(MylarTasklistPlugin.getTaskListManager().getTaskList()); + parser.addCollector(new ReminderRequiredCollector()); + parser.checkTasks(); + if (!parser.getTasks().isEmpty()) { + Workbench.getInstance().getDisplay().asyncExec(new Runnable() { + public void run() { + TasksReminderDialog dialog = new TasksReminderDialog(Workbench.getInstance().getDisplay().getActiveShell(), parser.getTasks()); + dialog.setBlockOnOpen(false); + dialog.open(); + } + }); + } + } + } + public void shellClosed(ShellEvent arg0) { saveState(); } @@ -206,6 +228,7 @@ public class MylarTasklistPlugin extends AbstractUIPlugin { } public void shellActivated(ShellEvent arg0) { checkTaskListSave(); + checkReminders(); } public void shellDeiconified(ShellEvent arg0) { } @@ -261,16 +284,17 @@ public class MylarTasklistPlugin extends AbstractUIPlugin { MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER); } - }); + }); super.start(context); } - + @Override public void stop(BundleContext context) throws Exception { super.stop(context); plugin = null; resourceBundle = null; createFileBackup(); + getPrefs().setValue(REMINDER_CHECK, true); } @Override @@ -282,6 +306,8 @@ public class MylarTasklistPlugin extends AbstractUIPlugin { store.setDefault(REPORT_OPEN_EXTERNAL, false); store.setDefault(MULTIPLE_ACTIVE_TASKS, false); store.setDefault(SAVE_TASKLIST_MODE, TaskListSaveMode.THREE_HOURS.toString()); + store.setDefault(REMINDER_CHECK, true); + } public static TaskListManager getTaskListManager() { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java index 12186f2f4..b2b848fe7 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java @@ -43,6 +43,7 @@ public class Task implements ITask { private boolean active = false; protected String handle = "-1"; private boolean category = false; + private boolean hasReminded = false; /** @@ -61,6 +62,7 @@ public class Task implements ITask { private Date timeActivated = null; private Date endDate = null; + private Date reminderDate=null; private long elapsed; /** * null if root @@ -424,4 +426,62 @@ public class Task implements ITask { } } } + + public void setReminderDate(Date date) { + reminderDate = date; + } + + public void setReminderDate(String date) { + if (!date.equals("")) { + String formatString = "yyyy-MM-dd HH:mm:ss.S z"; + SimpleDateFormat format = new SimpleDateFormat(formatString, Locale.ENGLISH); + try { + reminderDate = format.parse(date); + } catch (ParseException e) { + MylarPlugin.log(e, "Could not parse end date"); + reminderDate = null; + } + } else { + reminderDate = null; + } + + } + + public Date getReminderDate() { + return reminderDate; + } + + public String getReminderDateString(boolean forDisplay) { + if (reminderDate != null) { + String f = ""; + if (forDisplay) { + f = "EEE, yyyy-MM-dd"; + } else { + f = "yyyy-MM-dd HH:mm:ss.S z"; + } + SimpleDateFormat format = new SimpleDateFormat(f, Locale.ENGLISH); + return format.format(reminderDate); + } else { + return ""; + } + } + + public boolean hasBeenReminded() { + return hasReminded; + } + + public void setReminded(boolean reminded) { + this.hasReminded = reminded; + } + + public String getReminderDateForDisplay() { + if (reminderDate != null) { + + String f = "EEE, yyyy-MM-dd"; + SimpleDateFormat format = new SimpleDateFormat(f, Locale.ENGLISH); + return format.format(reminderDate); + } else { + return ""; + } + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java index 0775047e7..17d89007a 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java @@ -49,6 +49,8 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer { public static final String TRUE = "true"; public static final String NAME = "Name"; public static final String END_DATE = "EndDate"; + public static final String REMINDER_DATE = "ReminderDate"; + public static final String REMINDED = "Reminded"; private List<ITaskListExternalizer> externalizers = new ArrayList<ITaskListExternalizer>(); @@ -107,7 +109,12 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer { node.setAttribute(ELAPSED, task.getElapsedTime()); node.setAttribute(ESTIMATED, task.getEstimatedTime()); node.setAttribute(END_DATE, task.getEndDateString()); - + node.setAttribute(REMINDER_DATE, task.getReminderDateString(false)); + if (task.hasBeenReminded()) { + node.setAttribute(REMINDED, TRUE); + } else { + node.setAttribute(REMINDED, FALSE); + } List<String> rl = task.getRelatedLinks().getLinks(); int i = 0; for (String link : rl) { @@ -220,7 +227,17 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer { task.setEndDate(element.getAttribute(END_DATE)); } else { task.setEndDate(""); - } + } + if (element.hasAttribute(REMINDER_DATE)) { + task.setReminderDate(element.getAttribute(REMINDER_DATE)); + } else { + task.setReminderDate(""); + } + if (element.hasAttribute(REMINDED) && element.getAttribute(REMINDED).compareTo(TRUE) == 0) { + task.setReminded(true); + } else { + task.setReminded(false); + } int i = 0; while (element.hasAttribute(LINK+i)) { task.getRelatedLinks().add(element.getAttribute(LINK+i)); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ReminderRequiredCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ReminderRequiredCollector.java new file mode 100644 index 000000000..9898e06ff --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ReminderRequiredCollector.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2005 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.tasklist.report.internal; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.eclipse.mylar.tasklist.ITask; + +/** + * @author Ken Sueda + */ +public class ReminderRequiredCollector implements ITasksCollector { + + private List<ITask> tasks = new ArrayList<ITask>(); + private Date curr = null; + + public ReminderRequiredCollector() { + curr = new Date(); + } + + public void consumeTask(ITask task) { + if (task.getReminderDate() != null && !task.hasBeenReminded() && task.getReminderDate().compareTo(curr) < 0) { + task.setReminded(true); + tasks.add(task); + } + } + + public List<ITask> getTasks() { + return tasks; + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java index 06027ba07..cbdda0c80 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java @@ -29,10 +29,12 @@ public class TaskReportGenerator { private List<ITask> tasks = new ArrayList<ITask>(); private TaskList tasklist = null; - public TaskReportGenerator(TaskList tlist, int prevDays) { - tasklist = tlist; - collectors.add(new CompletedTaskCollector(prevDays)); - getTasksForReport(); + public TaskReportGenerator(TaskList tlist) { + tasklist = tlist; + } + + public void addCollector(ITasksCollector collector) { + collectors.add(collector); } private void getTasksForReport() { @@ -61,6 +63,10 @@ public class TaskReportGenerator { } } + public void checkTasks() { + getTasksForReport(); + } + public List<ITask> getTasks() { return tasks; } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameEditorInput.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameEditorInput.java index 72261b924..cb1ed99ad 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameEditorInput.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameEditorInput.java @@ -16,6 +16,7 @@ import java.util.List; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.mylar.tasklist.ITask; import org.eclipse.mylar.tasklist.internal.TaskList; +import org.eclipse.mylar.tasklist.report.internal.CompletedTaskCollector; import org.eclipse.mylar.tasklist.report.internal.TaskReportGenerator; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; @@ -28,7 +29,9 @@ public class PlanningGameEditorInput implements IEditorInput { private TaskReportGenerator parser = null; public PlanningGameEditorInput(int prevDays, TaskList tlist) { - parser = new TaskReportGenerator(tlist, prevDays); + parser = new TaskReportGenerator(tlist); + parser.addCollector(new CompletedTaskCollector(prevDays)); + parser.checkTasks(); completedTasks = parser.getTasks(); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java index 38729531f..1bbf5273d 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java @@ -56,6 +56,7 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Image; @@ -330,6 +331,7 @@ public class TaskSummaryEditor extends EditorPart { TableWrapLayout layout = new TableWrapLayout(); layout.numColumns = 3; container.setLayout(layout); + container.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); Label l = toolkit.createLabel(container, "Description:"); l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); @@ -345,7 +347,28 @@ public class TaskSummaryEditor extends EditorPart { markDirty(true); } }); - } + } + l = toolkit.createLabel(container, "Reminder:"); + l.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); + Text reminderDate = toolkit.createText(container,task.getReminderDateString(true), SWT.BORDER); + reminderDate.setLayoutData(layout); + td = new TableWrapData(TableWrapData.FILL_GRAB); + td.grabHorizontal = true; + td.colspan = 1; + reminderDate.setLayoutData(td); + reminderDate.setEnabled(false); + + Button dateSelect = toolkit.createButton(container, "Select", SWT.PUSH); +// td = new TableWrapData(TableWrapData.RIGHT); +// dateSelect.setLayoutData(td); + dateSelect.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + // TODO: open Date Chooser + } + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + }); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java new file mode 100644 index 000000000..48c8fafdd --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java @@ -0,0 +1,256 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2005 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.tasklist.ui; + +import java.util.Date; +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.mylar.tasklist.ITask; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +/** + * @author Ken Sueda + */ +public class TasksReminderDialog extends Dialog { + private List<ITask> tasks = null; + private Table table = null; + private TableViewer tableViewer = null; + private String[] columnNames = new String[] { "Description", "Priority", "Reminder Day"}; + + private static final int DISMISS_ALL_ID = 200; + private static final int DISMISS_ID = 201; + private static final int SNOOZE_ID = 202; + private static final String DISMISS_ALL_LABEL = "Dismiss All"; + private static final String DISMISS_LABEL = "Dismiss Selected"; + private static final String SNOOZE_ALL_LABEL = "Remind tommorrow"; + private static long DAY = 24 * 3600 * 1000; + + public TasksReminderDialog(Shell parentShell, List<ITask> remTasks) { + super(parentShell); + tasks = remTasks; + } + + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText("Reminders"); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + setBlockOnOpen(false); + GridLayout gl = new GridLayout(1, false); + composite.setLayout(gl); + GridData data = new GridData(GridData.FILL_BOTH); + composite.setLayoutData(data); + + Composite container = new Composite(composite, SWT.NONE); + gl = new GridLayout(1, false); + container.setLayout(gl); + createTable(container); + createTableViewer(); + + return composite; + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, DISMISS_ALL_ID, DISMISS_ALL_LABEL, false); + createButton(parent, DISMISS_ID, DISMISS_LABEL, false); + createButton(parent, SNOOZE_ID, SNOOZE_ALL_LABEL, true); + } + + private void createTable(Composite parent) { + int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION; + table = new Table(parent, style ); + GridLayout tlayout = new GridLayout(); + table.setLayout(tlayout); + GridData wd = new GridData(GridData.FILL_BOTH); + wd.heightHint = 300; + table.setLayoutData(wd); + + table.setLinesVisible(true); + table.setHeaderVisible(true); + + TableColumn column = new TableColumn(table, SWT.LEFT, 0); + column.setText(columnNames[0]); + column.setWidth(180); + column.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + tableViewer.setSorter(new ReminderTaskSorter(ReminderTaskSorter.DESCRIPTION)); + + } + }); + + column = new TableColumn(table, SWT.LEFT, 1); + column.setText(columnNames[1]); + column.setWidth(50); + column.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + tableViewer.setSorter(new ReminderTaskSorter(ReminderTaskSorter.PRIORITY)); + } + }); + + column = new TableColumn(table, SWT.LEFT, 2); + column.setText(columnNames[2]); + column.setWidth(100); + column.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + tableViewer.setSorter(new ReminderTaskSorter(ReminderTaskSorter.DATE)); + } + }); + } + + private void createTableViewer() { + tableViewer = new TableViewer(table); + tableViewer.setUseHashlookup(true); + tableViewer.setContentProvider(new ReminderTasksContentProvider()); + tableViewer.setLabelProvider(new ReminderTasksLabelProvider()); + tableViewer.setInput(tasks); + } + + + protected void buttonPressed(int buttonId) { + if (buttonId == DISMISS_ALL_ID) { + for (ITask t : tasks) { + t.setReminded(true); + } + okPressed(); + } else if (buttonId == DISMISS_ID) { + Object sel = ((IStructuredSelection)tableViewer.getSelection()).getFirstElement(); + if (sel != null && sel instanceof ITask ) { + ITask t = (ITask) sel; + t.setReminded(true); + tasks.remove(t); + if (tasks.isEmpty()) { + okPressed(); + } else { + tableViewer.refresh(); + } + } + } else if (buttonId == SNOOZE_ID) { + Object sel = ((IStructuredSelection)tableViewer.getSelection()).getFirstElement(); + if (sel != null && sel instanceof ITask ) { + ITask t = (ITask) sel; + t.setReminded(false); + t.setReminderDate( new Date(new Date().getTime() + DAY)); + tasks.remove(t); + if (tasks.isEmpty()) { + okPressed(); + } else { + tableViewer.refresh(); + } + } + } + super.buttonPressed(buttonId); + } + + private class ReminderTasksContentProvider implements IStructuredContentProvider { + + public Object[] getElements(Object inputElement) { + return tasks.toArray(); + } + + public void dispose() { + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + private class ReminderTasksLabelProvider extends LabelProvider implements + ITableLabelProvider { + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + public String getColumnText(Object element, int columnIndex) { + if (element instanceof ITask) { + ITask task = (ITask) element; + switch (columnIndex) { + case 0: + return task.getDescription(true); + case 1: + return task.getPriority(); + case 2: + return task.getReminderDateString(true); + } + } + return null; + } + + } + + class ReminderTaskSorter extends ViewerSorter { + + public final static int DESCRIPTION = 1; + public final static int PRIORITY = 2; + public final static int DATE = 3; + + private int criteria; + + public ReminderTaskSorter(int criteria) { + super(); + this.criteria = criteria; + } + + @Override + public int compare(Viewer viewer, Object obj1, Object obj2) { + ITask t1 = (ITask) obj1; + ITask t2 = (ITask) obj2; + + switch (criteria) { + case DESCRIPTION: + return compareDescription(t1, t2); + case PRIORITY: + return comparePriority(t1, t2); + case DATE: + return compareDate(t1, t2); + default: + return 0; + } + } + + private int compareDescription(ITask task1, ITask task2) { + return task1.getLabel().compareTo(task2.getLabel()); + } + + private int comparePriority(ITask task1, ITask task2) { + return task1.getPriority().compareTo(task2.getPriority()); + } + + private int compareDate(ITask task1, ITask task2) { + return task2.getReminderDate().compareTo(task1.getReminderDate()); + } + } +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateCategoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateCategoryAction.java index df4049b0a..7af18eb0e 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateCategoryAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateCategoryAction.java @@ -12,10 +12,13 @@ package org.eclipse.mylar.tasklist.ui.actions; import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.window.Window; import org.eclipse.mylar.tasklist.MylarTasklistPlugin; import org.eclipse.mylar.tasklist.TaskListImages; import org.eclipse.mylar.tasklist.internal.TaskCategory; import org.eclipse.mylar.tasklist.ui.views.TaskListView; +import org.eclipse.ui.internal.Workbench; /** * @author Mik Kersten and Ken Sueda @@ -36,13 +39,17 @@ public class CreateCategoryAction extends Action { @Override public void run() { -// MylarPlugin.getDefault().actionObserved(this); - String[] input = this.view.getLabelPriorityFromUser("Category"); - if (input == null) return; - String label = input[0]; - if(label == null) return; - TaskCategory cat = new TaskCategory(label); - MylarTasklistPlugin.getTaskListManager().addCategory(cat); - this.view.getViewer().refresh(); + InputDialog dialog = new InputDialog( + Workbench.getInstance().getActiveWorkbenchWindow().getShell(), + "Enter name", + "Enter a name for the Category: ", + "", + null); + int dialogResult = dialog.open(); + if (dialogResult == Window.OK) { + TaskCategory cat = new TaskCategory(dialog.getValue()); + MylarTasklistPlugin.getTaskListManager().addCategory(cat); + this.view.getViewer().refresh(); + } } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateTaskAction.java index 33694ecbc..92896ce87 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateTaskAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/CreateTaskAction.java @@ -13,11 +13,14 @@ package org.eclipse.mylar.tasklist.ui.actions; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; import org.eclipse.mylar.tasklist.MylarTasklistPlugin; import org.eclipse.mylar.tasklist.Task; import org.eclipse.mylar.tasklist.TaskListImages; import org.eclipse.mylar.tasklist.internal.TaskCategory; +import org.eclipse.mylar.tasklist.ui.views.TaskInputDialog; import org.eclipse.mylar.tasklist.ui.views.TaskListView; +import org.eclipse.ui.internal.Workbench; /** * @author Mik Kersten and Ken Sueda @@ -38,32 +41,27 @@ public class CreateTaskAction extends Action { @Override public void run() { -// MylarPlugin.getDefault().actionObserved(this); - String[] input = this.view.getLabelPriorityFromUser("task"); - if (input == null) return; - String label = input[0]; - String priority = input[1]; - if(label == null) return; - Task newTask = new Task(MylarTasklistPlugin.getTaskListManager().genUniqueTaskId(), label); - if (priority != null) { - newTask.setPriority(priority); - } - Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); - if (selectedObject instanceof TaskCategory){ - newTask.setCategory((TaskCategory)selectedObject); - ((TaskCategory)selectedObject).addTask(newTask); - } -// else if (selectedObject instanceof Task) { -// ITask t = (ITask) selectedObject; -// newTask.setParent(t); -// t.addSubTask(newTask); -// } - else { - MylarTasklistPlugin.getTaskListManager().addRootTask(newTask); - } -// MylarUiPlugin.getDefault().setHighlighterMapping( -// newTask.getHandle(), -// MylarUiPlugin.getDefault().getDefaultHighlighter().getName()); - this.view.getViewer().refresh(); + TaskInputDialog dialog = new TaskInputDialog(Workbench.getInstance() + .getActiveWorkbenchWindow().getShell()); + int dialogResult = dialog.open(); + if (dialogResult == Window.OK) { + Task newTask = new Task(MylarTasklistPlugin.getTaskListManager() + .genUniqueTaskId(), dialog.getTaskname()); + newTask.setPriority(dialog.getSelectedPriority()); + newTask.setReminderDate(dialog.getReminderDate()); + + Object selectedObject = ((IStructuredSelection) this.view + .getViewer().getSelection()).getFirstElement(); + if (selectedObject instanceof TaskCategory) { + newTask.setCategory((TaskCategory) selectedObject); + ((TaskCategory) selectedObject).addTask(newTask); + } else { + MylarTasklistPlugin.getTaskListManager().addRootTask(newTask); + } +// MylarUiPlugin.getDefault().setHighlighterMapping( +// newTask.getHandle(), +// MylarUiPlugin.getDefault().getDefaultHighlighter().getName()); + this.view.getViewer().refresh(); + } } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/DateChooserDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/DateChooserDialog.java new file mode 100644 index 000000000..8f484a14b --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/DateChooserDialog.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2005 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.tasklist.ui.views; + +import java.util.Date; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Ken Sueda + */ +public class DateChooserDialog extends Dialog { + +// private DatePicker picker = null; + private Date reminderDate = null; + + public DateChooserDialog(Shell parentShell) { + super(parentShell); + } + +// protected Control createDialogArea(Composite parent) { +// Composite composite = (Composite) super.createDialogArea(parent); +// GridLayout gl = new GridLayout(1, false); +// composite.setLayout(gl); +// GridData data = new GridData(GridData.FILL_BOTH); +// +// picker = new DatePicker(composite, SWT.NONE); +// data.heightHint = 90; // HACK +// picker.setLayoutData(data); +// return composite; +// } +// +// protected void buttonPressed(int buttonId) { +// if (buttonId == IDialogConstants.OK_ID) { +// reminderDate = picker.getDate(); +// } else { +// } +// super.buttonPressed(buttonId); +// } + + public Date getReminderDate() { + return reminderDate; + } +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskInputDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskInputDialog.java new file mode 100644 index 000000000..e1988f469 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskInputDialog.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2005 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.tasklist.ui.views; + +import java.util.Date; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** + * @author Ken Sueda + */ +public class TaskInputDialog extends Dialog { + + private String taskName = ""; + private String priority = "P3"; + private Date reminderDate = null; + private Text text; + + public TaskInputDialog(Shell parentShell) { + super(parentShell); + } + + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + GridLayout gl = new GridLayout(4, false); + composite.setLayout(gl); + GridData data = new GridData(GridData.GRAB_HORIZONTAL + | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL + | GridData.VERTICAL_ALIGN_CENTER); + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + composite.setLayoutData(data); + + Label label = new Label(composite, SWT.WRAP); + label.setText("Task name:"); + label.setFont(parent.getFont()); + + text = new Text(composite, SWT.SINGLE | SWT.BORDER); + text.setLayoutData(data); + text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL + | GridData.HORIZONTAL_ALIGN_FILL)); + + final Combo c = new Combo(composite, SWT.NO_BACKGROUND | SWT.MULTI + | SWT.V_SCROLL | SWT.READ_ONLY | SWT.DROP_DOWN); + c.setItems(TaskListView.PRIORITY_LEVELS); + c.setText(priority); + c.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + priority = c.getText(); + } + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + }); + + Button button = new Button(composite, SWT.PUSH); + button.setText("Remind me"); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { +// DateChooserDialog dialog = new DateChooserDialog(Workbench.getInstance().getActiveWorkbenchWindow().getShell()); +// dialog.open(); +// reminderDate = dialog.getReminderDate(); + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + return composite; + } + + public String getSelectedPriority() { + return priority; + } + + public String getTaskname() { + return taskName; + } + + public Date getReminderDate() { + return reminderDate; + } + + protected void buttonPressed(int buttonId) { + if (buttonId == IDialogConstants.OK_ID) { + taskName = text.getText(); + } else { + taskName = null; + } + super.buttonPressed(buttonId); + } + + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText("Enter Task Name"); + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java index 97e121d0f..f73edb93b 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java @@ -26,8 +26,6 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.CellEditor; @@ -84,15 +82,9 @@ import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; @@ -150,7 +142,7 @@ public class TaskListView extends ViewPart { public static final String tableSortIdentifier = "org.eclipse.mylar.tasklist.ui.views.tasklist.sortIndex"; private int sortIndex = 2; - private static String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" }; + public static String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" }; private TaskActivationHistory taskHistory = new TaskActivationHistory(); @@ -448,7 +440,8 @@ public class TaskListView extends ViewPart { } private List<Object> getFilteredChildrenFor(Object parent) { - if (((Text) tree.getFilterControl()).getText() == "") { + if (((Text) tree.getFilterControl()).getText() == "" + || ((Text) tree.getFilterControl()).getText().startsWith("type filter")) { List<Object> children = new ArrayList<Object>(); if (parent instanceof AbstractCategory) { List<? extends ITaskListElement> list = ((AbstractCategory) parent) @@ -772,7 +765,7 @@ public class TaskListView extends ViewPart { @Override public void createPartControl(Composite parent) { tree = new FilteredTree(parent, SWT.VERTICAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION, new TaskListPatternFilter()); - ((Text)tree.getFilterControl()).setText("type filter text here"); + ((Text)tree.getFilterControl()).setText("<filter>"); getViewer().getTree().setHeaderVisible(true); getViewer().getTree().setLinesVisible(true); getViewer().setColumnProperties(columnNames); @@ -1158,35 +1151,35 @@ public class TaskListView extends ViewPart { } } - public String[] getLabelPriorityFromUser(String kind) { - String[] result = new String[2]; - Dialog dialog = null; - boolean isTask = kind.equals("task"); - if (isTask) { - dialog = new TaskInputDialog( - Workbench.getInstance().getActiveWorkbenchWindow().getShell()); - } else { - dialog = new InputDialog( - Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Enter name", - "Enter a name for the " + kind + ": ", - "", - null); - } - - int dialogResult = dialog.open(); - if (dialogResult == Window.OK) { - if (isTask) { - result[0] = ((TaskInputDialog)dialog).getTaskname(); - result[1] = ((TaskInputDialog)dialog).getSelectedPriority(); - } else { - result[0] = ((InputDialog)dialog).getValue(); - } - return result; - } else { - return null; - } - } +// public String[] getLabelPriorityFromUser(String kind) { +// String[] result = new String[2]; +// Dialog dialog = null; +// boolean isTask = kind.equals("task"); +// if (isTask) { +// dialog = new TaskInputDialog( +// Workbench.getInstance().getActiveWorkbenchWindow().getShell()); +// } else { +// dialog = new InputDialog( +// Workbench.getInstance().getActiveWorkbenchWindow().getShell(), +// "Enter name", +// "Enter a name for the " + kind + ": ", +// "", +// null); +// } +// +// int dialogResult = dialog.open(); +// if (dialogResult == Window.OK) { +// if (isTask) { +// result[0] = ((TaskInputDialog)dialog).getTaskname(); +// result[1] = ((TaskInputDialog)dialog).getSelectedPriority(); +// } else { +// result[0] = ((InputDialog)dialog).getValue(); +// } +// return result; +// } else { +// return null; +// } +// } public void notifyTaskDataChanged(ITask task) { if (getViewer().getTree() != null && !getViewer().getTree().isDisposed()) { @@ -1214,70 +1207,70 @@ public class TaskListView extends ViewPart { return PRIORITY_FILTER; } - public class TaskInputDialog extends Dialog { - private String taskName = ""; - private String priority = "P3"; - private Text text; - public TaskInputDialog(Shell parentShell) { - super(parentShell); - } - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite)super.createDialogArea(parent); - GridLayout gl = new GridLayout(3, false); - composite.setLayout(gl); - GridData data = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL - | GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - composite.setLayoutData(data); - - - Label label = new Label(composite, SWT.WRAP); - label.setText("Task name:"); - label.setFont(parent.getFont()); - - text = new Text(composite, SWT.SINGLE | SWT.BORDER); - text.setLayoutData(data); - text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_FILL)); - - - final Combo c = new Combo(composite, SWT.NO_BACKGROUND - | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY | SWT.DROP_DOWN); - c.setItems(PRIORITY_LEVELS); - c.setText(priority); - c.addSelectionListener(new SelectionListener() { - - public void widgetSelected(SelectionEvent e) { - priority = c.getText(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - label = new Label(composite, SWT.NONE); - return composite; - } - public String getSelectedPriority() { - return priority; - } - public String getTaskname() { - return taskName; - } - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.OK_ID) { - taskName = text.getText(); - } else { - taskName = null; - } - super.buttonPressed(buttonId); - } - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText("Enter Task Name"); - } - } +// public class TaskInputDialog extends Dialog { +// private String taskName = ""; +// private String priority = "P3"; +// private Text text; +// public TaskInputDialog(Shell parentShell) { +// super(parentShell); +// } +// protected Control createDialogArea(Composite parent) { +// Composite composite = (Composite)super.createDialogArea(parent); +// GridLayout gl = new GridLayout(3, false); +// composite.setLayout(gl); +// GridData data = new GridData(GridData.GRAB_HORIZONTAL +// | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL +// | GridData.VERTICAL_ALIGN_CENTER); +// data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); +// composite.setLayoutData(data); +// +// +// Label label = new Label(composite, SWT.WRAP); +// label.setText("Task name:"); +// label.setFont(parent.getFont()); +// +// text = new Text(composite, SWT.SINGLE | SWT.BORDER); +// text.setLayoutData(data); +// text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL +// | GridData.HORIZONTAL_ALIGN_FILL)); +// +// +// final Combo c = new Combo(composite, SWT.NO_BACKGROUND +// | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY | SWT.DROP_DOWN); +// c.setItems(PRIORITY_LEVELS); +// c.setText(priority); +// c.addSelectionListener(new SelectionListener() { +// +// public void widgetSelected(SelectionEvent e) { +// priority = c.getText(); +// } +// +// public void widgetDefaultSelected(SelectionEvent e) { +// widgetSelected(e); +// } +// }); +// label = new Label(composite, SWT.NONE); +// return composite; +// } +// public String getSelectedPriority() { +// return priority; +// } +// public String getTaskname() { +// return taskName; +// } +// protected void buttonPressed(int buttonId) { +// if (buttonId == IDialogConstants.OK_ID) { +// taskName = text.getText(); +// } else { +// taskName = null; +// } +// super.buttonPressed(buttonId); +// } +// protected void configureShell(Shell shell) { +// super.configureShell(shell); +// shell.setText("Enter Task Name"); +// } +// } private void fillLocalToolBar(IToolBarManager manager) { manager.removeAll(); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/ToolTipHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/ToolTipHandler.java index 26f5c802f..be7fa7904 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/ToolTipHandler.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/ToolTipHandler.java @@ -17,10 +17,25 @@ package org.eclipse.mylar.tasklist.ui.views; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.mylar.tasklist.ITask; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.events.HelpEvent; +import org.eclipse.swt.events.HelpListener; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseTrackAdapter; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.Widget; public class ToolTipHandler { |