Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-02-09 08:55:48 +0000
committerspingel2011-02-09 08:55:48 +0000
commit60b5d6c1e70fde9a870561d6ce78827066633e7a (patch)
treeb859de2d7169cc7d2af871ee24a5c30467546456 /org.eclipse.mylyn.tasks.ui
parent81054e3f0df2c6d210450e2613b740aad87a935e (diff)
downloadorg.eclipse.mylyn.tasks-60b5d6c1e70fde9a870561d6ce78827066633e7a.tar.gz
org.eclipse.mylyn.tasks-60b5d6c1e70fde9a870561d6ce78827066633e7a.tar.xz
org.eclipse.mylyn.tasks-60b5d6c1e70fde9a870561d6ce78827066633e7a.zip
NEW - bug 334023: decorate task relations in outline
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334023
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java141
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/messages.properties1
3 files changed, 96 insertions, 48 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/Messages.java
index a427243a6..8150032ba 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/Messages.java
@@ -16,6 +16,8 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.tasks.ui.editors.outline.messages"; //$NON-NLS-1$
+ public static String QuickOutlineDialog_Node_Label_Decoration;
+
public static String QuickOutlineDialog_Press_Esc_Info_Text;
static {
// initialize resource bundle
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java
index 20ce60fa3..a5e062251 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java
@@ -23,17 +23,22 @@ import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylyn.internal.provisional.commons.ui.DecoratingPatternStyledCellLabelProvider;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineContentProvider;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineModel;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineNode;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -50,6 +55,7 @@ import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -72,6 +78,48 @@ import org.eclipse.ui.forms.editor.IFormPage;
public class QuickOutlineDialog extends PopupDialog implements IInformationControl, IInformationControlExtension,
IInformationControlExtension2, DisposeListener {
+ public final class Filter extends PatternFilter {
+ @Override
+ protected boolean wordMatches(String text) {
+ return super.wordMatches(text);
+ }
+ }
+
+ public final class TaskEditorOutlineLabelDecorator implements ILabelDecorator {
+
+ public String decorateText(String text, Object element) {
+ if (element instanceof TaskEditorOutlineNode) {
+ TaskEditorOutlineNode node = (TaskEditorOutlineNode) element;
+ if (node.getTaskRelation() != null) {
+ return NLS.bind(Messages.QuickOutlineDialog_Node_Label_Decoration, text, node.getTaskRelation()
+ .toString());
+ }
+ }
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ // ignore
+ }
+
+ public void dispose() {
+ // ignore
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ // ignore
+ }
+
+ public Image decorateImage(Image image, Object element) {
+ return null;
+ }
+
+ }
+
private class OpenListener implements IOpenListener, IDoubleClickListener, MouseListener {
private final Viewer viewer;
@@ -126,7 +174,7 @@ public class QuickOutlineDialog extends PopupDialog implements IInformationContr
private Text filterText;
- private PatternFilter namePatternFilter;
+ private Filter namePatternFilter;
private OpenListener openListener;
@@ -162,7 +210,7 @@ public class QuickOutlineDialog extends PopupDialog implements IInformationContr
viewer.addOpenListener(openListener);
viewer.getTree().addMouseListener(openListener);
- namePatternFilter = new PatternFilter();
+ namePatternFilter = new Filter();
namePatternFilter.setIncludeLeadingWildcard(true);
viewer.addFilter(namePatternFilter);
@@ -188,7 +236,8 @@ public class QuickOutlineDialog extends PopupDialog implements IInformationContr
viewer.setUseHashlookup(true);
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.setContentProvider(new TaskEditorOutlineContentProvider());
- viewer.setLabelProvider(new QuickOutlineLabelProvider());
+ viewer.setLabelProvider(new DecoratingPatternStyledCellLabelProvider(new QuickOutlineLabelProvider(),
+ new TaskEditorOutlineLabelDecorator(), null));
return viewer;
}
@@ -473,7 +522,7 @@ public class QuickOutlineDialog extends PopupDialog implements IInformationContr
viewer.getControl().setRedraw(false);
viewer.refresh();
viewer.expandAll();
-// selectFirstMatch();
+ selectFirstMatch();
viewer.getControl().setRedraw(true);
}
@@ -494,49 +543,45 @@ public class QuickOutlineDialog extends PopupDialog implements IInformationContr
return taskEditorPage;
}
-// /**
-// * Selects the first element in the tree which matches the current filter pattern.
-// */
-// private void selectFirstMatch() {
-// Tree tree = viewer.getTree();
-// Object element = findFirstMatchToPattern(tree.getItems());
-// if (element != null) {
-// viewer.setSelection(new StructuredSelection(element), true);
-// } else {
-// viewer.setSelection(StructuredSelection.EMPTY);
-// }
-// }
-//
-// /**
-// * @param items
-// * @return
-// */
-// private Object findFirstMatchToPattern(TreeItem[] items) {
-// // Match the string pattern against labels
-// ILabelProvider labelProvider = (ILabelProvider) viewer.getLabelProvider();
-// // Process each item in the tree
-// for (TreeItem item : items) {
-// Object element = item.getData();
-// // Return the first element if no pattern is set
-// if (fStringMatcher == null) {
-// return element;
-// }
-// // Return the element if it matches the pattern
-// if (element != null) {
-// String label = labelProvider.getText(element);
-// if (fStringMatcher.match(label)) {
-// return element;
-// }
-// }
-// // Recursively check the elements children for a match
-// element = findFirstMatchToPattern(item.getItems());
-// // Return the child element match if found
-// if (element != null) {
-// return element;
-// }
-// }
-// // No match found
-// return null;
-// }
+ /**
+ * Selects the first element in the tree which matches the current filter pattern.
+ */
+ private void selectFirstMatch() {
+ Tree tree = viewer.getTree();
+ Object element = findFirstMatchToPattern(tree.getItems());
+ if (element != null) {
+ viewer.setSelection(new StructuredSelection(element), true);
+ } else {
+ viewer.setSelection(StructuredSelection.EMPTY);
+ }
+ }
+
+ /**
+ * @param items
+ * @return
+ */
+ private Object findFirstMatchToPattern(TreeItem[] items) {
+ // Match the string pattern against labels
+ ILabelProvider labelProvider = (ILabelProvider) viewer.getLabelProvider();
+ // Process each item in the tree
+ for (TreeItem item : items) {
+ Object element = item.getData();
+ // Return the element if it matches the pattern
+ if (element != null) {
+ String label = labelProvider.getText(element);
+ if (namePatternFilter.wordMatches(label)) {
+ return element;
+ }
+ }
+ // Recursively check the elements children for a match
+ element = findFirstMatchToPattern(item.getItems());
+ // Return the child element match if found
+ if (element != null) {
+ return element;
+ }
+ }
+ // No match found
+ return null;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/messages.properties
index 7c7f7bc60..c16a81814 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/messages.properties
@@ -8,4 +8,5 @@
# Contributors:
# Tasktop Technologies - initial API and implementation
###############################################################################
+QuickOutlineDialog_Node_Label_Decoration={0} [{1}]
QuickOutlineDialog_Press_Esc_Info_Text=Press 'Esc' to exit the dialog.

Back to the top