use of com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener in project cuba by cuba-platform.
the class DesktopRowsCount method setDatasource.
@Override
public void setDatasource(CollectionDatasource datasource) {
this.datasource = datasource;
if (datasource != null) {
collectionChangeListener = e -> {
samePage = Operation.REFRESH != e.getOperation() && Operation.CLEAR != e.getOperation();
onCollectionChanged();
};
// noinspection unchecked
this.datasource.addCollectionChangeListener(new WeakCollectionChangeListener(this.datasource, collectionChangeListener));
impl.getCountButton().addActionListener(e -> onLinkClick());
impl.getPrevButton().addActionListener(e -> onPrevClick());
impl.getNextButton().addActionListener(e -> onNextClick());
impl.getFirstButton().addActionListener(e -> onFirstClick());
impl.getLastButton().addActionListener(e -> onLastClick());
if (datasource.getState() == Datasource.State.VALID) {
onCollectionChanged();
}
}
}
use of com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener in project cuba by cuba-platform.
the class DesktopTokenList method setDatasource.
@SuppressWarnings("unchecked")
@Override
public void setDatasource(CollectionDatasource datasource) {
this.datasource = datasource;
collectionChangeListener = e -> {
if (lookupPickerField != null) {
if (isLookup()) {
if (getLookupScreen() != null)
lookupAction.setLookupScreen(getLookupScreen());
else
lookupAction.setLookupScreen(null);
lookupAction.setLookupScreenOpenType(lookupOpenMode);
lookupAction.setLookupScreenParams(lookupScreenParams);
lookupAction.setLookupScreenDialogParams(lookupScreenDialogParams);
}
}
rootPanel.refreshComponent();
rootPanel.refreshClickListeners(itemClickListener);
};
datasource.addCollectionChangeListener(new WeakCollectionChangeListener(datasource, collectionChangeListener));
}
use of com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener in project cuba by cuba-platform.
the class WebRowsCount method setDatasource.
@Override
public void setDatasource(CollectionDatasource datasource) {
Preconditions.checkNotNullArgument(datasource, "datasource is null");
if (this.datasource != null) {
// noinspection unchecked
this.datasource.removeCollectionChangeListener(weakCollectionChangeListener);
weakCollectionChangeListener = null;
} else {
// noinspection unchecked
collectionChangeListener = e -> {
samePage = Operation.REFRESH != e.getOperation() && Operation.CLEAR != e.getOperation();
onCollectionChanged();
};
}
this.datasource = datasource;
weakCollectionChangeListener = new WeakCollectionChangeListener(datasource, collectionChangeListener);
// noinspection unchecked
datasource.addCollectionChangeListener(weakCollectionChangeListener);
component.getCountButton().addClickListener(event -> onLinkClick());
component.getPrevButton().addClickListener(event -> onPrevClick());
component.getNextButton().addClickListener(event -> onNextClick());
component.getFirstButton().addClickListener(event -> onFirstClick());
component.getLastButton().addClickListener(event -> onLastClick());
if (datasource.getState() == Datasource.State.VALID) {
onCollectionChanged();
}
}
Aggregations