diff options
author | fbecker | 2009-02-18 22:04:24 +0000 |
---|---|---|
committer | fbecker | 2009-02-18 22:04:24 +0000 |
commit | 2de3bd303c1a3cc10c9357a4cc23dc9a28f49b12 (patch) | |
tree | 0be1764625373a1b48d86692169163b2e7ad11f8 /org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui | |
parent | 98165cd122a7610a4f1157389e3efd51a5c69d10 (diff) | |
download | org.eclipse.mylyn.tasks-2de3bd303c1a3cc10c9357a4cc23dc9a28f49b12.tar.gz org.eclipse.mylyn.tasks-2de3bd303c1a3cc10c9357a4cc23dc9a28f49b12.tar.xz org.eclipse.mylyn.tasks-2de3bd303c1a3cc10c9357a4cc23dc9a28f49b12.zip |
ASSIGNED - bug 166595: [api] support moving bugs across products
https://bugs.eclipse.org/bugs/show_bug.cgi?id=166595
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui')
2 files changed, 65 insertions, 27 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/BooleanAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/BooleanAttributeEditor.java index e2306cfa7..1e22f5eb1 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/BooleanAttributeEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/BooleanAttributeEditor.java @@ -26,21 +26,27 @@ import org.eclipse.ui.forms.widgets.FormToolkit; */ public class BooleanAttributeEditor extends AbstractAttributeEditor { + private Button button; + + private boolean ignoreNotification; + public BooleanAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) { super(manager, taskAttribute); } @Override public void createControl(Composite parent, FormToolkit toolkit) { - final Button button = toolkit.createButton(parent, super.getLabel(), SWT.CHECK); + button = toolkit.createButton(parent, super.getLabel(), SWT.CHECK); button.setEnabled(!isReadOnly()); - button.setSelection(getValue()); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - setValue(button.getSelection()); + if (!ignoreNotification) { + setValue(button.getSelection()); + } } }); + refresh(); setControl(button); } @@ -58,4 +64,13 @@ public class BooleanAttributeEditor extends AbstractAttributeEditor { attributeChanged(); } + @Override + public void refresh() { + try { + ignoreNotification = true; + button.setSelection(getValue()); + } finally { + ignoreNotification = false; + } + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/SingleSelectionAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/SingleSelectionAttributeEditor.java index 2379d80a5..623fa6ddf 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/SingleSelectionAttributeEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/SingleSelectionAttributeEditor.java @@ -34,6 +34,10 @@ public class SingleSelectionAttributeEditor extends AbstractAttributeEditor { private CCombo combo; + private boolean ignoreNotification; + + private Text text; + public SingleSelectionAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) { super(manager, taskAttribute); } @@ -41,17 +45,11 @@ public class SingleSelectionAttributeEditor extends AbstractAttributeEditor { @Override public void createControl(Composite parent, FormToolkit toolkit) { if (isReadOnly()) { - Text text = new Text(parent, SWT.FLAT | SWT.READ_ONLY); + text = new Text(parent, SWT.FLAT | SWT.READ_ONLY); text.setFont(EditorUtil.TEXT_FONT); toolkit.adapt(text, false, false); text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE); - String label = getValueLabel(); - if ("".equals(label)) { //$NON-NLS-1$ - // if set to the empty string the label will use 64px on GTK - text.setText(" "); //$NON-NLS-1$ - } else { - text.setText(label); - } + refresh(); setControl(text); } else { combo = new CCombo(parent, SWT.FLAT | SWT.READ_ONLY); @@ -59,25 +57,19 @@ public class SingleSelectionAttributeEditor extends AbstractAttributeEditor { combo.setFont(EditorUtil.TEXT_FONT); combo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); - Map<String, String> labelByValue = getAttributeMapper().getOptions(getTaskAttribute()); - if (labelByValue != null) { - values = labelByValue.keySet().toArray(new String[0]); - for (String value : values) { - combo.add(labelByValue.get(value)); - } - } - - select(getValue(), getValueLabel()); + refresh(); if (values != null) { combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - int index = combo.getSelectionIndex(); - if (index > -1) { - Assert.isNotNull(values); - Assert.isLegal(index >= 0 && index <= values.length - 1); - setValue(values[index]); + if (!ignoreNotification) { + int index = combo.getSelectionIndex(); + if (index > -1) { + Assert.isNotNull(values); + Assert.isLegal(index >= 0 && index <= values.length - 1); + setValue(values[index]); + } } } }); @@ -109,8 +101,11 @@ public class SingleSelectionAttributeEditor extends AbstractAttributeEditor { } public void setValue(String value) { - getAttributeMapper().setValue(getTaskAttribute(), value); - attributeChanged(); + String oldValue = getAttributeMapper().getValue(getTaskAttribute()); + if (!oldValue.equals(value)) { + getAttributeMapper().setValue(getTaskAttribute(), value); + attributeChanged(); + } } void selectDefaultValue() { @@ -120,4 +115,32 @@ public class SingleSelectionAttributeEditor extends AbstractAttributeEditor { } } + @Override + public void refresh() { + try { + ignoreNotification = true; + if (text != null) { + String label = getValueLabel(); + if ("".equals(label)) { //$NON-NLS-1$ + // if set to the empty string the label will use 64px on GTK + text.setText(" "); //$NON-NLS-1$ + } else { + text.setText(label); + } + } else { + combo.removeAll(); + Map<String, String> labelByValue = getAttributeMapper().getOptions(getTaskAttribute()); + if (labelByValue != null) { + values = labelByValue.keySet().toArray(new String[0]); + for (String value : values) { + combo.add(labelByValue.get(value)); + } + } + select(getValue(), getValueLabel()); + combo.redraw(); + } + } finally { + ignoreNotification = false; + } + } } |