Search in sources :

Example 1 with GWT

use of com.google.gwt.core.client.GWT 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)

Aggregations

GWT (com.google.gwt.core.client.GWT)1 JsArray (com.google.gwt.core.client.JsArray)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Label (com.google.gwt.user.client.ui.Label)1 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)1 ListDataProvider (com.google.gwt.view.client.ListDataProvider)1 ArrayList (java.util.ArrayList)1 ServerError (org.rstudio.studio.client.server.ServerError)1