summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-09-23 23:38:56 (EDT)
committerSteffen Pingel2012-09-23 23:38:56 (EDT)
commit3f5048053279a0b69ec70deba5a3e4a06a4ee467 (patch)
treecc6f47a061d59821f2a556431f295eed21060796
parent60c1f836e5271b7a2eaa8b64f2bc4b3c2dd824e3 (diff)
downloadorg.eclipse.mylyn.tasks-3f5048053279a0b69ec70deba5a3e4a06a4ee467.zip
org.eclipse.mylyn.tasks-3f5048053279a0b69ec70deba5a3e4a06a4ee467.tar.gz
org.eclipse.mylyn.tasks-3f5048053279a0b69ec70deba5a3e4a06a4ee467.tar.bz2
389674: [activity] editor comes up with broken activity section whenrefs/changes/82/7782/3
creating new tasks Change-Id: If5492d95d51bc518890f10974aee2aa64aab6b0e Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=389674
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java19
-rw-r--r--org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java6
-rw-r--r--org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java48
3 files changed, 44 insertions, 29 deletions
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
index 3c97d4a..20cf16b 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
@@ -25,6 +25,7 @@ import org.eclipse.mylyn.tasks.activity.core.TaskActivityScope;
import org.eclipse.mylyn.tasks.activity.core.spi.ActivityProvider;
import org.eclipse.mylyn.tasks.activity.core.spi.IActivitySession;
import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.osgi.util.NLS;
/**
* @author Steffen Pingel
@@ -46,14 +47,16 @@ public class TaskActivityProvider extends ActivityProvider {
public void query(ActivityScope scope, IProgressMonitor monitor) throws CoreException {
if (scope instanceof TaskActivityScope) {
ITask scopeTask = ((TaskActivityScope) scope).getTask();
-
- GetAssociatedTasks collector = new GetAssociatedTasks(session);
- IndexReference reference = new IndexReference();
- try {
- TaskListIndex taskListIndex = reference.index();
- taskListIndex.find(scopeTask.getTaskKey(), collector, 50);
- } finally {
- reference.dispose();
+ String url = scopeTask.getUrl();
+ if (url != null) {
+ GetAssociatedTasks collector = new GetAssociatedTasks(session);
+ IndexReference reference = new IndexReference();
+ try {
+ TaskListIndex taskListIndex = reference.index();
+ taskListIndex.find(NLS.bind("content:\"{0}\"", url), collector, 50); //$NON-NLS-1$
+ } finally {
+ reference.dispose();
+ }
}
}
}
diff --git a/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java b/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java
index b9734d5..f4d1a56 100644
--- a/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java
+++ b/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java
@@ -38,6 +38,7 @@ import org.junit.Test;
*/
@SuppressWarnings("restriction")
public class TaskActivityProviderTest {
+
protected List<ActivityEvent> events = new ArrayList<ActivityEvent>();
private IndexReference reference;
@@ -47,13 +48,13 @@ public class TaskActivityProviderTest {
@Before
public void setUp() throws Exception {
task1 = new TaskTask(LocalRepositoryConnector.CONNECTOR_KIND, LocalRepositoryConnector.REPOSITORY_URL, "2");
- task1.setSummary("1: hit");
+ task1.setSummary("1: hit http://task/url1");
task1.setTaskKey("2");
task1.setCreationDate(new Date());
TaskTask task2 = new TaskTask(LocalRepositoryConnector.CONNECTOR_KIND, LocalRepositoryConnector.REPOSITORY_URL,
"3");
- task2.setSummary("2: miss");
+ task2.setSummary("2: miss http://task/url2");
task2.setTaskKey("3");
task2.setCreationDate(new Date());
@@ -76,6 +77,7 @@ public class TaskActivityProviderTest {
LocalRepositoryConnector.REPOSITORY_URL, "1");
searchTask.setSummary("summary");
searchTask.setTaskKey("1");
+ searchTask.setUrl("http://task/url1");
TaskActivityProvider provider = new TaskActivityProvider();
IActivitySession session = new IActivitySession() {
diff --git a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java
index f87d4ae..7d5ca88 100644
--- a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java
+++ b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Timur Achmetow - initial API and implementation
+ * Tasktop Technologies - improvements
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.activity.ui;
@@ -17,21 +18,22 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.internal.tasks.activity.core.ActivityManager;
import org.eclipse.mylyn.internal.tasks.activity.ui.provider.ActivityRecordContentProvider;
import org.eclipse.mylyn.internal.tasks.activity.ui.provider.ActivityRecordLabelProvider;
+import org.eclipse.mylyn.internal.tasks.ui.editors.AbstractTaskEditorSection;
+import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
import org.eclipse.mylyn.tasks.activity.core.IActivityStream;
import org.eclipse.mylyn.tasks.activity.core.TaskActivityScope;
-import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.swt.SWT;
-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.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
/**
* @author Timur Achmetow
+ * @author Steffen Pingel
*/
@SuppressWarnings("restriction")
-public class ActivityPart extends AbstractTaskEditorPart {
+public class ActivityPart extends AbstractTaskEditorSection {
+
public ActivityPart() {
setPartName("Activity"); //$NON-NLS-1$
setExpandVertically(true);
@@ -39,27 +41,35 @@ public class ActivityPart extends AbstractTaskEditorPart {
@Override
public void createControl(Composite parent, FormToolkit toolkit) {
- final Section section = createSection(parent, toolkit, false);
- section.setText("Activity"); //$NON-NLS-1$
-
- Composite activityComposite = toolkit.createComposite(section);
- activityComposite.setLayout(new GridLayout(1, false));
- activityComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createTreeViewer(toolkit, activityComposite);
-
- toolkit.paintBordersFor(activityComposite);
- section.setClient(activityComposite);
- setSection(toolkit, section);
+ // do not show the part for unsubmitted tasks
+ if (getTaskData().isNew()) {
+ return;
+ }
+ super.createControl(parent, toolkit);
}
- private void createTreeViewer(FormToolkit toolkit, Composite activityComposite) {
- TreeViewer viewer = new TreeViewer(toolkit.createTree(activityComposite, SWT.MULTI | SWT.H_SCROLL
+ @Override
+ protected Control createContent(FormToolkit toolkit, Composite parent) {
+ Composite activityComposite = toolkit.createComposite(parent);
+ activityComposite.setLayout(EditorUtil.createSectionClientLayout());
+
+ TreeViewer viewer = new TreeViewer(toolkit.createTree(activityComposite, SWT.SINGLE | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION));
GridDataFactory.fillDefaults().hint(500, 100).grab(true, true).applyTo(viewer.getControl());
viewer.setContentProvider(new ActivityRecordContentProvider());
viewer.setLabelProvider(new DecoratingStyledCellLabelProvider(new ActivityRecordLabelProvider(), null, null));
IActivityStream stream = new ActivityManager().getStream(new TaskActivityScope(getModel().getTask()));
viewer.setInput(stream);
+
+ EditorUtil.addScrollListener(viewer.getTree());
+ toolkit.paintBordersFor(activityComposite);
+
+ return activityComposite;
}
+
+ @Override
+ protected boolean shouldExpandOnCreate() {
+ return false;
+ }
+
} \ No newline at end of file