Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaCcAttributeEditor.java71
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaVotesEditor.java11
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java134
3 files changed, 158 insertions, 58 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaCcAttributeEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaCcAttributeEditor.java
index 0bc7b1b4f..190556799 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaCcAttributeEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaCcAttributeEditor.java
@@ -37,6 +37,8 @@ public class BugzillaCcAttributeEditor extends AbstractAttributeEditor {
private TaskAttribute attrRemoveCc;
+ protected boolean cflowWidgetSelected;
+
public BugzillaCcAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
super(manager, taskAttribute);
setLayoutHint(new LayoutHint(RowSpan.MULTIPLE, ColumnSpan.SINGLE));
@@ -51,12 +53,7 @@ public class BugzillaCcAttributeEditor extends AbstractAttributeEditor {
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(list);
list.setToolTipText(getDescription());
- TaskAttribute attrUserCC = getTaskAttribute();
- if (attrUserCC != null) {
- for (String value : attrUserCC.getValues()) {
- list.add(value);
- }
- }
+ populateFromAttribute();
attrRemoveCc = getModel().getTaskData().getRoot().getMappedAttribute(BugzillaAttribute.REMOVECC.getKey());
@@ -64,29 +61,29 @@ public class BugzillaCcAttributeEditor extends AbstractAttributeEditor {
attrRemoveCc = BugzillaTaskDataHandler.createAttribute(getModel().getTaskData(), BugzillaAttribute.REMOVECC);
}
- 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);
}
});
@@ -94,4 +91,36 @@ public class BugzillaCcAttributeEditor 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;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaVotesEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaVotesEditor.java
index 64a0c7749..dc920e646 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaVotesEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaVotesEditor.java
@@ -118,4 +118,15 @@ public class BugzillaVotesEditor extends AbstractAttributeEditor {
attributeChanged();
}
+ @Override
+ public void refresh() {
+ if (showVotes != null && !showVotes.isDisposed()) {
+ showVotes.setText(getTaskAttribute().getValue());
+ }
+ }
+
+ @Override
+ public boolean shouldAutoRefresh() {
+ return true;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java
index 9a5352795..9f83e29b8 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java
@@ -63,6 +63,14 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
private ImageHyperlink selfLink;
+ private Text flagText;
+
+ private Text requesteeROText;
+
+ private boolean cflowUserEditing;
+
+ private Composite flagComposite;
+
public FlagAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
super(manager, taskAttribute);
setLayoutHint(new LayoutHint(RowSpan.SINGLE, ColumnSpan.SINGLE));
@@ -73,7 +81,7 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
@Override
public void createControl(Composite parent, FormToolkit toolkit) {
- final Composite flagComposite = toolkit.createComposite(parent);
+ flagComposite = toolkit.createComposite(parent);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 1;
@@ -81,29 +89,27 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
layout.horizontalSpacing = 10;
flagComposite.setLayout(layout);
if (isReadOnly()) {
- Text text = new Text(flagComposite, SWT.FLAT | SWT.READ_ONLY);
- toolkit.adapt(text, false, false);
- text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
- text.setText(getValueLabel());
- text.setBackground(parent.getBackground());
- text.setEditable(false);
+ flagText = new Text(flagComposite, SWT.FLAT | SWT.READ_ONLY);
+ toolkit.adapt(flagText, false, false);
+ flagText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
+ flagText.setText(getValueLabel());
+ flagText.setBackground(parent.getBackground());
+ flagText.setEditable(false);
String tooltip = getTaskAttribute().getMetaData().getLabel();
if (tooltip == null) {
tooltip = getDescription();
}
if (tooltip != null) {
- text.setToolTipText(tooltip);
+ flagText.setToolTipText(tooltip);
}
TaskAttribute requestee = getTaskAttribute().getAttribute("requestee"); //$NON-NLS-1$
- if (!"".equals(requestee.getValue())) { //$NON-NLS-1$
- text = new Text(flagComposite, SWT.FLAT | SWT.READ_ONLY);
- toolkit.adapt(text, false, false);
- text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
- text.setText(requestee.getValue());
- text.setBackground(parent.getBackground());
- text.setEditable(false);
- text.setToolTipText(requestee.getMetaData().getValue(TaskAttribute.META_DESCRIPTION));
- }
+ requesteeROText = new Text(flagComposite, SWT.FLAT | SWT.READ_ONLY);
+ toolkit.adapt(requesteeROText, false, false);
+ requesteeROText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
+ requesteeROText.setText(requestee.getValue());
+ requesteeROText.setBackground(parent.getBackground());
+ requesteeROText.setEditable(false);
+ requesteeROText.setToolTipText(requestee.getMetaData().getValue(TaskAttribute.META_DESCRIPTION));
} else {
combo = new CCombo(flagComposite, SWT.FLAT | SWT.READ_ONLY);
toolkit.adapt(combo, false, false);
@@ -117,14 +123,7 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
}
EditorUtil.addScrollListener(combo);
- Map<String, String> labelByValue = getAttributeMapper().getAssoctiatedAttribute(getTaskAttribute())
- .getOptions();
- if (labelByValue != null) {
- values = labelByValue.keySet().toArray(new String[0]);
- for (String value : values) {
- combo.add(labelByValue.get(value));
- }
- }
+ updateComboWithOptions();
select(getValue(), getValueLabel());
@@ -136,10 +135,12 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
if (index > -1) {
Assert.isNotNull(values);
Assert.isLegal(index >= 0 && index <= values.length - 1);
- setValue(values[index]);
- if (requesteeText != null) {
- requesteeText.setEnabled(values[index].equals("?")); //$NON-NLS-1$
- selfLink.setEnabled(values[index].equals("?")); //$NON-NLS-1$
+ try {
+ cflowUserEditing = true;
+ setValue(values[index]);
+ selectionChanged(index);
+ } finally {
+ cflowUserEditing = false;
}
}
}
@@ -226,9 +227,12 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
requesteeText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
- // ignore
- setRequestee(requesteeText.getText());
-
+ try {
+ cflowUserEditing = true;
+ setRequestee(requesteeText.getText());
+ } finally {
+ cflowUserEditing = false;
+ }
}
public void keyPressed(KeyEvent e) {
@@ -237,7 +241,12 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
requesteeText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- setRequestee(requesteeText.getText());
+ try {
+ cflowUserEditing = true;
+ setRequestee(requesteeText.getText());
+ } finally {
+ cflowUserEditing = false;
+ }
}
});
toolkit.adapt(requesteeText, false, false);
@@ -248,6 +257,18 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
setControl(flagComposite);
}
+ private void updateComboWithOptions() {
+ Map<String, String> labelByValue = getAttributeMapper().getAssoctiatedAttribute(getTaskAttribute())
+ .getOptions();
+ if (labelByValue != null) {
+ combo.removeAll();
+ values = labelByValue.keySet().toArray(new String[0]);
+ for (String value : values) {
+ combo.add(labelByValue.get(value));
+ }
+ }
+ }
+
public String getValue() {
return getAttributeMapper().getValue(getAttributeMapper().getAssoctiatedAttribute(getTaskAttribute()));
}
@@ -273,10 +294,8 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
TaskAttribute requestee = getTaskAttribute().getAttribute("requestee"); //$NON-NLS-1$
if (requestee != null) {
if (!requestee.getValue().equals(value)) {
- if (!requestee.getValue().equals(value)) {
- getAttributeMapper().setValue(requestee, value);
- attributeChanged();
- }
+ getAttributeMapper().setValue(requestee, value);
+ attributeChanged();
}
}
}
@@ -307,4 +326,45 @@ public class FlagAttributeEditor extends AbstractAttributeEditor {
}
return label;
}
+
+ @Override
+ public void refresh() {
+ if (!cflowUserEditing) {
+ if (flagText != null && !flagText.isDisposed()) {
+ flagText.setText(getValueLabel());
+ }
+ if (combo != null && !combo.isDisposed()) {
+ updateComboWithOptions();
+ select(getValue(), getValueLabel());
+ if (combo.getSelectionIndex() >= 0) {
+ selectionChanged(combo.getSelectionIndex());
+ }
+ }
+ TaskAttribute requestee = getTaskAttribute().getAttribute("requestee"); //$NON-NLS-1$
+ if (requestee != null) {
+ if (requesteeROText != null && !requesteeROText.isDisposed()) {
+ requesteeROText.setText(requestee.getValue());
+ }
+ if (requesteeText != null && !requesteeText.isDisposed()) {
+ requesteeText.setText(requestee.getValue());
+ }
+ }
+ updateLabel();
+ if (flagComposite != null && !flagComposite.isDisposed()) {
+ flagComposite.layout();
+ }
+ }
+ }
+
+ @Override
+ public boolean shouldAutoRefresh() {
+ return true;
+ }
+
+ private void selectionChanged(int index) {
+ if (requesteeText != null) {
+ requesteeText.setEnabled(values[index].equals("?")); //$NON-NLS-1$
+ selfLink.setEnabled(values[index].equals("?")); //$NON-NLS-1$
+ }
+ }
}

Back to the top