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 72143 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.
Basic implementation without Radio Buttons and Text Area
TracCustomQueryPage.patch (text/plain), 8.26 KB, created by
Andrey Larionov
on 2007-06-22 05:21:40 EDT
(
hide
)
Description:
Basic implementation without Radio Buttons and Text Area
Filename:
MIME Type:
Creator:
Andrey Larionov
Created:
2007-06-22 05:21:40 EDT
Size:
8.26 KB
patch
obsolete
>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.33 >diff -u -r1.33 TracCustomQueryPage.java >--- src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java 15 Jun 2007 22:04:30 -0000 1.33 >+++ src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java 22 Jun 2007 09:16:15 -0000 >@@ -12,6 +12,7 @@ > > import java.lang.reflect.InvocationTargetException; > import java.net.MalformedURLException; >+import java.util.ArrayList; > import java.util.HashMap; > import java.util.Map; > >@@ -29,6 +30,7 @@ > import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter; > import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator; > import org.eclipse.mylyn.internal.trac.ui.TracUiPlugin; >+import org.eclipse.mylyn.internal.trac.core.model.TracTicketField; > import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; > import org.eclipse.mylyn.tasks.core.TaskRepository; > import org.eclipse.mylyn.tasks.core.TaskRepositoryManager; >@@ -109,6 +111,8 @@ > > private Map<String, SearchField> searchFieldByName = new HashMap<String, SearchField>(); > >+ private Map<String, SearchField> customSearchFieldByName = new HashMap<String, SearchField>(); >+ > private boolean firstTime = true; > > // private UserSearchField ownerField; >@@ -218,6 +222,7 @@ > > createProductAttributes(group); > createTicketAttributes(group); >+ createCustomAttributes(group); > createUpdateButton(group); > > return group; >@@ -262,6 +267,106 @@ > return group; > } > >+ protected Control createCustomAttributes(Composite control) { >+ ITracClient client = updateClientData(true); >+ >+ // Arranging custom fields by types >+ TracTicketField[] allFields = client.getTicketFields(); >+ Map<TracTicketField.Type, ArrayList<TracTicketField>> customFields = new HashMap<TracTicketField.Type, ArrayList<TracTicketField>>(); >+ customFields.put(TracTicketField.Type.CHECKBOX, new ArrayList<TracTicketField>()); >+ customFields.put(TracTicketField.Type.RADIO, new ArrayList<TracTicketField>()); >+ customFields.put(TracTicketField.Type.SELECT, new ArrayList<TracTicketField>()); >+ customFields.put(TracTicketField.Type.TEXT, new ArrayList<TracTicketField>()); >+ customFields.put(TracTicketField.Type.TEXTAREA, new ArrayList<TracTicketField>()); >+ for (TracTicketField field : allFields) { >+ if (field.isCustom()) >+ // TODO: Implement order sorting >+ customFields.get(field.getType()).add(field); >+ } >+ >+ allFields = null; >+ >+ 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); >+ group.setLayoutData(gd); >+ >+ int curCol = 0; >+ >+ TracTicketField.Type lastType = null; >+ for (TracTicketField.Type type : customFields.keySet()) { >+ SearchField custom = null; >+ if (lastType == null) >+ lastType = type; >+ switch (type) { >+ case CHECKBOX: >+ for (int i = curCol; i > 0; i--) { >+ Label tmp = new Label(group, SWT.NONE); >+ tmp.setVisible(false); >+ tmp.setLayoutData(new GridData(SWT.END, SWT.END, false, false)); >+ } >+ >+ for (TracTicketField field : customFields.get(type)) { >+ custom = new CheckSearchField(field.getName()); >+ ((CheckSearchField) custom).createControls(group, field.getLabel()); >+ curCol = (curCol + 2) % 4; >+ } >+ break; >+ case RADIO: >+ for (TracTicketField field : customFields.get(type)) { >+ } >+ break; >+ case SELECT: >+ for (int i = curCol; i > 0; i--) { >+ Label tmp = new Label(group, SWT.NONE); >+ tmp.setVisible(false); >+ tmp.setLayoutData(new GridData(SWT.END, SWT.END, false, false)); >+ } >+ for (TracTicketField field : customFields.get(type)) { >+ Label label = new Label(group, SWT.LEFT); >+ label.setText(field.getLabel()); >+ custom = new ListSearchField(field.getName()); >+ ((ListSearchField) custom).createControls(group, STATUS_HEIGHT); >+ curCol = (curCol + 2) % 4; >+ } >+ break; >+ case TEXT: >+ for (int i = curCol; i > 0; i--) { >+ Label tmp = new Label(group, SWT.NONE); >+ tmp.setVisible(false); >+ tmp.setLayoutData(new GridData(SWT.END, SWT.END, false, false)); >+ } >+ for (TracTicketField field : customFields.get(type)) { >+ custom = new TextSearchField(field.getName()); >+ ((TextSearchField) custom).createControls(group, field.getLabel()); >+ curCol = (curCol + 4) % 4; >+ } >+ break; >+ case TEXTAREA: >+ break; >+ } >+ if (custom != null) >+ customSearchFieldByName.put(custom.getFieldName(), custom); >+ lastType = type; >+ } >+ >+ return control; >+ } >+ >+ private void updateCustomAttributes(ITracClient client) { >+ // TODO Auto-generated method stub >+ for (SearchField field : customSearchFieldByName.values()) { >+ if (field instanceof ListSearchField) { >+ for (TracTicketField repfield : client.getTicketFields()) { >+ if (repfield.getName() == field.getFieldName()) >+ ((ListSearchField) field).setValues(repfield.getOptions()); >+ } >+ } >+ } >+ } >+ > /** > * Creates the area for selection of ticket attributes > * status/resolution/priority. >@@ -378,7 +483,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; >@@ -386,7 +491,7 @@ > client = connector.getClientManager().getRepository(repository); > } catch (MalformedURLException e) { > TracUiPlugin.handleTracException(e); >- return; >+ return null; > } > > if (!client.hasAttributes() || force) { >@@ -411,12 +516,16 @@ > } > } catch (InvocationTargetException e) { > TracUiPlugin.handleTracException(e.getCause()); >- return; >+ return null; > } catch (InterruptedException e) { >- return; >+ return null; > } > } >+ return client; > >+ } >+ private void updateAttributesFromRepository(final boolean force) { >+ ITracClient client = updateClientData(force); > statusField.setValues(client.getTicketStatus()); > resolutionField.setValues(client.getTicketResolutions()); > typeField.setValues(client.getTicketTypes()); >@@ -425,6 +534,8 @@ > componentField.setValues(client.getComponents()); > versionField.setValues(client.getVersions()); > milestoneField.setValues(client.getMilestones()); >+ >+ updateCustomAttributes(client); > } > > public TaskRepository getRepository() { >@@ -534,7 +645,7 @@ > } > } > >- public String getFieldName() { >+ public String getFieldName() { > return fieldName; > } > >@@ -629,6 +740,62 @@ > > } > >+ private class CheckSearchField extends SearchField { >+ >+ protected Button searchCheck; >+ >+ private Label label; >+ >+ public CheckSearchField(String fieldName) { >+ super(fieldName); >+ } >+ >+ public void createControls(Composite parent, String labelText) { >+ if (labelText != null) { >+ label = new Label(parent, SWT.LEFT); >+ label.setText(labelText); >+ } >+ >+ searchCheck = new Button(parent, SWT.CHECK); >+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ // the user search field has additional controls and no fieldName >+ searchCheck.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() { >+ TracSearchFilter newFilter = new TracSearchFilter(getFieldName()); >+ newFilter.setOperator(CompareOperator.IS); >+ newFilter.addValue(String.valueOf(getSearchState())); >+ return newFilter; >+ } >+ >+ @Override >+ public void setFilter(TracSearchFilter filter) { >+ java.util.List<String> values = filter.getValues(); >+ setSearchState(Integer.parseInt(values.get(0))); >+ } >+ >+ public void setFieldName(String fieldName) { >+ this.fieldName = fieldName; >+ } >+ >+ } >+ > private class ListSearchField extends SearchField { > > private List list;
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 Raw
Actions:
View
Attachments on
bug 176964
:
72115
|
72142
| 72143 |
72866
|
72867
|
73057