use of org.uberfire.ext.widgets.common.client.common.ClickableLabel in project drools-wb by kiegroup.
the class FromCompositeFactPatternWidget method getCompositeLabel.
protected Widget getCompositeLabel() {
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from") + " </div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", click, !this.readOnly));
r++;
}
panel.setWidget(r, 0, new HTML(lbl));
ExpressionBuilder expressionBuilder = new ExpressionBuilder(this.getModeller(), this.getEventBus(), this.pattern.getExpression(), this.readOnly);
expressionBuilder.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
panel.setWidget(r, 1, expressionBuilder);
return panel;
}
use of org.uberfire.ext.widgets.common.client.common.ClickableLabel in project drools-wb by kiegroup.
the class FactPatternWidget method fieldLabel.
/**
* get the field widget. This may be a simple label, or it may be bound (and
* show the var name) or a icon to create a binding. It will only show the
* binding option of showBinding is true.
*/
private Widget fieldLabel(final SingleFieldConstraint con, final HasConstraints hasConstraints, final boolean showBinding, final int padding) {
HorizontalPanel ab = new HorizontalPanel();
ab.setStyleName("modeller-field-Label");
StringBuilder bindingLabel = new StringBuilder();
if (con.isBound()) {
bindingLabel.append("<b>[");
bindingLabel.append(con.getFieldBinding());
bindingLabel.append("]</b> ");
}
String fieldName = con.getFieldName();
bindingLabel.append(fieldName);
if (bindable && showBinding && !this.readOnly) {
ClickHandler click = new ClickHandler() {
public void onClick(final ClickEvent event) {
// If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type
String fieldName = con.getFieldName();
if (DataType.TYPE_THIS.equals(fieldName)) {
getConnectives().getDataModelOracle().getFieldCompletions(pattern.getFactType(), new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] fields) {
popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator);
}
});
} else {
getConnectives().getDataModelOracle().getFieldCompletions(con.getFieldType(), new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] fields) {
popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator);
}
});
}
}
};
ClickableLabel cl = new ClickableLabel(bindingLabel.toString(), click, !this.readOnly);
DOM.setStyleAttribute(cl.getElement(), "marginLeft", "" + padding + "pt");
ab.add(cl);
} else {
ab.add(new SmallLabel(bindingLabel.toString()));
}
return ab;
}
use of org.uberfire.ext.widgets.common.client.common.ClickableLabel in project drools-wb by kiegroup.
the class FromCollectCompositeFactPatternWidget method getCompositeLabel.
@Override
protected Widget getCompositeLabel() {
ClickHandler leftPatternclick = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
ClickHandler rightPatternclick = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget w = (Widget) event.getSource();
showRightPatternSelector(w);
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from collect") + "</div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", leftPatternclick, !this.readOnly));
}
panel.setWidget(r++, 0, new HTML(lbl));
if (this.getFromCollectPattern().getRightPattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", rightPatternclick, !this.readOnly));
} else {
IPattern rPattern = this.getFromCollectPattern().getRightPattern();
RuleModellerWidget patternWidget = null;
if (rPattern instanceof FactPattern) {
patternWidget = new FactPatternWidget(this.getModeller(), this.getEventBus(), rPattern, true, true, this.readOnly);
} else if (rPattern instanceof FromAccumulateCompositeFactPattern) {
patternWidget = new FromAccumulateCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromAccumulateCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromCollectCompositeFactPattern) {
patternWidget = new FromCollectCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCollectCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromEntryPointFactPattern) {
patternWidget = new FromEntryPointFactPatternWidget(this.getModeller(), this.getEventBus(), (FromEntryPointFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromCompositeFactPattern) {
patternWidget = new FromCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FreeFormLine) {
patternWidget = new FreeFormLineWidget(this.getModeller(), this.getEventBus(), (FreeFormLine) rPattern, this.readOnly);
} else {
throw new IllegalArgumentException("Unsupported pattern " + rPattern + " for right side of FROM COLLECT");
}
patternWidget.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
panel.setWidget(r++, 0, addRemoveButton(patternWidget, new ClickHandler() {
public void onClick(ClickEvent event) {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisBlockOfData())) {
setModified(true);
getFromCollectPattern().setRightPattern(null);
getModeller().refreshWidget();
}
}
}));
}
return panel;
}
use of org.uberfire.ext.widgets.common.client.common.ClickableLabel in project drools-wb by kiegroup.
the class CompositeFactPatternWidget method getCompositeLabel.
protected Widget getCompositeLabel() {
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget w = (Widget) event.getSource();
showFactTypeSelector(w);
}
};
String lbl = HumanReadable.getCEDisplayName(pattern.getType());
if (pattern.getPatterns() == null || pattern.getPatterns().length == 0) {
lbl += " <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>";
}
return new ClickableLabel(lbl + ":", click, !this.readOnly);
}
use of org.uberfire.ext.widgets.common.client.common.ClickableLabel in project drools-wb by kiegroup.
the class FactPatternWidget method getPatternLabel.
/**
* This returns the pattern label.
*/
private Widget getPatternLabel(final FactPattern fp) {
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
popupCreator.showPatternPopup(fp, null, false);
}
};
String patternName = (pattern.isBound()) ? pattern.getFactType() + " <b>[" + pattern.getBoundName() + "]</b>" : pattern.getFactType();
String desc;
if (isAll0WithLabel) {
desc = GuidedRuleEditorResources.CONSTANTS.All0with(patternName);
} else {
if (pattern.getNumberOfConstraints() > 0) {
desc = GuidedRuleEditorResources.CONSTANTS.ThereIsAAn0With(patternName);
} else {
desc = GuidedRuleEditorResources.CONSTANTS.ThereIsAAn0(patternName);
}
desc = anA(desc, patternName);
}
return new ClickableLabel(desc, click, !this.readOnly);
}
Aggregations