Search in sources :

Example 1 with CellTable

use of org.gwtbootstrap3.client.ui.gwt.CellTable 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 2 with CellTable

use of org.gwtbootstrap3.client.ui.gwt.CellTable 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 3 with CellTable

use of org.gwtbootstrap3.client.ui.gwt.CellTable 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)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)2 Label (org.gwtbootstrap3.client.ui.Label)2 ActionCell (com.google.gwt.cell.client.ActionCell)1 EditTextCell (com.google.gwt.cell.client.EditTextCell)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 CellTable (com.google.gwt.user.cellview.client.CellTable)1 IdentityColumn (com.google.gwt.user.cellview.client.IdentityColumn)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 ListDataProvider (com.google.gwt.view.client.ListDataProvider)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 AuditLogEntry (org.drools.workbench.models.datamodel.auditlog.AuditLogEntry)1 Attribute (org.drools.workbench.models.guided.scorecard.shared.Attribute)1 Button (org.gwtbootstrap3.client.ui.Button)1 ButtonCell (org.gwtbootstrap3.client.ui.gwt.ButtonCell)1 CellTable (org.gwtbootstrap3.client.ui.gwt.CellTable)1 RoleImpl (org.jboss.errai.security.shared.api.RoleImpl)1