Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-06-20 17:08:21 -0400
committermkersten2005-06-20 17:08:21 -0400
commit28cd3239ff0e182c6b8596d7ddd2a18879adcf98 (patch)
tree61abf228abc6ecbcd276bc7839616b2936439078
parentdecd09f35b89d0cd70579011734d8f46eca6354b (diff)
downloadorg.eclipse.mylyn.tasks-28cd3239ff0e182c6b8596d7ddd2a18879adcf98.tar.gz
org.eclipse.mylyn.tasks-28cd3239ff0e182c6b8596d7ddd2a18879adcf98.tar.xz
org.eclipse.mylyn.tasks-28cd3239ff0e182c6b8596d7ddd2a18879adcf98.zip
patch for bug 100915: make task # associations more robust
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java17
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java46
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java292
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java83
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java18
9 files changed, 343 insertions, 138 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java
index 22662d2cf..9b88603b5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java
@@ -16,6 +16,7 @@ package org.eclipse.mylar.tasks;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import javax.security.auth.login.LoginException;
@@ -29,6 +30,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylar.bugzilla.BugzillaPlugin;
+import org.eclipse.mylar.bugzilla.core.Attribute;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
@@ -311,11 +313,22 @@ public class BugzillaTask extends Task {
notifyTaskDataChange();
// Update time this bugtask was last downloaded.
lastRefresh = new Date();
- bugReport = downloadReport();
- state = BugTaskState.FREE;
+ bugReport = downloadReport();
+ state = BugTaskState.FREE;
+ updateTaskDetails();
notifyTaskDataChange();
saveBugReport(true);
return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null);
+ }
+ }
+
+ public void updateTaskDetails() {
+ for (Iterator<Attribute> it = bugReport.getAttributes().iterator(); it.hasNext();) {
+ Attribute attribute = it.next();
+ String key = attribute.getParameterName();
+ if (key != null &&key.equals("priority")) {
+ System.out.println(attribute.getValue());
+ }
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
index 1ade911a3..ff9abb0c5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
@@ -78,6 +78,11 @@ public interface ITask extends Serializable {
public abstract List<ITask> getSubTasksInProgress();
+ public abstract List<ITask> getCompletedSubTasks();
+
+ public abstract boolean hasCompletedSubTasks();
+
+ public abstract int findLargestTaskHandle();
/**
* Opens this task in an editor
*/
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
index 7702f8e97..440344269 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
@@ -303,4 +303,50 @@ public class Task implements ITask {
}
return complete;
}
+
+ public boolean hasCompletedSubTasks() {
+ return findCompletedSubtask(getChildren());
+ }
+
+ private boolean findCompletedSubtask(List<ITask> subtasks) {
+ for(ITask t : subtasks) {
+ if (t.isCompleted()) {
+ return true;
+ }
+ findCompletedSubtask(t.getChildren());
+ }
+ return false;
+ }
+
+ public int findLargestTaskHandle() {
+ int ihandle = 0;
+ if (this instanceof BugzillaTask) {
+ ihandle = 0;
+ } else {
+ ihandle = Integer.parseInt(this.handle.substring(handle.indexOf('-')+1, handle.length()));
+ }
+ int maxSub = findLargestSubTaskHandle(getChildren());
+ return maxSub > ihandle ? maxSub : ihandle;
+ }
+
+ private int findLargestSubTaskHandle(List<ITask> tasks) {
+ int ihandle = 0;
+ int maxHandle = 0;
+ for (ITask t : tasks) {
+ if (t instanceof BugzillaTask) {
+ ihandle = 0;
+ } else {
+ ihandle = Integer.parseInt(t.getHandle().substring(t.getHandle().indexOf('-')+1, t.getHandle().length()));
+ }
+
+ if (ihandle > maxHandle) {
+ maxHandle = ihandle;
+ }
+ int maxSub = findLargestSubTaskHandle(t.getChildren());
+ if (maxSub > maxHandle) {
+ maxHandle = maxSub;
+ }
+ }
+ return maxHandle;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
index cd3529701..4afb10a0f 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
@@ -131,8 +131,20 @@ public class TaskList implements Serializable {
for (ITask task : rootTasks) {
if (task.isCompleted()) {
complete.add(task);
+ } else if (task.hasCompletedSubTasks()) {
+ complete.add(task);
}
}
return complete;
}
+ public int findLargestTaskHandle() {
+ int max = 0;
+ for (ITask t : rootTasks) {
+ int maxSub = t.findLargestTaskHandle();
+ if (maxSub > max) {
+ max = maxSub;
+ }
+ }
+ return max;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java
index 93ace114e..ff6763c14 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java
@@ -53,6 +53,10 @@ public class TaskListManager {
try {
if (file.exists()) {
XmlUtil.readTaskList(taskList, file);
+ int maxHandle = taskList.findLargestTaskHandle();
+ if (maxHandle > nextTaskId) {
+ nextTaskId = maxHandle + 1;
+ }
for (ITaskActivityListener listener : listeners) listener.tasksActivated(taskList.getActiveTasks());
}
return true;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java
index 9b26348cf..dc196f992 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskEditor.java
@@ -16,7 +16,6 @@ package org.eclipse.mylar.tasks.ui;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -57,8 +56,7 @@ public class TaskEditor extends MultiPageEditorPart {
*/
private void createTaskSummaryPage() {
taskSummaryEditor.createPartControl(getContainer());
- Composite composite = taskSummaryEditor.getEditorComposite();
- int index = addPage(composite);
+ int index = addPage(taskSummaryEditor.getControl());
setPageText(index, "Summary");
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java
index d4673c949..e7e7e448e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java
@@ -18,8 +18,13 @@ package org.eclipse.mylar.tasks.ui;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CellEditor;
@@ -37,9 +42,12 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.ITaskActivityListener;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.RelatedLinks;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
import org.eclipse.mylar.tasks.util.RelativePathUtil;
+import org.eclipse.mylar.ui.MylarImages;
import org.eclipse.mylar.ui.MylarUiPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
@@ -55,9 +63,11 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
@@ -69,8 +79,11 @@ import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
@@ -80,6 +93,8 @@ import org.eclipse.ui.internal.browser.WorkbenchBrowserSupport;
import org.eclipse.ui.part.EditorPart;
/**
+ * For details on forms, go to:
+ * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/pde-ui-home/working/EclipseForms/EclipseForms.html
* @author Ken Sueda
*/
public class TaskSummaryEditor extends EditorPart {
@@ -99,9 +114,34 @@ public class TaskSummaryEditor extends EditorPart {
private TableViewer tableViewer;
private RelatedLinks links;
private RelatedLinksContentProvider contentProvider;
-
+
+ private Button browse;
private Text pathText;
+ private ScrolledForm sform;
+ private Action add;
+ private Action delete;
+
+ private ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {
+
+ public void taskActivated(ITask activeTask) {
+ if (activeTask.getHandle().equals(task.getHandle())) {
+ browse.setEnabled(false);
+ }
+ }
+
+ public void tasksActivated(List<ITask> tasks) {
+ for (ITask t : tasks) {
+ taskActivated(t);
+ }
+ }
+ public void taskDeactivated(ITask deactiveTask) {
+ if (deactiveTask.getHandle().equals(task.getHandle())) {
+ browse.setEnabled(true);
+ }
+ }
+
+ };
/**
*
*/
@@ -146,17 +186,16 @@ public class TaskSummaryEditor extends EditorPart {
copyAction.setAccelerator(SWT.CTRL | 'c');
copyAction.setEnabled(false);
+ MylarTasksPlugin.getTaskListManager().addListener(TASK_LIST_LISTENER);
}
@Override
public void doSave(IProgressMonitor monitor) {
// don't support saving
}
-
@Override
public void doSaveAs() {
// don't support saving
}
-
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
if (!(input instanceof TaskEditorInput)) {
@@ -167,12 +206,10 @@ public class TaskSummaryEditor extends EditorPart {
editorInput = (TaskEditorInput)input;
setPartName(editorInput.getLabel());
}
-
@Override
public boolean isDirty() {
return false;
}
-
@Override
public boolean isSaveAsAllowed() {
return false;
@@ -184,7 +221,9 @@ public class TaskSummaryEditor extends EditorPart {
// FormToolkit toolkit = form.getToolkit();
// editorComposite = form.getForm();
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
- editorComposite = toolkit.createComposite(parent);
+ sform = toolkit.createScrolledForm(parent);
+ sform.getBody().setLayout(new TableWrapLayout());
+ editorComposite = sform.getBody();
TableWrapLayout layout = new TableWrapLayout();
@@ -215,6 +254,10 @@ public class TaskSummaryEditor extends EditorPart {
return editorComposite;
}
+ public Control getControl() {
+ return sform;
+ }
+
public void setTask(ITask task) throws Exception {
if (task == null)
throw new Exception("ITask object is null.");
@@ -245,17 +288,28 @@ public class TaskSummaryEditor extends EditorPart {
Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
section.setText("Mylar Task Description");
section.setLayout(new TableWrapLayout());
- section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.addExpansionListener(new IExpansionListener() {
+ public void expansionStateChanging(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ public void expansionStateChanged(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ });
+
Composite container = toolkit.createComposite(section);
section.setClient(container);
TableWrapLayout layout = new TableWrapLayout();
- layout.numColumns = 2;
+ layout.numColumns = 3;
container.setLayout(layout);
Label l = toolkit.createLabel(container, "Description:");
l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
final Text text = toolkit.createText(container,task.getLabel(), SWT.BORDER);
- text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
+ td.colspan = 2;
+ text.setLayoutData(td);
text.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
// don't care about focus gained
@@ -264,37 +318,26 @@ public class TaskSummaryEditor extends EditorPart {
public void focusLost(FocusEvent e) {
String label = text.getText();
task.setLabel(label);
- refreshViewer();
+ refreshTaskListView();
}
});
l = toolkit.createLabel(container, "Task Handle:");
l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
Text handle = toolkit.createText(container, task.getHandle(), SWT.BORDER);
- handle.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ td = new TableWrapData(TableWrapData.FILL_GRAB);
+ td.colspan = 2;
+ handle.setLayoutData(td);
handle.setEditable(false);
-
-
- Composite taskContextContainer = toolkit.createComposite(parent);
- layout = new TableWrapLayout();
- layout.numColumns = 3;
- taskContextContainer.setLayout(layout);
- taskContextContainer.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+
-
- // TODO: fix the form so it looks better.
- l = toolkit.createLabel(taskContextContainer, "To change the Mylar_Dir, go to Mylar Preferences");
- l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
- td.colspan = 3;
- l.setLayoutData(td);
- Label l2 = toolkit.createLabel(taskContextContainer, "Task context path:");
+ Label l2 = toolkit.createLabel(container, "Task context path:");
l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- pathText = toolkit.createText(taskContextContainer, "<Mylar_Dir>/"+task.getPath()+".xml", SWT.BORDER);
+ pathText = toolkit.createText(container, "<Mylar_Dir>/"+task.getPath()+".xml", SWT.BORDER);
pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
pathText.setEditable(false);
- Button browse = toolkit.createButton(taskContextContainer, "Change", SWT.PUSH | SWT.CENTER);
+ browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER);
if (task.isActive()) {
browse.setEnabled(false);
} else {
@@ -304,24 +347,40 @@ public class TaskSummaryEditor extends EditorPart {
@Override
public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
- String[] ext = {"*.xml"};
- dialog.setFilterExtensions(ext);
-
- String mylarDir = MylarPlugin.getTaskscapeManager().getMylarDir() + "/";
- mylarDir = mylarDir.replaceAll("\\\\", "/");
- //mylarDir = formatPath(mylarDir);
- dialog.setFilterPath(formatPath(mylarDir));
-
- String res = dialog.open();
- if (res != null) {
- res = formatPath(res);
- res = RelativePathUtil.findRelativePath(mylarDir, res);
- pathText.setText("<MylarDir>/" + res + ".xml");
- task.setPath(res);
+ if (task.isActive()) {
+ MessageDialog.openInformation(
+ Display.getDefault().getActiveShell(),
+ "Task Message",
+ "Task can not be active when changing taskscape");
+ } else {
+ FileDialog dialog = new FileDialog(Display.getDefault()
+ .getActiveShell(), SWT.OPEN);
+ String[] ext = { "*.xml" };
+ dialog.setFilterExtensions(ext);
+
+ String mylarDir = MylarPlugin.getTaskscapeManager()
+ .getMylarDir()
+ + "/";
+ mylarDir = mylarDir.replaceAll("\\\\", "/");
+ // mylarDir = formatPath(mylarDir);
+ dialog.setFilterPath(formatPath(mylarDir));
+
+ String res = dialog.open();
+ if (res != null) {
+ res = formatPath(res);
+ res = RelativePathUtil.findRelativePath(mylarDir, res);
+ pathText.setText("<MylarDir>/" + res + ".xml");
+ task.setPath(res);
+ }
}
}
});
+ toolkit.createLabel(container, "");
+ l = toolkit.createLabel(container, "Go to Mylar Preferences to change <Mylar_Dir>");
+ l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+// td = new TableWrapData(TableWrapData.FILL_GRAB);
+// td.colspan = ;
+// l.setLayoutData(td);
}
private String formatPath(String path) {
@@ -342,14 +401,23 @@ public class TaskSummaryEditor extends EditorPart {
Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
section.setText("Notes");
section.setLayout(new TableWrapLayout());
- section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.addExpansionListener(new IExpansionListener() {
+ public void expansionStateChanging(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+
+ public void expansionStateChanged(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ });
Composite container = toolkit.createComposite(section);
section.setClient(container);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
container.setLayout(layout);
- final Text text = toolkit.createText(container, task.getNotes(), SWT.BORDER);
+ final Text text = toolkit.createText(container, task.getNotes(), SWT.BORDER | SWT.MULTI);
TableWrapData tablewrap = new TableWrapData(TableWrapData.FILL_GRAB);
tablewrap.heightHint = 100;
text.setLayoutData(tablewrap);
@@ -369,7 +437,16 @@ public class TaskSummaryEditor extends EditorPart {
Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
section.setText("Planning Game");
section.setLayout(new TableWrapLayout());
- section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.addExpansionListener(new IExpansionListener() {
+ public void expansionStateChanging(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+
+ public void expansionStateChanged(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ });
Composite container = toolkit.createComposite(section);
section.setClient(container);
TableWrapLayout layout = new TableWrapLayout();
@@ -401,15 +478,23 @@ public class TaskSummaryEditor extends EditorPart {
}
private void createRelatedLinksSection(Composite parent, FormToolkit toolkit) {
- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
+ Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
section.setText("Related Links");
section.setLayout(new TableWrapLayout());
section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.addExpansionListener(new IExpansionListener() {
+ public void expansionStateChanging(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+
+ public void expansionStateChanged(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ });
Composite container = toolkit.createComposite(section);
section.setClient(container);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
-
container.setLayout(layout);
Label l = toolkit.createLabel(container, "Related Links:");
@@ -426,14 +511,14 @@ public class TaskSummaryEditor extends EditorPart {
table = toolkit.createTable(parent, SWT.NONE );
TableColumn col1 = new TableColumn(table, SWT.NULL);
TableLayout tlayout = new TableLayout();
- tlayout.addColumnData(new ColumnWeightData(200, 20, true));
+ tlayout.addColumnData(new ColumnWeightData(0,0,false));
table.setLayout(tlayout);
TableWrapData wd = new TableWrapData(TableWrapData.FILL_GRAB);
+ wd.heightHint = 100;
wd.grabVertical = true;
- wd.heightHint = 100;
- table.setLayoutData(wd);
- col1.addSelectionListener(new SelectionAdapter() {
-
+ table.setLayoutData(wd);
+ table.setHeaderVisible(false);
+ col1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableViewer.setSorter(new RelatedLinksTableSorter(
@@ -467,11 +552,10 @@ public class TaskSummaryEditor extends EditorPart {
tableViewer = new TableViewer(table);
tableViewer.setColumnProperties(columnNames);
- //CellEditor[] editors = new CellEditor[columnNames.length];
CellEditor[] editors = new CellEditor[columnNames.length];
TextCellEditor textEditor = new TextCellEditor(table);
- ((Text) textEditor.getControl()).setTextLimit(20);
+ ((Text) textEditor.getControl()).setTextLimit(50);
((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT);
editors[0] = textEditor;
@@ -482,47 +566,33 @@ public class TaskSummaryEditor extends EditorPart {
tableViewer.setLabelProvider(new RelatedLinksLabelProvider());
links = task.getRelatedLinks();
tableViewer.setInput(links);
+ defineActions();
+ hookContextMenu();
}
private void createAddDeleteButtons(Composite parent, FormToolkit toolkit) {
Composite container = toolkit.createComposite(parent);
container.setLayout(new GridLayout(1, true));
- Button add = toolkit.createButton(container, "Add", SWT.PUSH | SWT.CENTER);
- add.addSelectionListener(new SelectionAdapter() {
-
+ Button addButton = toolkit.createButton(container, " Add ", SWT.PUSH | SWT.CENTER);
+ //add.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- InputDialog dialog = new InputDialog(Display.getDefault().getActiveShell(), "New related link",
- "Enter new related link for this task", "", null);
- dialog.open();
- String url = null;
- String link = dialog.getValue();
- if (!(link.startsWith("http://") || link.startsWith("https://"))) {
- url = "http://" + link;
- } else {
- url = link;
- }
- links.add(url);
- tableViewer.add(url);
+ addLink();
}
});
- Button delete = toolkit.createButton(container, "Delete", SWT.PUSH | SWT.CENTER);
- delete.setText("Delete");
-
- delete.addSelectionListener(new SelectionAdapter() {
+ Button deleteButton = toolkit.createButton(container, "Delete", SWT.PUSH | SWT.CENTER);
+ deleteButton.setText("Delete");
+ //delete.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ deleteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- String url = (String) ((IStructuredSelection) tableViewer
- .getSelection()).getFirstElement();
- if (url != null) {
- links.remove(url);
- tableViewer.remove(url);
- }
+ removeLink();
}
});
}
- private void refreshViewer() {
+ private void refreshTaskListView() {
if (TaskListView.getDefault() != null) TaskListView.getDefault().notifyTaskDataChanged();
}
private class RelatedLinksCellModifier implements ICellModifier, IColorProvider {
@@ -536,6 +606,7 @@ public class TaskSummaryEditor extends EditorPart {
public Object getValue(Object element, String property) {
Object res = null;
if (element instanceof String) {
+ tableViewer.setSelection(null);
String url = (String) element;
try {
IWebBrowser b = null;
@@ -655,6 +726,65 @@ public class TaskSummaryEditor extends EditorPart {
}
}
+ private void addLink() {
+ InputDialog dialog = new InputDialog(Display.getDefault().getActiveShell(), "New related link",
+ "Enter new related link for this task", "", null);
+ dialog.open();
+ String url = null;
+ String link = dialog.getValue();
+ if (!(link.startsWith("http://") || link.startsWith("https://"))) {
+ url = "http://" + link;
+ } else {
+ url = link;
+ }
+ links.add(url);
+ tableViewer.add(url);
+ }
+
+ private void removeLink() {
+ String url = (String) ((IStructuredSelection) tableViewer
+ .getSelection()).getFirstElement();
+ if (url != null) {
+ links.remove(url);
+ tableViewer.remove(url);
+ }
+ }
+ private void defineActions() {
+ delete = new Action() {
+ @Override
+ public void run() {
+ removeLink();
+ }
+ };
+ delete.setText("Delete");
+ delete.setToolTipText("Delete");
+ delete.setImageDescriptor(MylarImages.REMOVE);
+
+ add = new Action() {
+ @Override
+ public void run() {
+ addLink();
+ }
+ };
+ add.setText("Add");
+ add.setToolTipText("Add");
+ //add.setImageDescriptor(MylarImages.REMOVE);
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ manager.add(add);
+ manager.add(delete);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
+ tableViewer.getControl().setMenu(menu);
+ //getSite().registerContextMenu(menuMgr, tableViewer);
+ }
+
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
index d3beafdc5..0ba2b1512 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
@@ -44,8 +44,6 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.Window;
import org.eclipse.mylar.core.ITaskscapeListener;
import org.eclipse.mylar.core.MylarPlugin;
-import org.eclipse.mylar.core.model.ITaskscape;
-import org.eclipse.mylar.core.model.ITaskscapeNode;
import org.eclipse.mylar.dt.MylarWebRef;
import org.eclipse.mylar.tasks.BugzillaTask;
import org.eclipse.mylar.tasks.Category;
@@ -157,30 +155,6 @@ public class TaskListView extends ViewPart {
}
}
- private final ITaskscapeListener FILTER_LISTENER = new ITaskscapeListener() {
- public void interestChanged(ITaskscapeNode info) {}
- public void interestChanged(List<ITaskscapeNode> nodes) {}
- public void taskscapeActivated(ITaskscape taskscape) {}
- public void taskscapeDeactivated(ITaskscape taskscape) {}
- public void nodeDeleted(ITaskscapeNode node) {}
- public void landmarkAdded(ITaskscapeNode element) {}
- public void landmarkRemoved(ITaskscapeNode element) {}
- public void relationshipsChanged() {}
- public void presentationSettingsChanged(UpdateKind kind) {
- refresh();
- }
- public void presentationSettingsChanging(UpdateKind kind) {
- refresh();
- }
-
- private void refresh() {
- if (viewer != null && !viewer.getTree().isDisposed()) {
- viewer.refresh();
- setCheckedState(viewer.getTree().getItems());
- }
- }
- };
-
class TaskListContentProvider implements IStructuredContentProvider, ITreeContentProvider {
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
// don't care if the input changes
@@ -190,11 +164,20 @@ public class TaskListView extends ViewPart {
}
public Object[] getElements(Object parent) {
if (parent.equals(getViewSite())) {
- if (MylarUiPlugin.getDefault().isGlobalFilteringEnabled()) {
- return MylarTasksPlugin.getTaskListManager().getTaskList().getTasksInProgress().toArray();
+ if (MylarUiPlugin.getDefault().isFilterCompleteMode()) {
+ // don't show completed tasks
+ if (!MylarUiPlugin.getDefault().isFilterInCompleteMode()) {
+ return MylarTasksPlugin.getTaskListManager().getTaskList().getTasksInProgress().toArray();
+ }
} else {
- return MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks().toArray();
- }
+ if (MylarUiPlugin.getDefault().isFilterInCompleteMode()) {
+ // show only completed tasks
+ return MylarTasksPlugin.getTaskListManager().getTaskList().getCompletedTasks().toArray();
+ } else {
+ // show all tasks
+ return MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks().toArray();
+ }
+ }
}
return getChildren(parent);
}
@@ -206,11 +189,19 @@ public class TaskListView extends ViewPart {
}
public Object [] getChildren(Object parent) {
if (parent instanceof ITask) {
- if (MylarUiPlugin.getDefault().isGlobalFilteringEnabled()) {
- return ((ITask)parent).getSubTasksInProgress().toArray();
+ if (MylarUiPlugin.getDefault().isFilterCompleteMode()) {
+ if (!MylarUiPlugin.getDefault().isFilterInCompleteMode()) {
+ return ((ITask)parent).getSubTasksInProgress().toArray();
+ }
} else {
- return ((ITask)parent).getChildren().toArray();
- }
+ if (MylarUiPlugin.getDefault().isFilterInCompleteMode()) {
+ // show only completed tasks
+ return ((ITask)parent).getCompletedSubTasks().toArray();
+ } else {
+ // show all tasks
+ return ((ITask)parent).getChildren().toArray();
+ }
+ }
}
return new Object[0];
}
@@ -225,7 +216,6 @@ public class TaskListView extends ViewPart {
public TaskListView() {
INSTANCE = this;
- MylarPlugin.getTaskscapeManager().addListener(FILTER_LISTENER);
}
class TaskListCellModifier implements ICellModifier {
@@ -426,7 +416,6 @@ public class TaskListView extends ViewPart {
}
}
}
-
public void controlMoved(ControlEvent e) {
// don't care if the control is moved
}
@@ -459,7 +448,8 @@ public class TaskListView extends ViewPart {
ToolTipHandler toolTipHandler = new ToolTipHandler(viewer.getControl().getShell());
toolTipHandler.activateHoverHelp(viewer.getControl());
- initDragAndDrop(parent);
+ initDragAndDrop(parent);
+ expandToActiveTasks();
restoreState();
}
@@ -528,16 +518,11 @@ public class TaskListView extends ViewPart {
});
}
- private void setCheckedState(TreeItem[] items) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- if (item.getData() instanceof Task) {
- item.setChecked(((Task)item.getData()).isCompleted());
- } else if (item.getData() instanceof Category) {
- item.setGrayed(true);
- }
- setCheckedState(item.getItems());
- }
+ private void expandToActiveTasks() {
+ List<ITask> activeTasks = MylarTasksPlugin.getTaskListManager().getTaskList().getActiveTasks();
+ for (ITask t : activeTasks) {
+ viewer.expandToLevel(t, 0);
+ }
}
private void hookContextMenu() {
@@ -841,6 +826,7 @@ public class TaskListView extends ViewPart {
filterCompleteTask.setText("Filter Complete tasks");
filterCompleteTask.setToolTipText("Filter Completed tasks");
filterCompleteTask.setImageDescriptor(MylarImages.TASK_ACTIVE);
+ filterCompleteTask.setChecked(MylarUiPlugin.getDefault().isFilterCompleteMode());
filterInCompleteTask = new Action() {
@Override
@@ -851,7 +837,8 @@ public class TaskListView extends ViewPart {
};
filterInCompleteTask.setText("Filter Incomplete tasks");
filterInCompleteTask.setToolTipText("Filter Incomplete tasks");
- filterInCompleteTask.setImageDescriptor(MylarImages.TASK_INACTIVE);
+ filterInCompleteTask.setImageDescriptor(MylarImages.TASK_INACTIVE);
+ filterInCompleteTask.setChecked(MylarUiPlugin.getDefault().isFilterInCompleteMode());
}
/**
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
index 63e655f00..45f26a060 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
@@ -189,10 +189,16 @@ public class XmlUtil {
node.setAttribute("Notes", t.getNotes());
node.setAttribute("Elapsed", t.getElapsedTime());
node.setAttribute("Estimated", t.getEstimatedTime());
+ List<String> rl = t.getRelatedLinks().getLinks();
+ int i = 0;
+ for (String link : rl) {
+ node.setAttribute("link"+i, link);
+ i++;
+ }
List<ITask> children = t.getChildren();
- int i = 0;
+ i = 0;
for (i = 0; i < children.size(); i++) {
writeTask(children.get(i), doc, node);
}
@@ -333,15 +339,19 @@ public class XmlUtil {
} else {
t.setEstimatedTime("");
}
+
+ int i = 0;
+ while (e.hasAttribute("link"+i)) {
+ t.getRelatedLinks().add(e.getAttribute("link"+i));
+ i++;
+ }
if (!readVersion.equals("1.0.0")) {
// for newer revisions
// XXX: readVersion had to be read once to remove warning..
}
- // Recursively read subtask and add to root task
- //
- int i = 0;
+ i = 0;
NodeList list = e.getChildNodes();
for (i = 0; i < list.getLength(); i++) {
Node child = list.item(i);

Back to the top