diff options
author | spingel | 2011-05-10 13:09:49 +0000 |
---|---|---|
committer | spingel | 2011-05-10 13:09:49 +0000 |
commit | 2d7a669730eb1f8d01dba84cb952fb2c800272f2 (patch) | |
tree | 24e553bcd4d83b5682b958645cd30a396c80686f /org.eclipse.mylyn.trac.ui/src/org | |
parent | 51b83c592f188b85726255fdeef81346ada1e40c (diff) | |
download | org.eclipse.mylyn.tasks-2d7a669730eb1f8d01dba84cb952fb2c800272f2.tar.gz org.eclipse.mylyn.tasks-2d7a669730eb1f8d01dba84cb952fb2c800272f2.tar.xz org.eclipse.mylyn.tasks-2d7a669730eb1f8d01dba84cb952fb2c800272f2.zip |
NEW - bug 345212: Trac cc editor should refresh when model changes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=345212
Diffstat (limited to 'org.eclipse.mylyn.trac.ui/src/org')
-rw-r--r-- | org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java | 71 |
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; + } } |