Search in sources :

Example 6 with CheckBox

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

use of com.google.gwt.user.client.ui.CheckBox 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)

Example 8 with CheckBox

use of com.google.gwt.user.client.ui.CheckBox in project zxing by zxing.

the class CalendarEventGenerator method getWidget.

@Override
public Grid getWidget() {
    if (table != null) {
        return table;
    }
    datePicker1.setValue(new Date());
    datePicker2.setValue(new Date());
    table = new Grid(10, 2);
    table.setText(0, 0, "All day event");
    table.setWidget(0, 1, fullDay);
    table.setText(1, 0, "Event title");
    table.setWidget(1, 1, eventName);
    table.setText(2, 0, "Start date");
    table.setWidget(2, 1, datePicker1);
    table.setText(3, 0, "Time");
    table.setWidget(3, 1, timePicker1);
    table.setText(4, 0, "End date");
    table.setWidget(4, 1, datePicker2);
    table.setText(5, 0, "Time");
    table.setWidget(5, 1, timePicker2);
    table.setText(6, 0, "Time zone");
    table.setWidget(6, 1, timeZones);
    table.setText(7, 0, "Daylight savings");
    table.setWidget(7, 1, summerTime);
    table.setText(8, 0, "Location");
    table.setWidget(8, 1, location);
    table.setText(9, 0, "Description");
    table.setWidget(9, 1, description);
    table.getRowFormatter().getElement(3).setId(FULL_DAY_ONLY_IDS[0]);
    table.getRowFormatter().getElement(5).setId(FULL_DAY_ONLY_IDS[1]);
    table.getRowFormatter().getElement(6).setId(FULL_DAY_ONLY_IDS[2]);
    table.getRowFormatter().getElement(7).setId(FULL_DAY_ONLY_IDS[3]);
    fullDay.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            CheckBox cb = (CheckBox) event.getSource();
            for (String s : FULL_DAY_ONLY_IDS) {
                Element element = DOM.getElementById(s);
                String style = cb.getValue() ? "none" : "";
                element.getStyle().setProperty("display", style);
            }
        }
    });
    return table;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CheckBox(com.google.gwt.user.client.ui.CheckBox) Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Element(com.google.gwt.dom.client.Element) Date(java.util.Date)

Example 9 with CheckBox

use of com.google.gwt.user.client.ui.CheckBox in project opentsdb by OpenTSDB.

the class MetricForm method addTag.

private void addTag(final String default_tagname, final String default_value, final boolean is_groupby) {
    final int row = tagtable.getRowCount();
    final ValidatedTextBox tagname = new ValidatedTextBox();
    final SuggestBox suggesttagk = RemoteOracle.newSuggestBox("tagk", tagname);
    final ValidatedTextBox tagvalue = new ValidatedTextBox();
    final SuggestBox suggesttagv = RemoteOracle.newSuggestBox("tagv", tagvalue);
    final CheckBox groupby = new CheckBox();
    groupby.setValue(is_groupby);
    groupby.setTitle("Group by");
    groupby.addClickHandler(events_handler);
    tagname.setValidationRegexp(TSDB_ID_RE);
    tagvalue.setValidationRegexp(TSDB_TAGVALUE_RE);
    tagname.setWidth("100%");
    tagvalue.setWidth("100%");
    tagname.addBlurHandler(recompact_tagtable);
    tagname.addBlurHandler(events_handler);
    tagname.addKeyPressHandler(events_handler);
    tagvalue.addBlurHandler(recompact_tagtable);
    tagvalue.addBlurHandler(events_handler);
    tagvalue.addKeyPressHandler(events_handler);
    tagtable.setWidget(row, 1, suggesttagk);
    tagtable.setWidget(row, 2, suggesttagv);
    tagtable.setWidget(row, 3, groupby);
    if (row > 2) {
        final Button remove = new Button("x");
        remove.addClickHandler(removetag);
        tagtable.setWidget(row - 1, 0, remove);
    }
    if (default_tagname != null) {
        tagname.setText(default_tagname);
        if (default_value == null) {
            tagvalue.setFocus(true);
        }
    }
    if (default_value != null) {
        tagvalue.setText(default_value);
    }
}
Also used : SuggestBox(com.google.gwt.user.client.ui.SuggestBox) Button(com.google.gwt.user.client.ui.Button) CheckBox(com.google.gwt.user.client.ui.CheckBox)

Example 10 with CheckBox

use of com.google.gwt.user.client.ui.CheckBox 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)

Aggregations

CheckBox (com.google.gwt.user.client.ui.CheckBox)37 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)9 Test (org.junit.Test)9 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 Label (com.google.gwt.user.client.ui.Label)7 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)6 ListBox (com.google.gwt.user.client.ui.ListBox)5 TreeItem (com.google.gwt.user.client.ui.TreeItem)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Button (com.google.gwt.user.client.ui.Button)3 Grid (com.google.gwt.user.client.ui.Grid)3 HTML (com.google.gwt.user.client.ui.HTML)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 TextBox (com.google.gwt.user.client.ui.TextBox)3 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2