List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter
public FlexCellFormatter getFlexCellFormatter()
From source file:org.drools.guvnor.client.moduleeditor.drools.SnapshotView.java
License:Apache License
private Widget header() { FlexTable ft = new FlexTable(); ft.setWidget(0, 0, new Label(Constants.INSTANCE.ViewingSnapshot())); ft.setWidget(0, 1, new HTML("<b>" + this.snapInfo.getName() + "</b>")); ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); ft.setWidget(1, 0, new Label(Constants.INSTANCE.ForPackage())); ft.setWidget(1, 1, new Label(this.parentConf.getName())); ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT); HTML dLink = new HTML( "<a href='" + PackageBuilderWidget.getDownloadLink(this.parentConf) + "' target='_blank'>" + Constants.INSTANCE.clickHereToDownloadBinaryOrCopyURLForDeploymentAgent() + "</a>"); ft.setWidget(2, 0, new Label(Constants.INSTANCE.DeploymentURL())); ft.setWidget(2, 1, dLink);/* w w w . j a va2s. com*/ ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT); ft.setWidget(3, 0, new Label(Constants.INSTANCE.SnapshotCreatedOn())); ft.getFlexCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT); ft.setWidget(3, 1, new Label(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT) .format(parentConf.getLastModified()))); ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT); ft.setWidget(4, 0, new Label(Constants.INSTANCE.CommentColon())); ft.setWidget(4, 1, new Label(parentConf.getCheckinComment())); ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT); HorizontalPanel actions = new HorizontalPanel(); actions.add(getDeleteButton(this.snapInfo.getName(), this.parentConf.getName())); actions.add(getCopyButton(this.snapInfo.getName(), this.parentConf.getName())); ft.setWidget(5, 0, actions); ft.setWidget(6, 0, getCompareWidget(this.parentConf.getName(), this.snapInfo.getName())); ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT); ft.getFlexCellFormatter().setColSpan(5, 0, 2); return ft; }
From source file:org.drools.guvnor.client.packages.PackageEditor.java
License:Apache License
private void refreshWidgets() { clear();/* www. ja va2 s . c o m*/ FlexTable headerWidgets = new FlexTable(); headerWidgets.setWidget(0, 0, new HTML("<b>" + constants.PackageName() + ":</b>")); //NON-NLS headerWidgets.setWidget(0, 1, new Label(this.conf.name)); if (!conf.isSnapshot) { headerWidgets.setWidget(1, 0, modifyWidgets()); headerWidgets.getFlexCellFormatter().setColSpan(1, 0, 2); } addHeader(images.packageLarge(), headerWidgets); startSection(constants.ConfigurationSection()); addRow(warnings()); addAttribute(constants.Configuration(), header()); addAttribute(constants.DescriptionColon(), description()); addAttribute(constants.CategoryRules(), getAddCatRules()); addAttribute("", getShowCatRules()); if (!conf.isSnapshot) { Button save = new Button(constants.SaveAndValidateConfiguration()); save.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { doSaveAction(null); } }); addAttribute("", save); } endSection(); if (!conf.isSnapshot) { startSection(constants.BuildAndValidate()); addRow(new PackageBuilderWidget(this.conf, editEvent)); endSection(); } startSection(constants.InformationAndImportantURLs()); if (!conf.isSnapshot) { addAttribute(constants.LastModified() + ":", new Label(getDateString(conf.lastModified))); } addAttribute(constants.LastContributor() + ":", new Label(this.conf.lasContributor)); addAttribute(constants.DateCreated(), new Label(getDateString(this.conf.dateCreated))); Button buildSource = new Button(constants.ShowPackageSource()); buildSource.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { PackageBuilderWidget.doBuildSource(conf.uuid, conf.name); } }); addAttribute(constants.ShowPackageSource() + ":", buildSource); HTML html0 = new HTML("<a href='" + getDocumentationDownload(this.conf) + "' target='_blank'>" + getDocumentationDownload(this.conf) + "</a>"); addAttribute(constants.URLForDocumention(), h(html0, constants.URLDocumentionDescription())); HTML html = new HTML("<a href='" + getSourceDownload(this.conf) + "' target='_blank'>" + getSourceDownload(this.conf) + "</a>"); addAttribute(constants.URLForPackageSource(), h(html, constants.URLSourceDescription())); HTML html2 = new HTML("<a href='" + getBinaryDownload(this.conf) + "' target='_blank'>" + getBinaryDownload(this.conf) + "</a>"); addAttribute(constants.URLForPackageBinary(), h(html2, constants.UseThisUrlInTheRuntimeAgentToFetchAPreCompiledBinary())); HTML html3 = new HTML( "<a href='" + getScenarios(this.conf) + "' target='_blank'>" + getScenarios(this.conf) + "</a>"); addAttribute(constants.URLForRunningTests(), h(html3, constants.URLRunTestsRemote())); HTML html4 = new HTML( "<a href='" + getChangeset(this.conf) + "' target='_blank'>" + getChangeset(this.conf) + "</a>"); addAttribute(constants.ChangeSet(), h(html4, constants.URLToChangeSetForDeploymentAgents())); status = new HTML(); HorizontalPanel statusBar = new HorizontalPanel(); Image editState = new ImageButton(images.edit()); editState.setTitle(constants.ChangeStatusDot()); editState.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showStatusChanger((Widget) event.getSource()); } }); statusBar.add(status); if (!this.conf.isSnapshot) { statusBar.add(editState); } setState(conf.state); addAttribute(constants.Status() + ":", statusBar); endSection(); }
From source file:org.drools.guvnor.client.packages.PackageEditor2.java
License:Apache License
private void refreshWidgets() { clear();/*from w ww . ja v a 2s . c o m*/ FlexTable headerWidgets = new FlexTable(); headerWidgets.setWidget(0, 0, new HTML("<b>Package name:</b>")); headerWidgets.setWidget(0, 1, new Label(this.conf.name)); if (!conf.isSnapshot) { //headerWidgets.setWidget(1, 1, modifyWidgets() ); headerWidgets.setWidget(1, 0, modifyWidgets()); headerWidgets.getFlexCellFormatter().setColSpan(1, 0, 2); } addHeader("images/package_large.png", headerWidgets); //addHeader( "images/package_large.png", headerWidgets ); startSection("Configuration"); addRow(warnings()); addAttribute("Configuration:", header()); addAttribute("Description:", description()); addAttribute("Category Rules:", getAddCatRules()); addAttribute("", getShowCatRules()); if (!conf.isSnapshot) { Button save = new Button("Save and validate configuration"); save.addClickListener(new ClickListener() { public void onClick(Widget w) { doSaveAction(null); } }); addAttribute("", save); } endSection(); if (!conf.isSnapshot) { startSection("Build and validate"); addRow(new PackageBuilderWidget(this.conf, editEvent)); endSection(); } startSection("Information"); if (!conf.isSnapshot) { addAttribute("Last modified:", new Label(getDateString(conf.lastModified))); } addAttribute("Last contributor:", new Label(this.conf.lasContributor)); addAttribute("Date created:", new Label(getDateString(this.conf.dateCreated))); Button buildSource = new Button("Show package source"); buildSource.addClickListener(new ClickListener() { public void onClick(Widget w) { PackageBuilderWidget.doBuildSource(conf.uuid, conf.name); } }); addAttribute("View source for package:", buildSource); HTML html = new HTML("<a href='" + getDownloadLink(this.conf) + "' target='_blank'>Download source</a>"); addAttribute("Download package source:", html); status = new HTML(); HorizontalPanel statusBar = new HorizontalPanel(); Image editState = new ImageButton("images/edit.gif"); editState.setTitle("Change status."); editState.addClickListener(new ClickListener() { public void onClick(Widget w) { showStatusChanger(w); } }); statusBar.add(status); if (!this.conf.isSnapshot) { statusBar.add(editState); } setState(conf.state); addAttribute("Status:", statusBar); endSection(); }
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();// w w w .j av a2s .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.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.VerifyFactWidget.java
License:Apache License
private FlexTable render(final VerifyFact vf) { FlexTable data = new FlexTable(); for (int i = 0; i < vf.fieldValues.size(); i++) { final VerifyField fld = (VerifyField) vf.fieldValues.get(i); data.setWidget(i, 1, new SmallLabel(fld.fieldName + ":")); data.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT); final ListBox opr = new ListBox(); opr.addItem(constants.equalsScenario(), "=="); opr.addItem(constants.doesNotEqualScenario(), "!="); if (fld.operator.equals("==")) { opr.setSelectedIndex(0);//w w w. j av a 2 s . com } else { opr.setSelectedIndex(1); } opr.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { fld.operator = opr.getValue(opr.getSelectedIndex()); } }); data.setWidget(i, 2, opr); Widget cellEditor = new VerifyFieldConstraintEditor(type, new ValueChanged() { public void valueChanged(String newValue) { fld.expected = newValue; } }, fld, sce, this.scenario, this.executionTrace); data.setWidget(i, 3, cellEditor); Image del = new ImageButton(images.deleteItemSmall(), constants.RemoveThisFieldExpectation(), new ClickHandler() { public void onClick(ClickEvent w) { if (Window.confirm(Format.format( constants.AreYouSureYouWantToRemoveThisFieldExpectation(), fld.fieldName))) { vf.fieldValues.remove(fld); FlexTable data = render(vf); outer.setWidget(1, 0, data); } } }); data.setWidget(i, 4, del); if (showResults && fld.successResult != null) { if (!fld.successResult.booleanValue()) { data.setWidget(i, 0, new Image(images.warning())); data.setWidget(i, 5, new HTML(Format.format(constants.ActualResult(), fld.actualResult))); data.getCellFormatter().addStyleName(i, 5, "testErrorValue"); //NON-NLS } else { data.setWidget(i, 0, new Image(images.testPassed())); } } } return data; }
From source file:org.drools.guvnor.client.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.successResult != null) { if (!v.successResult.booleanValue()) { data.setWidget(i, 0, new Image(images.warning())); data.setWidget(i, 4, new HTML(Format.format(constants.ActualResult(), v.actualResult))); data.getCellFormatter().addStyleName(i, 4, "testErrorValue"); //NON-NLS } else { data.setWidget(i, 0, new Image(images.testPassed())); }//from www .ja v a2 s . c om } data.setWidget(i, 1, new SmallLabel(v.ruleName + ":")); data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE); final ListBox b = new ListBox(); b.addItem(constants.firedAtLeastOnce(), "y"); b.addItem(constants.didNotFire(), "n"); b.addItem(constants.firedThisManyTimes(), "e"); final TextBox num = new TextBox(); num.setVisibleLength(5); if (v.expectedFire != null) { b.setSelectedIndex((v.expectedFire.booleanValue()) ? 0 : 1); num.setVisible(false); } else { b.setSelectedIndex(2); String xc = (v.expectedCount != null) ? "" + v.expectedCount.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.expectedFire = (s.equals("y")) ? Boolean.TRUE : Boolean.FALSE; v.expectedCount = null; } else { num.setVisible(true); v.expectedFire = null; num.setText("1"); v.expectedCount = new Integer(1); } } }); b.addItem(constants.ChooseDotDotDot()); num.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { v.expectedCount = new Integer(num.getText()); } }); HorizontalPanel h = new HorizontalPanel(); h.add(b); h.add(num); data.setWidget(i, 2, h); Image del = new ImageButton(images.deleteItemSmall(), constants.RemoveThisRuleExpectation(), new ClickHandler() { public void onClick(ClickEvent w) { if (Window.confirm(constants.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.ruleeditor.DSLRuleEditor.java
License:Apache License
public DSLRuleEditor(RuleAsset asset) { RuleContentText cont = (RuleContentText) asset.content; this.data = cont; text = new TextArea(); text.setWidth("100%"); // text.setHeight( "100%" ); text.setVisibleLines(16);/*from w ww . j a va 2s .c o m*/ text.setText(data.content); text.setTitle("Hint: press control+space for popup assistance, or use one of the icons to the right."); SuggestionCompletionEngine eng = SuggestionCompletionCache.getInstance() .getEngineFromCache(asset.metaData.packageName); this.actions = eng.actionDSLSentences; this.conditions = eng.conditionDSLSentences; text.setStyleName("dsl-text-Editor"); FlexTable layout = new FlexTable(); layout.setWidget(0, 0, text); text.addChangeListener(new ChangeListener() { public void onChange(Widget w) { data.content = text.getText(); makeDirty(); } }); text.addKeyboardListener(new KeyboardListenerAdapter() { public void onKeyDown(Widget arg0, char arg1, int arg2) { if (arg1 == ' ' && arg2 == MODIFIER_CTRL) { showInTextOptions(); } if (arg1 == KEY_TAB) { insertText("\t"); text.setCursorPos(text.getCursorPos() + 1); text.cancelKey(); } } }); VerticalPanel vert = new VerticalPanel(); Image lhsOptions = new ImageButton("images/new_dsl_pattern.gif"); final String msg = "Add a new condition"; lhsOptions.setTitle(msg); lhsOptions.addClickListener(new ClickListener() { public void onClick(Widget w) { showSuggestions(conditions); } }); Image rhsOptions = new ImageButton("images/new_dsl_action.gif"); final String msg2 = "Add an action"; rhsOptions.setTitle(msg2); rhsOptions.addClickListener(new ClickListener() { public void onClick(Widget w) { 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.ruleeditor.FactsConstraintsEditorPanel.java
License:Apache License
public FactsConstraintsEditorPanel(WorkingSetEditor workingSetEditor) { this.workingSetEditor = workingSetEditor; this.workingSet = workingSetEditor.getWorkingSet(); factsCombo.setVisibleItemCount(1);//w w w . ja v a 2s. 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 = new ImageButton(images.newItem()); addNewConstraint.setTitle(constants.AddNewConstraint()); addNewConstraint.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showNewConstrainPop(); } }); Image removeConstraint = new Image(images.trash()); removeConstraint.setTitle(constants.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.FactTypes())); vp.add(factsCombo); table.setWidget(0, 0, vp); vp = new VerticalPanel(); vp.add(new SmallLabel(constants.Field())); vp.add(fieldsCombo); table.setWidget(1, 0, vp); vp = new VerticalPanel(); HorizontalPanel hp = new HorizontalPanel(); vp.add(new SmallLabel(constants.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.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.workbench.screens.guided.rule.client.widget.FactPatternWidget.java
License:Apache License
/** * This will render a field constraint into the given table. The row is the * row number to stick it into./*from w w w.j ava 2 s .com*/ */ private void renderFieldConstraint(final FlexTable inner, int row, FieldConstraint constraint, HasConstraints hasConstraints, boolean showBinding, int tabs) { //if nesting, or predicate, then it will need to span 5 cols. if (constraint instanceof SingleFieldConstraint) { renderSingleFieldConstraint(inner, row, (SingleFieldConstraint) constraint, hasConstraints, showBinding, tabs); } else if (constraint instanceof CompositeFieldConstraint) { inner.setWidget(row, 1, compositeFieldConstraintEditor((CompositeFieldConstraint) constraint)); inner.getFlexCellFormatter().setColSpan(row, 1, 5); inner.setWidget(row, 0, new HTML(" ")); //NON-NLS } }
From source file:org.drools.workbench.screens.guided.rule.client.widget.FactPatternWidget.java
License:Apache License
/** * This will show the constraint editor - allowing field constraints to be * nested etc./* w ww . j av a 2 s . c o 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(constraint); } }; if (constraint.getCompositeJunctionType().equals(CompositeFieldConstraint.COMPOSITE_TYPE_AND)) { desc = GuidedRuleEditorResources.CONSTANTS.AllOf() + ":"; } else { desc = GuidedRuleEditorResources.CONSTANTS.AnyOf() + ":"; } t.setWidget(0, 0, new ClickableLabel(desc, click, !this.readOnly)); t.getFlexCellFormatter().setColSpan(0, 0, 2); FieldConstraint[] nested = constraint.getConstraints(); FlexTable inner = new FlexTable(); 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 = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall(); clear.setTitle(GuidedRuleEditorResources.CONSTANTS.RemoveThisNestedRestriction()); clear.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (Window.confirm( GuidedRuleEditorResources.CONSTANTS.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; }