List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter
public FlexCellFormatter getFlexCellFormatter()
From source file:org.drools.workbench.screens.guided.rule.client.widget.FactPatternWidget.java
License:Apache License
/** * Applies a single field constraint to the given table, and start row. *//*from w w w. j a v a2 s . c om*/ private void renderSingleFieldConstraint(final FlexTable inner, final int row, final SingleFieldConstraint constraint, final HasConstraints hasConstraints, boolean showBinding, final int tabs) { final int col = 1; //for offsetting, just a slight indent inner.setWidget(row, 0, new HTML(" ")); if (constraint.getConstraintValueType() != SingleFieldConstraint.TYPE_PREDICATE) { HorizontalPanel ebContainer = null; if (constraint instanceof SingleFieldConstraintEBLeftSide) { ebContainer = expressionBuilderLS((SingleFieldConstraintEBLeftSide) constraint, showBinding); inner.setWidget(row, 0 + col, ebContainer); } else { inner.setWidget(row, 0 + col, fieldLabel(constraint, hasConstraints, showBinding, tabs * 20)); } inner.setWidget(row, 1 + col, operatorDropDown(constraint, inner, row, 2 + col)); //Get first part of constraint.fieldName? #1=Fact1, #2=SubFact1 inner.setWidget(row, 2 + col, createValueEditor(constraint)); inner.setWidget(row, 3 + col, connectives.connectives(constraint)); if (ebContainer != null && ebContainer.getWidgetCount() > 0) { if (ebContainer.getWidget(0) instanceof ExpressionBuilder) { associateExpressionWithChangeHandler(inner, row, constraint, col, ebContainer); } } } else if (constraint.getConstraintValueType() == SingleFieldConstraint.TYPE_PREDICATE) { inner.setWidget(row, 1, predicateEditor(constraint)); inner.getFlexCellFormatter().setColSpan(row, 1, 5); } }
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();/*from www . j a va 2s .com*/ 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.VerifyFactWidget.java
License:Apache License
private FlexTable render(final VerifyFact vf) { FlexTable data = new FlexTable(); for (int i = 0; i < vf.getFieldValues().size(); i++) { final VerifyField fld = (VerifyField) vf.getFieldValues().get(i); data.setWidget(i, 1, new SmallLabel(fld.getFieldName() + ":")); data.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT); final ListBox opr = new ListBox(); opr.addItem(TestScenarioConstants.INSTANCE.equalsScenario(), "=="); opr.addItem(TestScenarioConstants.INSTANCE.doesNotEqualScenario(), "!="); if (fld.getOperator().equals("==")) { opr.setSelectedIndex(0);// w w w . j av a2 s. c o m } else { opr.setSelectedIndex(1); } opr.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { fld.setOperator(opr.getValue(opr.getSelectedIndex())); } }); data.setWidget(i, 2, opr); Widget cellEditor = new VerifyFieldConstraintEditor(type, new ValueChanged() { public void valueChanged(String newValue) { fld.setExpected(newValue); } }, fld, oracle, this.scenario, this.executionTrace); data.setWidget(i, 3, cellEditor); Image del = CommonAltedImages.INSTANCE.DeleteItemSmall(); del.setAltText(TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation()); del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation()); del.addClickHandler(new ClickHandler() { public void onClick(ClickEvent w) { if (Window.confirm(TestScenarioConstants.INSTANCE .AreYouSureYouWantToRemoveThisFieldExpectation(fld.getFieldName()))) { vf.getFieldValues().remove(fld); FlexTable data = render(vf); outer.setWidget(1, 0, data); } } }); data.setWidget(i, 4, del); if (showResults && fld.getSuccessResult() != null) { if (!fld.getSuccessResult().booleanValue()) { data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning())); data.setWidget(i, 5, new HTML(TestScenarioConstants.INSTANCE.ActualResult(fld.getActualResult()))); data.getCellFormatter().addStyleName(i, 5, "testErrorValue"); //NON-NLS } else { data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed())); } } } return 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,/*from w w w .j a v a2s . com*/ 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; }
From source file:org.ebayopensource.turmeric.monitoring.client.view.ErrorView.java
License:Open Source License
/** * @param errorData//from w ww. ja va 2 s .c o m */ private void setErrorTableData(FlexTable table, ErrorMetricData errorData) { /* * Columns: error Id, error Name, Error Count: date1, date2 Error to Call Ratio: date1, date2 */ if (errorData == null) return; String d1 = formatDateAndDuration(errorData.getMetricCriteria().date1, errorData.getMetricCriteria().durationSec); String d2 = formatDateAndDuration(errorData.getMetricCriteria().date2, errorData.getMetricCriteria().durationSec); table.clear(); table.removeAllRows(); table.setWidget(0, 2, new Label(ConsoleUtil.constants.count())); table.getFlexCellFormatter().setColSpan(0, 2, 2); table.getRowFormatter().addStyleName(0, "tbl-header1"); table.setWidget(0, 3, new Label(ConsoleUtil.constants.errorsToCalls())); table.getFlexCellFormatter().setColSpan(0, 3, 2); table.setWidget(1, 0, new Label(ConsoleUtil.constants.error())); table.setWidget(1, 1, new Label(ConsoleUtil.constants.name())); table.setWidget(1, 2, new Label(d1)); table.setWidget(1, 3, new Label(d2)); table.setWidget(1, 4, new Label(d1)); table.setWidget(1, 5, new Label(d2)); table.getRowFormatter().addStyleName(1, "tbl-header1"); if (errorData.getReturnData() == null) return; int i = 2; for (ErrorViewData evd : errorData.getReturnData()) { Label id = new Label(evd.getErrorId()); id.addStyleName("clickable"); table.setWidget(i, 0, id); Label name = new Label(evd.getErrorName()); name.addStyleName("clickable"); table.setWidget(i, 1, name); try { table.setWidget(i, 2, new Label(NumberFormat.getDecimalFormat().format(Long.valueOf(evd.getErrorCount1())))); } catch (NumberFormatException e) { table.setWidget(i, 2, new Label(ConsoleUtil.constants.error())); } try { table.setWidget(i, 3, new Label(NumberFormat.getDecimalFormat().format(Long.valueOf(evd.getErrorCount2())))); } catch (NumberFormatException e) { table.setWidget(i, 3, new Label(ConsoleUtil.constants.error())); } try { table.setWidget(i, 4, new Label( NumberFormat.getDecimalFormat().format(Double.valueOf(evd.getErrorCallRatio1())))); } catch (NumberFormatException e) { table.setWidget(i, 4, new Label(ConsoleUtil.constants.error())); } try { table.setWidget(i, 5, new Label( NumberFormat.getDecimalFormat().format(Double.valueOf(evd.getErrorCallRatio2())))); } catch (NumberFormatException e) { table.setWidget(i, 5, new Label(ConsoleUtil.constants.error())); } i++; } }
From source file:org.ebayopensource.turmeric.monitoring.client.view.ErrorView.java
License:Open Source License
private void setErrorDetailTableData(FlexTable table, ErrorMetricData errorData) { /*//from w w w .ja v a2s. co m * Columns: Consumer Name, Error Count: date1, date2 Error to Call Ratio: date1, date2 */ if (errorData == null) return; String d1 = formatDateAndDuration(errorData.getMetricCriteria().date1, errorData.getMetricCriteria().durationSec); String d2 = formatDateAndDuration(errorData.getMetricCriteria().date2, errorData.getMetricCriteria().durationSec); table.clear(); table.setWidget(0, 1, new Label(ConsoleUtil.constants.count())); table.getFlexCellFormatter().setColSpan(0, 1, 2); table.setWidget(0, 2, new Label(ConsoleUtil.constants.errorsToCalls())); table.getRowFormatter().addStyleName(0, "tbl-header1"); table.getFlexCellFormatter().setColSpan(0, 2, 2); table.setWidget(1, 0, new Label(ConsoleUtil.constants.consumers())); table.setWidget(1, 1, new Label(d1)); table.setWidget(1, 2, new Label(d2)); table.setWidget(1, 3, new Label(d1)); table.setWidget(1, 4, new Label(d2)); table.getRowFormatter().addStyleName(1, "tbl-header1"); if (errorData.getReturnData() == null) return; int i = 2; for (ErrorViewData evd : errorData.getReturnData()) { Label str = new Label(evd.getConsumer()); str.addStyleName("clickable"); table.setWidget(i, 0, str); try { table.setWidget(i, 1, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCount1()))); } catch (NumberFormatException e) { table.setWidget(i, 1, new Label(ConsoleUtil.constants.error())); } try { table.setWidget(i, 2, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCount2()))); } catch (NumberFormatException e) { table.setWidget(i, 2, new Label(ConsoleUtil.constants.error())); } try { table.setWidget(i, 3, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCallRatio1()))); } catch (NumberFormatException e) { table.setWidget(i, 3, new Label(ConsoleUtil.constants.error())); } try { table.setWidget(i, 4, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCallRatio2()))); } catch (NumberFormatException e) { table.setWidget(i, 4, new Label(ConsoleUtil.constants.error())); } i++; } }
From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.FlexTableHelper.java
License:Open Source License
/** * Fixes problem with {@link FlexCellFormatter#setRowSpan(int, int, int)}, * see comment for.// w w w . ja va 2 s .c o m * * @param flexTable * the flex table {@link #FlexTableHelper}. */ public static void fixRowSpan(final FlexTable flexTable) { Set<Element> tdToRemove = new HashSet<Element>(); { int rowCount = flexTable.getRowCount(); for (int row = 0; row < rowCount; row++) { int cellCount = flexTable.getCellCount(row); for (int cell = 0; cell < cellCount; cell++) { int colSpan = flexTable.getFlexCellFormatter().getColSpan(row, cell); int rowSpan = flexTable.getFlexCellFormatter().getRowSpan(row, cell); if (rowSpan != 1) { int column = getColumnOfCell(flexTable, row, cell); for (int row2 = row + 1; row2 < row + rowSpan; row2++) { int baseCell2 = getCellOfColumn(flexTable, row2, column); for (int cell2 = baseCell2; cell2 < baseCell2 + colSpan; cell2++) { if (cell2 != -1) { Element td = flexTable.getCellFormatter().getElement(row2, cell2); tdToRemove.add(td); } } } } } } } // remove TD elements for (Element td : tdToRemove) { Element tr = DOM.getParent(td); DOM.removeChild(tr, td); } }
From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.FlexTableHelper.java
License:Open Source License
private static int getColSpan(final FlexTable flexTable, final int row, final int cell) { return flexTable.getFlexCellFormatter().getColSpan(row, cell); }
From source file:org.eclipse.kura.web.client.settings.SecurityTab.java
License:Open Source License
protected void onRender(Element parent, int index) { super.onRender(parent, index); //setLayout(new FitLayout()); setId("device-command"); ClickHandler clickHandler1 = new ClickHandler() { @Override//from w ww. j a v a 2 s . c om public void onClick(ClickEvent event) { gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() { @Override public void onFailure(Throwable ex) { FailureHandler.handle(ex); } @Override public void onSuccess(GwtXSRFToken token) { gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() { @Override public void onFailure(Throwable ex) { FailureHandler.handle(ex); } @Override public void onSuccess(GwtXSRFToken token) { AsyncCallback<Void> callback = new AsyncCallback<Void>() { public void onFailure(Throwable caught) { Info.display(MSGS.error(), "Error reloading security policy fingerprint!"); } public void onSuccess(Void result) { Info.display(MSGS.info(), "Fingerprint successfully reloaded!"); } }; gwtSecurityService.reloadSecurityPolicyFingerprint(token, callback); } }); } }); } }; ClickHandler clickHandler2 = new ClickHandler() { @Override public void onClick(ClickEvent event) { gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() { @Override public void onFailure(Throwable ex) { FailureHandler.handle(ex); } @Override public void onSuccess(GwtXSRFToken token) { gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() { @Override public void onFailure(Throwable ex) { FailureHandler.handle(ex); } @Override public void onSuccess(GwtXSRFToken token) { AsyncCallback<Void> callback = new AsyncCallback<Void>() { public void onFailure(Throwable caught) { Info.display(MSGS.error(), "Error reloading command line fingerprint!"); } public void onSuccess(Void result) { Info.display(MSGS.info(), "Fingerprint successfully reloaded!"); } }; gwtSecurityService.reloadCommandLineFingerprint(token, callback); } }); } }); } }; VerticalPanel vPanel = new VerticalPanel(); vPanel.setSpacing(5); vPanel.setWidth("100%"); LayoutContainer description = new LayoutContainer(); description.setBorders(false); description.setLayout(new ColumnLayout()); Label descriptionLabel = new Label(MSGS.settingsSecurityDescription()); description.add(descriptionLabel); description.setStyleAttribute("padding-bottom", "10px"); vPanel.add(description); VerticalPanel buttonsVPanel = new VerticalPanel(); buttonsVPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); buttonsVPanel.setWidth("100%"); buttonsVPanel.setHeight("100%"); buttonsVPanel.setSpacing(5); Button securityPolicyButton = new Button(MSGS.settingsSecurityReloadPolicy()); securityPolicyButton.addDomHandler(clickHandler1, ClickEvent.getType()); FlexTable layout = new FlexTable(); layout.setCellSpacing(6); FlexCellFormatter cellFormatter = layout.getFlexCellFormatter(); // Add a title layout.setHTML(0, 0, MSGS.settingsSecurityReloadPolicyTitle()); cellFormatter.setColSpan(0, 0, 2); cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); // Add description and reload button layout.setHTML(1, 0, MSGS.settingsSecurityReloadPolicyDescription()); layout.setWidget(2, 0, securityPolicyButton); cellFormatter.setColSpan(2, 0, 2); cellFormatter.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER); // Wrap the content in a DecoratorPanel DecoratorPanel decPanel = new DecoratorPanel(); decPanel.setWidget(layout); decPanel.setWidth("100%"); decPanel.setHeight("100%"); buttonsVPanel.add(decPanel); //Button to reload start script fingerprint Button startScriptReloadButton = new Button(MSGS.settingsReloadStartupFingerprint()); startScriptReloadButton.addDomHandler(clickHandler2, ClickEvent.getType()); FlexTable startScriptLayout = new FlexTable(); startScriptLayout.setCellSpacing(6); FlexCellFormatter startScriptCellFormatter = startScriptLayout.getFlexCellFormatter(); // Add a title startScriptLayout.setHTML(0, 0, MSGS.settingsReloadStartupFingerprintTitle()); startScriptCellFormatter.setColSpan(0, 0, 2); startScriptCellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); // Add description and reload button startScriptLayout.setHTML(1, 0, MSGS.settingsReloadStartupFingerprintDescription()); startScriptLayout.setWidget(2, 0, startScriptReloadButton); startScriptCellFormatter.setColSpan(2, 0, 2); startScriptCellFormatter.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER); // Wrap the content in a DecoratorPanel DecoratorPanel startScriptDecPanel = new DecoratorPanel(); startScriptDecPanel.setWidth("100%"); startScriptDecPanel.setHeight("100%"); startScriptDecPanel.setWidget(startScriptLayout); buttonsVPanel.add(startScriptDecPanel); vPanel.add(buttonsVPanel); vPanel.ensureDebugId("cwVerticalPanel"); add(vPanel); }
From source file:org.freemedsoftware.gwt.client.screen.DocumentScreen.java
License:Open Source License
public DocumentScreen() { SimplePanel spanel = new SimplePanel(); initWidget(spanel);//from w ww .j a va2 s . com final FlexTable flexTable = new FlexTable(); spanel.setWidget(flexTable); flexTable.setSize("100%", "100%"); final Label label = new Label("New Label"); flexTable.setWidget(0, 0, label); final Label label_1 = new Label("New Label"); flexTable.setWidget(1, 0, label_1); final Label label_2 = new Label("New Label"); flexTable.setWidget(2, 0, label_2); final TextBox textBox = new TextBox(); flexTable.setWidget(2, 1, textBox); textBox.setWidth("100%"); flexTable.setWidget(3, 0, sP); flexTable.getFlexCellFormatter().setColSpan(3, 0, 2); }