Search in sources :

Example 1 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project rstudio by rstudio.

the class UnsavedChangesDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // create cell table
    targetsCellTable_ = new CellTable<UnsavedChangesTarget>(15, UnsavedChangesCellTableResources.INSTANCE, KEY_PROVIDER);
    selectionModel_ = new MultiSelectionModel<UnsavedChangesTarget>(KEY_PROVIDER);
    targetsCellTable_.setSelectionModel(selectionModel_, DefaultSelectionEventManager.<UnsavedChangesTarget>createCheckboxManager());
    targetsCellTable_.setWidth("100%", true);
    // add columns
    addSelectionColumn();
    addIconColumn();
    addNameAndPathColumn();
    // hook-up data provider 
    dataProvider_ = new ListDataProvider<UnsavedChangesTarget>();
    dataProvider_.setList(targets_);
    dataProvider_.addDataDisplay(targetsCellTable_);
    targetsCellTable_.setPageSize(targets_.size());
    // select all by default
    for (UnsavedChangesTarget editingTarget : dataProvider_.getList()) selectionModel_.setSelected(editingTarget, true);
    // enclose cell table in scroll panel
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setStylePrimaryName(RESOURCES.styles().targetScrollPanel());
    scrollPanel.setWidget(targetsCellTable_);
    if (dataProvider_.getList().size() > 4)
        scrollPanel.setHeight("280px");
    // always save check box (may not be shown)
    chkAlwaysSave_ = new CheckBox(alwaysSaveOption_);
    // main widget
    VerticalPanel panel = new VerticalPanel();
    Label captionLabel = new Label("The following files have unsaved changes:");
    captionLabel.setStylePrimaryName(RESOURCES.styles().captionLabel());
    panel.add(captionLabel);
    panel.add(scrollPanel);
    if (!StringUtil.isNullOrEmpty(alwaysSaveOption_)) {
        panel.add(chkAlwaysSave_);
        panel.setCellHeight(chkAlwaysSave_, "30px");
        panel.setCellVerticalAlignment(chkAlwaysSave_, HasVerticalAlignment.ALIGN_MIDDLE);
    }
    return panel;
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) UnsavedChangesTarget(org.rstudio.studio.client.workbench.model.UnsavedChangesTarget) CheckBox(com.google.gwt.user.client.ui.CheckBox) Label(com.google.gwt.user.client.ui.Label) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 2 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel 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 3 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project rstudio by rstudio.

the class ShowContentDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // main widget is scroll panel with embeddeed html 
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setStylePrimaryName(styleName_);
    HTML htmlContent = new HTML(content_);
    if (isFixedFont_)
        FontSizer.applyNormalFontSize(htmlContent);
    scrollPanel.setWidget(htmlContent);
    // if we don't have a preferred size then size based on content
    Size size = preferredSize_;
    if (size.isEmpty())
        size = DomMetrics.measureHTML(content_, styleName_);
    // compute the widget size and set it
    Size minimumSize = new Size(300, 300);
    size = DomMetrics.adjustedElementSize(size, minimumSize, // pad
    70, // client margin
    100);
    scrollPanel.setSize(size.width + "px", size.height + "px");
    // return it
    return scrollPanel;
}
Also used : Size(org.rstudio.core.client.Size) HTML(com.google.gwt.user.client.ui.HTML) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 4 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project rstudio by rstudio.

the class ChunkConsolePage method init.

private void init(ChunkOutputStream stream) {
    preview_ = new ChunkConsolePreview();
    preview_.addText(stream.getAllConsoleText());
    stream_ = stream;
    panel_ = new ScrollPanel();
    panel_.add(stream);
    if (chunkOutputSize_ != ChunkOutputSize.Full) {
        content_ = new FixedRatioWidget(panel_, ChunkOutputUi.OUTPUT_ASPECT, ChunkOutputUi.MAX_PLOT_WIDTH);
    } else {
        panel_.getElement().getStyle().setWidth(100, Unit.PCT);
        content_ = panel_;
    }
    thumbnail_ = new ChunkOutputThumbnail("R Console", "", preview_, ChunkOutputWidget.getEditorColors());
}
Also used : FixedRatioWidget(org.rstudio.core.client.widget.FixedRatioWidget) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 5 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project perun by CESNET.

the class GroupRelationsTabItem method draw.

@Override
public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": unions");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // if members group, hide
    if (group.isCoreGroup()) {
        vp.add(new HTML("<h2>Members group cannot have unions.</h2>"));
        this.contentWidget.setWidget(vp);
        return getWidget();
    }
    final GetGroupUnions unions = new GetGroupUnions(group, false);
    // Events for reloading when group is created
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(unions);
    // menu
    TabMenu menu = new TabMenu();
    final CheckBox subGroupsCheckBox = new CheckBox("Show sub-groups");
    final ListBox reverseDropdown = new ListBox();
    reverseDropdown.addItem("Normal");
    reverseDropdown.addItem("Reverse");
    reverseDropdown.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            switch(reverseDropdown.getSelectedIndex()) {
                case 1:
                    unions.setReverseAndRefresh(true);
                    subGroupsCheckBox.setVisible(false);
                    break;
                default:
                    unions.setReverseAndRefresh(false);
                    subGroupsCheckBox.setVisible(true);
            }
        }
    });
    menu.addWidget(UiElements.getRefreshButton(this));
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupUnion(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            // creates a new form
            session.getTabManager().addTabToCurrentTab(new AddGroupUnionTabItem(group), true);
        }
    });
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
        createButton.setEnabled(false);
        unions.setCheckable(false);
    }
    menu.addWidget(createButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupUnion());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Group> itemsToRemove = unions.getTableSelectedList();
            String text = "Following group unions will be deleted.";
            UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    RemoveGroupUnions request = new RemoveGroupUnions(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                    if (unions.isReverse()) {
                        request.deleteGroupUnions(itemsToRemove, group);
                    } else {
                        request.deleteGroupUnions(group, itemsToRemove);
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // filter box
    final ExtendedSuggestBox box = new ExtendedSuggestBox(unions.getOracle());
    menu.addFilterWidget(box, new PerunSearchEvent() {

        public void searchFor(String text) {
            unions.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    subGroupsCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            unions.setShowSubgroupsAndRefresh(valueChangeEvent.getValue(), box.getSuggestBox().getText());
        }
    });
    menu.addWidget(new HTML("<strong>Direction: </strong>"));
    menu.addWidget(reverseDropdown);
    menu.addWidget(subGroupsCheckBox);
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<Group> table = unions.getTable(new FieldUpdater<Group, String>() {

        @Override
        public void update(int arg0, Group group, String arg2) {
            if (session.isGroupAdmin(group.getId()) || session.isVoAdmin(group.getId())) {
                session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
            } else {
                UiElements.generateInfo("Not privileged", "You are not manager of selected group or its VO.");
            }
        }
    });
    removeButton.setEnabled(false);
    if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
        JsonUtils.addTableManagedButton(unions, table, removeButton);
    // adds the table into the panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) RemoveGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.RemoveGroupUnions) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) CheckBox(com.google.gwt.user.client.ui.CheckBox) GetGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions) ListBox(com.google.gwt.user.client.ui.ListBox) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Aggregations

ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)14 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)7 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)5 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)3 HTML (com.google.gwt.user.client.ui.HTML)3 Label (com.google.gwt.user.client.ui.Label)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 ArrayList (java.util.ArrayList)3 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JsArray (com.google.gwt.core.client.JsArray)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)2 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 GetGroupUnions (cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions)2 GetSpecificUsersByUser (cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser)2 GetUsersBySpecificUser (cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser)2 Group (cz.metacentrum.perun.webgui.model.Group)2