Example usage for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE

List of usage examples for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.

Prototype

VerticalAlignmentConstant ALIGN_MIDDLE

To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.

Click Source Link

Document

Specifies that the widget's contents should be aligned in the middle.

Usage

From source file:org.drools.workbench.screens.guided.rule.client.editor.RuleModeller.java

License:Apache License

/**
 * Do all the widgets for the RHS./*from w  ww . j ava  2s.co m*/
 */
private void renderRhs(final RuleModel model) {

    for (int i = 0; i < model.rhs.length; i++) {
        DirtyableVerticalPane widget = new DirtyableVerticalPane();
        widget.setWidth("100%");

        IAction action = model.rhs[i];

        //if lockRHS() set the widget RO, otherwise let them decide.
        Boolean readOnly = this.lockRHS() ? true : null;

        RuleModellerWidget w = getWidgetFactory().getWidget(this, eventBus, action, readOnly);
        w.addOnModifiedCommand(this.onWidgetModifiedCommand);

        widget.add(wrapRHSWidget(model, i, w));
        widget.add(spacerWidget());

        layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
        layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());

        layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, false));
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2,
                HasHorizontalAlignment.ALIGN_CENTER);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2,
                HasVerticalAlignment.ALIGN_MIDDLE);

        layout.setWidget(currentLayoutRow, 3, widget);
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3,
                HasHorizontalAlignment.ALIGN_LEFT);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
        layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");

        layout.getRowFormatter().addStyleName(currentLayoutRow,
                (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow()
                        : GuidedRuleEditorResources.INSTANCE.css().oddRow()));

        if (!w.isFactTypeKnown()) {
            addInvalidPatternIcon();
            addFactTypeKnownValueChangeHandler(w, currentLayoutRow);
        }

        final int index = i;
        if (!(this.lockRHS() || w.isReadOnly())) {
            this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAnActionBelow(),
                    new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            showActionSelector((Widget) event.getSource(), index + 1);
                        }
                    }, new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            model.moveRhsItemDown(index);
                            refreshWidget();
                        }
                    }, new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            model.moveRhsItemUp(index);
                            refreshWidget();
                        }
                    });
        }

        this.rhsWidgets.add(w);
        currentLayoutRow++;

    }

}

From source file:org.drools.workbench.screens.guided.rule.client.editor.RuleModeller.java

License:Apache License

/**
 * Builds all the condition widgets./*www .  ja  va 2s  . c  o m*/
 */
private void renderLhs(final RuleModel model) {

    for (int i = 0; i < model.lhs.length; i++) {
        DirtyableVerticalPane vert = new DirtyableVerticalPane();
        vert.setWidth("100%");

        //if lockLHS() set the widget RO, otherwise let them decide.
        Boolean readOnly = this.lockLHS() ? true : null;

        IPattern pattern = model.lhs[i];

        final RuleModellerWidget widget = getWidgetFactory().getWidget(this, eventBus, pattern, readOnly);
        widget.addOnModifiedCommand(this.onWidgetModifiedCommand);

        vert.add(wrapLHSWidget(model, i, widget));
        vert.add(spacerWidget());

        layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
        layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());

        layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, true));
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2,
                HasHorizontalAlignment.ALIGN_CENTER);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2,
                HasVerticalAlignment.ALIGN_MIDDLE);

        layout.setWidget(currentLayoutRow, 3, vert);
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3,
                HasHorizontalAlignment.ALIGN_LEFT);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
        layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");

        layout.getRowFormatter().addStyleName(currentLayoutRow,
                (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow()
                        : GuidedRuleEditorResources.INSTANCE.css().oddRow()));

        if (!widget.isFactTypeKnown()) {
            addInvalidPatternIcon();
            addFactTypeKnownValueChangeHandler(widget, currentLayoutRow);
        }

        final int index = i;
        if (!(this.lockLHS() || widget.isReadOnly())) {
            this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAConditionBelow(),
                    new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            showConditionSelector(index + 1);
                        }
                    }, new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            model.moveLhsItemDown(index);
                            refreshWidget();
                        }
                    }, new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            model.moveLhsItemUp(index);
                            refreshWidget();
                        }
                    });
        }

        this.lhsWidgets.add(widget);
        currentLayoutRow++;
    }

}

From source file:org.drools.workbench.screens.guided.rule.client.editor.RuleModeller.java

License:Apache License

private void addActionsButtonsToLayout(String title, ClickHandler addBelowListener,
        ClickHandler moveDownListener, ClickHandler moveUpListener) {

    final DirtyableHorizontalPane hp = new DirtyableHorizontalPane();

    Image addPattern = CommonAltedImages.INSTANCE.NewItemBelow();
    addPattern.setTitle(title);//w  w w.j  a  v  a2s  .  com
    addPattern.addClickHandler(addBelowListener);

    Image moveDown = CommonAltedImages.INSTANCE.MoveDown();
    moveDown.setTitle(GuidedRuleEditorResources.CONSTANTS.MoveDown());
    moveDown.addClickHandler(moveDownListener);

    Image moveUp = CommonAltedImages.INSTANCE.MoveUp();
    moveUp.setTitle(GuidedRuleEditorResources.CONSTANTS.MoveUp());
    moveUp.addClickHandler(moveUpListener);

    hp.add(addPattern);
    hp.add(moveDown);
    hp.add(moveUp);

    layout.setWidget(currentLayoutRow, 4, hp);
    layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 4,
            HasHorizontalAlignment.ALIGN_CENTER);
    layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 4, HasVerticalAlignment.ALIGN_MIDDLE);
}

From source file:org.drools.workbench.screens.guided.rule.client.widget.ExpressionBuilder.java

License:Apache License

public ExpressionBuilder(RuleModeller modeller, EventBus eventBus, ExpressionFormLine expression,
        Boolean readOnly) {//from  ww w .  j av  a2  s.  com
    super(modeller, eventBus);
    this.expression = expression;

    if (this.expression.isEmpty()) {
        this.isFactTypeKnown = true;
    } else {
        this.isFactTypeKnown = getModeller().getDataModelOracle().isFactTypeRecognized(getModeller()
                .getDataModelOracle().getFactNameFromType(this.expression.getRootExpression().getClassType()));
    }

    if (readOnly == null) {
        this.readOnly = !this.isFactTypeKnown;
    } else {
        this.readOnly = readOnly;
    }

    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    panel.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container());

    initializeWidgets();

    initWidget(panel);
}

From source file:org.drools.workbench.screens.guided.rule.client.widget.ExpressionBuilder.java

License:Apache License

private Widget createWidgetForExpression() {
    final HorizontalPanel container = new HorizontalPanel();
    container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    container.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container());
    for (ExpressionPart expressionPart : expression.getParts()) {
        if (expressionPart instanceof ExpressionUnboundFact) {
            continue;
        } else if (this.readOnly) {
            container.add(new Label(expressionPart.getName()));
        } else if (expressionPart instanceof ExpressionMethod) {
            container.add(new Label(expressionPart.getName()));
            container.add(new Label("("));
            final ExpressionMethod em = (ExpressionMethod) expressionPart;
            final List<ExpressionFormLine> emParams = em.getOrderedParams();
            for (int index = 0; index < emParams.size(); index++) {
                final ExpressionFormLine paramValueHolder = emParams.get(index);
                final String paramDataType = em.getParameterDataType(paramValueHolder);
                final ExpressionMethodParameter paramValue = ((ExpressionMethodParameter) paramValueHolder
                        .getRootExpression());
                final TextBox paramValueEditor = TextBoxFactory.getTextBox(paramDataType);
                paramValueEditor.addValueChangeHandler(new ValueChangeHandler<String>() {
                    @Override/*from   w w  w.j av a  2s .  c  om*/
                    public void onValueChange(ValueChangeEvent<String> event) {
                        paramValue.setText(event.getValue());
                    }
                });
                paramValueEditor.setText(paramValue.getName());
                container.add(paramValueEditor);
                if (index < emParams.size() - 1) {
                    container.add(new Label(", "));
                }
            }
            container.add(new Label(")"));
        } else if (!(expressionPart instanceof ExpressionText)) {
            container.add(new Label(expressionPart.getName()));
        } else {
            final TextBox tb = new TextBox();
            final ExpressionText expressionTextPart = (ExpressionText) expressionPart;
            tb.setText(expressionTextPart.getName());
            tb.addChangeHandler(new ChangeHandler() {
                @Override
                public void onChange(final ChangeEvent changeEvent) {
                    expressionTextPart.setText(tb.getText());
                }
            });
            container.add(tb);
        }
        container.add(new Label("."));
    }
    return container;
}

From source file:org.drools.workbench.screens.testscenario.client.ActivateRuleFlowWidget.java

License:Apache License

private void render(final FixtureList retList, final FlexTable outer, final Scenario sc) {
    outer.clear();// w  ww . ja v  a 2  s  .  co  m
    outer.getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader");
    outer.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    outer.setStyleName("modeller-fact-pattern-Widget");
    outer.setWidget(0, 0, new SmallLabel(TestScenarioConstants.INSTANCE.ActivateRuleFlowGroup()));
    outer.getFlexCellFormatter().setColSpan(0, 0, 2);

    int row = 1;
    for (Fixture fixture : retList) {
        final ActivateRuleFlowGroup acticateRuleFlowGroup = (ActivateRuleFlowGroup) fixture;
        outer.setWidget(row, 0, new SmallLabel(acticateRuleFlowGroup.getName()));
        Image image = CommonAltedImages.INSTANCE.DeleteItemSmall();
        image.setAltText(TestScenarioConstants.INSTANCE.RemoveThisRuleFlowActivation());
        ImageButton del = new ImageButton(image, TestScenarioConstants.INSTANCE.RemoveThisRuleFlowActivation(),
                new ClickHandler() {
                    public void onClick(ClickEvent w) {
                        retList.remove(acticateRuleFlowGroup);
                        sc.getFixtures().remove(acticateRuleFlowGroup);
                        render(retList, outer, sc);
                        parent.renderEditor();
                    }
                });
        outer.setWidget(row, 1, del);

        row++;
    }
}

From source file:org.drools.workbench.screens.testscenario.client.RetractWidget.java

License:Apache License

private void render() {

    clear();//w w  w . j ava  2  s.co m

    getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader");
    getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    setStyleName("modeller-fact-pattern-Widget");
    setWidget(0, 0, new SmallLabel(TestScenarioConstants.INSTANCE.DeleteFacts()));
    getFlexCellFormatter().setColSpan(0, 0, 2);

    int row = 1;
    for (Fixture fixture : retractList) {
        if (fixture instanceof RetractFact) {
            final RetractFact retractFact = (RetractFact) fixture;
            setWidget(row, 0, new SmallLabel(retractFact.getName()));

            setWidget(row, 1, new DeleteButton(retractFact));

            row++;
        }
    }
}

From source file:org.drools.workbench.screens.testscenario.client.VerifyFactWidget.java

License:Apache License

public VerifyFactWidget(final VerifyFact vf, final Scenario sc, final AsyncPackageDataModelOracle oracle,
        final ExecutionTrace executionTrace, final boolean showResults) {
    outer = new Grid(2, 1);
    outer.getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader"); //NON-NLS
    outer.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    outer.setStyleName("modeller-fact-pattern-Widget"); //NON-NLS
    this.oracle = oracle;
    this.scenario = sc;
    this.executionTrace = executionTrace;
    HorizontalPanel ab = new HorizontalPanel();
    ClickableLabel label = null;// w  w  w . j  a  v  a  2  s.  c  om

    final ClickHandler handler = new ClickHandler() {
        public void onClick(ClickEvent w) {

            final ListBox fieldsListBox = new ListBox();
            VerifyFactWidget.this.oracle.getFieldCompletions(type, new Callback<ModelField[]>() {
                @Override
                public void callback(final ModelField[] fields) {

                    // Add fields
                    for (int i = 0; i < fields.length; i++) {
                        fieldsListBox.addItem(fields[i].getName());
                    }

                    // Add methods
                    oracle.getMethodInfos(type, new Callback<List<MethodInfo>>() {
                        @Override
                        public void callback(List<MethodInfo> result) {
                            for (MethodInfo info : result) {
                                if (info.getParams().isEmpty() && !"void".equals(info.getReturnClassType())) {
                                    fieldsListBox.addItem(info.getName());
                                }
                            }
                        }
                    });
                }
            });

            final FormStylePopup pop = new FormStylePopup(TestScenarioAltedImages.INSTANCE.RuleAsset(),
                    TestScenarioConstants.INSTANCE.ChooseAFieldToAdd());
            pop.addRow(fieldsListBox);
            pop.add(new ModalFooterOKCancelButtons(new Command() {
                @Override
                public void execute() {
                    String f = fieldsListBox.getItemText(fieldsListBox.getSelectedIndex());
                    vf.getFieldValues().add(new VerifyField(f, "", "=="));
                    FlexTable data = render(vf);
                    outer.setWidget(1, 0, data);
                    pop.hide();
                }
            }, new Command() {
                @Override
                public void execute() {
                    pop.hide();
                }
            }));

            pop.show();

        }
    };

    if (!vf.anonymous) {
        type = (String) sc.getVariableTypes().get(vf.getName());
        label = new ClickableLabel(TestScenarioConstants.INSTANCE.scenarioFactTypeHasValues(type, vf.getName()),
                handler);
    } else {
        type = vf.getName();
        label = new ClickableLabel(TestScenarioConstants.INSTANCE.AFactOfType0HasValues(vf.getName()), handler);
    }
    ab.add(label);
    this.showResults = showResults;

    outer.setWidget(0, 0, ab);
    initWidget(outer);

    FlexTable data = render(vf);
    outer.setWidget(1, 0, data);

}

From source file:org.drools.workbench.screens.testscenario.client.VerifyRulesFiredWidget.java

License:Apache License

/**
 * @param rfl List<VeryfyRuleFired>
 * @param scenario = the scenario to add/remove from
 *///from  ww w .j a  v a2 s  . c om
public VerifyRulesFiredWidget(final FixtureList rfl, final Scenario scenario, final boolean showResults) {
    outer = new Grid(2, 1);
    this.showResults = showResults;
    outer.getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader"); //NON-NLS
    outer.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    outer.setStyleName("modeller-fact-pattern-Widget"); //NON-NLS

    outer.setWidget(0, 0, new SmallLabel(TestScenarioConstants.INSTANCE.ExpectRules()));
    initWidget(outer);

    FlexTable data = render(rfl, scenario);
    outer.setWidget(1, 0, data);
}

From source file:org.drools.workbench.screens.testscenario.client.VerifyRulesFiredWidget.java

License:Apache License

private FlexTable render(final FixtureList rfl, final Scenario sc) {
    FlexTable data = new FlexTable();

    for (int i = 0; i < rfl.size(); i++) {
        final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i);

        if (showResults && v.getSuccessResult() != null) {
            if (!v.getSuccessResult().booleanValue()) {
                data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
                data.setWidget(i, 4,/* w  ww .  j  a  v  a2  s .c  om*/
                        new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));

                data.getCellFormatter().addStyleName(i, 4, "testErrorValue"); //NON-NLS

            } else {
                data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
            }

        }
        data.setWidget(i, 1, new SmallLabel(v.getRuleName() + ":"));
        data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT,
                HasVerticalAlignment.ALIGN_MIDDLE);

        final ListBox b = new ListBox();
        b.addItem(TestScenarioConstants.INSTANCE.firedAtLeastOnce(), "y");
        b.addItem(TestScenarioConstants.INSTANCE.didNotFire(), "n");
        b.addItem(TestScenarioConstants.INSTANCE.firedThisManyTimes(), "e");
        final TextBox num = new TextBox();
        num.setVisibleLength(5);

        if (v.getExpectedFire() != null) {
            b.setSelectedIndex((v.getExpectedFire().booleanValue()) ? 0 : 1);
            num.setVisible(false);
        } else {
            b.setSelectedIndex(2);
            String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
            num.setText(xc);
        }

        b.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                String s = b.getValue(b.getSelectedIndex());
                if (s.equals("y") || s.equals("n")) {
                    num.setVisible(false);
                    v.setExpectedFire((s.equals("y")) ? Boolean.TRUE : Boolean.FALSE);
                    v.setExpectedCount(null);
                } else {
                    num.setVisible(true);
                    v.setExpectedFire(null);
                    num.setText("1");
                    v.setExpectedCount(Integer.valueOf(1));
                }
            }
        });

        b.addItem(TestScenarioConstants.INSTANCE.ChooseDotDotDot());

        num.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                v.setExpectedCount(Integer.valueOf(num.getText()));
            }
        });

        HorizontalPanel h = new HorizontalPanel();
        h.add(b);
        h.add(num);
        data.setWidget(i, 2, h);

        Image del = CommonAltedImages.INSTANCE.DeleteItemSmall();
        del.setAltText(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
        del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
        del.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                if (Window.confirm(
                        TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation())) {
                    rfl.remove(v);
                    sc.removeFixture(v);
                    outer.setWidget(1, 0, render(rfl, sc));
                }
            }
        });

        data.setWidget(i, 3, del);

        //we only want numbers here...
        num.addKeyPressHandler(new KeyPressHandler() {
            public void onKeyPress(KeyPressEvent event) {
                if (Character.isLetter(event.getCharCode())) {
                    ((TextBox) event.getSource()).cancelKey();
                }
            }
        });
    }
    return data;
}