List of usage examples for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE
VerticalAlignmentConstant ALIGN_MIDDLE
To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.
Click Source Link
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.ExpressionBuilder.java
License:Apache License
public ExpressionBuilder(RuleModeller modeller, EventBus eventBus, ExpressionFormLine expression, Boolean readOnly) {/* w ww . ja v a 2 s. c o m*/ super(modeller, eventBus); this.expression = expression; if (readOnly == null) { this.readOnly = !modeller.getSuggestionCompletions() .containsFactType(modeller.getSuggestionCompletions() .getFactNameFromType(this.expression.getRootExpression().getClassType())); } else { this.readOnly = readOnly; } panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); StringBuilder bindingLabel = new StringBuilder(); String binding = getBoundText(); if (binding != null && !binding.equals("")) { bindingLabel.append("<b>"); bindingLabel.append(getBoundText()); bindingLabel.append("</b>"); } bindingLabel.append(expression.getText(false)); 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(bindingLabel.toString())); } else { bindingLabel.append("."); panel.add(createWidgetForExpression(bindingLabel.toString())); panel.add(getWidgetForCurrentType()); } } initWidget(panel); }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.factPattern.Connectives.java
License:Apache License
public Widget connectives(SingleFieldConstraint c, String factClass) { HorizontalPanel hp = new HorizontalPanel(); if (c.connectives != null && c.connectives.length > 0) { hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); for (int i = 0; i < c.connectives.length; i++) { ConnectiveConstraint con = c.connectives[i]; hp.add(connectiveOperatorDropDown(con)); hp.add(connectiveValueEditor(con)); if (!isReadOnly) { Image clear = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); clear.setAltText(Constants.INSTANCE.RemoveThisRestriction()); clear.setTitle(Constants.INSTANCE.RemoveThisRestriction()); clear.addClickHandler(createClickHandlerForClearImageButton(c, i)); hp.add(clear);//from w w w. ja va2 s. c om } } } return hp; }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModeller.java
License:Apache License
/** * Do all the widgets for the RHS./*from w w w . ja v a 2 s.c o 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); w.setWidth("100%"); widget.add(spacerWidget()); DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); horiz.setWidth("100%"); //horiz.setBorderWidth(2); Image remove = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); remove.setTitle(Constants.INSTANCE.RemoveThisAction()); final int idx = i; remove.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (Window.confirm(Constants.INSTANCE.RemoveThisItem())) { model.removeRhsItem(idx); refreshWidget(); //Signal possible change in Template variables TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(model); eventBus.fireEventFromSource(tvce, model); } } }); horiz.add(w); if (!(w instanceof ActionRetractFactWidget)) { w.setWidth("100%"); //NON-NLS horiz.setWidth("100%"); } if (!(this.lockRHS() || w.isReadOnly())) { horiz.add(remove); } widget.add(horiz); layout.setHTML(currentLayoutRow, 0, "<div class='form-field'>" + (i + 1) + ".</div>"); layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0, HasHorizontalAlignment.ALIGN_CENTER); layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0, HasVerticalAlignment.ALIGN_MIDDLE); layout.setWidget(currentLayoutRow, 1, widget); layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT); layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP); layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%"); final int index = i; if (!(this.lockRHS() || w.isReadOnly())) { this.addActionsButtonsToLayout(Constants.INSTANCE.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.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModeller.java
License:Apache License
/** * Builds all the condition widgets./* www .ja v a2s. 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]; RuleModellerWidget w = getWidgetFactory().getWidget(this, eventBus, pattern, readOnly); w.addOnModifiedCommand(this.onWidgetModifiedCommand); vert.add(wrapLHSWidget(model, i, w)); vert.add(spacerWidget()); layout.setWidget(currentLayoutRow, 0, this.wrapLineNumber(i + 1, true)); layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0, HasHorizontalAlignment.ALIGN_CENTER); layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0, HasVerticalAlignment.ALIGN_MIDDLE); layout.setWidget(currentLayoutRow, 1, vert); layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT); layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP); layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%"); final int index = i; if (!(this.lockLHS() || w.isReadOnly())) { this.addActionsButtonsToLayout(Constants.INSTANCE.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(w); currentLayoutRow++; } }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModeller.java
License:Apache License
private void addActionsButtonsToLayout(String title, ClickHandler addBelowListener, ClickHandler moveDownListener, ClickHandler moveUpListener) { final DirtyableHorizontalPane hp = new DirtyableHorizontalPane(); Image addPattern = DroolsGuvnorImages.INSTANCE.NewItemBelow(); addPattern.setTitle(title);/*w w w . ja v a2 s . c o m*/ addPattern.addClickHandler(addBelowListener); Image moveDown = DroolsGuvnorImages.INSTANCE.MoveDown(); moveDown.setTitle(Constants.INSTANCE.MoveDown()); moveDown.addClickHandler(moveDownListener); Image moveUp = DroolsGuvnorImages.INSTANCE.MoveUp(); moveUp.setTitle(Constants.INSTANCE.MoveUp()); moveUp.addClickHandler(moveUpListener); hp.add(addPattern); hp.add(moveDown); hp.add(moveUp); layout.setWidget(currentLayoutRow, 2, hp); layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER); layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE); }
From source file:org.drools.guvnor.client.common.FormStyleLayout.java
License:Apache License
/** * Add a widget to the "form"// w w w .j a v a 2 s . c om * * @param lbl * The label displayed in column 0 * @param editor * The Widget displayed in column 1 * @return Index of row created */ public int addAttribute(String lbl, Widget editor) { String id = DOM.createUniqueId(); if (editor instanceof CheckBox) { editor.getElement().getFirstChildElement().setAttribute("aria-labelledby", id); editor.getElement().getFirstChildElement().setAttribute("aria-required", String.valueOf(true)); editor.getElement().getFirstChildElement().setTabIndex(0); } else { editor.getElement().setAttribute("aria-labelledby", id); editor.getElement().setAttribute("aria-required", String.valueOf(true)); editor.getElement().setTabIndex(0); } int row = numInLayout; HTML label = new HTML("<div class='form-field' id=" + id + ">" + lbl + "</div>"); layout.setWidget(numInLayout, 0, label); formatter.setAlignment(numInLayout, 0, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE); layout.setWidget(numInLayout, 1, editor); formatter.setAlignment(numInLayout, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE); numInLayout++; return row; }
From source file:org.drools.guvnor.client.common.FormStyleLayout.java
License:Apache License
private void doHeader(Image image, Widget title) { //The image in FormStyleLayout is merely for the purpose of decoration, no need to set it's alt text for section 508. image.setAltText(""); layout.setWidget(0, 0, image);//from ww w. j ava2 s . co m formatter.setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE); layout.setWidget(0, 1, title); numInLayout++; }
From source file:org.drools.guvnor.client.decisiontable.GuidedDecisionTableWidget.java
License:Apache License
private void refreshAttributeWidget() { this.attributeConfigWidget.clear(); if (guidedDecisionTable.getMetadataCols().size() > 0) { HorizontalPanel hp = new HorizontalPanel(); hp.add(new HTML(" ")); hp.add(new SmallLabel(Constants.INSTANCE.Metadata1())); attributeConfigWidget.add(hp);/*from w w w .j a v a 2s . c o m*/ } for (MetadataCol52 atc : guidedDecisionTable.getMetadataCols()) { HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hp.add(new HTML(" ")); if (!isReadOnly) { hp.add(removeMeta(atc)); } final SmallLabel label = makeColumnLabel(atc); hp.add(label); final MetadataCol52 at = atc; final CheckBox hide = new CheckBox(Constants.INSTANCE.HideThisColumn()); hide.setStyleName("form-field"); hide.setValue(atc.isHideColumn()); hide.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { at.setHideColumn(hide.getValue()); dtable.setColumnVisibility(at, !at.isHideColumn()); setColumnLabelStyleWhenHidden(label, hide.getValue()); } }); hp.add(new HTML(" ")); hp.add(hide); attributeConfigWidget.add(hp); } if (guidedDecisionTable.getAttributeCols().size() > 0) { HorizontalPanel hp = new HorizontalPanel(); hp.add(new HTML(" ")); hp.add(new SmallLabel(Constants.INSTANCE.Attributes())); attributeConfigWidget.add(hp); } for (AttributeCol52 atc : guidedDecisionTable.getAttributeCols()) { final AttributeCol52 at = atc; HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hp.add(new HTML(" ")); if (!isReadOnly) { hp.add(removeAttr(at)); } final SmallLabel label = makeColumnLabel(atc); hp.add(label); final TextBox defaultValue = new TextBox(); final DTCellValue52 dcv = at.getDefaultValue(); defaultValue.setStyleName("form-field"); defaultValue.setText((dcv == null ? "" : dcv.getStringValue())); defaultValue.setEnabled(!isReadOnly); defaultValue.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { at.setDefaultValue(new DTCellValue52(defaultValue.getText())); } }); if (at.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) { hp.add(new HTML(" ")); final CheckBox useRowNumber = new CheckBox(Constants.INSTANCE.UseRowNumber()); useRowNumber.setStyleName("form-field"); useRowNumber.setValue(at.isUseRowNumber()); useRowNumber.setEnabled(!isReadOnly); hp.add(useRowNumber); hp.add(new SmallLabel("(")); final CheckBox reverseOrder = new CheckBox(Constants.INSTANCE.ReverseOrder()); reverseOrder.setStyleName("form-field"); reverseOrder.setValue(at.isReverseOrder()); reverseOrder.setEnabled(at.isUseRowNumber() && !isReadOnly); useRowNumber.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { at.setUseRowNumber(useRowNumber.getValue()); reverseOrder.setEnabled(useRowNumber.getValue()); dtable.updateSystemControlledColumnValues(); } }); reverseOrder.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { at.setReverseOrder(reverseOrder.getValue()); dtable.updateSystemControlledColumnValues(); } }); hp.add(reverseOrder); hp.add(new SmallLabel(")")); } hp.add(new HTML(" ")); hp.add(new SmallLabel(Constants.INSTANCE.DefaultValue())); hp.add(defaultValue); final CheckBox hide = new CheckBox(Constants.INSTANCE.HideThisColumn()); hide.setStyleName("form-field"); hide.setValue(at.isHideColumn()); hide.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { at.setHideColumn(hide.getValue()); dtable.setColumnVisibility(at, !at.isHideColumn()); setColumnLabelStyleWhenHidden(label, hide.getValue()); } }); hp.add(new HTML(" ")); hp.add(hide); attributeConfigWidget.add(hp); setupColumnsNote(); } }
From source file:org.drools.guvnor.client.explorer.navigation.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 av a2 s . c om*/ 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.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 = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); image.setAltText(Constants.INSTANCE.RemoveThisRuleFlowActivation()); ImageButton del = new ImageButton(image, Constants.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.guvnor.client.explorer.navigation.qa.testscenarios.DataInputWidget.java
License:Apache License
private void setStyles() { getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader"); //NON-NLS getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE); setStyleName("modeller-fact-pattern-Widget"); //NON-NLS }