Search in sources :

Example 11 with ListBox

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

the class ChooseMirrorDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // create progress container
    final SimplePanelWithProgress panel = new SimplePanelWithProgress(ProgressImages.createLargeGray());
    panel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    // show progress (with delay)
    panel.showProgress(200);
    // query data source for packages
    mirrorSource_.requestData(new SimpleRequestCallback<JsArray<T>>() {

        @Override
        public void onResponseReceived(JsArray<T> mirrors) {
            // keep internal list of mirrors 
            boolean haveInsecureMirror = false;
            mirrors_ = new ArrayList<T>(mirrors.length());
            // create list box and select default item
            listBox_ = new ListBox();
            listBox_.setMultipleSelect(false);
            // all
            listBox_.setVisibleItemCount(18);
            listBox_.setWidth("100%");
            if (mirrors.length() > 0) {
                for (int i = 0; i < mirrors.length(); i++) {
                    T mirror = mirrors.get(i);
                    if (mirrorSource_.getLabel(mirror).startsWith("0-Cloud"))
                        continue;
                    mirrors_.add(mirror);
                    String item = mirrorSource_.getLabel(mirror);
                    String value = mirrorSource_.getURL(mirror);
                    if (!value.startsWith("https"))
                        haveInsecureMirror = true;
                    listBox_.addItem(item, value);
                }
                listBox_.setSelectedIndex(0);
                enableOkButton(true);
            }
            // set it into the panel
            panel.setWidget(listBox_);
            // set caption
            String protocolQualifer = !haveInsecureMirror ? " HTTPS" : "";
            setText("Choose" + protocolQualifer + " CRAN Mirror");
            // update ok button on changed
            listBox_.addDoubleClickHandler(new DoubleClickHandler() {

                @Override
                public void onDoubleClick(DoubleClickEvent event) {
                    clickOkButton();
                }
            });
            // if the list box is larger than the space we initially allocated
            // then increase the panel height
            final int kDefaultPanelHeight = 285;
            if (listBox_.getOffsetHeight() > kDefaultPanelHeight)
                panel.setHeight(listBox_.getOffsetHeight() + "px");
            // set focus   
            FocusHelper.setFocusDeferred(listBox_);
        }

        @Override
        public void onError(ServerError error) {
            closeDialog();
            super.onError(error);
        }
    });
    return panel;
}
Also used : SimplePanelWithProgress(org.rstudio.core.client.widget.SimplePanelWithProgress) JsArray(com.google.gwt.core.client.JsArray) GWT(com.google.gwt.core.client.GWT) ServerError(org.rstudio.studio.client.server.ServerError) DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) ArrayList(java.util.ArrayList) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 12 with ListBox

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

the class InstallPackageDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // vertical panel
    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.setSpacing(2);
    mainPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    // source type
    reposCaption_ = new CaptionWithHelp("Install from:", "Configuring Repositories", "configuring_repositories");
    reposCaption_.setIncludeVersionInfo(false);
    reposCaption_.setWidth("100%");
    mainPanel.add(reposCaption_);
    packageSourceListBox_ = new ListBox();
    packageSourceListBox_.setStylePrimaryName(RESOURCES.styles().packageSourceListBox());
    packageSourceListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    JsArrayString repos = installContext_.selectedRepositoryNames();
    if (repos.length() == 1) {
        packageSourceListBox_.addItem("Repository (" + repos.get(0) + ")");
    } else {
        StringBuilder reposItem = new StringBuilder();
        reposItem.append("Repository (");
        for (int i = 0; i < repos.length(); i++) {
            if (i != 0)
                reposItem.append(", ");
            reposItem.append(repos.get(i));
        }
        reposItem.append(")");
        packageSourceListBox_.addItem(reposItem.toString());
    }
    packageSourceListBox_.addItem("Package Archive File (" + installContext_.packageArchiveExtension() + ")");
    mainPanel.add(packageSourceListBox_);
    // source panel container
    sourcePanel_ = new SimplePanel();
    sourcePanel_.setStylePrimaryName(RESOURCES.styles().packageSourcePanel());
    // repos source panel
    reposSourcePanel_ = new FlowPanel();
    Label packagesLabel = new Label("Packages (separate multiple with space or comma):");
    packagesLabel.setStylePrimaryName(RESOURCES.styles().packagesLabel());
    reposSourcePanel_.add(packagesLabel);
    packagesTextBox_ = new MultipleItemSuggestTextBox();
    packagesSuggestBox_ = new SuggestBox(new PackageOracle(), packagesTextBox_);
    packagesSuggestBox_.setWidth("100%");
    packagesSuggestBox_.setLimit(20);
    packagesSuggestBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    reposSourcePanel_.add(packagesSuggestBox_);
    sourcePanel_.setWidget(reposSourcePanel_);
    mainPanel.add(sourcePanel_);
    // archive source panel
    packageArchiveFile_ = new TextBoxWithButton("Package archive:", "Browse...", browseForArchiveClickHandler_);
    // create check box here because manageUIState accesses it
    installDependenciesCheckBox_ = new CheckBox();
    if (defaultInstallOptions_.getInstallFromRepository())
        packageSourceListBox_.setSelectedIndex(0);
    else
        packageSourceListBox_.setSelectedIndex(1);
    manageUIState();
    packageSourceListBox_.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            manageUIState();
            if (!installFromRepository())
                packageArchiveFile_.click();
        }
    });
    mainPanel.add(new Label("Install to Library:"));
    // library list box
    libraryListBox_ = new ListBox();
    libraryListBox_.setWidth("100%");
    libraryListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    JsArrayString libPaths = installContext_.getWriteableLibraryPaths();
    int selectedIndex = 0;
    for (int i = 0; i < libPaths.length(); i++) {
        String libPath = libPaths.get(i);
        if (!installContext_.isDevModeOn()) {
            if (defaultInstallOptions_.getLibraryPath().equals(libPath))
                selectedIndex = i;
        }
        if (libPath.equals(installContext_.getDefaultLibraryPath()))
            libPath = libPath + " [Default]";
        libraryListBox_.addItem(libPath);
    }
    libraryListBox_.setSelectedIndex(selectedIndex);
    mainPanel.add(libraryListBox_);
    // install dependencies check box
    installDependenciesCheckBox_.addStyleName(RESOURCES.styles().installDependenciesCheckBox());
    installDependenciesCheckBox_.setText("Install dependencies");
    installDependenciesCheckBox_.setValue(defaultInstallOptions_.getInstallDependencies());
    mainPanel.add(installDependenciesCheckBox_);
    mainPanel.add(new HTML("<br/>"));
    return mainPanel;
}
Also used : MultipleItemSuggestTextBox(org.rstudio.core.client.widget.MultipleItemSuggestTextBox) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) SuggestBox(com.google.gwt.user.client.ui.SuggestBox) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) TextBoxWithButton(org.rstudio.core.client.widget.TextBoxWithButton) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) CaptionWithHelp(org.rstudio.core.client.widget.CaptionWithHelp) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 13 with ListBox

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

the class GetGroupRichMembers method getTable.

/**
	 * Returns the table with rich members of group
	 *
	 * @return table widget
	 */
public CellTable<RichMember> getTable() {
    // retrieves data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<RichMember>(list);
    // Cell table
    table = new PerunTable<RichMember>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // Table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // Checkbox column column
    table.addCheckBoxColumn();
    // Status column
    Column<RichMember, String> statusColumn = new Column<RichMember, String>(new PerunStatusCell()) {

        @Override
        public String getValue(RichMember object) {
            return object.getStatus();
        }
    };
    // own onClick tab for changing member's status
    statusColumn.setFieldUpdater(new FieldUpdater<RichMember, String>() {

        public void update(int index, final RichMember object, String value) {
            FlexTable widget = new FlexTable();
            final ListBox lb = new ListBox(false);
            lb.addItem("VALID", "VALID");
            lb.addItem("INVALID", "INVALID");
            lb.addItem("SUSPENDED", "SUSPENDED");
            lb.addItem("EXPIRED", "EXPIRED");
            lb.addItem("DISABLED", "DISABLED");
            widget.setHTML(0, 0, "<strong>Status: </strong>");
            widget.setWidget(0, 1, lb);
            // pick which one is already set
            for (int i = 0; i < lb.getItemCount(); i++) {
                if (lb.getItemText(i).equalsIgnoreCase(object.getStatus())) {
                    lb.setSelectedIndex(i);
                }
            }
            Confirm conf = new Confirm("Change member's status: " + object.getUser().getFullName(), widget, true);
            conf.setCancelButtonText("Cancel");
            conf.setOkButtonText("Change status");
            conf.setOkClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    SetStatus call = new SetStatus(object.getId(), new JsonCallbackEvents() {

                        public void onFinished(JavaScriptObject jso) {
                            clearTable();
                            retrieveData();
                        }

                        public void onError(PerunError error) {
                            clearTable();
                            retrieveData();
                        }
                    });
                    call.setStatus(lb.getValue(lb.getSelectedIndex()));
                }
            });
            conf.show();
        }
    });
    // status column sortable
    statusColumn.setSortable(true);
    columnSortHandler.setComparator(statusColumn, new GeneralComparator<RichMember>(GeneralComparator.Column.STATUS));
    table.addColumn(statusColumn, "Status");
    table.setColumnWidth(statusColumn, 20, Unit.PX);
    // Create member ID column.
    Column<RichMember, String> memberIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<RichMember, String>() {

        public String getValue(RichMember object) {
            return String.valueOf(object.getId());
        }
    }, this.tableFieldUpdater);
    // Create User ID column.
    Column<RichMember, String> userIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<RichMember, String>() {

        public String getValue(RichMember object) {
            return String.valueOf(object.getUser().getId());
        }
    }, this.tableFieldUpdater);
    columnSortHandler.setComparator(memberIdColumn, new RichMemberComparator(RichMemberComparator.Column.MEMBER_ID));
    memberIdColumn.setSortable(true);
    userIdColumn.setSortable(true);
    columnSortHandler.setComparator(userIdColumn, new RichMemberComparator(RichMemberComparator.Column.USER_ID));
    table.setColumnWidth(memberIdColumn, 110.0, Unit.PX);
    table.setColumnWidth(userIdColumn, 110.0, Unit.PX);
    // headers
    if (JsonUtils.isExtendedInfoVisible()) {
        table.addColumn(memberIdColumn, "Member ID");
        table.addColumn(userIdColumn, "User ID");
    }
    table.addNameColumn(tableFieldUpdater);
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) RichMember(cz.metacentrum.perun.webgui.model.RichMember) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Column(com.google.gwt.user.cellview.client.Column) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunStatusCell(cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell) SetStatus(cz.metacentrum.perun.webgui.json.membersManager.SetStatus) RichMemberComparator(cz.metacentrum.perun.webgui.json.comparators.RichMemberComparator) PerunError(cz.metacentrum.perun.webgui.model.PerunError) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 14 with ListBox

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

the class GetApplicationForm method createWidget.

/**
	 * Create approval style change widget
	 *
	 * @param form
	 */
private void createWidget(final ApplicationForm form) {
    final CustomButton button = TabMenu.getPredefinedButton(ButtonType.SETTINGS, ButtonTranslation.INSTANCE.changeAppFormSettings());
    if (form != null) {
        // create click handler
        ClickHandler ch = new ClickHandler() {

            public void onClick(ClickEvent event) {
                // layout
                FlexTable ft = new FlexTable();
                ft.setCellSpacing(10);
                ft.setHTML(0, 0, "<strong>INITIAL: </strong>");
                ft.setHTML(1, 0, "<strong>EXTENSION: </strong>");
                ft.setHTML(2, 0, "<strong>Module name: </strong>");
                // widgets
                final ListBox lbInit = new ListBox();
                final ListBox lbExt = new ListBox();
                final TextBox className = new TextBox();
                lbInit.addItem("Automatic", "true");
                lbInit.addItem("Manual", "false");
                lbExt.addItem("Automatic", "true");
                lbExt.addItem("Manual", "false");
                if (form.getAutomaticApproval() == true) {
                    lbInit.setSelectedIndex(0);
                } else {
                    lbInit.setSelectedIndex(1);
                }
                if (form.getAutomaticApprovalExtension() == true) {
                    lbExt.setSelectedIndex(0);
                } else {
                    lbExt.setSelectedIndex(1);
                }
                className.setText(form.getModuleClassName());
                ft.setWidget(0, 1, lbInit);
                ft.setWidget(1, 1, lbExt);
                ft.setWidget(2, 1, className);
                // click on save
                ClickHandler click = new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        // switch and send request
                        UpdateForm request = new UpdateForm(new JsonCallbackEvents() {

                            public void onFinished(JavaScriptObject jso) {
                                // recreate same widget
                                content.clear();
                                ApplicationForm newForm = jso.cast();
                                createWidget(newForm);
                            }

                            ;
                        });
                        form.setAutomaticApproval(Boolean.parseBoolean(lbInit.getValue(lbInit.getSelectedIndex())));
                        form.setAutomaticApprovalExtension(Boolean.parseBoolean(lbExt.getValue(lbExt.getSelectedIndex())));
                        form.setModuleClassName(className.getText().trim());
                        request.updateForm(form);
                    }
                };
                Confirm c = new Confirm("Change application form settings", ft, click, true);
                c.show();
            }
        };
        button.addClickHandler(ch);
        String appStyle = "<strong>Approval style: </strong>";
        String module = "</br><strong>Module name: </strong>" + form.getModuleClassName();
        if (form.getAutomaticApproval() == true) {
            appStyle = appStyle + "<span style=\"color:red;\">Automatic</span> (INITIAL)";
        } else {
            appStyle = appStyle + "<span style=\"color:red;\">Manual</span> (INITIAL)";
        }
        if (form.getAutomaticApprovalExtension() == true) {
            appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EXTENSION)";
        } else {
            appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EXTENSION)";
        }
        if (form.getGroup() == null && !session.isVoAdmin(form.getVo().getId()))
            button.setEnabled(false);
        if (form.getGroup() != null && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
            button.setEnabled(false);
        content.setHTML(0, 0, appStyle + module);
        content.setWidget(0, 1, button);
        content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
    } else {
        button.setEnabled(false);
        String appStyle = "<strong>Approval style: </strong> Form doesn't exists.";
        String module = "</br><strong>Module name: </strong> Form doesn't exists.";
        content.setHTML(0, 0, appStyle + module);
        content.setWidget(0, 1, button);
        content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationForm(cz.metacentrum.perun.webgui.model.ApplicationForm) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) TextBox(com.google.gwt.user.client.ui.TextBox) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 15 with ListBox

use of com.google.gwt.user.client.ui.ListBox in project che by eclipse.

the class ResolveViewImpl method addConflictingFile.

@Override
public void addConflictingFile(String filePath) {
    Label filePathLabel = new Label(filePath);
    filePathLabel.getElement().getStyle().setFloat(Float.LEFT);
    filePathLabel.getElement().getStyle().setMarginRight(1, Unit.EM);
    ListBox conflictResolutionActions = new ListBox();
    for (ConflictResolutionAction action : conflictActions) {
        conflictResolutionActions.addItem(action.getText());
    }
    filesResolutionActions.put(filePath, conflictResolutionActions);
    Element resolutionDiv = DOM.createDiv();
    resolutionDiv.getStyle().setMarginLeft(1, Unit.EM);
    resolutionDiv.getStyle().setMarginRight(1, Unit.EM);
    resolutionDiv.getStyle().setMarginBottom(1, Unit.EM);
    resolutionDiv.getStyle().setTextAlign(TextAlign.RIGHT);
    resolutionDiv.appendChild(filePathLabel.getElement());
    resolutionDiv.appendChild(conflictResolutionActions.getElement());
    mainPanel.getElement().appendChild(resolutionDiv);
}
Also used : Element(com.google.gwt.dom.client.Element) Label(com.google.gwt.user.client.ui.Label) ListBox(com.google.gwt.user.client.ui.ListBox)

Aggregations

ListBox (com.google.gwt.user.client.ui.ListBox)25 Test (org.junit.Test)10 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)5 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)5 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 CheckBox (com.google.gwt.user.client.ui.CheckBox)5 Label (com.google.gwt.user.client.ui.Label)5 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)3 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)3 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)3 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 Button (com.google.gwt.user.client.ui.Button)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)2 Grid (com.google.gwt.user.client.ui.Grid)2 HTML (com.google.gwt.user.client.ui.HTML)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 TextBox (com.google.gwt.user.client.ui.TextBox)2