Search in sources :

Example 6 with WeakCollectionChangeListener

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();
        }
    }
}
Also used : WeakCollectionChangeListener(com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener)

Example 7 with WeakCollectionChangeListener

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));
}
Also used : WeakCollectionChangeListener(com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener)

Example 8 with WeakCollectionChangeListener

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();
    }
}
Also used : WeakCollectionChangeListener(com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener)

Aggregations

WeakCollectionChangeListener (com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener)8 Entity (com.haulmont.cuba.core.entity.Entity)2 Action (com.haulmont.cuba.gui.components.Action)2 CollectionDsActionsNotifier (com.haulmont.cuba.gui.data.impl.CollectionDsActionsNotifier)2 BasicEventList (ca.odell.glazedlists.BasicEventList)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 BaseUuidEntity (com.haulmont.cuba.core.entity.BaseUuidEntity)1 UserSessionSource (com.haulmont.cuba.core.global.UserSessionSource)1 RowSorterImpl (com.haulmont.cuba.desktop.gui.data.RowSorterImpl)1 TreeModelAdapter (com.haulmont.cuba.desktop.gui.data.TreeModelAdapter)1 FocusableTable (com.haulmont.cuba.desktop.sys.vcl.FocusableTable)1 WeakItemPropertyChangeListener (com.haulmont.cuba.gui.data.impl.WeakItemPropertyChangeListener)1 List (java.util.List)1 AbstractAction (javax.swing.AbstractAction)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 TableColumn (javax.swing.table.TableColumn)1 Element (org.dom4j.Element)1 JXTable (org.jdesktop.swingx.JXTable)1