Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.trac.ui')
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java71
1 files changed, 50 insertions, 21 deletions
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java
index 45ba2aef1..4b98cc2c8 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java
@@ -36,6 +36,8 @@ public class TracCcAttributeEditor extends AbstractAttributeEditor {
private TaskAttribute attrRemoveCc;
+ protected boolean cflowWidgetSelected;
+
public TracCcAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
super(manager, taskAttribute);
setLayoutHint(new LayoutHint(RowSpan.MULTIPLE, ColumnSpan.SINGLE));
@@ -50,37 +52,32 @@ public class TracCcAttributeEditor extends AbstractAttributeEditor {
list.setToolTipText(getDescription());
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(list);
- TaskAttribute attrUserCC = getTaskAttribute();
- if (attrUserCC != null) {
- for (String value : attrUserCC.getValues()) {
- list.add(value);
- }
- }
+ populateFromAttribute();
attrRemoveCc = getModel().getTaskData().getRoot().getMappedAttribute(TracAttributeMapper.REMOVE_CC);
- for (String item : attrRemoveCc.getValues()) {
- int i = list.indexOf(item);
- if (i != -1) {
- list.select(i);
- }
- }
+ selectValuesToRemove();
list.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- for (String cc : list.getItems()) {
- int index = list.indexOf(cc);
- if (list.isSelected(index)) {
- java.util.List<String> remove = attrRemoveCc.getValues();
- if (!remove.contains(cc)) {
- attrRemoveCc.addValue(cc);
+ try {
+ cflowWidgetSelected = true;
+ for (String cc : list.getItems()) {
+ int index = list.indexOf(cc);
+ if (list.isSelected(index)) {
+ java.util.List<String> remove = attrRemoveCc.getValues();
+ if (!remove.contains(cc)) {
+ attrRemoveCc.addValue(cc);
+ }
+ } else {
+ attrRemoveCc.removeValue(cc);
}
- } else {
- attrRemoveCc.removeValue(cc);
}
+ getModel().attributeChanged(attrRemoveCc);
+ } finally {
+ cflowWidgetSelected = false;
}
- getModel().attributeChanged(attrRemoveCc);
}
});
@@ -88,4 +85,36 @@ public class TracCcAttributeEditor extends AbstractAttributeEditor {
setControl(list);
}
+
+ private void populateFromAttribute() {
+ TaskAttribute attrUserCC = getTaskAttribute();
+ if (attrUserCC != null) {
+ for (String value : attrUserCC.getValues()) {
+ list.add(value);
+ }
+ }
+ }
+
+ private void selectValuesToRemove() {
+ for (String item : attrRemoveCc.getValues()) {
+ int i = list.indexOf(item);
+ if (i != -1) {
+ list.select(i);
+ }
+ }
+ }
+
+ @Override
+ public void refresh() {
+ if (!cflowWidgetSelected && list != null && !list.isDisposed()) {
+ list.removeAll();
+ populateFromAttribute();
+ selectValuesToRemove();
+ }
+ }
+
+ @Override
+ public boolean shouldAutoRefresh() {
+ return true;
+ }
}

Back to the top