private static void buildTextQueryPart( Query query, Map<IQueryField, ComboViewer> operators, Map<IQueryField, Text> values) { for (Entry<IQueryField, Text> entry : values.entrySet()) { IQueryField queryField = entry.getKey(); Text text = entry.getValue(); ComboViewer opCombo = operators.get(queryField); IStructuredSelection selection = (IStructuredSelection) opCombo.getSelection(); if (selection.getFirstElement() instanceof CompareOperator) { CompareOperator operator = (CompareOperator) selection.getFirstElement(); if (queryField instanceof CustomField) { CustomField customField = (CustomField) queryField; if (customField.getFieldFormat() == CustomField.Format.BOOL) { query.addFilter( customField, QueryField.BOOLEAN_TYPE, operator, IRedmineConstants.BOOLEAN_TRUE_SUBMIT_VALUE); } else { QueryField definition = customField.getQueryField(); query.addFilter(customField, definition, operator, text.getText().trim()); } } else { query.addFilter((QueryField) queryField, operator, text.getText().trim()); } } } }
public static void restoreTextQueryPart( Query query, Configuration configuration, Map<IQueryField, ComboViewer> operators, Map<IQueryField, Text> values) { for (Entry<IQueryField, Text> entry : values.entrySet()) { IQueryField queryField = entry.getKey(); QueryFilter queryFilter = query.getQueryFilter(queryField); if (queryFilter == null) { continue; } Text control = entry.getValue(); ComboViewer operatorCombo = operators.get(queryField); operatorCombo.setSelection(new StructuredSelection(queryFilter.getOperator())); if (queryFilter.getOperator().isValueBased()) { control.setEnabled(true); List<String> filterValues = queryFilter.getValues(); if (filterValues.size() > 0) { control.setText(filterValues.get(0)); } } } }
private static void buildStructuredQueryPart( Query query, Map<IQueryField, ComboViewer> operators, Map<IQueryField, StructuredViewer> values) { for (Entry<IQueryField, StructuredViewer> entry : values.entrySet()) { IQueryField queryField = entry.getKey(); StructuredViewer viewer = entry.getValue(); ComboViewer opCombo = operators.get(queryField); QueryField definition = queryField instanceof CustomField ? ((CustomField) queryField).getQueryField() : (QueryField) queryField; IStructuredSelection selection = (IStructuredSelection) opCombo.getSelection(); if (selection.getFirstElement() instanceof CompareOperator) { CompareOperator operator = (CompareOperator) selection.getFirstElement(); selection = (IStructuredSelection) viewer.getSelection(); if (selection.isEmpty()) { query.addFilter(queryField, definition, operator, ""); // $NON-NLS-1$ } else { Iterator<?> valIterator = selection.iterator(); while (valIterator.hasNext()) { Object obj = valIterator.next(); if (obj instanceof Property) { Property property = (Property) obj; query.addFilter( queryField, definition, operator, "" + property.getId()); // $NON-NLS-1$ } else { query.addFilter(queryField, definition, operator, obj.toString()); } } } } } }
public static void restoreStructuredQueryPart( Query query, Configuration configuration, Map<IQueryField, ComboViewer> operators, Map<IQueryField, StructuredViewer> values) { for (Entry<IQueryField, StructuredViewer> entry : values.entrySet()) { IQueryField queryField = entry.getKey(); QueryFilter queryFilter = query.getQueryFilter(queryField); if (queryFilter == null) { continue; } StructuredViewer viewer = entry.getValue(); ComboViewer operatorCombo = operators.get(queryField); operatorCombo.setSelection(new StructuredSelection(queryFilter.getOperator())); if (queryFilter.getOperator().isValueBased()) { viewer.getControl().setEnabled(true); List<String> filterValues = queryFilter.getValues(); if (queryField instanceof QueryField) { List<Object> properties = new ArrayList<Object>(filterValues.size()); for (String value : filterValues) { if (RedmineUtil.isInteger(value)) { Property property = queryFieldValue2Property( RedmineUtil.parseIntegerId(value), (QueryField) queryField, configuration); if (property != null) { properties.add(property); } } else { properties.add(value); } viewer.setSelection(new StructuredSelection(properties)); } } else { viewer.setSelection(new StructuredSelection(filterValues)); } } } }