Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 210639
Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/sandbox/dev/properties/TaskRepositoryPropertiesSource.java (-1 / +1 lines)
Lines 13-19 Link Here
13
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
13
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
14
14
15
/**
15
/**
16
 * @author maarten
16
 * @author Maarten Meijer
17
 */
17
 */
18
public class TaskRepositoryPropertiesSource implements IPropertySource {
18
public class TaskRepositoryPropertiesSource implements IPropertySource {
19
	/**
19
	/**
(-)src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskCategoryPropertySource.java (-35 / +14 lines)
Lines 9-63 Link Here
9
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
9
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
10
10
11
/**
11
/**
12
 * @author maarten
12
 * Display various {@link AbstractTaskCategory} properties in the Eclipse Properties View.<br />
13
 * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and
14
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br />
15
 *
16
 * @author Maarten Meijer
13
 */
17
 */
14
public class AbstractTaskCategoryPropertySource implements IPropertySource {
18
public class AbstractTaskCategoryPropertySource extends AbstractMylynPropertySource implements IPropertySource {
15
	/**
19
	/**
16
	 *
20
	 * @param adaptableObject to create sopurce for
17
	 */
18
	private static final String SUMMARY = "summary";
19
20
	private AbstractTaskCategory category;
21
	/**
22
	 * @param adaptableObject
23
	 */
21
	 */
24
	public AbstractTaskCategoryPropertySource(AbstractTaskCategory adaptableObject) {
22
	public AbstractTaskCategoryPropertySource(AbstractTaskCategory adaptableObject) {
25
		this.category = adaptableObject;
23
		super(adaptableObject);
26
	}
27
28
	public Object getEditableValue() {
29
		// TODO Auto-generated method stub
30
		return null;
31
	}
24
	}
32
25
33
	public IPropertyDescriptor[] getPropertyDescriptors() {
26
	public IPropertyDescriptor[] getPropertyDescriptors() {
34
		TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary");
27
		TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary");
35
		summary.setCategory(category.getClass().getName());
28
		summary.setCategory(description);
36
		return new IPropertyDescriptor[] {
29
		IPropertyDescriptor[] specific =  new IPropertyDescriptor[] {
37
				summary
30
				summary,
38
		};
31
		};
32
		return super.appendSpecifics(specific, super.getPropertyDescriptors());
39
	}
33
	}
40
34
41
	public Object getPropertyValue(Object id) {
35
	public Object getPropertyValue(Object id) {
36
		AbstractTaskCategory category = (AbstractTaskCategory) container;
42
		if(SUMMARY.equals(id)) {
37
		if(SUMMARY.equals(id)) {
43
			return category.getSummary();
38
			return category.getSummary();
44
		}
39
		}
45
		return null;
40
		return super.getPropertyValue(id);
46
	}
47
48
	public boolean isPropertySet(Object id) {
49
		// TODO Auto-generated method stub
50
		return false;
51
	}
41
	}
52
53
	public void resetPropertyValue(Object id) {
54
		// TODO Auto-generated method stub
55
56
	}
57
58
	public void setPropertyValue(Object id, Object value) {
59
		// TODO Auto-generated method stub
60
61
	}
62
63
}
42
}
(-)src/org/eclipse/mylyn/internal/sandbox/dev/properties/MylynPropertiesSourceAdapterFactory.java (-1 / +1 lines)
Lines 11-17 Link Here
11
import org.eclipse.ui.views.properties.IPropertySource;
11
import org.eclipse.ui.views.properties.IPropertySource;
12
12
13
/**
13
/**
14
 * @author maarten
14
 * @author Maarten Meijer
15
 */
15
 */
16
public class MylynPropertiesSourceAdapterFactory implements IAdapterFactory {
16
public class MylynPropertiesSourceAdapterFactory implements IAdapterFactory {
17
17
(-)src/org/eclipse/mylyn/internal/sandbox/dev/properties/RepositoryQueryPropertySource.java (-37 / +21 lines)
Lines 3-17 Link Here
3
 */
3
 */
4
package org.eclipse.mylyn.internal.sandbox.dev.properties;
4
package org.eclipse.mylyn.internal.sandbox.dev.properties;
5
5
6
6
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
7
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
7
import org.eclipse.ui.views.properties.IPropertyDescriptor;
8
import org.eclipse.ui.views.properties.IPropertyDescriptor;
8
import org.eclipse.ui.views.properties.IPropertySource;
9
import org.eclipse.ui.views.properties.IPropertySource;
9
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
10
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
10
11
11
/**
12
/**
12
 * @author maarten
13
 * Display various {@link AbstractRepositoryQuery} properties in the Eclipse Properties View.<br />
14
 * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and
15
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br />
16
 *
17
 * @author Maarten Meijer
13
 */
18
 */
14
public class RepositoryQueryPropertySource implements IPropertySource {
19
public class RepositoryQueryPropertySource extends AbstractMylynPropertySource implements IPropertySource {
15
	/**
20
	/**
16
	 *
21
	 *
17
	 */
22
	 */
Lines 20-61 Link Here
20
	private static final String STATUS = "status";
25
	private static final String STATUS = "status";
21
	private static final String URL = "url";
26
	private static final String URL = "url";
22
	private static final String KIND = "kind";
27
	private static final String KIND = "kind";
23
	private static final String SUMMARY = "summary";
24
28
25
	private AbstractRepositoryQuery query;
26
	/**
29
	/**
27
	 * @param adaptableObject
30
	 * @param adaptableObject
28
	 */
31
	 */
29
	public RepositoryQueryPropertySource(AbstractRepositoryQuery adaptableObject) {
32
	public RepositoryQueryPropertySource(AbstractRepositoryQuery adaptableObject) {
30
		this.query = adaptableObject;
33
		super(adaptableObject);
31
	}
32
33
	public Object getEditableValue() {
34
		// TODO Auto-generated method stub
35
		return null;
36
	}
34
	}
37
35
38
	public IPropertyDescriptor[] getPropertyDescriptors() {
36
	public IPropertyDescriptor[] getPropertyDescriptors() {
39
		TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary");
37
		TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Query Summary");
40
		summary.setCategory(query.getClass().getName());
38
		summary.setCategory(description);
41
		TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Connector Kind");
39
		TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Repository Connector Kind");
42
		kind.setCategory(query.getClass().getName());
40
		kind.setCategory(description);
43
		TextPropertyDescriptor url = new TextPropertyDescriptor(URL, "Repository URL");
41
		TextPropertyDescriptor url = new TextPropertyDescriptor(URL, "Repository URL");
44
		url.setCategory(query.getClass().getName());
42
		url.setCategory(description);
45
		TextPropertyDescriptor status = new TextPropertyDescriptor(STATUS, "Synchronization Status");
43
		TextPropertyDescriptor status = new TextPropertyDescriptor(STATUS, "Synchronization Status");
46
		status.setCategory(query.getClass().getName());
44
		status.setCategory(description);
47
		TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Last Synchronized Timestamp");
45
		TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Synchronization Timestamp");
48
		lastRead.setCategory(query.getClass().getName());
46
		lastRead.setCategory(description);
49
		return new IPropertyDescriptor[] {
47
		IPropertyDescriptor[] specific =  new IPropertyDescriptor[] {
50
				summary,
48
				summary,
51
				kind,
49
				kind,
52
				url,
50
				url,
53
				status,
51
				status,
54
				lastRead
52
				lastRead,
55
		};
53
		};
54
		return super.appendSpecifics(specific, super.getPropertyDescriptors());
56
	}
55
	}
57
56
58
	public Object getPropertyValue(Object id) {
57
	public Object getPropertyValue(Object id) {
58
		AbstractRepositoryQuery query = (AbstractRepositoryQuery) container;
59
		if(SUMMARY.equals(id)) {
59
		if(SUMMARY.equals(id)) {
60
			return query.getSummary();
60
			return query.getSummary();
61
		} else if(KIND.equals(id)) {
61
		} else if(KIND.equals(id)) {
Lines 67-88 Link Here
67
		} else if(LAST_READ.equals(id)) {
67
		} else if(LAST_READ.equals(id)) {
68
			return query.getLastSynchronizedTimeStamp() == null ? NULL_MSG : query.getLastSynchronizedTimeStamp().toString();
68
			return query.getLastSynchronizedTimeStamp() == null ? NULL_MSG : query.getLastSynchronizedTimeStamp().toString();
69
		}
69
		}
70
		return null;
70
		return super.getPropertyValue(id);
71
	}
72
73
	public boolean isPropertySet(Object id) {
74
		// TODO Auto-generated method stub
75
		return false;
76
	}
77
78
	public void resetPropertyValue(Object id) {
79
		// TODO Auto-generated method stub
80
81
	}
82
83
	public void setPropertyValue(Object id, Object value) {
84
		// TODO Auto-generated method stub
85
86
	}
71
	}
87
88
}
72
}
(-)src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskPropertiesSource.java (-39 / +21 lines)
Lines 9-17 Link Here
9
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
9
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
10
10
11
/**
11
/**
12
 * @author maarten
12
 * Display various {@link AbstractTask} properties in the Eclipse Properties View.<br />
13
 * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and
14
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br />
15
 *
16
 * @author Maarten Meijer
13
 */
17
 */
14
public class AbstractTaskPropertiesSource implements IPropertySource {
18
public class AbstractTaskPropertiesSource extends AbstractMylynPropertySource implements IPropertySource {
15
	/**
19
	/**
16
	 *
20
	 *
17
	 */
21
	 */
Lines 24-65 Link Here
24
	private static final String OWNER = "owner";
28
	private static final String OWNER = "owner";
25
	private static final String PARENT = "parent";
29
	private static final String PARENT = "parent";
26
	private static final String SCHEDULED = "scheduled";
30
	private static final String SCHEDULED = "scheduled";
27
	private static final String SUMMARY = "summary";
28
29
	private AbstractTask task;
30
	/**
31
	/**
31
	 * @param adaptableObject
32
	 * @param adaptableObject
32
	 */
33
	 */
33
	public AbstractTaskPropertiesSource(AbstractTask adaptableObject) {
34
	public AbstractTaskPropertiesSource(AbstractTask adaptableObject) {
34
		this.task = adaptableObject;
35
		super(adaptableObject);
35
	}
36
37
	public Object getEditableValue() {
38
		// TODO Auto-generated method stub
39
		return null;
40
	}
36
	}
41
37
42
	public IPropertyDescriptor[] getPropertyDescriptors() {
38
	public IPropertyDescriptor[] getPropertyDescriptors() {
43
44
		TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary");
39
		TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary");
45
		summary.setCategory(task.getClass().getName());
40
		summary.setCategory(description);
46
		TextPropertyDescriptor owner = new TextPropertyDescriptor(OWNER, "Owner");
41
		TextPropertyDescriptor owner = new TextPropertyDescriptor(OWNER, "Owner");
47
		owner.setCategory(task.getClass().getName());
42
		owner.setCategory(description);
48
		TextPropertyDescriptor scheduled = new TextPropertyDescriptor(SCHEDULED, "Scheduled for");
43
		TextPropertyDescriptor scheduled = new TextPropertyDescriptor(SCHEDULED, "Scheduled for");
49
		scheduled.setCategory(task.getClass().getName());
44
		scheduled.setCategory(description);
50
		TextPropertyDescriptor parent = new TextPropertyDescriptor(PARENT, "Parent Containers");
45
		TextPropertyDescriptor parent = new TextPropertyDescriptor(PARENT, "Parent Containers");
51
		parent.setCategory(task.getClass().getName());
46
		parent.setCategory(description);
52
		TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Connector Kind");
47
		TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Repository Connector Kind");
53
		kind.setCategory(task.getClass().getName());
48
		kind.setCategory(description);
54
		TextPropertyDescriptor url = new TextPropertyDescriptor(URL, "Repository URL");
49
		TextPropertyDescriptor url = new TextPropertyDescriptor(URL, "Repository URL");
55
		url.setCategory(task.getClass().getName());
50
		url.setCategory(description);
56
		TextPropertyDescriptor status = new TextPropertyDescriptor(STATUS, "Synchronization Status");
51
		TextPropertyDescriptor status = new TextPropertyDescriptor(STATUS, "Synchronization Status");
57
		status.setCategory(task.getClass().getName());
52
		status.setCategory(description);
58
		TextPropertyDescriptor state = new TextPropertyDescriptor(STATE, "Synchronization State");
53
		TextPropertyDescriptor state = new TextPropertyDescriptor(STATE, "Synchronization State");
59
		state.setCategory(task.getClass().getName());
54
		state.setCategory(description);
60
		TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Last Read Timestamp");
55
		TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Last Read Timestamp");
61
		lastRead.setCategory(task.getClass().getName());
56
		lastRead.setCategory(description);
62
		return new IPropertyDescriptor[] {
57
		IPropertyDescriptor[] specific =  new IPropertyDescriptor[] {
63
				summary,
58
				summary,
64
				owner,
59
				owner,
65
				scheduled,
60
				scheduled,
Lines 70-78 Link Here
70
				state,
65
				state,
71
				lastRead
66
				lastRead
72
		};
67
		};
68
		return super.appendSpecifics(specific, super.getPropertyDescriptors());
73
	}
69
	}
74
70
75
	public Object getPropertyValue(Object id) {
71
	public Object getPropertyValue(Object id) {
72
		AbstractTask task = (AbstractTask) container;
76
		if(SUMMARY.equals(id)) {
73
		if(SUMMARY.equals(id)) {
77
			return task.getSummary();
74
			return task.getSummary();
78
		} else if(OWNER.equals(id)) {
75
		} else if(OWNER.equals(id)) {
Lines 92-113 Link Here
92
		} else if(LAST_READ.equals(id)) {
89
		} else if(LAST_READ.equals(id)) {
93
			return task.getLastReadTimeStamp() == null ? NULL_MSG : task.getLastReadTimeStamp().toString();
90
			return task.getLastReadTimeStamp() == null ? NULL_MSG : task.getLastReadTimeStamp().toString();
94
		}
91
		}
95
		return null;
92
		return super.getPropertyValue(id);
96
	}
97
98
	public boolean isPropertySet(Object id) {
99
		// TODO Auto-generated method stub
100
		return false;
101
	}
102
103
	public void resetPropertyValue(Object id) {
104
		// TODO Auto-generated method stub
105
106
	}
107
108
	public void setPropertyValue(Object id, Object value) {
109
		// TODO Auto-generated method stub
110
111
	}
93
	}
112
94
113
}
95
}
(-)src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractMylynPropertySource.java (+165 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.sandbox.dev.properties;
10
11
import java.util.Collections;
12
import java.util.HashSet;
13
import java.util.Set;
14
15
import org.eclipse.mylyn.tasks.core.AbstractTask;
16
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
17
import org.eclipse.ui.views.properties.IPropertyDescriptor;
18
import org.eclipse.ui.views.properties.IPropertySource;
19
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
20
21
/**
22
 * Abstract class to display various properties in the Eclipse Properties View.<br />
23
 * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and
24
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br />
25
 *
26
 * @author Maarten Meijer
27
 */
28
public abstract class AbstractMylynPropertySource implements IPropertySource {
29
30
	protected static final String CHILDREN = "children";
31
32
	protected static final String OFFSPRING = "offspring";
33
34
	protected static final String IS_CYCLIC = "iscyclic";
35
36
	protected static final String SUMMARY = "summary";
37
38
	private boolean cyclic;
39
40
	protected AbstractTaskContainer container;
41
42
	protected String description;
43
44
	/**
45
	 *
46
	 */
47
	public AbstractMylynPropertySource() {
48
		super();
49
	}
50
51
	/**
52
	 * @param adaptableObject
53
	 */
54
	public AbstractMylynPropertySource(AbstractTaskContainer adaptableObject) {
55
		container = adaptableObject;
56
		description = container.getClass().getName();
57
	}
58
59
	/**
60
	 * @return an expanded set of all descendants, excluding itself.
61
	 */
62
	public Set<AbstractTask> getDescendants(AbstractTaskContainer parent) {
63
		Set<AbstractTask> childrenWithoutCycles = new HashSet<AbstractTask>();
64
		this.getDescendantsHelper(parent, childrenWithoutCycles, parent);
65
		return Collections.unmodifiableSet(childrenWithoutCycles);
66
	}
67
68
	protected void getDescendantsHelper(AbstractTaskContainer parent, Set<AbstractTask> visited,
69
			AbstractTaskContainer root) {
70
		for (AbstractTask child : parent.getChildrenInternal()) {
71
			if (child == root) {
72
				cyclic = true;
73
			}
74
			if (!visited.contains(child) && child != root) {
75
				visited.add(child);
76
				getDescendantsHelper(child, visited, root);
77
			}
78
		}
79
	}
80
81
	/**
82
	 * @return true if the parent also occurs in its offspring.
83
	 */
84
	public boolean containsCyclic(AbstractTaskContainer parent) {
85
		Set<AbstractTask> childrenWithoutCycles = new HashSet<AbstractTask>();
86
		Set<AbstractTaskContainer> parentStack= new HashSet<AbstractTaskContainer>();
87
		cyclic = false;
88
		this.containsCyclicHelper(parent, childrenWithoutCycles, parentStack);
89
		return cyclic;
90
	}
91
92
	protected void containsCyclicHelper(AbstractTaskContainer parent, Set<AbstractTask> visited,
93
			Set<AbstractTaskContainer> parentStack) {
94
		// fast exit
95
		if(cyclic)
96
			return;
97
98
		parentStack.add(parent);
99
		for (AbstractTask child : parent.getChildrenInternal()) {
100
			if (parentStack.contains(child)) {
101
				cyclic = true;
102
				return;
103
			} else {
104
				containsCyclicHelper(child, visited, parentStack);
105
			}
106
		}
107
		parentStack.remove(parent);
108
	}
109
110
	public IPropertyDescriptor[] getPropertyDescriptors() {
111
		TextPropertyDescriptor children= new TextPropertyDescriptor(CHILDREN, "Total Children (internal)");
112
		children.setCategory(description);
113
		TextPropertyDescriptor offspring = new TextPropertyDescriptor(OFFSPRING, "Total Offspring");
114
		offspring.setCategory(description);
115
		TextPropertyDescriptor cyclic = new TextPropertyDescriptor(IS_CYCLIC, "Test is offspring cyclic?");
116
		cyclic.setCategory(description);
117
		return new IPropertyDescriptor[] {
118
				children,
119
				offspring,
120
				cyclic
121
		};
122
	}
123
124
	public Object getPropertyValue(Object id) {
125
		if (CHILDREN.equals(id)) {
126
			return container.getChildrenInternal().size();
127
		} else if (OFFSPRING.equals(id)) {
128
			return getDescendants(container).size();
129
		} else if (IS_CYCLIC.equals(id)) {
130
			return containsCyclic(container) ? "Cyclic" : "Not Cyclic";
131
		}
132
		return null;
133
	}
134
135
	public boolean isPropertySet(Object id) {
136
		// ignore
137
		return false;
138
	}
139
140
	public void resetPropertyValue(Object id) {
141
		// ignore
142
143
	}
144
145
	public void setPropertyValue(Object id, Object value) {
146
		// ignore
147
	}
148
149
	public Object getEditableValue() {
150
		// ignore
151
		return null;
152
	}
153
154
	/**
155
	 * @param specific
156
	 * @return
157
	 */
158
	public IPropertyDescriptor[] appendSpecifics(IPropertyDescriptor[] specific, IPropertyDescriptor[] these) {
159
		IPropertyDescriptor[] all = new IPropertyDescriptor[specific.length + these.length];
160
		System.arraycopy(these, 0, all, 0, these.length);
161
		System.arraycopy(specific, 0, all, these.length, specific.length);
162
		return all;
163
	}
164
165
}

Return to bug 210639