Search in sources :

Example 26 with Column

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

the class EnumEditorViewImpl method init.

@PostConstruct
public void init() {
    final CellTable<EnumRow> cellTable = new CellTable<EnumRow>(Integer.MAX_VALUE);
    cellTable.setStriped(true);
    cellTable.setCondensed(true);
    cellTable.setBordered(true);
    cellTable.setEmptyTableWidget(new Label(EnumEditorConstants.INSTANCE.noEnumsDefined()));
    cellTable.setWidth("100%");
    final VerticalPanel panel = new VerticalPanel();
    panel.setWidth("100%");
    // Column definitions
    final Column<EnumRow, String> factNameColumn = new Column<EnumRow, String>(new EnumEditTextCell()) {

        @Override
        public String getValue(final EnumRow enumRow) {
            if (enumRow.isValid()) {
                return enumRow.getFactName();
            }
            return enumRow.getRaw();
        }
    };
    final Column<EnumRow, String> fieldNameColumn = new Column<EnumRow, String>(new EnumEditTextCell()) {

        @Override
        public String getValue(final EnumRow enumRow) {
            if (enumRow.isValid()) {
                return enumRow.getFieldName();
            }
            return "";
        }
    };
    final Column<EnumRow, String> contextColumn = new Column<EnumRow, String>(new EnumEditTextCell()) {

        @Override
        public String getValue(final EnumRow enumRow) {
            if (enumRow.isValid()) {
                return enumRow.getContext();
            }
            return "";
        }
    };
    // See https://bugzilla.redhat.com/show_bug.cgi?id=1167360
    // Replaced image-based ButtonCell with a button due to IE10 interpreting it as a form-submit button and hence responding to ENTER key presses.
    // See http://stackoverflow.com/questions/12325066/button-click-event-fires-when-pressing-enter-key-in-different-input-no-forms
    final ButtonCell deleteEnumButton = new ButtonCell(IconType.MINUS, ButtonType.DANGER, ButtonSize.SMALL);
    final Column<EnumRow, String> deleteEnumColumn = new Column<EnumRow, String>(deleteEnumButton) {

        @Override
        public String getValue(final EnumRow global) {
            return EnumEditorConstants.INSTANCE.remove();
        }
    };
    // Write updates back to the model
    factNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() {

        @Override
        public void update(final int index, final EnumRow enumRow, final String value) {
            enumRow.setFactName(value);
        }
    });
    fieldNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() {

        @Override
        public void update(final int index, final EnumRow enumRow, final String value) {
            enumRow.setFieldName(value);
        }
    });
    contextColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() {

        @Override
        public void update(final int index, final EnumRow enumRow, final String value) {
            enumRow.setContext(value);
        }
    });
    deleteEnumColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() {

        @Override
        public void update(final int index, final EnumRow enumRow, final String value) {
            dataProvider.getList().remove(index);
        }
    });
    cellTable.addColumn(factNameColumn, EnumEditorConstants.INSTANCE.FactColumnHeader());
    cellTable.addColumn(fieldNameColumn, EnumEditorConstants.INSTANCE.FieldColumnHeader());
    cellTable.addColumn(contextColumn, EnumEditorConstants.INSTANCE.ContextColumnHeader());
    cellTable.addColumn(deleteEnumColumn);
    cellTable.setColumnWidth(deleteEnumColumn, 100.0, Style.Unit.PX);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(cellTable);
    addButton.setText(EnumEditorConstants.INSTANCE.AddEnum());
    addButton.addClickHandler(clickEvent -> {
        final EnumRow enumRow = new EnumRow();
        dataProvider.getList().add(enumRow);
    });
    panel.add(addButton);
    panel.add(cellTable);
    initWidget(panel);
}
Also used : Label(org.gwtbootstrap3.client.ui.Label) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) CellTable(org.gwtbootstrap3.client.ui.gwt.CellTable) Column(com.google.gwt.user.cellview.client.Column) ButtonCell(org.gwtbootstrap3.client.ui.gwt.ButtonCell) PostConstruct(javax.annotation.PostConstruct)

Example 27 with Column

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

the class AuditLogViewImpl method setup.

public void setup() {
    // BZ-996917: Use a the gwtboostrap style "row-fluid" to allow display some events in the same row.
    eventTypes.setStyleName(Styles.ROW);
    // Fill panel with available events.
    for (Map.Entry<String, Boolean> e : auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) {
        eventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue()));
    }
    // Create the GWT Cell Table as events container.
    // BZ-996942: Set custom width and table css style.
    events = new CellTable<>();
    events.setWidth("100%");
    events.addStyleName(Styles.TABLE);
    dlp = new ListDataProvider<AuditLogEntry>() {

        @Override
        public void setList(final List<AuditLogEntry> listToWrap) {
            super.setList(listToWrap);
            cellTablePagination.rebuild(pager);
        }
    };
    dlp.addDataDisplay(events);
    AuditLogEntrySummaryColumn summaryColumn = new AuditLogEntrySummaryColumn(style.auditLogDetailLabel(), style.auditLogDetailValue());
    AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn();
    events.addColumn(summaryColumn);
    events.addColumn(commentColumn);
    events.setColumnWidth(summaryColumn, 60.0, Unit.PCT);
    events.setColumnWidth(commentColumn, 40.0, Unit.PCT);
    // If the current user is not an Administrator include the delete comment column
    if (identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {
        AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn();
        deleteCommentColumn.setFieldUpdater((int index, AuditLogEntry row, SafeHtml value) -> {
            row.setDeleted(true);
            dlp.setList(filterDeletedEntries(auditLog));
            dlp.refresh();
        });
        events.addColumn(deleteCommentColumn);
        events.setColumnWidth(commentColumn, 35.0, Unit.PCT);
        events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT);
    }
    events.setEmptyTableWidget(new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogNoEntries()));
    events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    events.setPageSize(PAGE_SIZE);
    // Configure the simple pager.
    pager.setDisplay(events);
    pager.setPageSize(PAGE_SIZE);
    // Add the table to the container.
    eventsContainer.add(events);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) RoleImpl(org.jboss.errai.security.shared.api.RoleImpl) Label(org.gwtbootstrap3.client.ui.Label) AuditLogEntry(org.drools.workbench.models.datamodel.auditlog.AuditLogEntry) Map(java.util.Map)

Example 28 with Column

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

the class DTCellValueWidgetFactoryTest method testEnumDropdownForBRLColumn.

@Test
public void testEnumDropdownForBRLColumn() throws Exception {
    BRLConditionVariableColumn column = mock(BRLConditionVariableColumn.class);
    doReturn("Person").when(column).getFactType();
    doReturn("name").when(column).getFactField();
    when(oracle.hasEnums("Person", "name")).thenReturn(true);
    IsWidget widget = factory.getWidget(column, cellValue);
    assertTrue(widget instanceof ListBox);
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

Example 29 with Column

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

the class AbstractFormPanel method updateFormItem.

/**
 * Updates the value and visibility of the given item.
 */
public void updateFormItem(FormItem item, Integer labelWidth) {
    Widget valueWidget = item.resolveValueWidget();
    valueWidget.getElement().setId(// $NON-NLS-1$
    ElementIdUtils.createFormGridElementId(elementId, item.getColumn(), item.getRow(), "_value"));
    valueWidget.setStyleName(style.formPanelValue());
    boolean visible = item.getIsAvailable();
    Column widgetColumn = findColumn(item.getRow(), item.getColumn());
    if (widgetColumn != null) {
        IsWidget itemCell = widgetColumn.getWidget(0);
        if (itemCell instanceof Row) {
            Row itemCellRow = (Row) itemCell;
            // Update item visibility
            itemCellRow.setVisible(visible);
            if (itemCellRow.getWidgetCount() > 1) {
                // Clear out old value.
                itemCellRow.remove(1);
            }
            Column valueColumn = new Column(COL_PREFIX + determineRealLabelWidth(item, labelWidth));
            valueColumn.add(valueWidget);
            itemCellRow.add(valueColumn);
        }
    }
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) Column(org.gwtbootstrap3.client.ui.Column) Widget(com.google.gwt.user.client.ui.Widget) IsWidget(com.google.gwt.user.client.ui.IsWidget) Row(org.gwtbootstrap3.client.ui.Row)

Example 30 with Column

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

the class AbstractFormPanel method findColumn.

private Column findColumn(int row, int column) {
    Column result = null;
    IsWidget rowWidget = container.getWidget(row);
    if (rowWidget instanceof Row) {
        IsWidget columnWidget = ((Row) rowWidget).getWidget(column);
        if (columnWidget instanceof Column) {
            result = (Column) columnWidget;
        }
    }
    return result;
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) Column(org.gwtbootstrap3.client.ui.Column) Row(org.gwtbootstrap3.client.ui.Row)

Aggregations

Column (org.gwtbootstrap3.client.ui.Column)30 Row (org.gwtbootstrap3.client.ui.Row)24 Column (com.google.gwt.user.cellview.client.Column)17 ButtonCell (org.gwtbootstrap3.client.ui.gwt.ButtonCell)12 DListElement (com.google.gwt.dom.client.DListElement)10 Button (org.gwtbootstrap3.client.ui.Button)9 TextColumn (com.google.gwt.user.cellview.client.TextColumn)8 Element (com.google.gwt.dom.client.Element)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 AbstractIconTypeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractIconTypeColumn)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)4 NativeEvent (com.google.gwt.dom.client.NativeEvent)4 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)4 HTMLButtonElement (elemental2.dom.HTMLButtonElement)4 Container (org.gwtbootstrap3.client.ui.Container)4 Icon (org.gwtbootstrap3.client.ui.Icon)4 Label (org.gwtbootstrap3.client.ui.Label)4 CellTable (com.google.gwt.user.cellview.client.CellTable)3 ListDataProvider (com.google.gwt.view.client.ListDataProvider)3