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.guvnor.client.explorer.navigation.qa.testscenarios.RetractWidget.java

License:Apache License

private void render() {

    clear();/*w  ww  . j  ava2  s.  com*/

    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(Constants.INSTANCE.RetractFacts()));
    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.guvnor.client.explorer.navigation.qa.VerifyFactWidget.java

License:Apache License

public VerifyFactWidget(final VerifyFact vf, final Scenario sc, final SuggestionCompletionEngine sce,
        ExecutionTrace executionTrace, 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.sce = sce;
    this.scenario = sc;
    this.executionTrace = executionTrace;
    HorizontalPanel ab = new HorizontalPanel();
    if (!vf.anonymous) {
        type = (String) sc.getVariableTypes().get(vf.getName());
        ab.add(new SmallLabel(Constants.INSTANCE.scenarioFactTypeHasValues(type, vf.getName())));
    } else {/*ww  w  . j  a v  a  2 s  .  c om*/
        type = vf.getName();
        ab.add(new SmallLabel(Constants.INSTANCE.AFactOfType0HasValues(vf.getName())));
    }
    this.showResults = showResults;

    Image add = DroolsGuvnorImages.INSTANCE.AddFieldToFact();
    add.setTitle(Constants.INSTANCE.AddAFieldToThisExpectation());
    add.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {

            String[] fields = sce.getModelFields(type);
            final FormStylePopup pop = new FormStylePopup(DroolsGuvnorImages.INSTANCE.RuleAsset(),
                    Constants.INSTANCE.ChooseAFieldToAdd());
            final ListBox b = new ListBox();
            for (int i = 0; i < fields.length; i++) {
                b.addItem(fields[i]);
            }
            pop.addRow(b);
            Button ok = new Button(Constants.INSTANCE.OK());
            ok.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    String f = b.getItemText(b.getSelectedIndex());
                    vf.getFieldValues().add(new VerifyField(f, "", "=="));
                    FlexTable data = render(vf);
                    outer.setWidget(1, 0, data);
                    pop.hide();
                }
            });
            pop.addRow(ok);
            pop.show();

        }
    });

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

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

}

From source file:org.drools.guvnor.client.explorer.navigation.qa.VerifyRulesFiredWidget.java

License:Apache License

/**
 * @param rfl List<VeryfyRuleFired>
 * @param scenario = the scenario to add/remove from
 *///from   w  ww  .j  a  v a 2  s .c o m
public VerifyRulesFiredWidget(final FixtureList rfl, final Scenario scenario, 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(Constants.INSTANCE.ExpectRules()));
    initWidget(outer);

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

From source file:org.drools.guvnor.client.explorer.navigation.qa.VerifyRulesFiredWidget.java

License:Apache License

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

    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(DroolsGuvnorImageResources.INSTANCE.warning()));
                data.setWidget(i, 4, new HTML(Constants.INSTANCE.ActualResult(v.getActualResult().toString())));

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

            } else {
                data.setWidget(i, 0, new Image(DroolsGuvnorImageResources.INSTANCE.testPassed()));
            }/*  ww  w. ja  v a 2  s .  c  o m*/

        }
        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(Constants.INSTANCE.firedAtLeastOnce(), "y");
        b.addItem(Constants.INSTANCE.didNotFire(), "n");
        b.addItem(Constants.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(new Integer(1));
                }
            }
        });

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

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

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

        Image del = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
        del.setAltText(Constants.INSTANCE.RemoveThisRuleExpectation());
        del.setTitle(Constants.INSTANCE.RemoveThisRuleExpectation());
        del.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                if (Window.confirm(Constants.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;
}

From source file:org.drools.guvnor.client.modeldriven.ui.ExpressionBuilder.java

License:Apache License

public ExpressionBuilder(RuleModeller modeller, ExpressionFormLine expression, Boolean readOnly) {
    super(modeller);

    if (readOnly == null) {
        this.readOnly = !modeller.getSuggestionCompletions()
                .containsFactType(modeller.getSuggestionCompletions()
                        .getFactNameFromType(this.expression.getRootExpression().getClassType()));
    } else {/*from  www .  j  a  v a  2 s  .c  o  m*/
        this.readOnly = readOnly;
    }

    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    this.expression = expression;
    if (expression == null || expression.isEmpty()) {
        if (this.readOnly) {
            panel.add(new SmallLabel("<b>-</b>"));
        } else {
            panel.add(createStartPointWidget());
        }
    } else {
        if (this.readOnly) {
            panel.add(createWidgetForExpression("<b>" + getBoundText() + expression.getText(false) + "</b>"));
        } else {
            panel.add(createWidgetForExpression("<b>" + getBoundText() + expression.getText(false) + ".</b>"));
            panel.add(getWidgetForCurrentType());
        }
    }
    initWidget(panel);
}

From source file:org.drools.guvnor.client.modeldriven.ui.FactPatternWidget.java

License:Apache License

public FactPatternWidget(RuleModeller mod, IPattern p, SuggestionCompletionEngine com, boolean canBind) {
    this.pattern = (FactPattern) p;
    this.completions = com;
    this.modeller = mod;
    this.bindable = canBind;

    this.connectives = new Connectives();
    this.connectives.setCompletions(completions);
    this.connectives.setModeller(modeller);
    this.connectives.setPattern(pattern);

    this.popupCreator = new PopupCreator();
    this.popupCreator.setBindable(bindable);
    this.popupCreator.setCompletions(completions);
    this.popupCreator.setModeller(modeller);
    this.popupCreator.setPattern(pattern);

    layout.setWidget(0, 0, getPatternLabel());
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    formatter.setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    formatter.setStyleName(0, 0, "modeller-fact-TypeHeader");

    ArrayList sortedConst = sortConstraints(pattern.getFieldConstraints());
    pattern.setFieldConstraints(sortedConst);
    drawConstraints(sortedConst);/*from  w w w.java 2 s.c  o m*/

    if (bindable)
        layout.setStyleName("modeller-fact-pattern-Widget");
    initWidget(layout);

}

From source file:org.drools.guvnor.client.qa.testscenarios.ActivateRuleFlowWidget.java

License:Apache License

private void render(final FixtureList retList, final FlexTable outer, final Scenario sc) {
    outer.clear();//from  w w w .  j a  v a2s  . 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(constants.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.name));
        Image del = new ImageButton(images.deleteItemSmall(), constants.RemoveThisRuleFlowActivation(),
                new ClickHandler() {
                    public void onClick(ClickEvent w) {
                        retList.remove(acticateRuleFlowGroup);
                        sc.fixtures.remove(acticateRuleFlowGroup);
                        render(retList, outer, sc);
                        parent.renderEditor();
                    }
                });
        outer.setWidget(row, 1, del);

        row++;
    }
}

From source file:org.drools.guvnor.client.qa.testscenarios.RetractWidget.java

License:Apache License

private void render() {

    clear();//ww  w.  ja v  a  2s .  c o 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(constants.RetractFacts()));
    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.name));

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

            row++;
        }
    }
}

From source file:org.drools.guvnor.client.qa.VerifyFactWidget.java

License:Apache License

public VerifyFactWidget(final VerifyFact vf, final Scenario sc, final SuggestionCompletionEngine sce,
        ExecutionTrace executionTrace, 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.sce = sce;
    this.scenario = sc;
    this.executionTrace = executionTrace;
    HorizontalPanel ab = new HorizontalPanel();
    if (!vf.anonymous) {
        type = (String) sc.getVariableTypes().get(vf.name);
        ab.add(new SmallLabel(Format.format(constants.scenarioFactTypeHasValues(), type, vf.name)));
    } else {//ww  w .j  a  v a  2 s.  c  om
        type = vf.name;
        ab.add(new SmallLabel(Format.format(constants.AFactOfType0HasValues(), vf.name)));
    }
    this.showResults = showResults;

    Image add = new ImageButton(images.addFieldToFact(), constants.AddAFieldToThisExpectation(),
            new ClickHandler() {
                public void onClick(ClickEvent w) {

                    String[] fields = (String[]) sce.getModelFields(type);
                    final FormStylePopup pop = new FormStylePopup(images.ruleAsset(),
                            constants.ChooseAFieldToAdd());
                    final ListBox b = new ListBox();
                    for (int i = 0; i < fields.length; i++) {
                        b.addItem(fields[i]);
                    }
                    pop.addRow(b);
                    Button ok = new Button(constants.OK());
                    ok.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent w) {
                            String f = b.getItemText(b.getSelectedIndex());
                            vf.fieldValues.add(new VerifyField(f, "", "=="));
                            FlexTable data = render(vf);
                            outer.setWidget(1, 0, data);
                            pop.hide();
                        }
                    });
                    pop.addRow(ok);
                    pop.show();

                }
            });

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

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

}

From source file:org.drools.guvnor.client.qa.VerifyRulesFiredWidget.java

License:Apache License

/**
 * @param rfl List<VeryfyRuleFired>
 * @param scenario = the scenario to add/remove from
 *//*w w  w  .j a v a2 s  .c  om*/
public VerifyRulesFiredWidget(final FixtureList rfl, final Scenario scenario, 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(constants.ExpectRules()));
    initWidget(outer);

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