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)); } } } }
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)); } } } }