use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class AttributeGroupFilterWidgets method draw.
public void draw(final Filter filter) {
final Filter value = new Filter(filter);
value.clearRestrictions(DIMENSION_TYPE);
// prevents executing the same command needlessly
if (prevFilter == null || !prevFilter.equals(filter)) {
prevFilter = filter;
Log.debug("AttributeGroupFilterWidgets called for filter " + filter);
// retrieve all attributegroups for the current filter
service.execute(new GetAttributeGroupsDimension(value), new AsyncCallback<AttributeGroupResult>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Failed to load attributes", caught);
}
@Override
public void onSuccess(final AttributeGroupResult attributeGroupResult) {
// if the result is indeed different from the last time, (re)draw the widgets
if (prevResult == null || !prevResult.equals(attributeGroupResult)) {
prevResult = attributeGroupResult;
Log.debug("AttributeGroupFilterWidgets drawing widgets for result: " + attributeGroupResult);
service.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Failed to load schema", caught);
}
@Override
public void onSuccess(final SchemaDTO schema) {
// clean up old widgets
for (AttributeGroupFilterWidget widget : widgets) {
panel.remove(widget);
}
duplicates.clear();
// decorate resultlist from schema
List<AttributeGroupDTO> pivotData = attributeGroupResult.getData();
groups = new ArrayList<AttributeGroupDTO>();
if (CollectionUtil.isNotEmpty(pivotData)) {
for (AttributeGroupDTO pivotGroup : pivotData) {
AttributeGroupDTO schemaGroup = schema.getAttributeGroupById(pivotGroup.getId());
if (schemaGroup != null) {
groups.add(schemaGroup);
}
}
}
// create new widgets, one for each attributegroup.
// remember the old selection
List<Integer> selection = getSelectedIds();
widgets = new ArrayList<AttributeGroupFilterWidget>();
for (AttributeGroupDTO group : groups) {
// create
AttributeGroupFilterWidget widget = new AttributeGroupFilterWidget(group);
// set old selection
widget.setSelection(selection);
// what to do when value changes
if (valueChangeHandler != null) {
widget.addValueChangeHandler(valueChangeHandler);
}
// already been added
if (isNoDuplicate(widget)) {
widgets.add(widget);
panel.add(widget);
} else {
// otherwise add to collection of duplicates
duplicates.put(group.getName().toLowerCase(), widget);
}
}
if (drawCallback != null) {
drawCallback.onSuccess(null);
}
}
});
}
}
});
}
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class FilterWidget method setValue.
@Override
public final void setValue(Filter value, boolean fireEvents) {
if (value == null) {
value = new Filter();
}
this.value = value;
if (fireEvents) {
ValueChangeEvent.fire(this, this.value);
}
updateView();
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class PartnerFilterPanel method applyFilter.
protected void applyFilter() {
value = new Filter();
if (isRendered()) {
List<Integer> selectedIds = getSelectedIds();
if (selectedIds.size() > 0) {
value.addRestriction(DimensionType.Partner, getSelectedIds());
}
}
ValueChangeEvent.fire(this, value);
filterToolBar.setApplyFilterEnabled(false);
filterToolBar.setRemoveFilterEnabled(true);
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class PartnerFilterPanel method applyBaseFilter.
@Override
public void applyBaseFilter(Filter rawFilter) {
// we need to remove any partner filter from this base filter
// so the user has the full selection
final Filter filter = new Filter(rawFilter);
filter.clearRestrictions(DimensionType.Partner);
if (baseFilter == null || !baseFilter.equals(filter)) {
service.execute(new GetPartnersDimension(filter), new AsyncCallback<PartnerResult>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(PartnerResult result) {
List<Integer> ids = getSelectedIds();
store.removeAll();
store.add(result.getData());
applyInternalValue();
for (PartnerDTO partner : store.getModels()) {
if (ids.contains(partner.getId())) {
listView.setChecked(partner, true);
}
}
baseFilter = filter;
}
});
}
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class AttributeFilterPanel method clearFilter.
protected void clearFilter() {
value = new Filter();
widgets.clearFilter();
filterToolBar.setRemoveFilterEnabled(false);
}
Aggregations