Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 83516 Details for
Bug 210639
Task, Category and Query should display # children, offspring and cyclic state in properties view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Extend the Mylyn IPropertySource with children count, offspring count, and cyclic test
clipboard.txt (text/plain), 18.62 KB, created by
maarten meijer
on 2007-11-22 06:26:33 EST
(
hide
)
Description:
Extend the Mylyn IPropertySource with children count, offspring count, and cyclic test
Filename:
MIME Type:
Creator:
maarten meijer
Created:
2007-11-22 06:26:33 EST
Size:
18.62 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.sandbox.dev >Index: src/org/eclipse/mylyn/internal/sandbox/dev/properties/TaskRepositoryPropertiesSource.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.dev/src/org/eclipse/mylyn/internal/sandbox/dev/properties/TaskRepositoryPropertiesSource.java,v >retrieving revision 1.1 >diff -u -r1.1 TaskRepositoryPropertiesSource.java >--- src/org/eclipse/mylyn/internal/sandbox/dev/properties/TaskRepositoryPropertiesSource.java 8 Nov 2007 23:22:05 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/sandbox/dev/properties/TaskRepositoryPropertiesSource.java 22 Nov 2007 11:24:57 -0000 >@@ -13,7 +13,7 @@ > import org.eclipse.ui.views.properties.TextPropertyDescriptor; > > /** >- * @author maarten >+ * @author Maarten Meijer > */ > public class TaskRepositoryPropertiesSource implements IPropertySource { > /** >Index: src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskCategoryPropertySource.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.dev/src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskCategoryPropertySource.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractTaskCategoryPropertySource.java >--- src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskCategoryPropertySource.java 8 Nov 2007 23:22:05 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskCategoryPropertySource.java 22 Nov 2007 11:24:57 -0000 >@@ -9,55 +9,34 @@ > import org.eclipse.ui.views.properties.TextPropertyDescriptor; > > /** >- * @author maarten >+ * Display various {@link AbstractTaskCategory} properties in the Eclipse Properties View.<br /> >+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and >+ * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br /> >+ * >+ * @author Maarten Meijer > */ >-public class AbstractTaskCategoryPropertySource implements IPropertySource { >+public class AbstractTaskCategoryPropertySource extends AbstractMylynPropertySource implements IPropertySource { > /** >- * >- */ >- private static final String SUMMARY = "summary"; >- >- private AbstractTaskCategory category; >- /** >- * @param adaptableObject >+ * @param adaptableObject to create sopurce for > */ > public AbstractTaskCategoryPropertySource(AbstractTaskCategory adaptableObject) { >- this.category = adaptableObject; >- } >- >- public Object getEditableValue() { >- // TODO Auto-generated method stub >- return null; >+ super(adaptableObject); > } > > public IPropertyDescriptor[] getPropertyDescriptors() { > TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary"); >- summary.setCategory(category.getClass().getName()); >- return new IPropertyDescriptor[] { >- summary >+ summary.setCategory(description); >+ IPropertyDescriptor[] specific = new IPropertyDescriptor[] { >+ summary, > }; >+ return super.appendSpecifics(specific, super.getPropertyDescriptors()); > } > > public Object getPropertyValue(Object id) { >+ AbstractTaskCategory category = (AbstractTaskCategory) container; > if(SUMMARY.equals(id)) { > return category.getSummary(); > } >- return null; >- } >- >- public boolean isPropertySet(Object id) { >- // TODO Auto-generated method stub >- return false; >+ return super.getPropertyValue(id); > } >- >- public void resetPropertyValue(Object id) { >- // TODO Auto-generated method stub >- >- } >- >- public void setPropertyValue(Object id, Object value) { >- // TODO Auto-generated method stub >- >- } >- > } >Index: src/org/eclipse/mylyn/internal/sandbox/dev/properties/MylynPropertiesSourceAdapterFactory.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.dev/src/org/eclipse/mylyn/internal/sandbox/dev/properties/MylynPropertiesSourceAdapterFactory.java,v >retrieving revision 1.1 >diff -u -r1.1 MylynPropertiesSourceAdapterFactory.java >--- src/org/eclipse/mylyn/internal/sandbox/dev/properties/MylynPropertiesSourceAdapterFactory.java 8 Nov 2007 23:22:05 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/sandbox/dev/properties/MylynPropertiesSourceAdapterFactory.java 22 Nov 2007 11:24:57 -0000 >@@ -11,7 +11,7 @@ > import org.eclipse.ui.views.properties.IPropertySource; > > /** >- * @author maarten >+ * @author Maarten Meijer > */ > public class MylynPropertiesSourceAdapterFactory implements IAdapterFactory { > >Index: src/org/eclipse/mylyn/internal/sandbox/dev/properties/RepositoryQueryPropertySource.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.dev/src/org/eclipse/mylyn/internal/sandbox/dev/properties/RepositoryQueryPropertySource.java,v >retrieving revision 1.1 >diff -u -r1.1 RepositoryQueryPropertySource.java >--- src/org/eclipse/mylyn/internal/sandbox/dev/properties/RepositoryQueryPropertySource.java 8 Nov 2007 23:22:05 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/sandbox/dev/properties/RepositoryQueryPropertySource.java 22 Nov 2007 11:24:57 -0000 >@@ -3,15 +3,20 @@ > */ > package org.eclipse.mylyn.internal.sandbox.dev.properties; > >+ > import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; > import org.eclipse.ui.views.properties.IPropertyDescriptor; > import org.eclipse.ui.views.properties.IPropertySource; > import org.eclipse.ui.views.properties.TextPropertyDescriptor; > > /** >- * @author maarten >+ * Display various {@link AbstractRepositoryQuery} properties in the Eclipse Properties View.<br /> >+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and >+ * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br /> >+ * >+ * @author Maarten Meijer > */ >-public class RepositoryQueryPropertySource implements IPropertySource { >+public class RepositoryQueryPropertySource extends AbstractMylynPropertySource implements IPropertySource { > /** > * > */ >@@ -20,42 +25,37 @@ > private static final String STATUS = "status"; > private static final String URL = "url"; > private static final String KIND = "kind"; >- private static final String SUMMARY = "summary"; > >- private AbstractRepositoryQuery query; > /** > * @param adaptableObject > */ > public RepositoryQueryPropertySource(AbstractRepositoryQuery adaptableObject) { >- this.query = adaptableObject; >- } >- >- public Object getEditableValue() { >- // TODO Auto-generated method stub >- return null; >+ super(adaptableObject); > } > > public IPropertyDescriptor[] getPropertyDescriptors() { >- TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary"); >- summary.setCategory(query.getClass().getName()); >- TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Connector Kind"); >- kind.setCategory(query.getClass().getName()); >+ TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Query Summary"); >+ summary.setCategory(description); >+ TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Repository Connector Kind"); >+ kind.setCategory(description); > TextPropertyDescriptor url = new TextPropertyDescriptor(URL, "Repository URL"); >- url.setCategory(query.getClass().getName()); >+ url.setCategory(description); > TextPropertyDescriptor status = new TextPropertyDescriptor(STATUS, "Synchronization Status"); >- status.setCategory(query.getClass().getName()); >- TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Last Synchronized Timestamp"); >- lastRead.setCategory(query.getClass().getName()); >- return new IPropertyDescriptor[] { >+ status.setCategory(description); >+ TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Synchronization Timestamp"); >+ lastRead.setCategory(description); >+ IPropertyDescriptor[] specific = new IPropertyDescriptor[] { > summary, > kind, > url, > status, >- lastRead >+ lastRead, > }; >+ return super.appendSpecifics(specific, super.getPropertyDescriptors()); > } > > public Object getPropertyValue(Object id) { >+ AbstractRepositoryQuery query = (AbstractRepositoryQuery) container; > if(SUMMARY.equals(id)) { > return query.getSummary(); > } else if(KIND.equals(id)) { >@@ -67,22 +67,6 @@ > } else if(LAST_READ.equals(id)) { > return query.getLastSynchronizedTimeStamp() == null ? NULL_MSG : query.getLastSynchronizedTimeStamp().toString(); > } >- return null; >- } >- >- public boolean isPropertySet(Object id) { >- // TODO Auto-generated method stub >- return false; >- } >- >- public void resetPropertyValue(Object id) { >- // TODO Auto-generated method stub >- >- } >- >- public void setPropertyValue(Object id, Object value) { >- // TODO Auto-generated method stub >- >+ return super.getPropertyValue(id); > } >- > } >Index: src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskPropertiesSource.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.dev/src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskPropertiesSource.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractTaskPropertiesSource.java >--- src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskPropertiesSource.java 8 Nov 2007 23:22:05 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractTaskPropertiesSource.java 22 Nov 2007 11:24:57 -0000 >@@ -9,9 +9,13 @@ > import org.eclipse.ui.views.properties.TextPropertyDescriptor; > > /** >- * @author maarten >+ * Display various {@link AbstractTask} properties in the Eclipse Properties View.<br /> >+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and >+ * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br /> >+ * >+ * @author Maarten Meijer > */ >-public class AbstractTaskPropertiesSource implements IPropertySource { >+public class AbstractTaskPropertiesSource extends AbstractMylynPropertySource implements IPropertySource { > /** > * > */ >@@ -24,42 +28,33 @@ > private static final String OWNER = "owner"; > private static final String PARENT = "parent"; > private static final String SCHEDULED = "scheduled"; >- private static final String SUMMARY = "summary"; >- >- private AbstractTask task; > /** > * @param adaptableObject > */ > public AbstractTaskPropertiesSource(AbstractTask adaptableObject) { >- this.task = adaptableObject; >- } >- >- public Object getEditableValue() { >- // TODO Auto-generated method stub >- return null; >+ super(adaptableObject); > } > > public IPropertyDescriptor[] getPropertyDescriptors() { >- > TextPropertyDescriptor summary = new TextPropertyDescriptor(SUMMARY, "Summary"); >- summary.setCategory(task.getClass().getName()); >+ summary.setCategory(description); > TextPropertyDescriptor owner = new TextPropertyDescriptor(OWNER, "Owner"); >- owner.setCategory(task.getClass().getName()); >+ owner.setCategory(description); > TextPropertyDescriptor scheduled = new TextPropertyDescriptor(SCHEDULED, "Scheduled for"); >- scheduled.setCategory(task.getClass().getName()); >+ scheduled.setCategory(description); > TextPropertyDescriptor parent = new TextPropertyDescriptor(PARENT, "Parent Containers"); >- parent.setCategory(task.getClass().getName()); >- TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Connector Kind"); >- kind.setCategory(task.getClass().getName()); >+ parent.setCategory(description); >+ TextPropertyDescriptor kind = new TextPropertyDescriptor(KIND, "Repository Connector Kind"); >+ kind.setCategory(description); > TextPropertyDescriptor url = new TextPropertyDescriptor(URL, "Repository URL"); >- url.setCategory(task.getClass().getName()); >+ url.setCategory(description); > TextPropertyDescriptor status = new TextPropertyDescriptor(STATUS, "Synchronization Status"); >- status.setCategory(task.getClass().getName()); >+ status.setCategory(description); > TextPropertyDescriptor state = new TextPropertyDescriptor(STATE, "Synchronization State"); >- state.setCategory(task.getClass().getName()); >+ state.setCategory(description); > TextPropertyDescriptor lastRead = new TextPropertyDescriptor(LAST_READ, "Last Read Timestamp"); >- lastRead.setCategory(task.getClass().getName()); >- return new IPropertyDescriptor[] { >+ lastRead.setCategory(description); >+ IPropertyDescriptor[] specific = new IPropertyDescriptor[] { > summary, > owner, > scheduled, >@@ -70,9 +65,11 @@ > state, > lastRead > }; >+ return super.appendSpecifics(specific, super.getPropertyDescriptors()); > } > > public Object getPropertyValue(Object id) { >+ AbstractTask task = (AbstractTask) container; > if(SUMMARY.equals(id)) { > return task.getSummary(); > } else if(OWNER.equals(id)) { >@@ -92,22 +89,7 @@ > } else if(LAST_READ.equals(id)) { > return task.getLastReadTimeStamp() == null ? NULL_MSG : task.getLastReadTimeStamp().toString(); > } >- return null; >- } >- >- public boolean isPropertySet(Object id) { >- // TODO Auto-generated method stub >- return false; >- } >- >- public void resetPropertyValue(Object id) { >- // TODO Auto-generated method stub >- >- } >- >- public void setPropertyValue(Object id, Object value) { >- // TODO Auto-generated method stub >- >+ return super.getPropertyValue(id); > } > > } >Index: src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractMylynPropertySource.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractMylynPropertySource.java >diff -N src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractMylynPropertySource.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/sandbox/dev/properties/AbstractMylynPropertySource.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,165 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.sandbox.dev.properties; >+ >+import java.util.Collections; >+import java.util.HashSet; >+import java.util.Set; >+ >+import org.eclipse.mylyn.tasks.core.AbstractTask; >+import org.eclipse.mylyn.tasks.core.AbstractTaskContainer; >+import org.eclipse.ui.views.properties.IPropertyDescriptor; >+import org.eclipse.ui.views.properties.IPropertySource; >+import org.eclipse.ui.views.properties.TextPropertyDescriptor; >+ >+/** >+ * Abstract class to display various properties in the Eclipse Properties View.<br /> >+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=210639">Bug 210639</a> and >+ * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208275">Bug 208275</a><br /> >+ * >+ * @author Maarten Meijer >+ */ >+public abstract class AbstractMylynPropertySource implements IPropertySource { >+ >+ protected static final String CHILDREN = "children"; >+ >+ protected static final String OFFSPRING = "offspring"; >+ >+ protected static final String IS_CYCLIC = "iscyclic"; >+ >+ protected static final String SUMMARY = "summary"; >+ >+ private boolean cyclic; >+ >+ protected AbstractTaskContainer container; >+ >+ protected String description; >+ >+ /** >+ * >+ */ >+ public AbstractMylynPropertySource() { >+ super(); >+ } >+ >+ /** >+ * @param adaptableObject >+ */ >+ public AbstractMylynPropertySource(AbstractTaskContainer adaptableObject) { >+ container = adaptableObject; >+ description = container.getClass().getName(); >+ } >+ >+ /** >+ * @return an expanded set of all descendants, excluding itself. >+ */ >+ public Set<AbstractTask> getDescendants(AbstractTaskContainer parent) { >+ Set<AbstractTask> childrenWithoutCycles = new HashSet<AbstractTask>(); >+ this.getDescendantsHelper(parent, childrenWithoutCycles, parent); >+ return Collections.unmodifiableSet(childrenWithoutCycles); >+ } >+ >+ protected void getDescendantsHelper(AbstractTaskContainer parent, Set<AbstractTask> visited, >+ AbstractTaskContainer root) { >+ for (AbstractTask child : parent.getChildrenInternal()) { >+ if (child == root) { >+ cyclic = true; >+ } >+ if (!visited.contains(child) && child != root) { >+ visited.add(child); >+ getDescendantsHelper(child, visited, root); >+ } >+ } >+ } >+ >+ /** >+ * @return true if the parent also occurs in its offspring. >+ */ >+ public boolean containsCyclic(AbstractTaskContainer parent) { >+ Set<AbstractTask> childrenWithoutCycles = new HashSet<AbstractTask>(); >+ Set<AbstractTaskContainer> parentStack= new HashSet<AbstractTaskContainer>(); >+ cyclic = false; >+ this.containsCyclicHelper(parent, childrenWithoutCycles, parentStack); >+ return cyclic; >+ } >+ >+ protected void containsCyclicHelper(AbstractTaskContainer parent, Set<AbstractTask> visited, >+ Set<AbstractTaskContainer> parentStack) { >+ // fast exit >+ if(cyclic) >+ return; >+ >+ parentStack.add(parent); >+ for (AbstractTask child : parent.getChildrenInternal()) { >+ if (parentStack.contains(child)) { >+ cyclic = true; >+ return; >+ } else { >+ containsCyclicHelper(child, visited, parentStack); >+ } >+ } >+ parentStack.remove(parent); >+ } >+ >+ public IPropertyDescriptor[] getPropertyDescriptors() { >+ TextPropertyDescriptor children= new TextPropertyDescriptor(CHILDREN, "Total Children (internal)"); >+ children.setCategory(description); >+ TextPropertyDescriptor offspring = new TextPropertyDescriptor(OFFSPRING, "Total Offspring"); >+ offspring.setCategory(description); >+ TextPropertyDescriptor cyclic = new TextPropertyDescriptor(IS_CYCLIC, "Test is offspring cyclic?"); >+ cyclic.setCategory(description); >+ return new IPropertyDescriptor[] { >+ children, >+ offspring, >+ cyclic >+ }; >+ } >+ >+ public Object getPropertyValue(Object id) { >+ if (CHILDREN.equals(id)) { >+ return container.getChildrenInternal().size(); >+ } else if (OFFSPRING.equals(id)) { >+ return getDescendants(container).size(); >+ } else if (IS_CYCLIC.equals(id)) { >+ return containsCyclic(container) ? "Cyclic" : "Not Cyclic"; >+ } >+ return null; >+ } >+ >+ public boolean isPropertySet(Object id) { >+ // ignore >+ return false; >+ } >+ >+ public void resetPropertyValue(Object id) { >+ // ignore >+ >+ } >+ >+ public void setPropertyValue(Object id, Object value) { >+ // ignore >+ } >+ >+ public Object getEditableValue() { >+ // ignore >+ return null; >+ } >+ >+ /** >+ * @param specific >+ * @return >+ */ >+ public IPropertyDescriptor[] appendSpecifics(IPropertyDescriptor[] specific, IPropertyDescriptor[] these) { >+ IPropertyDescriptor[] all = new IPropertyDescriptor[specific.length + these.length]; >+ System.arraycopy(these, 0, all, 0, these.length); >+ System.arraycopy(specific, 0, all, these.length, specific.length); >+ return all; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 210639
: 83516 |
83517