Search in sources :

Example 66 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class GuidedScoreCardEditor method addAttributeCellTable.

private Widget addAttributeCellTable(final FlexTable cGrid, final Characteristic characteristic, final boolean enumColumn, final String dataType, final List<String> operators) {
    String[] enumValues = null;
    if (characteristic != null) {
        // enum values
        if (enumColumn) {
            String factName = characteristic.getFact();
            String fieldName = characteristic.getField();
            enumValues = oracle.getEnumValues(factName, fieldName);
        }
    }
    final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>();
    // Operators column
    final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators);
    final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) {

        public String getValue(final Attribute object) {
            return object.getOperator();
        }
    };
    operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {

        public void update(int index, Attribute object, String value) {
            object.setOperator(value);
            attributeCellTable.redraw();
        }
    });
    // Value column
    Column<Attribute, String> valueColumn = null;
    if (enumValues != null && enumValues.length > 0) {
        valueColumn = new Column<Attribute, String>(new DynamicSelectionCell(Arrays.asList(enumValues))) {

            public String getValue(final Attribute object) {
                return object.getValue();
            }
        };
        valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {

            public void update(int index, Attribute object, String value) {
                object.setValue(value);
                attributeCellTable.redraw();
            }
        });
    }
    if (valueColumn == null) {
        valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) {

            public String getValue(final Attribute attribute) {
                return attribute.getValue();
            }
        };
        valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {

            public void update(int index, Attribute object, String value) {
                object.setValue(value);
                attributeCellTable.redraw();
            }
        });
    }
    // Partial Score column
    final EditTextCell partialScoreCell = new EditTextCell();
    final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) {

        public String getValue(final Attribute attribute) {
            return "" + attribute.getPartialScore();
        }
    };
    partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {

        public void update(int index, Attribute object, String value) {
            try {
                double d = Double.parseDouble(value);
                object.setPartialScore(d);
            } catch (Exception e1) {
                partialScoreCell.clearViewData(object);
            }
            attributeCellTable.redraw();
        }
    });
    // Reason Code column
    final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) {

        public String getValue(final Attribute attribute) {
            return attribute.getReasonCode();
        }
    };
    reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {

        public void update(int index, Attribute object, String value) {
            object.setReasonCode(value);
            attributeCellTable.redraw();
        }
    });
    final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() {

        public void execute(final Attribute attribute) {
            if (Window.confirm(GuidedScoreCardConstants.INSTANCE.promptDeleteAttribute())) {
                final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList();
                list.remove(attribute);
                if ("boolean".equalsIgnoreCase(dataType)) {
                    ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2);
                }
                attributeCellTable.redraw();
            }
        }
    };
    final Cell<Attribute> actionCell = new ActionCell<Attribute>(GuidedScoreCardConstants.INSTANCE.remove(), delegate);
    final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell);
    // Add the columns.
    attributeCellTable.addColumn(operatorColumn, GuidedScoreCardConstants.INSTANCE.operator());
    attributeCellTable.addColumn(valueColumn, GuidedScoreCardConstants.INSTANCE.value());
    attributeCellTable.addColumn(partialScoreColumn, GuidedScoreCardConstants.INSTANCE.partialScore());
    attributeCellTable.addColumn(reasonCodeColumn, GuidedScoreCardConstants.INSTANCE.reasonCode());
    attributeCellTable.addColumn(actionColumn, GuidedScoreCardConstants.INSTANCE.actions());
    attributeCellTable.setWidth("100%", true);
    attributeCellTable.setColumnWidth(operatorColumn, 20.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(valueColumn, 20.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(partialScoreColumn, 20.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(reasonCodeColumn, 20.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(actionColumn, 20.0, Style.Unit.PCT);
    ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>();
    dataProvider.addDataDisplay(attributeCellTable);
    characteristicsAttrMap.put(cGrid, dataProvider);
    if ("boolean".equalsIgnoreCase(dataType)) {
        CustomEditTextCell etc = (CustomEditTextCell) attributeCellTable.getColumn(1).getCell();
        etc.setEnabled(false);
    }
    return (attributeCellTable);
}
Also used : EditTextCell(com.google.gwt.cell.client.EditTextCell) ListDataProvider(com.google.gwt.view.client.ListDataProvider) Attribute(org.drools.workbench.models.guided.scorecard.shared.Attribute) IdentityColumn(com.google.gwt.user.cellview.client.IdentityColumn) ActionCell(com.google.gwt.cell.client.ActionCell) CellTable(com.google.gwt.user.cellview.client.CellTable) IdentityColumn(com.google.gwt.user.cellview.client.IdentityColumn) Column(com.google.gwt.user.cellview.client.Column) Button(org.gwtbootstrap3.client.ui.Button)

Example 67 with Button

use of org.gwtbootstrap3.client.ui.Button in project ovirt-engine by oVirt.

the class OvirtBreadCrumbsView method createSelectionDropDown.

// Can't make this a composite class since I can't put anything inside
// an AnchorListItem besides text using ui.xml files. But manually I can
// add widgets without issue.
private AnchorListItem createSelectionDropDown(SafeHtml currentName) {
    OvirtAnchorListItem dropDown = new OvirtAnchorListItem();
    Button exchangeButton = new Button();
    exchangeButton.setIcon(IconType.EXCHANGE);
    exchangeButton.addStyleName(QUICK_SWITCH);
    exchangeButton.getElement().getStyle().setMarginLeft(10, Unit.PX);
    exchangeButton.getElement().getStyle().setMarginTop(-5, Unit.PX);
    Anchor anchor = dropDown.getAnchor();
    anchor.getElement().setInnerHTML(currentName.asString());
    anchor.getElement().getStyle().setFontSize(28, Unit.PX);
    anchor.addClickHandler(e -> {
        if (popover.isVisible()) {
            popover.hide();
        } else {
            popover.show();
        }
    });
    anchor.add(exchangeButton);
    createPopover(anchor);
    dropDown.add(anchor);
    return dropDown;
}
Also used : Anchor(org.gwtbootstrap3.client.ui.Anchor) Button(org.gwtbootstrap3.client.ui.Button)

Example 68 with Button

use of org.gwtbootstrap3.client.ui.Button in project ovirt-engine by oVirt.

the class DisksContentTypeRadioGroup method getRadioGroupPanel.

private Widget getRadioGroupPanel() {
    buttonToType = new LinkedHashMap<>();
    // $NON-NLS-1$
    RadioButton allButton = new RadioButton(BUTTON_GROUP_NAME);
    buttonToType.put(allButton, null);
    allButton.setText(constants.allDisksLabel());
    for (DiskContentType contentType : DiskContentType.values()) {
        // $NON-NLS-1$
        RadioButton button = new RadioButton(BUTTON_GROUP_NAME);
        buttonToType.put(button, contentType);
    }
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.setDataToggle(Toggle.BUTTONS);
    buttonToType.entrySet().forEach(e -> {
        buttonGroup.add(e.getKey());
        e.getKey().addClickHandler(event -> fireChangeHandlers(e.getValue()));
    });
    setDiskContentType(null);
    localize();
    // $NON-NLS-1$
    buttonGroup.addStyleName("disk-type-buttons-group");
    return buttonGroup;
}
Also used : DiskContentType(org.ovirt.engine.core.common.businessentities.storage.DiskContentType) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) RadioButton(org.gwtbootstrap3.client.ui.RadioButton)

Example 69 with Button

use of org.gwtbootstrap3.client.ui.Button in project ovirt-engine by oVirt.

the class DropdownActionButton method initDropdownButton.

private void initDropdownButton(IconType icon, boolean splitButton) {
    button = new Button();
    caretButton = new Button();
    caretButton.setDataToggle(Toggle.DROPDOWN);
    caretButton.setToggleCaret(true);
    if (splitButton) {
        caretButton.getElement().getStyle().setMarginLeft(0, Unit.PX);
        caretButton.getElement().getStyle().setLeft(-1, Unit.PX);
        textButton = button;
        toolTip = new WidgetTooltip(textButton);
        add(toolTip);
        add(caretButton);
    } else {
        textButton = caretButton;
        toolTip = new WidgetTooltip(textButton);
        add(toolTip);
    }
    if (icon != null) {
        textButton.setIcon(icon);
    }
}
Also used : Button(org.gwtbootstrap3.client.ui.Button) WidgetTooltip(org.ovirt.engine.ui.common.widget.tooltip.WidgetTooltip)

Example 70 with Button

use of org.gwtbootstrap3.client.ui.Button in project ovirt-engine by oVirt.

the class AddRemoveRowWidget method createPlusButton.

private Button createPlusButton(final Pair<T, V> item) {
    final Button button = createButton(IconType.PLUS, event -> {
        V widget = item.getSecond();
        getEntry(widget).removeLastButton();
        Pair<T, V> item1 = addGhostEntry();
        onAdd(item1.getFirst(), item1.getSecond());
    });
    return button;
}
Also used : Button(org.gwtbootstrap3.client.ui.Button)

Aggregations

Button (org.gwtbootstrap3.client.ui.Button)71 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)33 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)33 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)14 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)12 HTML (com.google.gwt.user.client.ui.HTML)10 ListBox (org.gwtbootstrap3.client.ui.ListBox)10 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)9 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)9 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)9 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)7 TextBox (org.gwtbootstrap3.client.ui.TextBox)6 MenuItem (org.uberfire.workbench.model.menu.MenuItem)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 Widget (com.google.gwt.user.client.ui.Widget)5 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)5 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)5 FlexTable (com.google.gwt.user.client.ui.FlexTable)4 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 Inject (javax.inject.Inject)4