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 73057 Details for
Bug 176964
provide custom fields in query form
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 against head
clipboard.txt (text/plain), 26.17 KB, created by
Steffen Pingel
on 2007-07-04 14:54:12 EDT
(
hide
)
Description:
patch against head
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2007-07-04 14:54:12 EDT
Size:
26.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.trac.ui >Index: src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java,v >retrieving revision 1.39 >diff -u -r1.39 TracCustomQueryPage.java >--- src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java 3 Jul 2007 14:45:55 -0000 1.39 >+++ src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java 4 Jul 2007 18:51:45 -0000 >@@ -9,6 +9,7 @@ > > import java.lang.reflect.InvocationTargetException; > import java.net.MalformedURLException; >+import java.util.ArrayList; > import java.util.HashMap; > import java.util.Map; > >@@ -23,6 +24,7 @@ > import org.eclipse.mylyn.internal.trac.core.TracRepositoryQuery; > import org.eclipse.mylyn.internal.trac.core.model.TracSearch; > import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter; >+import org.eclipse.mylyn.internal.trac.core.model.TracTicketField; > import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator; > import org.eclipse.mylyn.internal.trac.ui.TracUiPlugin; > import org.eclipse.mylyn.monitor.core.StatusHandler; >@@ -32,10 +34,14 @@ > import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; > import org.eclipse.mylyn.tasks.ui.search.AbstractRepositoryQueryPage; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.KeyListener; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >@@ -43,9 +49,7 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.List; > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.progress.IProgressService; >@@ -55,6 +59,7 @@ > * > * @author Steffen Pingel > */ >+ > public class TracCustomQueryPage extends AbstractRepositoryQueryPage { > > private static final String TITLE = "Enter query parameters"; >@@ -63,16 +68,10 @@ > > private static final String TITLE_QUERY_TITLE = "Query Title:"; > >- private static final String[] DEFAULT_STATUS_SELECTION = new String[] { "new", "assigned", "reopened", }; >- > private TracRepositoryQuery query; > > private Text titleText; > >- private static final int PRODUCT_HEIGHT = 60; >- >- private static final int STATUS_HEIGHT = 40; >- > protected final static String PAGE_NAME = "TracSearchPage"; //$NON-NLS-1$ > > private static final String SEARCH_URL_ID = PAGE_NAME + ".SEARCHURL"; >@@ -81,37 +80,19 @@ > > protected Combo repositoryCombo = null; > >- private TextSearchField summaryField; >- >- private TextSearchField descriptionField; >- >- private ListSearchField componentField; >- >- private ListSearchField versionField; >- >- private ListSearchField milestoneField; >- >- private ListSearchField priorityField; >- >- private ListSearchField typeField; >- >- private ListSearchField resolutionField; >- >- private ListSearchField statusField; >- > private Button updateButton; > >- private TextSearchField keywordsField; >+ private Map<String, String> ticketFieldsLabelToName; > >- private Map<String, SearchField> searchFieldByName = new HashMap<String, SearchField>(); >+ private Map<String, TracTicketField> allTicketFieldsByName; > >- private boolean firstTime = true; >+ private Map<String, SearchField> selectedSearchFieldByName = new HashMap<String, SearchField>(); > >- // private UserSearchField ownerField; >- // >- // private UserSearchField reporterField; >- // >- // private UserSearchField ccField; >+ private boolean firstTime = true; >+ >+ private Composite optionsContainer; >+ >+ private Combo filterCombo; > > public TracCustomQueryPage(TaskRepository repository, AbstractRepositoryQuery query) { > super(TITLE); >@@ -129,6 +110,7 @@ > > @Override > public void createControl(Composite parent) { >+ updateAttributesFromRepository(false); > Composite control = new Composite(parent, SWT.NONE); > GridData gd = new GridData(GridData.FILL_BOTH); > control.setLayoutData(gd); >@@ -140,19 +122,9 @@ > control.setLayout(layout); > > createTitleGroup(control); >- >- summaryField = new TextSearchField("summary"); >- summaryField.createControls(control, "Summary"); >- >- descriptionField = new TextSearchField("description"); >- descriptionField.createControls(control, "Description"); >- >- keywordsField = new TextSearchField("keywords"); >- keywordsField.createControls(control, "Keywords"); >- > createOptionsGroup(control); >- >- createUserGroup(control); >+ createAddFilterGroup(control); >+ createUpdateButton(control); > > if (query != null) { > titleText.setText(query.getSummary()); >@@ -162,6 +134,73 @@ > setControl(control); > } > >+ private void createAddFilterGroup(Composite parent) { >+ GridLayout layout; >+ GridData gd; >+ >+ Composite composite = new Composite(parent, SWT.NONE); >+ layout = new GridLayout(2, false); >+ composite.setLayout(layout); >+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); >+ gd.horizontalSpan = 4; >+ composite.setLayoutData(gd); >+ >+ Label label = new Label(composite, SWT.LEFT); >+ label.setText("Select to add filter: "); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ >+ // condition >+ filterCombo = new Combo(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); >+ filterCombo.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); >+ >+ filterCombo.add(""); >+ for (String fieldLabel : ticketFieldsLabelToName.keySet()) >+ filterCombo.add(fieldLabel); >+ >+ filterCombo.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if (filterCombo.getText().length() > 0) { >+ TracTicketField field = allTicketFieldsByName.get(ticketFieldsLabelToName.get(filterCombo.getText())); >+ addFieldToPage(field); >+ } >+ } >+ }); >+ } >+ >+ >+ protected SearchField addFieldToPage(TracTicketField field) { >+ // TODO Auto-generated method stub >+ SearchField searchField = null; >+ if ((field.getType() == TracTicketField.Type.TEXT) || (field.getType() == TracTicketField.Type.TEXTAREA)) { >+ searchField = new TextSearchField(field.getName()); >+ selectedSearchFieldByName.put(field.getName(), searchField); >+ ((TextSearchField)searchField).createControls(optionsContainer, field.getLabel()); >+ } >+ if (field.getType() == TracTicketField.Type.CHECKBOX) { >+ searchField = new CheckSearchField(field.getName()); >+ selectedSearchFieldByName.put(field.getName(), searchField); >+ ((CheckSearchField)searchField).createControls(optionsContainer, field.getLabel()); >+ } >+ if (field.getType() == TracTicketField.Type.SELECT || (field.getType() == TracTicketField.Type.RADIO)) { >+ searchField = new ListSearchField(field.getName()); >+ selectedSearchFieldByName.put(field.getName(), searchField); >+ ((ListSearchField)searchField).createControls(optionsContainer, field.getLabel()); >+ } >+ >+ filterCombo.remove(field.getLabel()); >+ filterCombo.select(0); >+ updateScrollPane(); >+ return searchField; >+ >+ } >+ >+ private void updateScrollPane() { >+ //optionsContainer.setSize(optionsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT)); >+ ((ScrolledComposite)optionsContainer.getParent()).setMinHeight(optionsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >+ optionsContainer.layout(); >+ } >+ > @Override > public boolean canFlipToNextPage() { > return false; >@@ -170,7 +209,9 @@ > private void restoreWidgetValues(TracSearch search) { > java.util.List<TracSearchFilter> filters = search.getFilters(); > for (TracSearchFilter filter : filters) { >- SearchField field = searchFieldByName.get(filter.getFieldName()); >+ SearchField field = selectedSearchFieldByName.get(filter.getFieldName()); >+ if (field == null) >+ field = addFieldToPage(allTicketFieldsByName.get(filter.getFieldName())); > if (field != null) { > field.setFilter(filter); > } else { >@@ -185,10 +226,11 @@ > } > > Label titleLabel = new Label(control, SWT.NONE); >+ titleLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); > titleLabel.setText(TITLE_QUERY_TITLE); > > titleText = new Text(control, SWT.BORDER); >- GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); >+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); > gd.horizontalSpan = 3; > titleText.setLayoutData(gd); > titleText.addKeyListener(new KeyListener() { >@@ -203,99 +245,31 @@ > } > > protected Control createOptionsGroup(Composite control) { >- Group group = new Group(control, SWT.NONE); >- // group.setText("Ticket Attributes"); >- GridLayout layout = new GridLayout(); >- layout.numColumns = 1; >- group.setLayout(layout); > GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.horizontalSpan = 4; >- group.setLayoutData(gd); >- >- createProductAttributes(group); >- createTicketAttributes(group); >- createUpdateButton(group); >- >- return group; >- } >- >- protected void createUserGroup(Composite control) { >- UserSearchField userField = new UserSearchField(); >- userField.createControls(control); >- } >+ gd.horizontalSpan = 5; > >- /** >- * Creates the area for selection on product attributes component/version/milestone. >- */ >- protected Control createProductAttributes(Composite control) { >- Composite group = new Composite(control, SWT.NONE); >+ ScrolledComposite sc = new ScrolledComposite(control, SWT.V_SCROLL); >+ sc.setLayoutData(gd); > GridLayout layout = new GridLayout(); >- layout.numColumns = 3; >- group.setLayout(layout); >- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.horizontalSpan = 1; >- group.setLayoutData(gd); >- >- Label label = new Label(group, SWT.LEFT); >- label.setText("Component"); >- >- label = new Label(group, SWT.LEFT); >- label.setText("Version"); >- >- label = new Label(group, SWT.LEFT); >- label.setText("Milestone"); >- >- componentField = new ListSearchField("component"); >- componentField.createControls(group, PRODUCT_HEIGHT); >- >- versionField = new ListSearchField("version"); >- versionField.createControls(group, PRODUCT_HEIGHT); >- >- milestoneField = new ListSearchField("milestone"); >- milestoneField.createControls(group, PRODUCT_HEIGHT); >- >- return group; >+ layout.numColumns = 1; >+ layout.marginHeight = layout.marginWidth = 0; >+ sc.setLayout(layout); >+ >+ Composite innerComposite = new Composite(sc, SWT.NONE); >+ innerComposite.setLayout(new GridLayout(5, false)); >+ sc.setContent(innerComposite); >+ sc.setExpandHorizontal(true); >+ sc.setExpandVertical(true); >+ sc.setMinHeight(300); >+ >+ optionsContainer = innerComposite; >+ return innerComposite; > } >+ > > /** >- * Creates the area for selection of ticket attributes status/resolution/priority. >+ * Creates the area for update attributes button. > */ >- protected Control createTicketAttributes(Composite control) { >- Composite group = new Composite(control, SWT.NONE); >- GridLayout layout = new GridLayout(); >- layout.numColumns = 4; >- group.setLayout(layout); >- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.horizontalSpan = 1; >- group.setLayoutData(gd); >- >- Label label = new Label(group, SWT.LEFT); >- label.setText("Status"); >- >- label = new Label(group, SWT.LEFT); >- label.setText("Resolution"); >- >- label = new Label(group, SWT.LEFT); >- label.setText("Type"); >- >- label = new Label(group, SWT.LEFT); >- label.setText("Priority"); >- >- statusField = new ListSearchField("status"); >- statusField.createControls(group, STATUS_HEIGHT); >- >- resolutionField = new ListSearchField("resolution"); >- resolutionField.createControls(group, STATUS_HEIGHT); >- >- typeField = new ListSearchField("type"); >- typeField.createControls(group, STATUS_HEIGHT); >- >- priorityField = new ListSearchField("priority"); >- priorityField.createControls(group, STATUS_HEIGHT); >- >- return group; >- } >- > protected Control createUpdateButton(final Composite control) { > Composite group = new Composite(control, SWT.NONE); > GridLayout layout = new GridLayout(2, false); >@@ -350,14 +324,14 @@ > } > > private void initializePage() { >- updateAttributesFromRepository(false); >+ updateAttributesFromRepository(true); > boolean restored = (query != null); > if (inSearchContainer()) { > restored |= restoreWidgetValues(); > } > // initialize with default values > if (!restored) { >- statusField.selectItems(DEFAULT_STATUS_SELECTION); >+ //statusField.selectItems(DEFAULT_STATUS_SELECTION); > } > } > >@@ -372,7 +346,7 @@ > } > } > >- private void updateAttributesFromRepository(final boolean force) { >+ private ITracClient updateClientData(final boolean force) { > TracRepositoryConnector connector = (TracRepositoryConnector) TasksUiPlugin.getRepositoryManager() > .getRepositoryConnector(TracCorePlugin.REPOSITORY_KIND); > final ITracClient client; >@@ -380,7 +354,7 @@ > client = connector.getClientManager().getRepository(repository); > } catch (MalformedURLException e) { > StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e, repository)); >- return; >+ return null; > } > > if (!client.hasAttributes() || force) { >@@ -405,20 +379,28 @@ > } > } catch (InvocationTargetException e) { > StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e.getCause(), repository)); >- return; >+ return null; > } catch (InterruptedException e) { >- return; >+ return null; > } > } >+ return client; > >- statusField.setValues(client.getTicketStatus()); >- resolutionField.setValues(client.getTicketResolutions()); >- typeField.setValues(client.getTicketTypes()); >- priorityField.setValues(client.getPriorities()); >- >- componentField.setValues(client.getComponents()); >- versionField.setValues(client.getVersions()); >- milestoneField.setValues(client.getMilestones()); >+ } >+ private void updateAttributesFromRepository(final boolean force) { >+ ITracClient client = updateClientData(force); >+ TracTicketField[] ticketFields = client.getTicketFields(); >+ ticketFieldsLabelToName = new HashMap<String, String>(); >+ allTicketFieldsByName = new HashMap<String, TracTicketField>(); >+ for (TracTicketField tf : ticketFields) { >+ ticketFieldsLabelToName.put(tf.getLabel(), tf.getName()); >+ allTicketFieldsByName.put(tf.getName(), tf); >+ } >+ for (SearchField searchField : selectedSearchFieldByName.values()) >+ if (searchField instanceof ListSearchField) >+ //((ListSearchField)searchField).setValues(allTicketFieldsByName.get(ticketFieldsLabelToName.get(searchField.getFieldName())).getOptions()); >+ ((ListSearchField)searchField).setValues(allTicketFieldsByName.get(searchField.getFieldName()).getOptions()); >+ //TODO: Refresh selectable attributes > } > > public TaskRepository getRepository() { >@@ -449,7 +431,7 @@ > > private TracSearch getTracSearch() { > TracSearch search = new TracSearch(); >- for (SearchField field : searchFieldByName.values()) { >+ for (SearchField field : selectedSearchFieldByName.values()) { > TracSearchFilter filter = field.getFilter(); > if (filter != null) { > search.addFilter(filter); >@@ -516,17 +498,20 @@ > IDialogSettings settings = getDialogSettings(); > settings.put(SEARCH_URL_ID + repoId, getTracSearch().toUrl()); > } >+ > > private abstract class SearchField { > > protected String fieldName; >+ >+ protected ArrayList<Control> controlList= new ArrayList<Control>(); > > public SearchField(String fieldName) { > this.fieldName = fieldName; > > if (fieldName != null) { >- assert !searchFieldByName.containsKey(fieldName); >- searchFieldByName.put(fieldName, this); >+ assert !selectedSearchFieldByName.containsKey(fieldName); >+ selectedSearchFieldByName.put(fieldName, this); > } > } > >@@ -534,6 +519,31 @@ > return fieldName; > } > >+ protected Button placeRemoveButton(Composite parent) { >+ Button removeButton = new Button(parent, SWT.PUSH); >+ removeButton.setText("Remove"); >+ removeButton.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false)); >+ controlList.add(removeButton); >+ removeButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ widgetSelected(e); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ selectedSearchFieldByName.remove(getFieldName()); >+ for (Control con : controlList) >+ con.dispose(); >+ filterCombo.add(allTicketFieldsByName.get(getFieldName()).getLabel()); >+ updateScrollPane(); >+ } >+ >+ }); >+ return removeButton; >+ } >+ > public abstract TracSearchFilter getFilter(); > > public abstract void setFilter(TracSearchFilter filter); >@@ -559,6 +569,8 @@ > if (labelText != null) { > label = new Label(parent, SWT.LEFT); > label.setText(labelText); >+ label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); >+ controlList.add(label); > } > > conditionCombo = new Combo(parent, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); >@@ -566,6 +578,7 @@ > conditionCombo.add(op.toString()); > } > conditionCombo.setText(compareOperators[0].toString()); >+ controlList.add(conditionCombo); > > searchText = new Text(parent, SWT.BORDER); > GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); >@@ -574,6 +587,10 @@ > gd.horizontalSpan = 2; > } > searchText.setLayoutData(gd); >+ controlList.add(searchText); >+ >+ placeRemoveButton(parent); >+; > } > > public CompareOperator getCondition() { >@@ -625,154 +642,217 @@ > > } > >- private class ListSearchField extends SearchField { >+ private class CheckSearchField extends SearchField { > >- private List list; >+ protected Button searchCheck; > >- public ListSearchField(String fieldName) { >+ private Label label; >+ >+ public CheckSearchField(String fieldName) { > super(fieldName); > } > >- public void setValues(Object[] items) { >- // preserve selected values >- TracSearchFilter filter = getFilter(); >+ public void createControls(Composite parent, String labelText) { >+ if (labelText != null) { >+ label = new Label(parent, SWT.LEFT); >+ label.setText(labelText); >+ label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); >+ controlList.add(label); >+ } > >- list.removeAll(); >- if (items != null) { >- list.setEnabled(true); >- for (Object item : items) { >- list.add(item.toString()); >- } >+ searchCheck = new Button(parent, SWT.CHECK|SWT.LEFT); >+ //if (labelText != null) >+ // searchCheck.setText(labelText); >+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ gd.horizontalSpan = 3; >+ searchCheck.setLayoutData(gd); >+ controlList.add(searchCheck); >+ >+ placeRemoveButton(parent); > >- // restore selected values >- if (filter != null) { >- setFilter(filter); >- } >- } else { >- list.setEnabled(false); >- } > } > >- public void createControls(Composite parent, int height) { >- list = new List(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); >- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.heightHint = height; >- list.setLayoutData(gd); >+ public int getSearchState() { >+ if (searchCheck.getSelection()) >+ return 1; >+ else >+ return 0; >+ } >+ >+ public void setSearchState(int state) { >+ if (state != 0) >+ searchCheck.setSelection(true); >+ else >+ searchCheck.setSelection(false); > } > > @Override > public TracSearchFilter getFilter() { >- int[] indicies = list.getSelectionIndices(); >- if (indicies.length == 0) { >- return null; >- } >- > TracSearchFilter newFilter = new TracSearchFilter(getFieldName()); > newFilter.setOperator(CompareOperator.IS); >- for (int i : indicies) { >- newFilter.addValue(list.getItem(i)); >- } >+ newFilter.addValue(String.valueOf(getSearchState())); > return newFilter; > } > > @Override > public void setFilter(TracSearchFilter filter) { >- list.deselectAll(); > java.util.List<String> values = filter.getValues(); >- for (String item : values) { >- int i = list.indexOf(item); >- if (i != -1) { >- list.select(i); >- } else { >- list.add(item, 0); >- list.select(0); >- } >- } >+ setSearchState(Integer.parseInt(values.get(0))); > } > >- public void selectItems(String[] items) { >- list.deselectAll(); >- for (String item : items) { >- int i = list.indexOf(item); >- if (i != -1) { >- list.select(i); >- } >- } >+ public void setFieldName(String fieldName) { >+ this.fieldName = fieldName; > } > > } > >- private class UserSearchField extends SearchField { >- >- private TextSearchField textField; >- >- private Combo userCombo; >+ private class ListSearchField extends SearchField { > >- public UserSearchField() { >- super(null); >+ private ArrayList<Combo> combos = new ArrayList<Combo>(); >+ >+ private Composite container; >+ >+ public ListSearchField(String fieldName) { >+ super(fieldName); >+ } > >- textField = new TextSearchField(null); >+ public void setValues(Object[] items) { >+ // preserve selected values >+ TracSearchFilter filter = getFilter(); >+ for (Combo combo : combos) { >+ combo.removeAll(); >+ if (items != null) { >+ combo.setEnabled(true); >+ for (Object item : items) { >+ combo.add(item.toString()); >+ } > >- new UserSelectionSearchField("owner", 0); >+ // restore selected values >+ if (filter != null) { >+ setFilter(filter); >+ } >+ } else { >+ combo.setEnabled(false); >+ } >+ } >+ } > >- new UserSelectionSearchField("reporter", 1); >+ public void createControls(Composite parent, String caption) { >+ GridData gd; >+ >+ if (caption != null) { >+ Label label = new Label(parent, SWT.NONE); >+ label.setText(caption); >+ gd = new GridData(SWT.END, SWT.CENTER, false, false); >+ label.setLayoutData(gd); >+ controlList.add(label); >+ } >+ >+ container = new Composite(parent, SWT.NONE); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, false); >+ gd.horizontalSpan = 3; >+ container.setLayoutData(gd); >+ GridLayout layout = new GridLayout(3, false); >+ layout.marginHeight = layout.marginWidth = 0; >+ container.setLayout(layout); >+ controlList.add(container); >+ >+ Label isLabel = new Label(container, SWT.NONE); >+ isLabel.setText("is"); >+ gd = new GridData(SWT.END, SWT.CENTER, false, false); >+ gd.verticalIndent = 5; >+ isLabel.setLayoutData(gd); >+ Combo combo = new Combo(container, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); >+ combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ combo.setItems(allTicketFieldsByName.get(getFieldName()).getOptions()); >+ combos.add(combo); >+ >+ Button addButton = new Button(container, SWT.PUSH); >+ addButton.setText("+"); >+ gd = new GridData(SWT.FILL, SWT.FILL, false, false); >+ addButton.setLayoutData(gd); >+ addButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ widgetSelected(e); >+ } > >- new UserSelectionSearchField("cc", 2); >- } >+ public void widgetSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ addCombo(); >+ updateScrollPane(); >+ } >+ >+ }); >+ >+ >+ placeRemoveButton(parent); >+ } >+ >+ private Combo addCombo() { >+ final Label orLabel = new Label(container, SWT.NONE); >+ orLabel.setText("or"); >+ orLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); >+ >+ final Combo combo = new Combo(container, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); >+ combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ combo.setItems(allTicketFieldsByName.get(getFieldName()).getOptions()); >+ combos.add(combo); >+ >+ final Button remButton = new Button(container, SWT.PUSH); >+ remButton.setText("-"); >+ remButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); >+ remButton.addSelectionListener(new SelectionListener() { >+ >+ private Label tempLabel = orLabel; >+ private Combo tempCombo = combo; >+ private Button tempButton = remButton; >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ widgetSelected(e); >+ } > >- public void createControls(Composite parent) { >- userCombo = new Combo(parent, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); >- userCombo.add("Owner"); >- userCombo.add("Reporter"); >- userCombo.add("CC"); >- userCombo.select(0); >+ public void widgetSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ combos.remove(tempCombo); >+ tempLabel.dispose(); >+ tempCombo.dispose(); >+ tempButton.dispose(); >+ updateScrollPane(); >+ } >+ >+ }); >+ return combo; > >- textField.createControls(parent, null); > } > > @Override > public TracSearchFilter getFilter() { >- return null; >+ TracSearchFilter newFilter = new TracSearchFilter(getFieldName()); >+ newFilter.setOperator(CompareOperator.IS); >+ for (Combo combo : combos) { >+ newFilter.addValue(combo.getText()); >+ } >+ return newFilter; > } > > @Override > public void setFilter(TracSearchFilter filter) { >+ selectItems(filter.getValues().toArray(new String[]{})); > } > >- private void setSelection(int index) { >- userCombo.select(index); >- } >- >- private int getSelection() { >- return userCombo.getSelectionIndex(); >- } >- >- class UserSelectionSearchField extends SearchField { >- >- private int index; >- >- public UserSelectionSearchField(String fieldName, int index) { >- super(fieldName); >- >- this.index = index; >- } >- >- @Override >- public TracSearchFilter getFilter() { >- if (index == getSelection()) { >- textField.setFieldName(fieldName); >- return textField.getFilter(); >+ public void selectItems(String[] items) { >+ Combo combo; >+ for (int i = 0; i < items.length; i++) { >+ if (combos.size() <= i || combos.size() == 0) { >+ combo = addCombo(); >+ } else { >+ combo = combos.get(i); > } >- return null; >+ combo.select(combo.indexOf(items[i])); > } >- >- @Override >- public void setFilter(TracSearchFilter filter) { >- textField.setFieldName(fieldName); >- textField.setFilter(filter); >- setSelection(index); >- } >- > } > > }
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 176964
:
72115
|
72142
|
72143
|
72866
|
72867
| 73057