Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 72654 Details for
Bug 168895
improve UI for selecting multi-value attributues such as keywords
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch with Check Box Table
clipboard.txt (text/plain), 11.99 KB, created by
Shawn Minto
on 2007-06-27 18:24:02 EDT
(
hide
)
Description:
Patch with Check Box Table
Filename:
MIME Type:
Creator:
Shawn Minto
Created:
2007-06-27 18:24:02 EDT
Size:
11.99 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.bugzilla.ui >Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java,v >retrieving revision 1.73 >diff -u -r1.73 BugzillaTaskEditor.java >--- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java 26 Jun 2007 01:16:18 -0000 1.73 >+++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java 27 Jun 2007 22:22:34 -0000 >@@ -12,10 +12,10 @@ > import java.util.ArrayList; > import java.util.Calendar; > import java.util.Date; >-import java.util.Iterator; >+import java.util.List; > import java.util.Set; >-import java.util.StringTokenizer; > >+import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; >@@ -48,8 +48,9 @@ > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.List; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.forms.IFormColors; > import org.eclipse.ui.forms.editor.FormEditor; > import org.eclipse.ui.forms.events.HyperlinkAdapter; >@@ -61,6 +62,7 @@ > import org.eclipse.ui.forms.widgets.Section; > import org.eclipse.ui.themes.IThemeManager; > >+ > /** > * An editor used to view a bug report that exists on a server. It uses a <code>BugReport</code> object to store the > * data. >@@ -73,12 +75,6 @@ > > private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking"; > >- // protected BugzillaCompareInput compareInput; >- >- // protected Button compareButton; >- >- protected List keyWordsList; >- > protected Text keywordsText; > > protected Text estimateText; >@@ -521,10 +517,9 @@ > > protected void addKeywordsList(Composite attributesComposite) throws IOException { > // newLayout(attributesComposite, 1, "Keywords:", PROPERTY); >- RepositoryTaskAttribute attribute = taskData.getAttribute(RepositoryTaskAttribute.KEYWORDS); >+ final RepositoryTaskAttribute attribute = taskData.getAttribute(RepositoryTaskAttribute.KEYWORDS); > if (attribute == null) > return; >- String keywords = attribute.getValue(); > Label label = createLabel(attributesComposite, attribute); > GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); > >@@ -538,51 +533,48 @@ > keywordsData.horizontalSpan = 2; > keywordsData.widthHint = 200; > keywordsText.setLayoutData(keywordsData); >- // keywordsText.setText(keywords); >- keyWordsList = new List(attributesComposite, SWT.MULTI | SWT.V_SCROLL); >- keyWordsList.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); >- keyWordsList.setFont(TEXT_FONT); >- GridData keyWordsTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >- keyWordsTextData.horizontalSpan = 1; >- keyWordsTextData.widthHint = 125; >- keyWordsTextData.heightHint = 40; >- keyWordsList.setLayoutData(keyWordsTextData); >- >- // initialize the keywords list with valid values >- >- java.util.List<String> validKeywords = new ArrayList<String>(); >- try { >- validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getKeywords(); >- } catch (Exception e) { >- // ignore >- } >- >- if (validKeywords != null) { >- for (Iterator<String> it = validKeywords.iterator(); it.hasNext();) { >- String keyword = it.next(); >- keyWordsList.add(keyword); >- } >- >- // get the selected keywords for the bug >- StringTokenizer st = new StringTokenizer(keywords, ",", false); >- ArrayList<Integer> indicies = new ArrayList<Integer>(); >- while (st.hasMoreTokens()) { >- String s = st.nextToken().trim(); >- int index = keyWordsList.indexOf(s); >- if (index != -1) >- indicies.add(new Integer(index)); >- } >- >- // select the keywords that were selected for the bug >- int length = indicies.size(); >- int[] sel = new int[length]; >- for (int i = 0; i < length; i++) { >- sel[i] = indicies.get(i).intValue(); >+ >+ >+ Button changeKeywordsButton = getManagedForm().getToolkit().createButton(attributesComposite, "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 = attribute.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(repository, false).getKeywords(); >+ } catch (Exception ex) { >+ // ignore >+ } >+ >+ KeywordsDialog keywordsDialog = new KeywordsDialog(shell, keywords, validKeywords); >+ int responseCode = keywordsDialog.open(); >+ >+ String newKeywords = keywordsDialog.getSelectedKeywordsString(); >+ if (responseCode == Dialog.OK && keywords != null) { >+ keywordsText.setText(newKeywords); >+ attribute.setValue(newKeywords); >+ attributeChanged(attribute); >+ } else { >+ return; >+ } >+ > } >- keyWordsList.select(sel); >- } >- >- keyWordsList.addSelectionListener(new KeywordListener()); >+ >+ }); > } > > protected void addVoting(Composite attributesComposite) { >@@ -632,50 +624,6 @@ > }); > } > >- /** >- * Class to handle the selection change of the keywords. >- */ >- protected class KeywordListener implements SelectionListener { >- >- /* >- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >- */ >- public void widgetSelected(SelectionEvent arg0) { >- markDirty(true); >- >- // get the selected keywords and create a string to submit >- StringBuffer keywords = new StringBuffer(); >- String[] sel = keyWordsList.getSelection(); >- >- // allow unselecting 1 keyword when it is the only one selected >- if (keyWordsList.getSelectionCount() == 1) { >- int index = keyWordsList.getSelectionIndex(); >- String keyword = keyWordsList.getItem(index); >- if (taskData.getAttributeValue(BugzillaReportElement.KEYWORDS.getKeyString()).equals(keyword)) >- keyWordsList.deselectAll(); >- } >- >- for (int i = 0; i < keyWordsList.getSelectionCount(); i++) { >- keywords.append(sel[i]); >- if (i != keyWordsList.getSelectionCount() - 1) { >- keywords.append(","); >- } >- } >- >- taskData.setAttributeValue(BugzillaReportElement.KEYWORDS.getKeyString(), keywords.toString()); >- >- // update the keywords text field >- keywordsText.setText(keywords.toString()); >- } >- >- /* >- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) >- */ >- public void widgetDefaultSelected(SelectionEvent arg0) { >- // no need to listen to this >- } >- >- } > > @Override > protected void validateInput() { >Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java >diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/KeywordsDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,152 @@ >+package org.eclipse.mylyn.internal.bugzilla.ui.editor; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.List; >+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 List<String> selectedKeywords; >+ private List<String> validKeywords; >+ >+ private CheckboxTableViewer keyWordsList; >+ >+ public KeywordsDialog(Shell shell, String selectedKeywords, java.util.List<String> validKeywords) { >+ super(shell); >+ >+ StringTokenizer st = new StringTokenizer(selectedKeywords, ",", false); >+ 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("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) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ // TODO Auto-generated method stub >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return getChildren(inputElement); >+ } >+ >+ public void dispose() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ }); >+ >+ >+ keyWordsList.setInput(validKeywords); >+ >+ >+ for(String keyword: selectedKeywords){ >+ keyWordsList.setChecked(keyword, true); >+ } >+ } >+ >+ keyWordsList.addCheckStateListener(new KeywordListener()); >+ >+ super.createDialogArea(parent); >+ >+ parent.pack(); >+ >+ 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(","); >+ } >+ >+ String keywordsString = keywords.toString(); >+ >+ if(keywordsString.endsWith(",")){ >+ keywordsString = keywordsString.substring(0, keywordsString.length() - 1); >+ } >+ >+ return keywordsString; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 168895
:
60227
| 72654 |
74164
|
74165