Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-02-28 20:52:06 +0000
committerfbecker2010-02-28 20:52:06 +0000
commit98040727ff0c9ff0faa88bd51fcdc7fe1d3380dd (patch)
treebd02197081fbfb53f4d53877b648aa7ea3d48d63 /org.eclipse.mylyn.bugzilla.ui/src
parentc07c75d17d7d6686a1dd12bc50448bfb736a2234 (diff)
downloadorg.eclipse.mylyn.tasks-98040727ff0c9ff0faa88bd51fcdc7fe1d3380dd.tar.gz
org.eclipse.mylyn.tasks-98040727ff0c9ff0faa88bd51fcdc7fe1d3380dd.tar.xz
org.eclipse.mylyn.tasks-98040727ff0c9ff0faa88bd51fcdc7fe1d3380dd.zip
ASSIGNED - bug 287899: consume CheckBoxTreeDialog for KeywordsDialog
https://bugs.eclipse.org/bugs/show_bug.cgi?id=287899
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/KeywordsDialog.java160
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java54
4 files changed, 45 insertions, 173 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java
deleted file mode 100644
index 372046eee..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.bugzilla.ui.editor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Shawn Minto
- */
-public class KeywordsDialog extends Dialog {
-
- private final List<String> selectedKeywords;
-
- private final List<String> validKeywords;
-
- private CheckboxTableViewer keyWordsList;
-
- public KeywordsDialog(Shell shell, String selectedKeywords, java.util.List<String> validKeywords) {
- super(shell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- StringTokenizer st = new StringTokenizer(selectedKeywords, ",", false); //$NON-NLS-1$
- this.selectedKeywords = new ArrayList<String>();
- while (st.hasMoreTokens()) {
- String s = st.nextToken().trim();
- this.selectedKeywords.add(s);
- }
-
- this.validKeywords = validKeywords;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- getShell().setText(Messages.KeywordsDialog_Select_Keywords);
-
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- keyWordsList = CheckboxTableViewer.newCheckList(composite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
- GridData keyWordsTextData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
- keyWordsTextData.heightHint = 175;
- keyWordsTextData.widthHint = 160;
- keyWordsList.getTable().setLayoutData(keyWordsTextData);
-
- if (validKeywords != null) {
-
- keyWordsList.setContentProvider(new ITreeContentProvider() {
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof Collection<?>) {
- return ((Collection<?>) parentElement).toArray();
- }
- return null;
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- });
-
- Set<String> invalidKeywords = new HashSet<String>();
-
- keyWordsList.setInput(validKeywords);
-
- for (String keyword : selectedKeywords) {
- if (!keyWordsList.setChecked(keyword, true)) {
- invalidKeywords.add(keyword);
- }
- }
-
- selectedKeywords.removeAll(invalidKeywords);
-
- }
-
- keyWordsList.addCheckStateListener(new KeywordListener());
-
- parent.pack();
-
- applyDialogFont(composite);
-
- return composite;
- }
-
- protected class KeywordListener implements ICheckStateListener {
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- if (event.getChecked()) {
- selectedKeywords.add((String) event.getElement());
- } else {
- selectedKeywords.remove(event.getElement());
- }
- }
-
- }
-
- public List<String> getSelectedKeywords() {
- return selectedKeywords;
- }
-
- public String getSelectedKeywordsString() {
- StringBuffer keywords = new StringBuffer();
-
- for (String sel : selectedKeywords) {
- keywords.append(sel);
- keywords.append(","); //$NON-NLS-1$
- }
-
- String keywordsString = keywords.toString();
-
- if (keywordsString.endsWith(",")) { //$NON-NLS-1$
- keywordsString = keywordsString.substring(0, keywordsString.length() - 1);
- }
-
- return keywordsString;
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
index d7b1bbfd8..99d46675e 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
@@ -54,6 +54,4 @@ public class Messages extends NLS {
public static String BugzillaVotesEditor_Show_votes;
public static String BugzillaVotesEditor_Vote;
-
- public static String KeywordsDialog_Select_Keywords;
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
index 9426f2905..a35d874bd 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
@@ -26,5 +26,3 @@ BugzillaTaskEditorPage_Please_enter_a_bugid_for_duplicate_of_before_submitting=P
BugzillaVotesEditor_Show_votes=Show votes
BugzillaVotesEditor_Vote=Vote
-
-KeywordsDialog_Select_Keywords=Select Keywords
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
index a92876f32..e0cb7c7d5 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java
@@ -19,6 +19,10 @@ import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -44,7 +48,11 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
-import org.eclipse.mylyn.internal.bugzilla.ui.editor.KeywordsDialog;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.AbstractInPlaceDialog;
+import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.IInPlaceDialogListener;
+import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.InPlaceCheckBoxTreeDialog;
+import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.InPlaceDialogEvent;
import org.eclipse.mylyn.internal.tasks.ui.util.WebBrowserDialog;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
@@ -372,7 +380,7 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
}
emailPattern2.setText(""); //$NON-NLS-1$
keywords.setText(""); //$NON-NLS-1$
- keywordsOperation.deselectAll();
+ keywordsOperation.select(0);
daysText.setText(""); //$NON-NLS-1$
}
});
@@ -742,17 +750,45 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L
}
});
- Button keywordsSelectButton = new Button(keywordsComposite, SWT.NONE);
+ final Button keywordsSelectButton = new Button(keywordsComposite, SWT.NONE);
keywordsSelectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if (repositoryConfiguration != null && getShell() != null) {
- KeywordsDialog dialog = new KeywordsDialog(getShell(), keywords.getText(), //
- repositoryConfiguration.getKeywords());
- if (dialog.open() == Window.OK) {
- keywords.setText(dialog.getSelectedKeywordsString());
- }
+
+ final java.util.List<String> values = new ArrayList<String>();
+ for (String string : keywords.getText().split(",")) { //$NON-NLS-1$
+ values.add(string.trim());
}
+
+ Map<String, String> validValues = new HashMap<String, String>();
+ for (String string : repositoryConfiguration.getKeywords()) {
+ validValues.put(string, string);
+ }
+ final InPlaceCheckBoxTreeDialog selectionDialog = new InPlaceCheckBoxTreeDialog(
+ WorkbenchUtil.getShell(), keywordsSelectButton, values, validValues, ""); //$NON-NLS-1$
+ selectionDialog.addEventListener(new IInPlaceDialogListener() {
+
+ public void buttonPressed(InPlaceDialogEvent event) {
+ if (event.getReturnCode() == Window.OK) {
+ Set<String> newValues = selectionDialog.getSelectedValues();
+ if (!new HashSet<String>(values).equals(newValues)) {
+ String erg = ""; //$NON-NLS-1$
+ for (String string : newValues) {
+ if (erg.equals("")) { //$NON-NLS-1$
+ erg = string;
+ } else {
+ erg += (", " + string); //$NON-NLS-1$
+ }
+ }
+ keywords.setText(erg);
+ }
+ } else if (event.getReturnCode() == AbstractInPlaceDialog.ID_CLEAR) {
+ keywords.setText(""); //$NON-NLS-1$
+ }
+ }
+ });
+ selectionDialog.open();
+
}
});
keywordsSelectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

Back to the top