Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-02-09 03:55:48 -0500
committerspingel2011-02-09 03:55:48 -0500
commit60b5d6c1e70fde9a870561d6ce78827066633e7a (patch)
treeb859de2d7169cc7d2af871ee24a5c30467546456 /org.eclipse.mylyn.tasks.search
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.search')
-rw-r--r--org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java5
-rw-r--r--org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchStyledLabelProvider.java241
2 files changed, 3 insertions, 243 deletions
diff --git a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
index 10308e32d..350ba97a3 100644
--- a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
+++ b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
@@ -32,6 +32,7 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.mylyn.internal.provisional.commons.ui.DecoratingPatternStyledCellLabelProvider;
import org.eclipse.mylyn.internal.provisional.commons.ui.EnhancedFilteredTree;
import org.eclipse.mylyn.internal.provisional.commons.ui.SubstringPatternFilter;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
@@ -151,7 +152,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
private SearchResultSortAction sortByDialogAction;
- private RepositorySearchStyledLabelProvider styledLabelProvider;
+ private DecoratingPatternStyledCellLabelProvider styledLabelProvider;
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() {
public String[] getShowInTargetIds() {
@@ -221,7 +222,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
searchResultProvider = new SearchResultTreeContentProvider();
viewer.setContentProvider(searchResultProvider);
- styledLabelProvider = new RepositorySearchStyledLabelProvider(new SearchResultsLabelProvider(
+ styledLabelProvider = new DecoratingPatternStyledCellLabelProvider(new SearchResultsLabelProvider(
searchResultProvider, viewer), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(),
null);
viewer.setLabelProvider(styledLabelProvider);
diff --git a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchStyledLabelProvider.java b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchStyledLabelProvider.java
deleted file mode 100644
index 6179cc4e3..000000000
--- a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchStyledLabelProvider.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Perforce - enhancements for bug 319469
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.tasks.ui.search;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IDecorationContext;
-import org.eclipse.jface.viewers.IFontProvider;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.StyledCellLabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.ViewerColumn;
-import org.eclipse.search.internal.ui.text.DecoratingFileSearchLabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.misc.StringMatcher;
-import org.eclipse.ui.internal.misc.StringMatcher.Position;
-
-/**
- * Repository search styled label provider. Based on {@link DecoratingFileSearchLabelProvider}.
- *
- * @author Kevin Sawicki
- * @see DecoratingFileSearchLabelProvider
- */
-public class RepositorySearchStyledLabelProvider extends DecoratingStyledCellLabelProvider implements
- IPropertyChangeListener, ILabelProvider {
-
- /**
- * Color to use to decorate matches.
- */
- public static final String HIGHLIGHT_BG_COLOR_NAME = "org.eclipse.jdt.ui.ColoredLabels.match_highlight"; //$NON-NLS-1$
-
- private static class PatternStyledLabelProvider extends StyledCellLabelProvider implements IStyledLabelProvider,
- IColorProvider, IFontProvider {
-
- private final SearchResultsLabelProvider labelProvider;
-
- private StringMatcher matcher = null;
-
- public PatternStyledLabelProvider(SearchResultsLabelProvider provider) {
- this.labelProvider = provider;
- }
-
- /**
- * Set the pattern to highlight
- *
- * @param pattern
- */
- public void setPattern(String pattern) {
- if (pattern != null && pattern.length() > 0) {
- this.matcher = new StringMatcher(pattern, true, false);
- } else {
- this.matcher = null;
- }
- }
-
- public StyledString getStyledText(Object element) {
- StyledString styled = null;
- String label = this.labelProvider.getText(element);
- if (matcher == null || label.length() == 0) {
- styled = new StyledString(label);
- } else {
- styled = new StyledString();
- int start = 0;
- int end = 0;
- int length = label.length();
- Position position = matcher.find(label, start, length);
- while (position != null) {
- end = position.getStart();
- styled.append(label.substring(start, end));
- start = position.getEnd();
- styled.append(label.substring(end, start), DecoratingFileSearchLabelProvider.HIGHLIGHT_STYLE);
- position = matcher.find(label, start, length);
- }
- if (start > 0 && start < length) {
- styled.append(label.substring(start));
- }
- }
- return styled;
- }
-
- public Image getImage(Object element) {
- return this.labelProvider.getImage(element);
- }
-
- public Font getFont(Object element) {
- return this.labelProvider.getFont(element);
- }
-
- public Color getForeground(Object element) {
- return this.labelProvider.getForeground(element);
- }
-
- public Color getBackground(Object element) {
- return this.labelProvider.getBackground(element);
- }
-
- }
-
- private final ILabelProvider labelProvider;
-
- /**
- * Create a new repository search styled label provider that wraps an {@link ILabelProvider}
- *
- * @param labelProvider
- * @param decorator
- * @param decorationContext
- */
- public RepositorySearchStyledLabelProvider(SearchResultsLabelProvider labelProvider, ILabelDecorator decorator,
- IDecorationContext decorationContext) {
- super(new PatternStyledLabelProvider(labelProvider), decorator, decorationContext);
- this.labelProvider = labelProvider;
- }
-
- /**
- * @see org.eclipse.jface.viewers.StyledCellLabelProvider#initialize(org.eclipse.jface.viewers.ColumnViewer,
- * org.eclipse.jface.viewers.ViewerColumn)
- */
- @Override
- public void initialize(ColumnViewer viewer, ViewerColumn column) {
- PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
- JFaceResources.getColorRegistry().addListener(this);
-
- setOwnerDrawEnabled(PlatformUI.getPreferenceStore()
- .getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
-
- super.initialize(viewer, column);
- }
-
- /**
- * Get underyling label provider
- *
- * @return label provider
- */
- public ILabelProvider getLabelProvider() {
- return this.labelProvider;
- }
-
- /**
- * @see org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider#dispose()
- */
- @Override
- public void dispose() {
- PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
- JFaceResources.getColorRegistry().removeListener(this);
- this.labelProvider.dispose();
- super.dispose();
- }
-
- /**
- * Set the pattern to highlight
- *
- * @param pattern
- */
- public void setPattern(String pattern) {
- ((PatternStyledLabelProvider) getStyledStringProvider()).setPattern(pattern);
- }
-
- /**
- * Refresh the labels on viewer associated with this label provider. This method must be called on the UI-thread.
- */
- protected void refresh() {
- ColumnViewer viewer = getViewer();
- if (viewer != null) {
- boolean coloredLabels = PlatformUI.getPreferenceStore().getBoolean(
- IWorkbenchPreferenceConstants.USE_COLORED_LABELS);
- if (coloredLabels || coloredLabels != isOwnerDrawEnabled()) {
- setOwnerDrawEnabled(coloredLabels);
- viewer.refresh();
- }
- }
- }
-
- /**
- * Schedule a refresh of this label provider. This method can be called from any thread.
- */
- protected void scheduleRefresh() {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- refresh();
- }
- });
- }
-
- /**
- * @param event
- */
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (IWorkbenchPreferenceConstants.USE_COLORED_LABELS.equals(property)
- || HIGHLIGHT_BG_COLOR_NAME.equals(property)) {
- scheduleRefresh();
- }
- }
-
- /**
- * Get text of element from underyling label provider
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return this.labelProvider.getText(element);
- }
-
- /**
- * Override preparation of style range to add border dot about highlight regions that don't have colors applied
- *
- * @see org.eclipse.jface.viewers.StyledCellLabelProvider#prepareStyleRange(org.eclipse.swt.custom.StyleRange,
- * boolean)
- */
- @Override
- protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) {
- boolean addBorder = !applyColors && styleRange.background != null;
- styleRange = super.prepareStyleRange(styleRange, applyColors);
- if (addBorder) {
- styleRange.borderStyle = SWT.BORDER_DOT;
- }
- return styleRange;
- }
-
-}

Back to the top