Search in sources :

Example 1 with ListDataProvider

use of com.google.gwt.view.client.ListDataProvider in project rstudio by rstudio.

the class PackageActionConfirmationDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    FlowPanel flowPanel = new FlowPanel();
    String explanatoryText = getExplanatoryText();
    if (explanatoryText.length() > 0) {
        Label text = new Label(explanatoryText);
        text.setStylePrimaryName(RESOURCES.styles().explanatoryText());
        flowPanel.add(text);
    }
    actionsTable_ = new CellTable<PendingAction>(15, GWT.<PackagesCellTableResources>create(PackagesCellTableResources.class));
    actionsTable_.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    actionsTable_.setSelectionModel(new NoSelectionModel<PendingAction>());
    actionsTable_.setWidth("100%", true);
    ActionColumn actionColumn = new ActionColumn();
    actionsTable_.addColumn(actionColumn);
    actionsTable_.setColumnWidth(actionColumn, 30, Unit.PX);
    addTableColumns(actionsTable_);
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setWidget(actionsTable_);
    scrollPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    flowPanel.add(scrollPanel);
    // query for updates
    actionsDS_.requestData(new SimpleRequestCallback<JsArray<T>>() {

        @Override
        public void onResponseReceived(JsArray<T> actions) {
            if (actions != null && actions.length() > 0) {
                ArrayList<PendingAction> pendingActions = new ArrayList<PendingAction>();
                for (int i = 0; i < actions.length(); i++) pendingActions.add(new PendingAction(actions.get(i), false));
                actionsTable_.setPageSize(pendingActions.size());
                actionsDataProvider_ = new ListDataProvider<PendingAction>();
                actionsDataProvider_.setList(pendingActions);
                actionsDataProvider_.addDataDisplay(actionsTable_);
                enableCancelButton(true);
                selectAllButton_.setEnabled(true);
                selectNoneButton_.setEnabled(true);
            } else {
                closeDialog();
                showNoActionsRequired();
            }
        }

        @Override
        public void onError(ServerError error) {
            closeDialog();
            super.onError(error);
        }
    });
    return flowPanel;
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) Label(com.google.gwt.user.client.ui.Label) ArrayList(java.util.ArrayList) GWT(com.google.gwt.core.client.GWT) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 2 with ListDataProvider

use of com.google.gwt.view.client.ListDataProvider in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImplTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    GwtMockito.initMocks(this);
    ListDataProvider temp = new ListDataProvider();
    dataProvider = spy(temp);
    doNothing().when(dataProvider).addDataDisplay(any(HasData.class));
    doNothing().when(dataProvider).flush();
    doNothing().when(dataProvider).refresh();
    setFieldValue(reassignmentWidgetViewImpl, "modal", modal);
    setFieldValue(reassignmentWidgetViewImpl, "table", table);
    setFieldValue(reassignmentWidgetViewImpl, "dataProvider", dataProvider);
    doCallRealMethod().when(reassignmentWidgetViewImpl).init(any(ReassignmentWidgetView.Presenter.class), anyList());
    doCallRealMethod().when(reassignmentWidgetViewImpl).delete(any(ReassignmentRow.class));
    doCallRealMethod().when(reassignmentWidgetViewImpl).hide();
    doCallRealMethod().when(reassignmentWidgetViewImpl).ok();
    doCallRealMethod().when(reassignmentWidgetViewImpl).onSubscription(any(ReassignmentEvent.class));
    doCallRealMethod().when(reassignmentWidgetViewImpl).addOrEdit(any(ReassignmentRow.class));
    doNothing().when(reassignmentWidgetViewImpl).initTable();
    when(reassignmentWidgetViewImpl.getParent()).thenReturn(reassignmentWidgetViewImpl);
    doCallRealMethod().when(dataProvider).addDataDisplay(table);
    doCallRealMethod().when(dataProvider).getList();
    doCallRealMethod().when(dataProvider).setList(anyList());
    doCallRealMethod().when(dataProvider).flush();
    doCallRealMethod().when(dataProvider).refresh();
    doCallRealMethod().when(reassignmentEditorWidget).createOrEdit(any(ReassignmentWidgetView.class), any(ReassignmentRow.class));
    doCallRealMethod().when(presenter).getValue();
    doCallRealMethod().when(presenter).ok();
    doCallRealMethod().when(presenter).hide();
    doCallRealMethod().when(presenter).setValue(anyList());
    doCallRealMethod().when(presenter).setValue(anyList(), any(boolean.class));
    doCallRealMethod().when(presenter).setCallback(any(ReassignmentsEditorWidget.GetReassignmentsCallback.class));
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) HasData(com.google.gwt.view.client.HasData) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) Before(org.junit.Before)

Example 3 with ListDataProvider

use of com.google.gwt.view.client.ListDataProvider in project kie-wb-common by kiegroup.

the class NotificationWidgetViewImplTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    GwtMockito.initMocks(this);
    ListDataProvider temp = new ListDataProvider();
    dataProvider = spy(temp);
    doNothing().when(dataProvider).addDataDisplay(any(HasData.class));
    doNothing().when(dataProvider).flush();
    doNothing().when(dataProvider).refresh();
    setFieldValue(notificationWidgetViewImpl, "modal", modal);
    setFieldValue(notificationWidgetViewImpl, "table", table);
    setFieldValue(notificationWidgetViewImpl, "dataProvider", dataProvider);
    doCallRealMethod().when(notificationWidgetViewImpl).init(any(NotificationWidgetView.Presenter.class), anyList());
    doCallRealMethod().when(notificationWidgetViewImpl).delete(any(NotificationRow.class));
    doCallRealMethod().when(notificationWidgetViewImpl).hide();
    doCallRealMethod().when(notificationWidgetViewImpl).ok();
    doCallRealMethod().when(notificationWidgetViewImpl).onSubscription(any(NotificationEvent.class));
    doCallRealMethod().when(notificationWidgetViewImpl).addOrEdit(any(NotificationRow.class));
    doNothing().when(notificationWidgetViewImpl).initTable();
    when(notificationWidgetViewImpl.getParent()).thenReturn(notificationWidgetViewImpl);
    doCallRealMethod().when(dataProvider).addDataDisplay(table);
    doCallRealMethod().when(dataProvider).getList();
    doCallRealMethod().when(dataProvider).setList(anyList());
    doCallRealMethod().when(dataProvider).flush();
    doCallRealMethod().when(dataProvider).refresh();
    doCallRealMethod().when(notificationEditorWidget).createOrEdit(any(NotificationWidgetView.class), any(NotificationRow.class));
    doCallRealMethod().when(presenter).getValue();
    doCallRealMethod().when(presenter).ok();
    doCallRealMethod().when(presenter).hide();
    doCallRealMethod().when(presenter).setValue(anyList());
    doCallRealMethod().when(presenter).setValue(anyList(), any(boolean.class));
    doCallRealMethod().when(presenter).setCallback(any(NotificationsEditorWidget.GetNotificationsCallback.class));
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) HasData(com.google.gwt.view.client.HasData) Before(org.junit.Before)

Example 4 with ListDataProvider

use of com.google.gwt.view.client.ListDataProvider in project kie-wb-common by kiegroup.

the class ValidationPopupViewImpl method setValidationMessages.

@Override
public void setValidationMessages(List<ValidationMessage> messages) {
    ListDataProvider<ValidationMessage> listDataProvider = (ListDataProvider<ValidationMessage>) this.validationTable.getDataProvider();
    listDataProvider.getList().clear();
    listDataProvider.getList().addAll(messages);
    validationTable.setVisibleRangeAndClearData(new Range(0, 5), true);
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) Range(com.google.gwt.view.client.Range)

Example 5 with ListDataProvider

use of com.google.gwt.view.client.ListDataProvider in project ovirt-engine by oVirt.

the class HostNetworkInterfaceBondedListViewItem method createSlavesContainer.

private Container createSlavesContainer() {
    Row content = new Row();
    Column gridColumn = new Column(ColumnSize.SM_12);
    content.add(gridColumn);
    Container container = createItemContainerPanel(content);
    CellTable<HostInterface> slavesTable = new CellTable<>(MAX_SLAVES, (Resources) GWT.create(CellTablePopupTableResources.class));
    slavesTable.getElement().addClassName(Styles.TABLE);
    slavesTable.getElement().addClassName(PatternflyConstants.PF_TABLE_STRIPED);
    slavesTable.getElement().addClassName(PatternflyConstants.PF_TABLE_BORDERED);
    ListDataProvider<HostInterface> logicalNetworkDataProvider = new ListDataProvider<>();
    logicalNetworkDataProvider.addDataDisplay(slavesTable);
    logicalNetworkDataProvider.setList(getEntity().getInterfaces());
    // Setup columns
    TextColumn<HostInterface> name = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return hostInterface.getName();
        }
    };
    slavesTable.addColumn(name, constants.macInterface());
    TextColumn<HostInterface> macAddress = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return hostInterface.getInterface().getMacAddress() != null ? hostInterface.getInterface().getMacAddress() : constants.unAvailablePropertyLabel();
        }
    };
    slavesTable.addColumn(macAddress, constants.macInterface());
    TextColumn<HostInterface> speed = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return hostInterface.getInterface().hasSpeed() ? String.valueOf(hostInterface.getInterface().getSpeed()) : constants.unAvailablePropertyLabel();
        }
    };
    slavesTable.addColumn(speed, constants.speedInterface());
    TextColumn<HostInterface> rxRate = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return rateRenderer.render(new Double[] { hostInterface.getRxRate(), hostInterface.getSpeed().doubleValue() });
        }
    };
    slavesTable.addColumn(rxRate, templates.sub(constants.rxRate(), constants.mbps()));
    TextColumn<HostInterface> txRate = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return rateRenderer.render(new Double[] { hostInterface.getTxRate(), hostInterface.getSpeed().doubleValue() });
        }
    };
    slavesTable.addColumn(txRate, templates.sub(constants.txRate(), constants.mbps()));
    TextColumn<HostInterface> rxTotal = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return totalRenderer.render(hostInterface.getRxTotal());
        }
    };
    slavesTable.addColumn(rxTotal, templates.sub(constants.rxTotal(), constants.mbps()));
    TextColumn<HostInterface> txTotal = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return totalRenderer.render(hostInterface.getTxTotal());
        }
    };
    slavesTable.addColumn(txTotal, templates.sub(constants.txTotal(), constants.mbps()));
    TextColumn<HostInterface> dropRate = new TextColumn<HostInterface>() {

        @Override
        public String getValue(HostInterface hostInterface) {
            return String.valueOf(hostInterface.getRxDrop() + hostInterface.getTxDrop());
        }
    };
    slavesTable.addColumn(dropRate, templates.sub(constants.dropsInterface(), constants.pkts()));
    gridColumn.add(slavesTable);
    return container;
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) Container(org.gwtbootstrap3.client.ui.Container) Column(org.gwtbootstrap3.client.ui.Column) TextColumn(com.google.gwt.user.cellview.client.TextColumn) CellTable(com.google.gwt.user.cellview.client.CellTable) HostInterface(org.ovirt.engine.ui.uicommonweb.models.hosts.HostInterface) Row(org.gwtbootstrap3.client.ui.Row) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

ListDataProvider (com.google.gwt.view.client.ListDataProvider)8 CellTable (com.google.gwt.user.cellview.client.CellTable)3 TextColumn (com.google.gwt.user.cellview.client.TextColumn)3 Column (com.google.gwt.user.cellview.client.Column)2 HasData (com.google.gwt.view.client.HasData)2 ArrayList (java.util.ArrayList)2 Column (org.gwtbootstrap3.client.ui.Column)2 Container (org.gwtbootstrap3.client.ui.Container)2 Row (org.gwtbootstrap3.client.ui.Row)2 Before (org.junit.Before)2 ActionCell (com.google.gwt.cell.client.ActionCell)1 EditTextCell (com.google.gwt.cell.client.EditTextCell)1 GWT (com.google.gwt.core.client.GWT)1 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsArray (com.google.gwt.core.client.JsArray)1 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)1 IdentityColumn (com.google.gwt.user.cellview.client.IdentityColumn)1 RowStyles (com.google.gwt.user.cellview.client.RowStyles)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Label (com.google.gwt.user.client.ui.Label)1