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 145869 Details for
Bug 279334
make the bugzilla keywords attribute editor usable by other connectors
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]
updated patch
clipboard.txt (text/plain), 17.97 KB, created by
Shawn Minto
on 2009-08-27 18:06:29 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Shawn Minto
Created:
2009-08-27 18:06:29 EDT
Size:
17.97 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.commons.ui >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/CheckBoxTreeDialog.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/CheckBoxTreeDialog.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/CheckBoxTreeDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/CheckBoxTreeDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,170 @@ >+/******************************************************************************* >+ * 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.provisional.commons.ui; >+ >+import java.util.HashSet; >+import java.util.List; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTreeViewer; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+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; >+import org.eclipse.ui.dialogs.PatternFilter; >+ >+/** >+ * @author Shawn Minto >+ */ >+public class CheckBoxTreeDialog extends Dialog { >+ >+ private final Map<String, String> validValues; >+ >+ private CheckboxFilteredTree valueTree; >+ >+ private final List<String> selectedValues; >+ >+ private final String dialogLabel; >+ >+ private class CheckboxFilteredTree extends EnhancedFilteredTree { >+ >+ public CheckboxFilteredTree(Composite parent, int treeStyle, PatternFilter filter) { >+ super(parent, treeStyle, filter); >+ } >+ >+ @Override >+ protected TreeViewer doCreateTreeViewer(Composite parent, int style) { >+ return new CheckboxTreeViewer(parent, style); >+ } >+ >+ @Override >+ public CheckboxTreeViewer getViewer() { >+ return (CheckboxTreeViewer) super.getViewer(); >+ } >+ >+ } >+ >+ public CheckBoxTreeDialog(Shell shell, List<String> values, Map<String, String> validValues, >+ String dialogLabel) { >+ super(shell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ this.selectedValues = values; >+ this.validValues = validValues; >+ this.dialogLabel = dialogLabel; >+ } >+ >+ @Override >+ protected Control createDialogArea(Composite parent) { >+ getShell().setText(dialogLabel); >+ >+ 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); >+ >+ valueTree = new CheckboxFilteredTree(composite, SWT.CHECK | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL >+ | SWT.BORDER, new SubstringPatternFilter()); >+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); >+ gd.heightHint = 175; >+ gd.widthHint = 160; >+ CheckboxTreeViewer viewer = valueTree.getViewer(); >+ viewer.getControl().setLayoutData(gd); >+ >+ if (validValues != null) { >+ >+ viewer.setContentProvider(new ITreeContentProvider() { >+ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof Map<?, ?>) { >+ return ((Map<?, ?>) parentElement).keySet().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) { >+ } >+ >+ }); >+ >+ viewer.setSorter(new ViewerSorter()); >+ viewer.setLabelProvider(new LabelProvider() { >+ @Override >+ public String getText(Object element) { >+ if (element instanceof String) { >+ return validValues.get(element); >+ } >+ return super.getText(element); >+ } >+ }); >+ viewer.setInput(validValues); >+ >+ Set<String> invalidValues = new HashSet<String>(); >+ for (String value : validValues.keySet()) { >+ if (!viewer.setChecked(value, true)) { >+ invalidValues.add(value); >+ } >+ } >+ >+ selectedValues.removeAll(invalidValues); >+ >+ viewer.setCheckedElements(selectedValues.toArray()); >+ >+ } >+ >+ viewer.addCheckStateListener(new ICheckStateListener() { >+ >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ if (event.getChecked()) { >+ selectedValues.add((String) event.getElement()); >+ } else { >+ selectedValues.remove(event.getElement()); >+ } >+ } >+ >+ }); >+ >+ parent.pack(); >+ >+ applyDialogFont(composite); >+ >+ return composite; >+ } >+ >+ public List<String> getSelectedValues() { >+ return selectedValues; >+ } >+} >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties,v >retrieving revision 1.25 >diff -u -r1.25 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties 24 Aug 2009 20:11:46 -0000 1.25 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties 27 Aug 2009 22:08:21 -0000 >@@ -30,6 +30,8 @@ > CategoryEditor_URL_=URL: > > CategoryEditorInput_Category_Editor=Category Editor >+CheckboxMultiSelectAttributeEditor_Edit=Edit >+CheckboxMultiSelectAttributeEditor_Select_X=Select {0} > > CommentGroupStrategy_Current=Current > CommentGroupStrategy_Older=Older >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java,v >retrieving revision 1.19 >diff -u -r1.19 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java 24 Aug 2009 20:11:47 -0000 1.19 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java 27 Aug 2009 22:08:21 -0000 >@@ -61,6 +61,10 @@ > > public static String CategoryEditorInput_Category_Editor; > >+ public static String CheckboxMultiSelectAttributeEditor_Edit; >+ >+ public static String CheckboxMultiSelectAttributeEditor_Select_X; >+ > public static String CommentGroupStrategy_Current; > > public static String CommentGroupStrategy_Older; >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/CheckboxMultiSelectAttributeEditor.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/editors/CheckboxMultiSelectAttributeEditor.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/editors/CheckboxMultiSelectAttributeEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/CheckboxMultiSelectAttributeEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,137 @@ >+/******************************************************************************* >+ * 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.tasks.ui.editors; >+ >+import java.util.Collections; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.jface.window.Window; >+import org.eclipse.mylyn.internal.provisional.commons.ui.CheckBoxTreeDialog; >+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil; >+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.osgi.util.NLS; >+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.forms.widgets.FormToolkit; >+ >+/** >+ * @author Shawn Minto >+ */ >+public class CheckboxMultiSelectAttributeEditor extends AbstractAttributeEditor { >+ >+ private Text valueText; >+ >+ public CheckboxMultiSelectAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) { >+ super(manager, taskAttribute); >+ setLayoutHint(new LayoutHint(RowSpan.SINGLE, ColumnSpan.MULTIPLE)); >+ } >+ >+ @Override >+ public void createControl(Composite parent, FormToolkit toolkit) { >+ Composite composite = toolkit.createComposite(parent); >+ GridLayout layout = new GridLayout(2, false); >+ layout.marginWidth = 1; >+ composite.setLayout(layout); >+ >+ valueText = toolkit.createText(composite, "", SWT.FLAT); //$NON-NLS-1$ >+ valueText.setFont(EditorUtil.TEXT_FONT); >+ >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ valueText.setLayoutData(gd); >+ valueText.setEditable(false); >+ Button changeValueButton = toolkit.createButton(composite, Messages.CheckboxMultiSelectAttributeEditor_Edit, >+ SWT.FLAT); >+ gd = new GridData(); >+ changeValueButton.setLayoutData(gd); >+ changeValueButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ >+ List<String> values = getValues(); >+ >+ Map<String, String> validValues = getAttributeMapper().getOptions(getTaskAttribute()); >+ >+ Shell shell = WorkbenchUtil.getShell(); >+ >+ CheckBoxTreeDialog selectionDialog = new CheckBoxTreeDialog(shell, values, validValues, NLS.bind( >+ Messages.CheckboxMultiSelectAttributeEditor_Select_X, getLabel())); >+ int responseCode = selectionDialog.open(); >+ >+ List<String> newValues = selectionDialog.getSelectedValues(); >+ if (responseCode == Window.OK && values != null) { >+ setValues(newValues); >+ attributeChanged(); >+ updateText(); >+ } else { >+ return; >+ } >+ >+ } >+ >+ }); >+ toolkit.adapt(valueText, false, false); >+ updateText(); >+ setControl(composite); >+ } >+ >+ private void updateText() { >+ if (valueText != null && !valueText.isDisposed()) { >+ StringBuilder valueString = new StringBuilder(); >+ List<String> values = getValuesLabels(); >+ Collections.sort(values); >+ for (int i = 0; i < values.size(); i++) { >+ valueString.append(values.get(i)); >+ if (i != values.size() - 1) { >+ valueString.append(", "); //$NON-NLS-1$ >+ } >+ } >+ valueText.setText(valueString.toString()); >+ } >+ } >+ >+ public List<String> getValues() { >+ return getAttributeMapper().getValues(getTaskAttribute()); >+ } >+ >+ public List<String> getValuesLabels() { >+ return getAttributeMapper().getValueLabels(getTaskAttribute()); >+ } >+ >+ public void setValues(List<String> newValues) { >+ getAttributeMapper().setValues(getTaskAttribute(), newValues); >+ attributeChanged(); >+ } >+ >+ @Override >+ protected void decorateIncoming(Color color) { >+ if (valueText != null && !valueText.isDisposed()) { >+ valueText.setBackground(color); >+ } >+ } >+ >+} >#P org.eclipse.mylyn.bugzilla.ui >Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java,v >retrieving revision 1.5 >diff -u -r1.5 BugzillaKeywordAttributeEditor.java >--- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java 16 Dec 2008 00:21:39 -0000 1.5 >+++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaKeywordAttributeEditor.java 27 Aug 2009 22:08:22 -0000 >@@ -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(); > } > > }
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 279334
:
138459
|
145867
| 145869 |
146268
|
149063