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 154190 Details for
Bug 292330
[framework] HighlighterImageDescriptor should not hold on to image
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed patch
clipboard.txt (text/plain), 55.08 KB, created by
Steffen Pingel
on 2009-12-09 23:32:47 EST
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2009-12-09 23:32:47 EST
Size:
55.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.context.ui >Index: src/org/eclipse/mylyn/internal/context/ui/HighlighterImageDescriptor.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/context/ui/HighlighterImageDescriptor.java >diff -N src/org/eclipse/mylyn/internal/context/ui/HighlighterImageDescriptor.java >--- src/org/eclipse/mylyn/internal/context/ui/HighlighterImageDescriptor.java 10 Dec 2009 04:31:08 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,280 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2009 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 >- * Tasktop Technologies - changes to support reuse >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.context.ui; >- >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.ImageData; >-import org.eclipse.swt.graphics.PaletteData; >-import org.eclipse.swt.graphics.RGB; >-import org.eclipse.swt.widgets.Display; >- >-/** >- * @author Mik Kersten >- * @author Steffen Pingel >- */ >-public class HighlighterImageDescriptor extends ImageDescriptor { >- >- private final ImageData imageData; >- >- private final RGB fromColor; >- >- private final RGB toColor; >- >- @Deprecated >- public HighlighterImageDescriptor(Color fromColor, Color toColor) { >- this(fromColor != null ? fromColor.getRGB() : null, toColor != null ? toColor.getRGB() : null); >- } >- >- public HighlighterImageDescriptor(RGB fromColor, RGB toColor) { >- if (fromColor == null) { >- fromColor = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB(); >- } >- if (toColor == null) { >- toColor = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB(); >- } >- this.fromColor = fromColor; >- this.toColor = toColor; >- this.imageData = createGradientBand(50, 20, false, fromColor, toColor, 7, 7, 7); >- } >- >- @Override >- public ImageData getImageData() { >- return imageData; >- } >- >- public RGB getFromColor() { >- return fromColor; >- } >- >- public RGB getToColor() { >- return toColor; >- } >- >- @Override >- public int hashCode() { >- final int prime = 31; >- int result = 1; >- result = prime * result + ((fromColor == null) ? 0 : fromColor.hashCode()); >- result = prime * result + ((toColor == null) ? 0 : toColor.hashCode()); >- return result; >- } >- >- @Override >- public boolean equals(Object obj) { >- if (this == obj) { >- return true; >- } >- if (obj == null) { >- return false; >- } >- if (getClass() != obj.getClass()) { >- return false; >- } >- HighlighterImageDescriptor other = (HighlighterImageDescriptor) obj; >- if (fromColor == null) { >- if (other.fromColor != null) { >- return false; >- } >- } else if (!fromColor.equals(other.fromColor)) { >- return false; >- } >- if (toColor == null) { >- if (other.toColor != null) { >- return false; >- } >- } else if (!toColor.equals(other.toColor)) { >- return false; >- } >- return true; >- } >- >- // ----------- COPIED FROM ImageData --------------- >- >- /** >- * Creates an ImageData containing one band's worth of a gradient filled block. If <code>vertical</code> is true, >- * the band must be tiled horizontally to fill a region, otherwise it must be tiled vertically. >- * >- * @param width >- * the width of the region to be filled >- * @param height >- * the height of the region to be filled >- * @param vertical >- * if true sweeps from top to bottom, else sweeps from left to right >- * @param fromRGB >- * the color to start with >- * @param toRGB >- * the color to end with >- * @param redBits >- * the number of significant red bits, 0 for palette modes >- * @param greenBits >- * the number of significant green bits, 0 for palette modes >- * @param blueBits >- * the number of significant blue bits, 0 for palette modes >- * @return the new ImageData >- */ >- static ImageData createGradientBand(int width, int height, boolean vertical, RGB fromRGB, RGB toRGB, int redBits, >- int greenBits, int blueBits) { >- /* Gradients are drawn as tiled bands */ >- final int bandWidth, bandHeight, bitmapDepth; >- final byte[] bitmapData; >- final PaletteData paletteData; >- /* Select an algorithm depending on the depth of the screen */ >- if (redBits != 0 && greenBits != 0 && blueBits != 0) { >- paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000); >- bitmapDepth = 32; >- if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) { >- /* Precise color */ >- final int steps; >- if (vertical) { >- bandWidth = 1; >- bandHeight = height; >- steps = bandHeight > 1 ? bandHeight - 1 : 1; >- } else { >- bandWidth = width; >- bandHeight = 1; >- steps = bandWidth > 1 ? bandWidth - 1 : 1; >- } >- final int bytesPerLine = bandWidth * 4; >- bitmapData = new byte[bandHeight * bytesPerLine]; >- buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, >- bitmapData, 0, bytesPerLine); >- buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, >- bitmapData, 1, bytesPerLine); >- buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, >- 2, bytesPerLine); >- } else { >- /* Dithered color */ >- final int steps; >- if (vertical) { >- bandWidth = (width < 8) ? width : 8; >- bandHeight = height; >- steps = bandHeight > 1 ? bandHeight - 1 : 1; >- } else { >- bandWidth = width; >- bandHeight = (height < 8) ? height : 8; >- steps = bandWidth > 1 ? bandWidth - 1 : 1; >- } >- final int bytesPerLine = bandWidth * 4; >- bitmapData = new byte[bandHeight * bytesPerLine]; >- buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, >- bitmapData, 0, bytesPerLine, blueBits); >- buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, >- bitmapData, 1, bytesPerLine, greenBits); >- buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, >- bitmapData, 2, bytesPerLine, redBits); >- } >- } else { >- /* Dithered two tone */ >- paletteData = new PaletteData(new RGB[] { fromRGB, toRGB }); >- bitmapDepth = 8; >- final int blendi; >- if (vertical) { >- bandWidth = (width < 8) ? width : 8; >- bandHeight = height; >- blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1; >- } else { >- bandWidth = width; >- bandHeight = (height < 8) ? height : 8; >- blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1; >- } >- final int bytesPerLine = (bandWidth + 3) & -4; >- bitmapData = new byte[bandHeight * bytesPerLine]; >- if (vertical) { >- for (int dy = 0, blend = 0, dp = 0; dy < bandHeight; ++dy, blend += blendi, dp += bytesPerLine) { >- for (int dx = 0; dx < bandWidth; ++dx) { >- bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) < 0x1000000 ? (byte) 0 : (byte) 1; >- } >- } >- } else { >- for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) { >- for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) { >- bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) < 0x1000000 ? (byte) 0 : (byte) 1; >- } >- } >- } >- } >- return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData); >- } >- >- /* >- * Fill in dithered gradated values for a color channel >- */ >- static final void buildDitheredGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, >- boolean vertical, byte[] bitmapData, int dp, int bytesPerLine, int bits) { >- final int mask = 0xff00 >>> bits; >- int val = from << 16; >- final int inc = ((to << 16) - val) / steps + 1; >- if (vertical) { >- for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) { >- for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) { >- final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits; >- int temp = val + thresh; >- if (temp > 0xffffff) { >- bitmapData[dptr] = -1; >- } else { >- bitmapData[dptr] = (byte) ((temp >>> 16) & mask); >- } >- } >- val += inc; >- } >- } else { >- for (int dx = 0; dx < bandWidth; ++dx, dp += 4) { >- for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) { >- final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits; >- int temp = val + thresh; >- if (temp > 0xffffff) { >- bitmapData[dptr] = -1; >- } else { >- bitmapData[dptr] = (byte) ((temp >>> 16) & mask); >- } >- } >- val += inc; >- } >- } >- } >- >- /* >- * Fill in gradated values for a color channel >- */ >- static final void buildPreciseGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, >- boolean vertical, byte[] bitmapData, int dp, int bytesPerLine) { >- int val = from << 16; >- final int inc = ((to << 16) - val) / steps + 1; >- if (vertical) { >- for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) { >- bitmapData[dp] = (byte) (val >>> 16); >- val += inc; >- } >- } else { >- for (int dx = 0; dx < bandWidth; ++dx, dp += 4) { >- bitmapData[dp] = (byte) (val >>> 16); >- val += inc; >- } >- } >- } >- >- /** >- * Scaled 8x8 Bayer dither matrix. >- */ >- static final int[][] DITHER_MATRIX = { >- { 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 }, >- { 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 }, >- { 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 }, >- { 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 }, >- { 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 }, >- { 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 }, >- { 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 }, >- { 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 } }; >-} >#P org.eclipse.mylyn.sandbox.ui >Index: src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java,v >retrieving revision 1.18 >diff -u -r1.18 SandboxUiPlugin.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java 24 Jul 2009 12:07:51 -0000 1.18 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java 10 Dec 2009 04:35:57 -0000 >@@ -11,15 +11,10 @@ > > package org.eclipse.mylyn.internal.sandbox.ui; > >-import java.util.List; >- > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.mylyn.commons.core.StatusHandler; >-import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin; >-import org.eclipse.mylyn.internal.sandbox.ui.highlighters.Highlighter; >-import org.eclipse.mylyn.internal.sandbox.ui.highlighters.HighlighterList; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; >@@ -48,8 +43,6 @@ > > private InterestInducingProblemListener problemListener; > >- private HighlighterList highlighters; >- > public SandboxUiPlugin() { > super(); > plugin = this; >@@ -67,9 +60,6 @@ > problemListener.enable(); > } > >- // initialize colors to work around deadlock on bug 237596 >- getHighlighterList(); >- > final IWorkbench workbench = PlatformUI.getWorkbench(); > workbench.getDisplay().asyncExec(new Runnable() { > public void run() { >@@ -93,11 +83,6 @@ > > @Override > public void stop(BundleContext context) throws Exception { >- if (highlighters != null) { >- highlighters.dispose(); >- highlighters = null; >- } >- > if (problemListener != null) { > getPreferenceStore().removePropertyChangeListener(problemListener); > } >@@ -141,54 +126,4 @@ > return sharedDataDirectoryManager; > } > >- private void initializeHighlighters() { >- String hlist = getPreferenceStore().getString(HIGHLIGHTER_PREFIX); >- if (hlist.length() == 0) { >- // migrate preference from context ui >- hlist = ContextUiPlugin.getDefault().getPreferenceStore().getString(HIGHLIGHTER_PREFIX); >- getPreferenceStore().setValue(HIGHLIGHTER_PREFIX, hlist); >- ContextUiPlugin.getDefault().getPreferenceStore().setToDefault(HIGHLIGHTER_PREFIX); >- } >- if (hlist.length() == 0) { >- highlighters = new HighlighterList(); >- highlighters.setToDefaultList(); >- } else { >- highlighters = new HighlighterList(hlist); >- } >- } >- >- public synchronized HighlighterList getHighlighterList() { >- if (highlighters == null) { >- initializeHighlighters(); >- } >- return highlighters; >- } >- >- public List<Highlighter> getHighlighters() { >- return getHighlighterList().getHighlighters(); >- } >- >- /** >- * @return null if not found >- */ >- public Highlighter getHighlighter(String name) { >- return getHighlighterList().getHighlighter(name); >- } >- >- public Highlighter getHighlighterForContextId(String id) { >- String prefId = TASK_HIGHLIGHTER_PREFIX + id; >- String highlighterName = getPreferenceStore().getString(prefId); >- if (highlighterName.equals("")) { >- highlighterName = ContextUiPlugin.getDefault().getPreferenceStore().getString(prefId); >- getPreferenceStore().setValue(prefId, highlighterName); >- ContextUiPlugin.getDefault().getPreferenceStore().setToDefault(prefId); >- } >- return getHighlighter(highlighterName); >- } >- >- public void setHighlighterMapping(String id, String name) { >- String prefId = TASK_HIGHLIGHTER_PREFIX + id; >- getPreferenceStore().putValue(prefId, name); >- } >- > } >Index: src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java,v >retrieving revision 1.22 >diff -u -r1.22 SandboxUiPreferencePage.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java 10 Dec 2009 04:31:08 -0000 1.22 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java 10 Dec 2009 04:35:57 -0000 >@@ -14,48 +14,19 @@ > > package org.eclipse.mylyn.internal.sandbox.ui; > >-import java.util.Arrays; >- > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.preference.PreferencePage; >-import org.eclipse.jface.viewers.CellEditor; >-import org.eclipse.jface.viewers.ColorCellEditor; >-import org.eclipse.jface.viewers.ComboBoxCellEditor; >-import org.eclipse.jface.viewers.ICellEditorListener; >-import org.eclipse.jface.viewers.ICellModifier; >-import org.eclipse.jface.viewers.IStructuredContentProvider; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.ITableLabelProvider; >-import org.eclipse.jface.viewers.LabelProvider; >-import org.eclipse.jface.viewers.TableViewer; >-import org.eclipse.jface.viewers.TextCellEditor; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerSorter; > import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin; >-import org.eclipse.mylyn.internal.context.ui.HighlighterImageDescriptor; >-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; >-import org.eclipse.mylyn.internal.sandbox.ui.highlighters.Highlighter; >-import org.eclipse.mylyn.internal.sandbox.ui.highlighters.HighlighterList; > import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Group; >-import org.eclipse.swt.widgets.Table; >-import org.eclipse.swt.widgets.TableColumn; >-import org.eclipse.swt.widgets.TableItem; >-import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPreferencePage; > >@@ -64,40 +35,19 @@ > * @author Mik Kersten > * @author Eugene Kuleshov > */ >-public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICellEditorListener { >- >- private Table table; >- >- private TableViewer tableViewer; >+public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { > >- private Button enableErrorInterest = null; >+ private Button enableErrorInterest; > >- private ColorCellEditor colorDialogEditor; >- >- private Button incomingOverlaysButton = null; >+ private Button incomingOverlaysButton; > > private Button activateOnOpen; > > private Button showTaskTrimButton; > >- private Highlighter selection = null; >- > private Button useStrikethrough; > >- private HighlighterContentProvider contentProvider = null; >- >- private static final String LABEL_COLUMN = "Label"; >- >- private static final String COLOR_COLUMN = "Color"; >- >- private static final String TYPE_COLUMN = "Type"; >- >- private static String[] columnNames = new String[] { LABEL_COLUMN, COLOR_COLUMN, TYPE_COLUMN, }; >- >- static final String[] TYPE_ARRAY = { "Gradient", "Solid" }; >- > public SandboxUiPreferencePage() { >- super(); > setPreferenceStore(ContextUiPlugin.getDefault().getPreferenceStore()); > } > >@@ -111,14 +61,6 @@ > createTaskListGroup(container); > createJavaGroup(container); > >- createHighlightersTable(container); >- createTableViewer(); >- >- contentProvider = new HighlighterContentProvider(); >- tableViewer.setContentProvider(contentProvider); >- tableViewer.setLabelProvider(new HighlighterLabelProvider()); >- tableViewer.setInput(SandboxUiPlugin.getDefault().getHighlighterList()); >- > return container; > } > >@@ -174,62 +116,6 @@ > InterestInducingProblemListener.PREDICTED_INTEREST_ERRORS)); > } > >- private void createHighlightersTable(Composite parent) { >- Group tableComposite = new Group(parent, SWT.SHADOW_ETCHED_IN); >- tableComposite.setText("Context Highlighters"); >- tableComposite.setLayout(new GridLayout(2, false)); >- tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- >- int style = SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION; >- >- table = new Table(tableComposite, style); >- >- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); >- table.setLayoutData(gridData); >- table.setLinesVisible(true); >- table.setHeaderVisible(true); >- >- // 1st column with Label >- TableColumn column = new TableColumn(table, SWT.NONE, 0); >- column.setText("Label"); >- column.setWidth(150); >- column.addSelectionListener(new SelectionAdapter() { >- >- @Override >- public void widgetSelected(SelectionEvent e) { >- tableViewer.setSorter(new HighlighterTableSorter(HighlighterTableSorter.LABEL)); >- } >- }); >- >- // 2nd column with highlighter Description >- column = new TableColumn(table, SWT.LEAD, 1); >- column.setResizable(false); >- column.setText("Color"); >- column.setWidth(100); >- column.addSelectionListener(new SelectionAdapter() { >- >- @Override >- public void widgetSelected(SelectionEvent e) { >- tableViewer.setSorter(new HighlighterTableSorter(HighlighterTableSorter.COLOR)); >- } >- }); >- >- // 3rd column with Type >- column = new TableColumn(table, SWT.LEAD, 2); >- column.setResizable(false); >- column.setText("Kind"); >- column.setWidth(80); >- column.addSelectionListener(new SelectionAdapter() { >- >- @Override >- public void widgetSelected(SelectionEvent e) { >- tableViewer.setSorter(new HighlighterTableSorter(HighlighterTableSorter.TYPE)); >- } >- }); >- >- createAddRemoveButtons(tableComposite); >- } >- > @Override > public boolean performOk() { > IPreferenceStore uiPreferenceStore = TasksUiPlugin.getDefault().getPreferenceStore(); >@@ -250,9 +136,6 @@ > > SandboxUiPlugin.getDefault().getPreferenceStore().setValue( > InterestInducingProblemListener.PREDICTED_INTEREST_ERRORS, enableErrorInterest.getSelection()); >- >- getPreferenceStore().setValue(SandboxUiPlugin.HIGHLIGHTER_PREFIX, >- SandboxUiPlugin.getDefault().getHighlighterList().externalizeToString()); > return true; > } > >@@ -264,15 +147,9 @@ > useStrikethrough.setSelection(TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( > ITasksUiPreferenceConstants.USE_STRIKETHROUGH_FOR_COMPLETED)); > >- String highlighters = getPreferenceStore().getString(SandboxUiPlugin.HIGHLIGHTER_PREFIX); >- SandboxUiPlugin.getDefault().getHighlighterList().internalizeFromString(highlighters); >- > IPreferenceStore uiPreferenceStore = TasksUiPlugin.getDefault().getPreferenceStore(); > activateOnOpen.setSelection(uiPreferenceStore.getBoolean(ITasksUiPreferenceConstants.ACTIVATE_WHEN_OPENED)); > showTaskTrimButton.setSelection(uiPreferenceStore.getBoolean(ITasksUiPreferenceConstants.SHOW_TRIM)); >- >- contentProvider = new HighlighterContentProvider(); >- tableViewer.setContentProvider(contentProvider); > return true; > } > >@@ -284,378 +161,6 @@ > > useStrikethrough.setSelection(TasksUiPlugin.getDefault().getPreferenceStore().getDefaultBoolean( > ITasksUiPreferenceConstants.USE_STRIKETHROUGH_FOR_COMPLETED)); >- >- contentProvider = new HighlighterContentProvider(); >- tableViewer.setContentProvider(contentProvider); >- SandboxUiPlugin.getDefault().getHighlighterList().setToDefaultList(); >- } >- >- /** >- * Class HighlighterLabelProvider - Label and image provider for tableViewer >- */ >- private static class HighlighterLabelProvider extends LabelProvider implements ITableLabelProvider { >- >- public HighlighterLabelProvider() { >- // don't have any initialization to do >- } >- >- /** >- * getColumnText - returns text for label and combo box cells >- */ >- public String getColumnText(Object obj, int columnIndex) { >- String result = ""; >- if (obj instanceof Highlighter) { >- Highlighter h = (Highlighter) obj; >- switch (columnIndex) { >- case 0: >- // return name for label column >- result = h.getName(); >- break; >- case 2: >- // return type for type column >- result = h.getHighlightKind(); >- break; >- default: >- break; >- } >- } >- return result; >- } >- >- /** >- * getColumnImage - returns image for color column >- */ >- public Image getColumnImage(Object obj, int columnIndex) { >- if (obj instanceof Highlighter) { >- Highlighter h = (Highlighter) obj; >- switch (columnIndex) { >- case 1: >- HighlighterImageDescriptor des; >- if (h.isGradient()) { >- des = new HighlighterImageDescriptor(h.getBase(), h.getHighlightColor()); >- } else { >- des = new HighlighterImageDescriptor(h.getHighlightColor(), h.getHighlightColor()); >- } >- return CommonImages.getImage(des); >- default: >- break; >- } >- } >- return null; >- } >- } >- >- /** >- * Class HighLighterContentProvider - content provider for table viewer >- */ >- private class HighlighterContentProvider implements IStructuredContentProvider { >- >- /** >- * getElements - returns array of Highlighters for table >- */ >- public Object[] getElements(Object inputElement) { >- return SandboxUiPlugin.getDefault().getHighlighterList().getHighlighters().toArray(); >- } >- >- public void dispose() { >- // don't care when we are disposed >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- // don't care when the input changes >- } >- >- /** >- * addHighlighter - notify the tableViewer to add a highlighter called when a highlighter is added to the >- * HighlighterList >- */ >- public void addHighlighter(Highlighter hl) { >- tableViewer.add(hl); >- } >- >- /** >- * removeHighlighter - notify the tableViewer to remove a highlighter called when a highlighter is removed from >- * the HighlighterList >- */ >- public void removeHighlighter(Highlighter hl) { >- tableViewer.remove(hl); >- } >- >- /** >- * updateHighlighter - notify the tableViewer to update a highlighter called when a highlighter property has >- * been changed >- */ >- public void updateHighlighter(Highlighter hl) { >- tableViewer.update(hl, null); >- } >- } >- >- /** >- * class HighlighterCellModifier - cellModifier for tableViewer handles all modification to the table >- */ >- private class HighlighterCellModifier implements ICellModifier { >- >- HighlighterCellModifier() { >- super(); >- } >- >- public boolean canModify(Object element, String property) { >- if (element instanceof Highlighter) { >- if (!((Highlighter) element).getName().equals(HighlighterList.DEFAULT_HIGHLIGHTER.getName())) { >- return true; >- } >- } >- return false; >- } >- >- /** >- * getValue - returns content of the current selection >- */ >- public Object getValue(Object element, String property) { >- // Find the index of the column >- int columnIndex = Arrays.asList(columnNames).indexOf(property); >- Object res = null; >- if (element instanceof Highlighter) { >- Highlighter hl = (Highlighter) element; >- switch (columnIndex) { >- case 0: // LABEL_COLUMN >- res = hl.getName(); >- break; >- case 1: // COLOR_COLUMN >- selection = hl; >- if (selection.getCore() != null) { >- return selection.getCore().getRGB(); >- } else { >- return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB(); >- } >- case 2: // KIND_COLUMN >- // return index of current value >- if (hl.isGradient()) { >- res = new Integer(0); >- } else if (hl.isIntersection()) { >- res = new Integer(2); >- } else { >- res = new Integer(1); >- } >- break; >- default: >- return null; >- } >- } >- return res; >- } >- >- /** >- * modify - modifies Highlighter with new property >- */ >- public void modify(Object element, String property, Object value) { >- // Find the index of the column >- int columnIndex = Arrays.asList(columnNames).indexOf(property); >- >- TableItem item = (TableItem) element; >- Highlighter hl = (Highlighter) item.getData(); >- switch (columnIndex) { >- case 0: // LABEL_COLUMN >- // change value of name >- if (value instanceof String) { >- // TableItem ti = (TableItem) element; >- hl.setName((String) value); >- >- // update contentprovider >- contentProvider.updateHighlighter(hl); >- } >- break; >- case 1: // COLOR_COLUMN >- // never gets called since color dialog is used. >- break; >- case 2: // KIND_COLUMN >- // sets new type >- if (value instanceof Integer) { >- int choice = ((Integer) value).intValue(); >- switch (choice) { >- case 0: >- // Gradient >- hl.setGradient(true); >- hl.setIntersection(false); >- break; >- case 1: >- // Solid >- hl.setGradient(false); >- hl.setIntersection(false); >- break; >- case 2: >- // Instersection >- hl.setGradient(false); >- hl.setIntersection(true); >- break; >- default: >- break; >- } >- // update content provider >- contentProvider.updateHighlighter(hl); >- } >- default: >- break; >- } >- return; >- } >- >- } >- >- /** >- * class HighlighterTableSorter - sort columns of table added to every column as a sorter >- */ >- private static class HighlighterTableSorter extends ViewerSorter { >- >- public final static int LABEL = 1; >- >- public final static int COLOR = 2; >- >- public final static int TYPE = 3; >- >- private final int criteria; >- >- /** >- * set the criteria >- */ >- public HighlighterTableSorter(int criteria) { >- super(); >- this.criteria = criteria; >- } >- >- /** >- * compare - invoked when column is selected calls the actual comparison method for particular criteria >- */ >- @Override >- public int compare(Viewer viewer, Object o1, Object o2) { >- Highlighter h1 = (Highlighter) o1; >- Highlighter h2 = (Highlighter) o2; >- switch (criteria) { >- case LABEL: >- return compareLabel(h1, h2); >- case COLOR: >- return compareImage(h1, h2); >- case TYPE: >- return compareType(h1, h2); >- default: >- return 0; >- } >- } >- >- /** >- * compareLabel - compare by label >- */ >- protected int compareLabel(Highlighter h1, Highlighter h2) { >- return h1.getName().compareTo(h2.getName()); >- } >- >- /** >- * compareImage - do nothing >- */ >- protected int compareImage(Highlighter h1, Highlighter h2) { >- return 0; >- } >- >- /** >- * compareType - compare by type >- */ >- protected int compareType(Highlighter h1, Highlighter h2) { >- return h1.getHighlightKind().compareTo(h2.getHighlightKind()); >- } >- >- } >- >- private void createTableViewer() { >- >- tableViewer = new TableViewer(table); >- tableViewer.setUseHashlookup(true); >- tableViewer.setColumnProperties(columnNames); >- >- CellEditor[] editors = new CellEditor[columnNames.length]; >- >- TextCellEditor textEditor = new TextCellEditor(table); >- ((Text) textEditor.getControl()).setTextLimit(20); >- ((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT); >- editors[0] = textEditor; >- >- colorDialogEditor = new ColorCellEditor(table); >- colorDialogEditor.addListener(this); >- editors[1] = colorDialogEditor; >- >- editors[2] = new ComboBoxCellEditor(table, TYPE_ARRAY, SWT.READ_ONLY); >- >- tableViewer.setCellEditors(editors); >- tableViewer.setCellModifier(new HighlighterCellModifier()); >- } >- >- private void createAddRemoveButtons(Composite parent) { >- >- Composite addRemoveComposite = new Composite(parent, SWT.LEAD); >- addRemoveComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); >- addRemoveComposite.setLayout(new GridLayout(2, false)); >- >- Button add = new Button(addRemoveComposite, SWT.PUSH | SWT.CENTER); >- add.setText("Add"); >- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >- gridData.widthHint = 80; >- add.setLayoutData(gridData); >- >- add.addSelectionListener(new SelectionAdapter() { >- >- @Override >- public void widgetSelected(SelectionEvent e) { >- Highlighter hl = SandboxUiPlugin.getDefault().getHighlighterList().addHighlighter(); >- contentProvider.addHighlighter(hl); >- } >- }); >- >- Button delete = new Button(addRemoveComposite, SWT.PUSH | SWT.CENTER); >- delete.setText("Delete"); >- gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >- gridData.widthHint = 80; >- delete.setLayoutData(gridData); >- >- delete.addSelectionListener(new SelectionAdapter() { >- >- @Override >- public void widgetSelected(SelectionEvent e) { >- Highlighter hl = (Highlighter) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement(); >- if (hl != null) { >- SandboxUiPlugin.getDefault().getHighlighterList().removeHighlighter(hl); >- contentProvider.removeHighlighter(hl); >- } >- } >- }); >- } >- >- /** >- * applyEditorValue - method called when Color selected >- */ >- public void applyEditorValue() { >- Object obj = colorDialogEditor.getValue(); >- if (!colorDialogEditor.isDirty() || !colorDialogEditor.isValueValid()) { >- return; >- } >- >- if (obj instanceof RGB) { >- // create new color >- RGB rgb = (RGB) obj; >- Color c = new Color(Display.getCurrent(), rgb.red, rgb.green, rgb.blue); >- if (selection != null) { >- selection.setCore(c); >- contentProvider.updateHighlighter(selection); >- } >- } else { >- // ignore >- } >- } >- >- public void cancelEditor() { >- // don't care about this >- } >- >- public void editorValueChanged(boolean oldValidState, boolean newValidState) { >- // don't care when the value is changed > } > > } >Index: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java 13 Jan 2009 07:05:17 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,275 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Tasktop Technologies 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: >- * Tasktop Technologies - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.highlighters; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.mylyn.commons.core.StatusHandler; >-import org.eclipse.mylyn.context.core.IInteractionElement; >-import org.eclipse.mylyn.internal.context.ui.ColorMap; >-import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.widgets.Display; >- >-/** >- * @author Mik Kersten >- */ >-public class Highlighter { >- >- private static final String LABEL_SOLID = "Solid"; >- >- private static final String LABEL_INTERSECTION = "Intersection"; >- >- private static final String LABEL_GRADIENT = "Gradient"; >- >- private static final int NUM_LEVELS = 17; >- >- private static final String VAL_DEFAULT = ""; >- >- private final List<Color> gradients = new ArrayList<Color>(); >- >- private String name; >- >- private Color core; >- >- private Color highlightColor; >- >- private boolean isGradient; >- >- private boolean isIntersection; >- >- public boolean isIntersection() { >- return isIntersection; >- } >- >- public void setIntersection(boolean isIntersection) { >- this.isIntersection = isIntersection; >- } >- >- public Highlighter(String name, Color coreColor, boolean isGradient) { >- this.name = name; >- this.core = coreColor; >- this.isGradient = isGradient; >- if (coreColor != null) { >- initializeHighlight(); >- initializeGradients(); >- } >- } >- >- public Highlighter(String attributes) { >- if (initializeFromString(attributes)) { >- initializeHighlight(); >- initializeGradients(); >- } >- } >- >- public void dispose() { >- for (Color color : gradients) { >- color.dispose(); >- } >- } >- >- public Color getHighlightColor() { >- return highlightColor; >- } >- >- public Color getHighlight(IInteractionElement info, boolean isLandmark) { >- if (info.getInterest().getValue() > 0) { >- if (isGradient) { >- return mapDoiToElevation(info); >- } else { >- return highlightColor; >- } >- } else { >- return ColorMap.COLOR_WHITE; >- } >- } >- >- public Color mapDoiToElevation(IInteractionElement element) { >- if (element == null) { >- return ColorMap.COLOR_WHITE; >- } >- if (element.getInterest().getValue() < 0) { >- return highlightColor; >- } >- >- int step = 2; >- Color color = ColorMap.COLOR_WHITE; >- for (Iterator<Color> it = gradients.iterator(); it.hasNext();) { >- color = it.next(); >- if (element.getInterest().getValue() < step) { >- return color; >- } >- step += 2; >- } >- return color; >- } >- >- private void initializeHighlight() { >- try { >- int redStep = (int) Math.ceil((core.getRed() + 2 * ColorMap.COLOR_WHITE.getRed()) / 3); >- int greenStep = (int) Math.ceil((core.getGreen() + 2 * ColorMap.COLOR_WHITE.getGreen()) / 3); >- int blueStep = (int) Math.ceil((core.getBlue() + 2 * ColorMap.COLOR_WHITE.getBlue()) / 3); >- >- highlightColor = new Color(Display.getDefault(), redStep, greenStep, blueStep); >- } catch (Throwable t) { >- StatusHandler.log(new Status(IStatus.ERROR, ContextUiPlugin.ID_PLUGIN, "Highlighter initialization failed", >- t)); >- } >- } >- >- private void initializeGradients() { >- try { >- int redStep = (int) Math.ceil((highlightColor.getRed() - ColorMap.COLOR_WHITE.getRed()) / NUM_LEVELS); >- int greenStep = (int) Math.ceil((highlightColor.getGreen() - ColorMap.COLOR_WHITE.getGreen()) / NUM_LEVELS); >- int blueStep = (int) Math.ceil((highlightColor.getBlue() - ColorMap.COLOR_WHITE.getBlue()) / NUM_LEVELS); >- >- int OFFSET = 1; >- int red = ColorMap.COLOR_WHITE.getRed() + redStep * OFFSET; >- int green = ColorMap.COLOR_WHITE.getGreen() + greenStep * OFFSET; >- int blue = ColorMap.COLOR_WHITE.getBlue() + blueStep * OFFSET; >- for (int i = 0; i < NUM_LEVELS - OFFSET; i++) { >- if (red > 255) { >- red = 255; // TODO: fix this mess >- } >- if (green > 255) { >- green = 255; >- } >- if (blue > 255) { >- blue = 255; >- } >- if (red < 0) { >- red = 0; >- } >- if (green < 0) { >- green = 0; >- } >- if (blue < 0) { >- blue = 0; >- } >- gradients.add(new Color(Display.getDefault(), red, green, blue)); >- red += redStep; >- blue += blueStep; >- green += greenStep; >- } >- } catch (Throwable t) { >- StatusHandler.log(new Status(IStatus.ERROR, ContextUiPlugin.ID_PLUGIN, "Gradients initialization failed", t)); >- } >- } >- >- @Override >- public String toString() { >- return name; >- } >- >- public String getName() { >- return name; >- } >- >- public void setName(String name) { >- this.name = name; >- } >- >- public Color getBase() { >- return ColorMap.COLOR_WHITE; >- } >- >-// public void setBase(Color base) { >-// ColorMap.COLOR_WHITE = base; >-// } >- >- public static Color blend(List<Highlighter> highlighters, IInteractionElement info, boolean isLandmark) { >- int red = 0; >- int green = 0; >- int blue = 0; >- int num = highlighters.size(); >- for (Highlighter highlighter : highlighters) { >- Color color = highlighter.getHighlight(info, isLandmark); >- red += color.getRed(); >- green += color.getGreen(); >- blue += color.getBlue(); >- } >- return new Color(Display.getDefault(), red / num, green / num, blue / num); >- } >- >- public boolean isGradient() { >- return isGradient; >- } >- >- public void setGradient(boolean isGradient) { >- this.isGradient = isGradient; >- } >- >- public Color getCore() { >- return core; >- } >- >- public void setCore(Color core) { >- this.core = core; >- this.initializeGradients(); >- this.initializeHighlight(); >- } >- >- public String getHighlightKind() { >- String res = VAL_DEFAULT; >- if (this.isGradient) { >- res = LABEL_GRADIENT; >- } else if (this.isIntersection) { >- res = LABEL_INTERSECTION; >- } else { >- res = LABEL_SOLID; >- } >- return res; >- } >- >- public String externalizeToString() { >- if (core == null) { >- return VAL_DEFAULT; >- } else { >- Integer r = new Integer(this.core.getRed()); >- Integer g = new Integer(this.core.getGreen()); >- Integer b = new Integer(this.core.getBlue()); >- return r.toString() + ";" + g.toString() + ";" + b.toString() + ";" + this.name + ";" >- + this.getHighlightKind(); >- } >- } >- >- private boolean initializeFromString(String attributes) { >- if (!VAL_DEFAULT.equals(attributes)) { >- String[] data = attributes.split(";"); >- Integer r = new Integer(data[0]); >- Integer g = new Integer(data[1]); >- Integer b = new Integer(data[2]); >- this.core = new Color(Display.getCurrent(), r.intValue(), g.intValue(), b.intValue()); >- this.name = data[3]; >- if (data[4].compareTo(LABEL_GRADIENT) == 0) { >- this.isGradient = true; >- this.isIntersection = false; >- } else if (data[4].compareTo(LABEL_INTERSECTION) == 0) { >- this.isGradient = false; >- this.isIntersection = true; >- } else { >- this.isGradient = false; >- this.isIntersection = false; >- } >- return true; >- } else { >- this.name = HighlighterList.DEFAULT_HIGHLIGHTER.getName(); >- this.core = HighlighterList.DEFAULT_HIGHLIGHTER.getCore(); >- return false; >- } >- } >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java 13 Jan 2009 07:05:17 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,174 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Tasktop Technologies 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: >- * Tasktop Technologies - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.highlighters; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.mylyn.internal.context.ui.ColorMap; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.widgets.Display; >- >-/** >- * List class that wraps List of highlighters >- * >- * @author Mik Kersten >- */ >-public class HighlighterList { >- >- public static final Highlighter DEFAULT_HIGHLIGHTER = new Highlighter("<none>", ColorMap.DEFAULT, false); >- >- private final List<Highlighter> highlighters; >- >- public HighlighterList() { >- highlighters = new ArrayList<Highlighter>(); >- } >- >- public HighlighterList(List<Highlighter> hlist) { >- highlighters = new ArrayList<Highlighter>(); >- for (Highlighter highlighter : hlist) { >- highlighters.add(highlighter); >- } >- } >- >- public HighlighterList(String attributes) { >- highlighters = new ArrayList<Highlighter>(); >- this.internalizeFromString(attributes); >- } >- >- public void dispose() { >- for (Highlighter highlighter : highlighters) { >- highlighter.dispose(); >- } >- } >- >- public void setToDefaultList() { >- this.highlighters.clear(); >- highlighters.add(DEFAULT_HIGHLIGHTER); >- highlighters.add(new Highlighter("yellow", ColorMap.HIGHLIGHTER_YELLOW, false)); >- highlighters.add(new Highlighter("rose", ColorMap.PANTONE_PASTEL_ROSE, false)); >- highlighters.add(new Highlighter("purple", ColorMap.PANTONE_PASTEL_PURPLE, false)); >- highlighters.add(new Highlighter("blue", ColorMap.PANTONE_PASTEL_BLUE, false)); >- highlighters.add(new Highlighter("green", ColorMap.PANTONE_PASTERL_GREEN, false)); >- highlighters.add(new Highlighter("blue gradient", ColorMap.HIGLIGHTER_BLUE_GRADIENT, true)); >- highlighters.add(new Highlighter("orange gradient", ColorMap.HIGHLIGHTER_ORANGE_GRADIENT, true)); >- >- Highlighter intersectionHighlighter = new Highlighter("intersection", ColorMap.HIGLIGHTER_RED_INTERSECTION, >- false); >- intersectionHighlighter.setIntersection(true); >-// ContextUiPlugin.getDefault().setIntersectionHighlighter(intersectionHighlighter); >- } >- >- public void add(Highlighter hl) { >- this.highlighters.add(hl); >- } >- >- /** >- * @return Returns the list. >- */ >- public List<Highlighter> getHighlighters() { >- return highlighters; >- } >- >- public Highlighter addHighlighter() { >-// ColorMap colorMap = new ColorMap(); >- Highlighter hl = new Highlighter("new", ColorMap.GRAY_DARK, false); >- this.highlighters.add(hl); >- return hl; >- } >- >- public Highlighter getHighlighter(String name) { >- for (Highlighter highlighter : highlighters) { >- if (highlighter.getName().equals(name)) { >- return highlighter; >- } >- } >- return null; >- } >- >- public void removeHighlighter(Highlighter hl) { >- this.highlighters.remove(hl); >- } >- >- public String externalizeToString() { >- // Add an initial flag so that we know if the highlighterlist has been >- // save before. >- // This is only used when Mylyn is first launched with eclipse. >- // if the preference store returns a null string, then we would >- // initialize >- // the default highlighter. >- // but if this flag is in place, we will know if highlighterlist has >- // ever been saved >- String result = "flag:"; >- for (Highlighter highlighter : highlighters) { >- result += highlighter.externalizeToString() + ":"; >- } >- return result; >- } >- >- public void internalizeFromString(String attributes) { >- if (attributes != null) { >- this.highlighters.clear(); >- String[] data = attributes.split(":"); >- // skip the flag >- // >- for (int i = 1; i < data.length; i++) { >- Highlighter hl = new Highlighter(data[i]); >- this.highlighters.add(hl); >- } >- } >- } >- >- public void updateHighlighterWithGamma(ColorMap.GammaSetting prev, ColorMap.GammaSetting curr) { >- int res = ColorMap.GammaSetting.compare(prev, curr); >- if (res < 0) { >- lightenAllColors(Math.abs(res)); >- >- } else if (res > 0) { >- darkenAllColors(Math.abs(res)); >- } >- } >- >- private void darkenAllColors(int degree) { >- for (Highlighter hl : highlighters) { >- Color c = hl.getCore(); >- double[] HSV = ColorCoordinatesChange.RGBToHSV(c.getRed(), c.getGreen(), c.getBlue()); >- if (degree != 2) { >- HSV[1] *= 2; >- } else { >- HSV[1] *= 3; >- } >- if (HSV[1] > 1) { >- HSV[1] = 1; >- } >- >- int[] newRGB = ColorCoordinatesChange.HSVtoRGB(HSV[0], HSV[1], HSV[2]); >- Color rgb = new Color(Display.getDefault(), newRGB[0], newRGB[1], newRGB[2]); >- hl.setCore(rgb); >- } >- } >- >- private void lightenAllColors(int degree) { >- for (Highlighter hl : highlighters) { >- Color c = hl.getCore(); >- double[] HSV = ColorCoordinatesChange.RGBToHSV(c.getRed(), c.getGreen(), c.getBlue()); >- if (degree != 2) { >- HSV[1] *= 0.5; >- } else { >- HSV[1] *= 0.333; >- } >- int[] newRGB = ColorCoordinatesChange.HSVtoRGB(HSV[0], HSV[1], HSV[2]); >- Color rgb = new Color(Display.getDefault(), newRGB[0], newRGB[1], newRGB[2]); >- hl.setCore(rgb); >- } >- } >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java 13 Jan 2009 07:05:17 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,75 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Tasktop Technologies 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: >- * Tasktop Technologies - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.highlighters; >- >-import org.eclipse.jface.viewers.IDecoration; >-import org.eclipse.jface.viewers.ILabelProviderListener; >-import org.eclipse.jface.viewers.ILightweightLabelDecorator; >-import org.eclipse.mylyn.internal.sandbox.ui.SandboxUiPlugin; >-import org.eclipse.mylyn.internal.tasks.ui.ITaskHighlighter; >-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >-import org.eclipse.mylyn.tasks.core.ITask; >-import org.eclipse.swt.graphics.Color; >- >-/** >- * Decorator that provides a background color for tasks. >- * >- * NOTE: Setting the background color through a ILightweightLabelDecorator does not seem to work on the task list. >- * >- * TODO remove ITaskHighlighter and replace by ILightweightLabelDecorator >- * >- * @author Steffen Pingel >- */ >-public class TaskHighlighter implements ILightweightLabelDecorator, ITaskHighlighter { >- >- public TaskHighlighter() { >- TasksUiPlugin.getDefault().setHighlighter(this); >- } >- >- public void addListener(ILabelProviderListener listener) { >- // ignore >- } >- >- public void decorate(Object element, IDecoration decoration) { >- if (element instanceof ITask) { >- ITask task = (ITask) element; >- Highlighter highlighter = SandboxUiPlugin.getDefault().getHighlighterForContextId( >- "" + task.getHandleIdentifier()); >- if (highlighter != null) { >- decoration.setBackgroundColor(highlighter.getHighlightColor()); >- } >- } >- } >- >- public void dispose() { >- // ignore >- } >- >- public Color getHighlightColor(ITask task) { >- Highlighter highlighter = SandboxUiPlugin.getDefault().getHighlighterForContextId( >- "" + task.getHandleIdentifier()); >- if (highlighter != null) { >- return highlighter.getHighlightColor(); >- } >- return null; >- } >- >- public boolean isLabelProperty(Object element, String property) { >- // ignore >- return false; >- } >- >- public void removeListener(ILabelProviderListener listener) { >- // ignore >- } >- >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java 13 Jan 2009 07:05:17 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,67 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Tasktop Technologies 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: >- * Tasktop Technologies - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.highlighters; >- >-import java.util.List; >- >-import org.eclipse.jface.action.Action; >-import org.eclipse.jface.action.MenuManager; >-import org.eclipse.jface.action.Separator; >-import org.eclipse.mylyn.internal.context.ui.HighlighterImageDescriptor; >-import org.eclipse.mylyn.internal.sandbox.ui.SandboxUiPlugin; >-import org.eclipse.mylyn.internal.tasks.core.AbstractTask; >-import org.eclipse.mylyn.internal.tasks.ui.IDynamicSubMenuContributor; >-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; >-import org.eclipse.mylyn.tasks.core.IRepositoryElement; >-import org.eclipse.mylyn.tasks.core.ITask; >- >-/** >- * @author Mik Kersten >- */ >-public class TaskHighlighterMenuContributor implements IDynamicSubMenuContributor { >- >- private static final String CHOOSE_HIGHLIGHTER = "Highlighter"; >- >- public MenuManager getSubMenuManager(final List<IRepositoryElement> selectedElements) { >- final MenuManager subMenuManager = new MenuManager(CHOOSE_HIGHLIGHTER); >- for (final Highlighter highlighter : SandboxUiPlugin.getDefault().getHighlighters()) { >- Action action = new Action() { >- @Override >- public void run() { >- AbstractTask task = null; >- for (IRepositoryElement selectedElement : selectedElements) { >- if (selectedElement instanceof ITask) { >- task = (AbstractTask) selectedElement; >- } >- if (task != null) { >- SandboxUiPlugin.getDefault().setHighlighterMapping(task.getHandleIdentifier(), >- highlighter.getName()); >- TasksUiInternal.getTaskList().notifyElementChanged(task); >- } >- } >- } >- }; >- if (highlighter.isGradient()) { >- action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getBase(), >- highlighter.getHighlightColor())); >- } else { >- action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getHighlightColor(), >- highlighter.getHighlightColor())); >- } >- action.setText(highlighter.toString()); >- subMenuManager.add(action); >- } >- subMenuManager.add(new Separator()); >- subMenuManager.add(new EditHighlightersAction()); >- return subMenuManager; >- } >-} >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/ITaskHighlighter.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/ITaskHighlighter.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/ITaskHighlighter.java >--- src/org/eclipse/mylyn/internal/tasks/ui/ITaskHighlighter.java 13 Jan 2009 07:07:36 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,23 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Tasktop Technologies 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: >- * Tasktop Technologies - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.tasks.ui; >- >-import org.eclipse.mylyn.tasks.core.ITask; >-import org.eclipse.swt.graphics.Color; >- >-/** >- * @author Mik Kersten >- */ >-public interface ITaskHighlighter { >- >- public Color getHighlightColor(ITask task); >-} >Index: src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java,v >retrieving revision 1.126 >diff -u -r1.126 TasksUiPlugin.java >--- src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java 2 Dec 2009 20:03:52 -0000 1.126 >+++ src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java 10 Dec 2009 04:35:59 -0000 >@@ -155,8 +155,6 @@ > > private TaskListExternalizer taskListExternalizer; > >- private ITaskHighlighter highlighter; >- > private final Map<String, Image> brandingIcons = new HashMap<String, Image>(); > > private final Map<String, ImageDescriptor> overlayIcons = new HashMap<String, ImageDescriptor>(); >@@ -957,14 +955,6 @@ > return getDataDirectory() + DEFAULT_PATH_SEPARATOR + ITasksCoreConstants.DEFAULT_BACKUP_FOLDER_NAME; > } > >- public ITaskHighlighter getHighlighter() { >- return highlighter; >- } >- >- public void setHighlighter(ITaskHighlighter highlighter) { >- this.highlighter = highlighter; >- } >- > /** > * @since 3.0 > */ >Index: src/org/eclipse/mylyn/tasks/ui/TaskElementLabelProvider.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskElementLabelProvider.java,v >retrieving revision 1.20 >diff -u -r1.20 TaskElementLabelProvider.java >--- src/org/eclipse/mylyn/tasks/ui/TaskElementLabelProvider.java 24 Jul 2009 12:05:46 -0000 1.20 >+++ src/org/eclipse/mylyn/tasks/ui/TaskElementLabelProvider.java 10 Dec 2009 04:35:59 -0000 >@@ -33,7 +33,6 @@ > import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; > import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer; > import org.eclipse.mylyn.internal.tasks.core.WeekDateRange; >-import org.eclipse.mylyn.internal.tasks.ui.ITaskHighlighter; > import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; > import org.eclipse.mylyn.internal.tasks.ui.Messages; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >@@ -219,13 +218,6 @@ > } > > public Color getBackground(Object element) { >- if (element instanceof ITask) { >- ITask task = (ITask) element; >- ITaskHighlighter highlighter = TasksUiPlugin.getDefault().getHighlighter(); >- if (highlighter != null) { >- return highlighter.getHighlightColor(task); >- } >- } > return null; > } >
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 292330
:
154188
|
154189
| 154190 |
158097