Search in sources :

Example 1 with ListBox

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

the class ResolveViewImpl method getConflictResolutionAction.

@Override
public String getConflictResolutionAction(String filePath) {
    ListBox conflictResolutionActions = filesResolutionActions.get(filePath);
    int selectedIndex = conflictResolutionActions.getSelectedIndex();
    return conflictResolutionActions.getValue(selectedIndex);
}
Also used : ListBox(com.google.gwt.user.client.ui.ListBox)

Example 2 with ListBox

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

the class ProjectInfoScreen method getPluginConfigValues.

private Map<String, Map<String, ConfigParameterValue>> getPluginConfigValues() {
    Map<String, Map<String, ConfigParameterValue>> pluginConfigValues = new HashMap<>(pluginConfigWidgets.size());
    for (Entry<String, Map<String, HasEnabled>> e : pluginConfigWidgets.entrySet()) {
        Map<String, ConfigParameterValue> values = new HashMap<>(e.getValue().size());
        pluginConfigValues.put(e.getKey(), values);
        for (Entry<String, HasEnabled> e2 : e.getValue().entrySet()) {
            HasEnabled widget = e2.getValue();
            if (widget instanceof TextBox) {
                values.put(e2.getKey(), ConfigParameterValue.create().value(((TextBox) widget).getValue().trim()));
            } else if (widget instanceof CheckBox) {
                values.put(e2.getKey(), ConfigParameterValue.create().value(Boolean.toString(((CheckBox) widget).getValue())));
            } else if (widget instanceof ListBox) {
                ListBox listBox = (ListBox) widget;
                // the inherited value is at index 0,
                // if it is selected no value should be set on this project
                String value = listBox.getSelectedIndex() > 0 ? listBox.getValue(listBox.getSelectedIndex()) : null;
                values.put(e2.getKey(), ConfigParameterValue.create().value(value));
            } else if (widget instanceof StringListPanel) {
                values.put(e2.getKey(), ConfigParameterValue.create().values(((StringListPanel) widget).getValues(0).toArray(new String[] {})));
            } else {
                throw new UnsupportedOperationException("unsupported widget type");
            }
        }
    }
    return pluginConfigValues;
}
Also used : HasEnabled(com.google.gwt.user.client.ui.HasEnabled) HashMap(java.util.HashMap) ConfigParameterValue(com.google.gerrit.client.projects.ConfigInfo.ConfigParameterValue) TextBox(com.google.gwt.user.client.ui.TextBox) NpIntTextBox(com.google.gerrit.client.ui.NpIntTextBox) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox) CheckBox(com.google.gwt.user.client.ui.CheckBox) AccessMap(com.google.gerrit.client.access.AccessMap) Map(java.util.Map) HashMap(java.util.HashMap) NativeMap(com.google.gerrit.client.rpc.NativeMap) ListBox(com.google.gwt.user.client.ui.ListBox) StringListPanel(com.google.gerrit.client.StringListPanel)

Example 3 with ListBox

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

the class MyPreferencesScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    showSiteHeader = new CheckBox(Util.C.showSiteHeader());
    useFlashClipboard = new CheckBox(Util.C.useFlashClipboard());
    maximumPageSize = new ListBox();
    for (final int v : PAGESIZE_CHOICES) {
        maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
    }
    reviewCategoryStrategy = new ListBox();
    reviewCategoryStrategy.addItem(Util.C.messageShowInReviewCategoryNone(), GeneralPreferencesInfo.ReviewCategoryStrategy.NONE.name());
    reviewCategoryStrategy.addItem(Util.C.messageShowInReviewCategoryName(), GeneralPreferencesInfo.ReviewCategoryStrategy.NAME.name());
    reviewCategoryStrategy.addItem(Util.C.messageShowInReviewCategoryEmail(), GeneralPreferencesInfo.ReviewCategoryStrategy.EMAIL.name());
    reviewCategoryStrategy.addItem(Util.C.messageShowInReviewCategoryUsername(), GeneralPreferencesInfo.ReviewCategoryStrategy.USERNAME.name());
    reviewCategoryStrategy.addItem(Util.C.messageShowInReviewCategoryAbbrev(), GeneralPreferencesInfo.ReviewCategoryStrategy.ABBREV.name());
    emailStrategy = new ListBox();
    emailStrategy.addItem(Util.C.messageCCMeOnMyComments(), GeneralPreferencesInfo.EmailStrategy.CC_ON_OWN_COMMENTS.name());
    emailStrategy.addItem(Util.C.messageEnabled(), GeneralPreferencesInfo.EmailStrategy.ENABLED.name());
    emailStrategy.addItem(Util.C.messageDisabled(), GeneralPreferencesInfo.EmailStrategy.DISABLED.name());
    emailFormat = new ListBox();
    emailFormat.addItem(Util.C.messagePlaintextOnly(), GeneralPreferencesInfo.EmailFormat.PLAINTEXT.name());
    emailFormat.addItem(Util.C.messageHtmlPlaintext(), GeneralPreferencesInfo.EmailFormat.HTML_PLAINTEXT.name());
    defaultBaseForMerges = new ListBox();
    defaultBaseForMerges.addItem(Util.C.autoMerge(), GeneralPreferencesInfo.DefaultBase.AUTO_MERGE.name());
    defaultBaseForMerges.addItem(Util.C.firstParent(), GeneralPreferencesInfo.DefaultBase.FIRST_PARENT.name());
    diffView = new ListBox();
    diffView.addItem(com.google.gerrit.client.changes.Util.C.sideBySide(), GeneralPreferencesInfo.DiffView.SIDE_BY_SIDE.name());
    diffView.addItem(com.google.gerrit.client.changes.Util.C.unifiedDiff(), GeneralPreferencesInfo.DiffView.UNIFIED_DIFF.name());
    Date now = new Date();
    dateFormat = new ListBox();
    for (GeneralPreferencesInfo.DateFormat fmt : GeneralPreferencesInfo.DateFormat.values()) {
        StringBuilder r = new StringBuilder();
        r.append(DateTimeFormat.getFormat(fmt.getShortFormat()).format(now));
        r.append(" ; ");
        r.append(DateTimeFormat.getFormat(fmt.getLongFormat()).format(now));
        dateFormat.addItem(r.toString(), fmt.name());
    }
    timeFormat = new ListBox();
    for (GeneralPreferencesInfo.TimeFormat fmt : GeneralPreferencesInfo.TimeFormat.values()) {
        StringBuilder r = new StringBuilder();
        r.append(DateTimeFormat.getFormat(fmt.getFormat()).format(now));
        timeFormat.addItem(r.toString(), fmt.name());
    }
    FlowPanel dateTimePanel = new FlowPanel();
    final int labelIdx;
    final int fieldIdx;
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        labelIdx = 1;
        fieldIdx = 0;
        dateTimePanel.add(timeFormat);
        dateTimePanel.add(dateFormat);
    } else {
        labelIdx = 0;
        fieldIdx = 1;
        dateTimePanel.add(dateFormat);
        dateTimePanel.add(timeFormat);
    }
    highlightAssigneeInChangeTable = new CheckBox(Util.C.highlightAssigneeInChangeTable());
    relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
    sizeBarInChangeTable = new CheckBox(Util.C.showSizeBarInChangeTable());
    legacycidInChangeTable = new CheckBox(Util.C.showLegacycidInChangeTable());
    muteCommonPathPrefixes = new CheckBox(Util.C.muteCommonPathPrefixes());
    signedOffBy = new CheckBox(Util.C.signedOffBy());
    publishCommentsOnPush = new CheckBox(Util.C.publishCommentsOnPush());
    boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
    final Grid formGrid = new Grid(15 + (flashClippy ? 1 : 0), 2);
    int row = 0;
    formGrid.setText(row, labelIdx, Util.C.reviewCategoryLabel());
    formGrid.setWidget(row, fieldIdx, reviewCategoryStrategy);
    row++;
    formGrid.setText(row, labelIdx, Util.C.maximumPageSizeFieldLabel());
    formGrid.setWidget(row, fieldIdx, maximumPageSize);
    row++;
    formGrid.setText(row, labelIdx, Util.C.dateFormatLabel());
    formGrid.setWidget(row, fieldIdx, dateTimePanel);
    row++;
    formGrid.setText(row, labelIdx, Util.C.emailFieldLabel());
    formGrid.setWidget(row, fieldIdx, emailStrategy);
    row++;
    formGrid.setText(row, labelIdx, Util.C.emailFormatFieldLabel());
    formGrid.setWidget(row, fieldIdx, emailFormat);
    row++;
    formGrid.setText(row, labelIdx, Util.C.defaultBaseForMerges());
    formGrid.setWidget(row, fieldIdx, defaultBaseForMerges);
    row++;
    formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
    formGrid.setWidget(row, fieldIdx, diffView);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, showSiteHeader);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, highlightAssigneeInChangeTable);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, relativeDateInChangeTable);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, sizeBarInChangeTable);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, legacycidInChangeTable);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, muteCommonPathPrefixes);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, signedOffBy);
    row++;
    formGrid.setText(row, labelIdx, "");
    formGrid.setWidget(row, fieldIdx, publishCommentsOnPush);
    row++;
    if (flashClippy) {
        formGrid.setText(row, labelIdx, "");
        formGrid.setWidget(row, fieldIdx, useFlashClipboard);
    }
    add(formGrid);
    save = new Button(Util.C.buttonSaveChanges());
    save.setEnabled(false);
    save.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            doSave();
        }
    });
    myMenus = new MyMenuPanel(save);
    add(myMenus);
    add(save);
    final OnEditEnabler e = new OnEditEnabler(save);
    e.listenTo(showSiteHeader);
    e.listenTo(useFlashClipboard);
    e.listenTo(maximumPageSize);
    e.listenTo(dateFormat);
    e.listenTo(timeFormat);
    e.listenTo(highlightAssigneeInChangeTable);
    e.listenTo(relativeDateInChangeTable);
    e.listenTo(sizeBarInChangeTable);
    e.listenTo(legacycidInChangeTable);
    e.listenTo(muteCommonPathPrefixes);
    e.listenTo(signedOffBy);
    e.listenTo(publishCommentsOnPush);
    e.listenTo(diffView);
    e.listenTo(reviewCategoryStrategy);
    e.listenTo(emailStrategy);
    e.listenTo(emailFormat);
    e.listenTo(defaultBaseForMerges);
}
Also used : Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GerritUiExtensionPoint(com.google.gerrit.client.GerritUiExtensionPoint) Date(java.util.Date) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(com.google.gwt.user.client.ui.Button) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) GeneralPreferencesInfo(com.google.gerrit.extensions.client.GeneralPreferencesInfo) OnEditEnabler(com.google.gerrit.client.ui.OnEditEnabler) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 4 with ListBox

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

the class ContactPanelShort method onInitUI.

protected void onInitUI() {
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        labelIdx = 1;
        fieldIdx = 0;
    } else {
        labelIdx = 0;
        fieldIdx = 1;
    }
    nameTxt = new NpTextBox();
    nameTxt.setVisibleLength(60);
    nameTxt.setReadOnly(!canEditFullName());
    emailPick = new ListBox();
    final Grid infoPlainText = new Grid(2, 2);
    infoPlainText.setStyleName(Gerrit.RESOURCES.css().infoBlock());
    infoPlainText.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
    body.add(infoPlainText);
    registerNewEmail = new Button(Util.C.buttonOpenRegisterNewEmail());
    registerNewEmail.setEnabled(false);
    registerNewEmail.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            doRegisterNewEmail();
        }
    });
    final FlowPanel emailLine = new FlowPanel();
    emailLine.add(emailPick);
    if (canRegisterNewEmail()) {
        emailLine.add(registerNewEmail);
    }
    int row = 0;
    if (!Gerrit.info().auth().canEdit(AccountFieldName.USER_NAME) && Gerrit.info().auth().siteHasUsernames()) {
        infoPlainText.resizeRows(infoPlainText.getRowCount() + 1);
        row(infoPlainText, row++, Util.C.userName(), new UsernameField());
    }
    if (!canEditFullName()) {
        FlowPanel nameLine = new FlowPanel();
        nameLine.add(nameTxt);
        if (Gerrit.info().auth().editFullNameUrl() != null) {
            Button edit = new Button(Util.C.linkEditFullName());
            edit.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    Window.open(Gerrit.info().auth().editFullNameUrl(), "_blank", null);
                }
            });
            nameLine.add(edit);
        }
        Button reload = new Button(Util.C.linkReloadContact());
        reload.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                Window.Location.replace(Gerrit.loginRedirect(PageLinks.SETTINGS_CONTACT));
            }
        });
        nameLine.add(reload);
        row(infoPlainText, row++, Util.C.contactFieldFullName(), nameLine);
    } else {
        row(infoPlainText, row++, Util.C.contactFieldFullName(), nameTxt);
    }
    row(infoPlainText, row++, Util.C.contactFieldEmail(), emailLine);
    infoPlainText.getCellFormatter().addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
    infoPlainText.getCellFormatter().addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
    infoPlainText.getCellFormatter().addStyleName(row - 1, 0, Gerrit.RESOURCES.css().bottomheader());
    save = new Button(Util.C.buttonSaveChanges());
    save.setEnabled(false);
    save.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            doSave();
        }
    });
    emailPick.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(final ChangeEvent event) {
            final int idx = emailPick.getSelectedIndex();
            final String v = 0 <= idx ? emailPick.getValue(idx) : null;
            if (Util.C.buttonOpenRegisterNewEmail().equals(v)) {
                for (int i = 0; i < emailPick.getItemCount(); i++) {
                    if (currentEmail.equals(emailPick.getValue(i))) {
                        emailPick.setSelectedIndex(i);
                        break;
                    }
                }
                doRegisterNewEmail();
            } else {
                save.setEnabled(true);
            }
        }
    });
    onEditEnabler = new OnEditEnabler(save, nameTxt);
}
Also used : Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) NativeString(com.google.gerrit.client.rpc.NativeString) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) Button(com.google.gwt.user.client.ui.Button) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) OnEditEnabler(com.google.gerrit.client.ui.OnEditEnabler) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 5 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)

Aggregations

ListBox (com.google.gwt.user.client.ui.ListBox)36 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)12 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)12 HTML (com.google.gwt.user.client.ui.HTML)10 Test (org.junit.Test)10 CheckBox (com.google.gwt.user.client.ui.CheckBox)8 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)7 Label (com.google.gwt.user.client.ui.Label)7 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)5 Button (com.google.gwt.user.client.ui.Button)3 FlexTable (com.google.gwt.user.client.ui.FlexTable)3 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 TextBox (com.google.gwt.user.client.ui.TextBox)3 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)3 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2