Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-02-03 20:49:47 +0000
committerspingel2010-02-03 20:49:47 +0000
commitc7b2836f40bc99de0f07269f28ce0efb437a920f (patch)
tree83038adf8ad3f59fce583861855c79e10e498640 /org.eclipse.mylyn.sandbox.ui
parentecd1dcb3a5072c4db86492272c08130b0ccc99d3 (diff)
downloadorg.eclipse.mylyn.incubator-c7b2836f40bc99de0f07269f28ce0efb437a920f.tar.gz
org.eclipse.mylyn.incubator-c7b2836f40bc99de0f07269f28ce0efb437a920f.tar.xz
org.eclipse.mylyn.incubator-c7b2836f40bc99de0f07269f28ce0efb437a920f.zip
NEW - bug 292330: [patch][framework] HighlighterImageDescriptor should not hold on to image
https://bugs.eclipse.org/bugs/show_bug.cgi?id=292330
Diffstat (limited to 'org.eclipse.mylyn.sandbox.ui')
-rw-r--r--org.eclipse.mylyn.sandbox.ui/plugin.xml18
-rw-r--r--org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java65
-rw-r--r--org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java501
-rw-r--r--org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java275
-rw-r--r--org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java174
-rw-r--r--org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java75
-rw-r--r--org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java67
7 files changed, 3 insertions, 1172 deletions
diff --git a/org.eclipse.mylyn.sandbox.ui/plugin.xml b/org.eclipse.mylyn.sandbox.ui/plugin.xml
index a9385654..66b109a9 100644
--- a/org.eclipse.mylyn.sandbox.ui/plugin.xml
+++ b/org.eclipse.mylyn.sandbox.ui/plugin.xml
@@ -275,12 +275,6 @@
</viewContribution>
</extension>
-->
-
- <extension point="org.eclipse.mylyn.tasks.ui.actions">
- <dynamicPopupMenu
- class="org.eclipse.mylyn.internal.sandbox.ui.highlighters.TaskHighlighterMenuContributor"
- menuPath="operations"/>
- </extension>
<extension
point="org.eclipse.ui.keywords">
@@ -349,18 +343,6 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
- <extension
- point="org.eclipse.ui.decorators">
- <decorator
- class="org.eclipse.mylyn.internal.sandbox.ui.highlighters.TaskHighlighter"
- icon="icons/etool16/presentation.gif"
- id="org.eclipse.mylyn.sandbox.ui.decorator.tasks"
- label="Task Highlighter"
- lightweight="true"
- objectClass="org.eclipse.mylyn.internal.tasks.core.AbstractTask"
- state="true">
- </decorator>
- </extension>
<extension
point="org.eclipse.mylyn.tasks.ui.editors">
<pageFactory
diff --git a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java
index 30e6338e..619f582e 100644
--- a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java
+++ b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPlugin.java
@@ -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 @@ public class SandboxUiPlugin extends AbstractUIPlugin {
private InterestInducingProblemListener problemListener;
- private HighlighterList highlighters;
-
public SandboxUiPlugin() {
super();
plugin = this;
@@ -67,9 +60,6 @@ public class SandboxUiPlugin extends AbstractUIPlugin {
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 @@ public class SandboxUiPlugin extends AbstractUIPlugin {
@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 @@ public class SandboxUiPlugin extends AbstractUIPlugin {
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);
- }
-
}
diff --git a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java
index c6393b7e..fcf4d28a 100644
--- a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java
+++ b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/SandboxUiPreferencePage.java
@@ -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 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
* @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 @@ public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenc
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 @@ public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenc
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 @@ public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenc
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 @@ public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenc
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 @@ public class SandboxUiPreferencePage extends PreferencePage implements IWorkbenc
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
}
}
diff --git a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java
deleted file mode 100644
index ed60ba27..00000000
--- a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/Highlighter.java
+++ /dev/null
@@ -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;
- }
- }
-}
diff --git a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java
deleted file mode 100644
index 71b6abf3..00000000
--- a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/HighlighterList.java
+++ /dev/null
@@ -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);
- }
- }
-}
diff --git a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java
deleted file mode 100644
index 55326eef..00000000
--- a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighter.java
+++ /dev/null
@@ -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
- }
-
-}
diff --git a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java b/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java
deleted file mode 100644
index a051b734..00000000
--- a/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/highlighters/TaskHighlighterMenuContributor.java
+++ /dev/null
@@ -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;
- }
-}

Back to the top