Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2009-08-27 22:09:49 +0000
committersminto2009-08-27 22:09:49 +0000
commit935582f76b110ad90fb6904c2f2d89c242a960c1 (patch)
tree41e8d3032d39cccbb2834886d672961e6058e28f /org.eclipse.mylyn.bugzilla.ui/src
parent6723c7aa8c8e39768254282543e58fdfe81873a3 (diff)
downloadorg.eclipse.mylyn.tasks-935582f76b110ad90fb6904c2f2d89c242a960c1.tar.gz
org.eclipse.mylyn.tasks-935582f76b110ad90fb6904c2f2d89c242a960c1.tar.xz
org.eclipse.mylyn.tasks-935582f76b110ad90fb6904c2f2d89c242a960c1.zip
RESOLVED - bug 279334: make the bugzilla keywords attribute editor usable by other connectors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=279334
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java103
1 files changed, 24 insertions, 79 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java
index d3a1b5ea9..3a98802d5 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java
@@ -12,104 +12,49 @@
package org.eclipse.mylyn.internal.bugzilla.ui.editor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.StringTokenizer;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+import org.eclipse.mylyn.internal.tasks.ui.editors.CheckboxMultiSelectAttributeEditor;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
-import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
-import org.eclipse.mylyn.tasks.ui.editors.LayoutHint;
-import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan;
-import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* @author Rob Elves
*/
-public class BugzillaKeywordAttributeEditor extends AbstractAttributeEditor {
-
- private Text keywordsText;
+public class BugzillaKeywordAttributeEditor extends CheckboxMultiSelectAttributeEditor {
public BugzillaKeywordAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
super(manager, taskAttribute);
- setLayoutHint(new LayoutHint(RowSpan.SINGLE, ColumnSpan.MULTIPLE));
+
}
@Override
- public void createControl(Composite parent, FormToolkit toolkit) {
- Composite keywordComposite = toolkit.createComposite(parent);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 1;
- keywordComposite.setLayout(layout);
-
- keywordsText = toolkit.createText(keywordComposite, getTaskAttribute().getValue());
- GridData keywordsData = new GridData(GridData.FILL_HORIZONTAL);
- keywordsText.setLayoutData(keywordsData);
- keywordsText.setEditable(false);
-
- Button changeKeywordsButton = toolkit.createButton(keywordComposite, Messages.BugzillaKeywordAttributeEditor_Edit_, SWT.FLAT);
- GridData keyWordsButtonData = new GridData();
- changeKeywordsButton.setLayoutData(keyWordsButtonData);
- changeKeywordsButton.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
-
- String keywords = getTaskAttribute().getValue();
-
- Shell shell = null;
- if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
- shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- } else {
- shell = new Shell(PlatformUI.getWorkbench().getDisplay());
- }
-
- List<String> validKeywords = new ArrayList<String>();
- try {
- validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(getModel().getTaskRepository(),
- false, new NullProgressMonitor()).getKeywords();
- } catch (Exception ex) {
- // ignore
- }
-
- KeywordsDialog keywordsDialog = new KeywordsDialog(shell, keywords, validKeywords);
- int responseCode = keywordsDialog.open();
-
- String newKeywords = keywordsDialog.getSelectedKeywordsString();
- if (responseCode == Window.OK && keywords != null) {
- keywordsText.setText(newKeywords);
- getAttributeMapper().setValue(getTaskAttribute(), newKeywords);
- attributeChanged();
- } else {
- return;
- }
-
- }
+ public List<String> getValues() {
+ List<String> values = new ArrayList<String>();
+ String selectedKeywords = getAttributeMapper().getValue(getTaskAttribute());
+ StringTokenizer st = new StringTokenizer(selectedKeywords, ",", false); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ values.add(s);
+ }
- });
- setControl(keywordComposite);
+ return values;
}
@Override
- protected void decorateIncoming(Color color) {
- if (keywordsText != null && !keywordsText.isDisposed()) {
- keywordsText.setBackground(color);
+ public void setValues(List<String> newValues) {
+ StringBuilder valueString = new StringBuilder();
+ Collections.sort(newValues);
+ for (int i = 0; i < newValues.size(); i++) {
+ valueString.append(newValues.get(i));
+ if (i != newValues.size() - 1) {
+ valueString.append(", "); //$NON-NLS-1$
+ }
}
+ getAttributeMapper().setValue(getTaskAttribute(), valueString.toString());
+ attributeChanged();
}
}

Back to the top