List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter
public FlexCellFormatter getFlexCellFormatter()
From source file:org.drools.brms.client.rulelist.AssetBrowser.java
License:Apache License
/** This will setup the explorer tab */ private FlexTable doExplorer() { final FlexTable table = new FlexTable(); //and the the delegate to open an editor for a rule resource when //chosen to/*from ww w. ja va 2 s.c o m*/ list = new AssetItemListViewer(new EditItemEvent() { public void open(String key) { showLoadEditor(key); } }, AssetItemListViewer.RULE_LIST_TABLE_ID); FlexCellFormatter formatter = table.getFlexCellFormatter(); //setup the nav, which will drive the list CategoryExplorerWidget nav = new CategoryExplorerWidget(new CategorySelectHandler() { public void selected(final String selectedPath) { Command load = getRuleListLoadingCommand(list, selectedPath); table.setWidget(0, 1, list); LoadingPopup.showMessage("Retrieving list, please wait..."); DeferredCommand.add(load); list.setRefreshCommand(load); } }); final QuickFindWidget quick = new QuickFindWidget(new EditItemEvent() { public void open(String key) { showLoadEditor(key); } }); table.setWidget(0, 1, quick); formatter.setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); formatter.setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); formatter.setWidth(0, 0, "30%"); formatter.setWidth(0, 1, "70%"); // formatter.setHeight( 0, // 0, // "90%" ); //Image newRule = new ImageButton( "images/new_rule.gif" ); Button newRule = new Button("Create new rule"); newRule.setTitle("Create new rule"); newRule.addClickListener(new ClickListener() { public void onClick(Widget w) { showNewAssetWizard(); } }); Image showFinder = new ImageButton("images/system_search_small.png"); showFinder.setTitle("Show the rule finder."); showFinder.addClickListener(new ClickListener() { public void onClick(Widget w) { table.setWidget(0, 1, quick); } }); HorizontalPanel actions = new HorizontalPanel(); actions.add(newRule); actions.add(showFinder); actions.setStyleName("new-asset-Icons"); VerticalPanel left = new VerticalPanel(); left.add(actions); left.add(nav); left.setWidth("100%"); table.setWidget(0, 0, left); return table; }
From source file:org.drools.brms.client.rulelist.QuickFindWidget.java
License:Apache License
protected void populateList(TableDataResult result) { FlexTable data = new FlexTable(); //if its only one, just open it... if (result.data.length == 1) { editEvent.open(result.data[0].id); }/*from w w w.j a v a2 s . c o m*/ for (int i = 0; i < result.data.length; i++) { final TableDataRow row = result.data[i]; if (row.id.equals("MORE")) { data.setWidget(i, 0, new HTML("<i>There are more items... try narrowing the search terms..</i>")); data.getFlexCellFormatter().setColSpan(i, 0, 3); } else { data.setWidget(i, 0, new Label(row.values[0])); data.setWidget(i, 1, new Label(row.values[1])); Button open = new Button("Open"); open.addClickListener(new ClickListener() { public void onClick(Widget w) { editEvent.open(row.id); } }); data.setWidget(i, 2, open); } } data.setWidth("100%"); listPanel.setWidget(0, 0, data); LoadingPopup.close(); }
From source file:org.drools.guvnor.client.admin.RepoConfigManager.java
License:Apache License
public DecoratorPanel getDbTypePanel() { FlexTable layoutA = new FlexTable(); layoutA.setCellSpacing(6);//from w ww. j a va 2s.c o m FlexCellFormatter cellFormatter = layoutA.getFlexCellFormatter(); // Add a title to the form layoutA.setHTML(0, 0, "RDBMS Info"); cellFormatter.setColSpan(0, 0, 2); cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); layoutA.setHTML(1, 0, constants.SelectRdbmsType()); final ListBox databaseList = getDatabaseList(); databaseList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { ListBox listBox = (ListBox) event.getSource(); int index = listBox.getSelectedIndex(); rdbmsConf.setDbType(listBox.getItemText(index)); layoutB.setHTML(0, 0, listBox.getItemText(index) + " Info"); layoutC.setHTML(0, 0, listBox.getItemText(index) + " Info"); repoDisplayArea.setVisible(false); saveRepoConfigForm.setVisible(false); } }); if (rdbmsConf.getDbType() == null || rdbmsConf.getDbType().length() < 1) { databaseList.setSelectedIndex(0); } else { for (int i = 0; i < databaseList.getItemCount(); i++) { if (rdbmsConf.getDbType().equals(databaseList.getItemText(i))) { databaseList.setSelectedIndex(i); break; } } } databaseList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { rdbmsConf.setDbType(databaseList.getValue(databaseList.getSelectedIndex())); } }); layoutA.setWidget(1, 1, databaseList); layoutA.setHTML(2, 0, constants.UseJndi()); final CheckBox useJndi = new CheckBox(); useJndi.setValue(rdbmsConf.isJndi()); useJndi.addClickHandler(new ClickHandler() { public void onClick(ClickEvent w) { rdbmsConf.setJndi(useJndi.isEnabled()); if (useJndi.isEnabled()) { noJndiInfo.setVisible(false); jndiInfo.setVisible(true); } else { noJndiInfo.setVisible(true); jndiInfo.setVisible(false); } repoDisplayArea.setVisible(false); saveRepoConfigForm.setVisible(false); } }); layoutA.setWidget(2, 1, useJndi); Button continueButton = new Button("Continue"); continueButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent w) { if (databaseList.getSelectedIndex() == 0) { Window.alert(constants.PleaseSelectRdbmsType()); return; } if (!useJndi.isEnabled()) { jndiInfo.setVisible(false); } vPanel2.setVisible(true); } }); layoutA.setWidget(3, 1, continueButton); DecoratorPanel decPanel = new DecoratorPanel(); decPanel.setWidget(layoutA); return decPanel; }
From source file:org.drools.guvnor.client.asseteditor.drools.DSLRuleEditor.java
License:Apache License
public DSLRuleEditor(Asset asset) { RuleContentText cont = (RuleContentText) asset.getContent(); this.data = cont; text = new TextArea(); text.setWidth("100%"); text.setVisibleLines(16);/*from w w w. jav a 2s . c om*/ text.setText(data.content); SuggestionCompletionEngine eng = SuggestionCompletionCache.getInstance() .getEngineFromCache(asset.getMetaData().getModuleName()); this.actions = eng.actionDSLSentences; this.conditions = eng.conditionDSLSentences; text.setStyleName("dsl-text-Editor"); //NON-NLS FlexTable layout = new FlexTable(); layout.setWidget(0, 0, text); text.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { data.content = text.getText(); makeDirty(); } }); text.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == ' ' && event.getNativeKeyCode() == KeyCodes.KEY_CTRL) { showInTextOptions(); } if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { int nextPos = text.getCursorPos() + 1; text.cancelKey(); insertText("\t"); text.setCursorPos(nextPos); } } }); VerticalPanel vert = new VerticalPanel(); Image lhsOptions = DroolsGuvnorImages.INSTANCE.NewDSLPattern(); lhsOptions.setTitle(Constants.INSTANCE.AddANewCondition()); lhsOptions.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showSuggestions(conditions); } }); Image rhsOptions = DroolsGuvnorImages.INSTANCE.NewDSLAction(); rhsOptions.setTitle(Constants.INSTANCE.AddAnAction()); rhsOptions.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showSuggestions(actions); } }); vert.add(lhsOptions); vert.add(rhsOptions); layout.setWidget(0, 1, vert); layout.getCellFormatter().setWidth(0, 0, "95%"); layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); layout.getCellFormatter().setWidth(0, 1, "5%"); layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE); layout.setWidth("100%"); layout.setHeight("100%"); initWidget(layout); }
From source file:org.drools.guvnor.client.asseteditor.drools.FactsConstraintsEditorPanel.java
License:Apache License
public FactsConstraintsEditorPanel(WorkingSetEditor workingSetEditor) { this.workingSetEditor = workingSetEditor; this.workingSet = workingSetEditor.getWorkingSet(); factsCombo.setVisibleItemCount(1);/*from ww w .j av a 2 s. co m*/ fieldsCombo.setVisibleItemCount(1); constraintsCombo.setVisibleItemCount(5); factsCombo.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { fillSelectedFactFields(); } }); fieldsCombo.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { fillFieldConstrains(); } }); Image addNewConstraint = DroolsGuvnorImages.INSTANCE.NewItem(); addNewConstraint.setAltText(Constants.INSTANCE.AddNewConstraint()); addNewConstraint.setTitle(Constants.INSTANCE.AddNewConstraint()); addNewConstraint.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showNewConstrainPop(); } }); Image removeConstraint = new Image(DroolsGuvnorImageResources.INSTANCE.trash()); removeConstraint.setTitle(Constants.INSTANCE.removeConstraint()); removeConstraint.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { removeConstraint(); } }); final FlexTable table = new FlexTable(); VerticalPanel vp = new VerticalPanel(); vp.add(new SmallLabel(Constants.INSTANCE.FactTypes())); vp.add(factsCombo); table.setWidget(0, 0, vp); vp = new VerticalPanel(); vp.add(new SmallLabel(Constants.INSTANCE.Field())); vp.add(fieldsCombo); table.setWidget(1, 0, vp); vp = new VerticalPanel(); HorizontalPanel hp = new HorizontalPanel(); vp.add(new SmallLabel(Constants.INSTANCE.Constraints())); hp.add(constraintsCombo); VerticalPanel btnPanel = new VerticalPanel(); btnPanel.add(addNewConstraint); btnPanel.add(removeConstraint); hp.add(btnPanel); vp.add(hp); table.setWidget(2, 0, vp); table.getFlexCellFormatter().setRowSpan(2, 0, 3); constraintsCombo.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { showConstraintConfig(); } }); vpConstraintConf.add(new SmallLabel(Constants.INSTANCE.ConstraintsParameters())); vpConstraintConf.add(new SmallLabel("")); table.setWidget(0, 1, vpConstraintConf); table.getFlexCellFormatter().setRowSpan(0, 1, 5); fillSelectedFacts(); fillSelectedFactFields(); fillFieldConstrains(); showConstraintConfig(); this.initWidget(table); }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.FactPatternWidget.java
License:Apache License
/** * This will show the constraint editor - allowing field constraints to be * nested etc.// w ww.j a v a 2s .co m */ private Widget compositeFieldConstraintEditor(final CompositeFieldConstraint constraint) { FlexTable t = new FlexTable(); String desc = null; ClickHandler click = new ClickHandler() { public void onClick(ClickEvent event) { popupCreator.showPatternPopupForComposite((Widget) event.getSource(), constraint); } }; if (constraint.compositeJunctionType.equals(CompositeFieldConstraint.COMPOSITE_TYPE_AND)) { desc = Constants.INSTANCE.AllOf() + ":"; } else { desc = Constants.INSTANCE.AnyOf() + ":"; } t.setWidget(0, 0, new ClickableLabel(desc, click, !this.readOnly)); t.getFlexCellFormatter().setColSpan(0, 0, 2); FieldConstraint[] nested = constraint.constraints; DirtyableFlexTable inner = new DirtyableFlexTable(); if (nested != null) { for (int i = 0; i < nested.length; i++) { this.renderFieldConstraint(inner, i, nested[i], constraint, true, 0); //add in remove icon here... final int currentRow = i; Image clear = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); clear.setTitle(Constants.INSTANCE.RemoveThisNestedRestriction()); clear.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (Window.confirm(Constants.INSTANCE.RemoveThisItemFromNestedConstraint())) { setModified(true); constraint.removeConstraint(currentRow); getModeller().refreshWidget(); } } }); if (!this.readOnly) { //This used to be 5 and Connectives were not rendered inner.setWidget(i, 6, clear); } } } t.setWidget(1, 1, inner); t.setWidget(1, 0, new HTML(" ")); return t; }
From source file:org.drools.guvnor.client.explorer.navigation.admin.widget.RepoConfigManager.java
License:Apache License
public DecoratorPanel getDbTypePanel() { FlexTable layoutA = new FlexTable(); layoutA.setCellSpacing(6);//from w w w. j av a 2 s.c om FlexCellFormatter cellFormatter = layoutA.getFlexCellFormatter(); // Add a title to the form layoutA.setHTML(0, 0, "RDBMS Info"); cellFormatter.setColSpan(0, 0, 2); cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); layoutA.setHTML(1, 0, constants.SelectRdbmsType()); final ListBox databaseList = getDatabaseList(); databaseList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { ListBox listBox = (ListBox) event.getSource(); int index = listBox.getSelectedIndex(); rdbmsConf.setDbType(listBox.getItemText(index)); layoutB.setHTML(0, 0, listBox.getItemText(index) + " Info"); layoutC.setHTML(0, 0, listBox.getItemText(index) + " Info"); repoDisplayArea.setVisible(false); saveRepoConfigForm.setVisible(false); } }); if (rdbmsConf.getDbType() == null || rdbmsConf.getDbType().length() < 1) { databaseList.setSelectedIndex(0); } else { for (int i = 0; i < databaseList.getItemCount(); i++) { if (rdbmsConf.getDbType().equals(databaseList.getItemText(i))) { databaseList.setSelectedIndex(i); break; } } } databaseList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { rdbmsConf.setDbType(databaseList.getValue(databaseList.getSelectedIndex())); } }); layoutA.setWidget(1, 1, databaseList); layoutA.setHTML(2, 0, constants.UseJndi()); final CheckBox useJndi = new CheckBox(); useJndi.setChecked(rdbmsConf.isJndi()); useJndi.addClickHandler(new ClickHandler() { public void onClick(ClickEvent w) { // do not change this to isEnabled..it will always return true. boolean checked = ((CheckBox) w.getSource()).getValue(); rdbmsConf.setJndi(checked); if (checked) { noJndiInfo.setVisible(false); jndiInfo.setVisible(true); } else { noJndiInfo.setVisible(true); jndiInfo.setVisible(false); } repoDisplayArea.setVisible(false); saveRepoConfigForm.setVisible(false); } }); layoutA.setWidget(2, 1, useJndi); Button continueButton = new Button("Continue"); continueButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent w) { if (databaseList.getSelectedIndex() == 0) { Window.alert(constants.PleaseSelectRdbmsType()); return; } if (!useJndi.getValue()) { jndiInfo.setVisible(false); } vPanel2.setVisible(true); } }); layoutA.setWidget(3, 1, continueButton); DecoratorPanel decPanel = new DecoratorPanel(); decPanel.setWidget(layoutA); return decPanel; }
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();// w w w. ja va2s . c o 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.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.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(Constants.INSTANCE.equalsScenario(), "=="); opr.addItem(Constants.INSTANCE.doesNotEqualScenario(), "!="); if (fld.getOperator().equals("==")) { opr.setSelectedIndex(0);/*from w w w. ja v a 2 s . co 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, sce, this.scenario, this.executionTrace); data.setWidget(i, 3, cellEditor); Image del = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); del.setAltText(Constants.INSTANCE.RemoveThisFieldExpectation()); del.setTitle(Constants.INSTANCE.RemoveThisFieldExpectation()); del.addClickHandler(new ClickHandler() { public void onClick(ClickEvent w) { if (Window.confirm( Constants.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(DroolsGuvnorImageResources.INSTANCE.warning())); data.setWidget(i, 5, new HTML(Constants.INSTANCE.ActualResult(fld.getActualResult()))); data.getCellFormatter().addStyleName(i, 5, "testErrorValue"); //NON-NLS } else { data.setWidget(i, 0, new Image(DroolsGuvnorImageResources.INSTANCE.testPassed())); } } } return 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())); }/*from ww w . j a v a 2s.c om*/ } 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; }