use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.
the class PopupCreator method doBindingEditor.
/**
* This adds in (optionally) the editor for changing the bound variable
* name. If its a bindable pattern, it will show the editor, if it is
* already bound, and the name is used, it should not be editable.
*/
private void doBindingEditor(final FormStylePopup popup) {
if (bindable || !(modeller.getModel().isBoundFactUsed(pattern.getBoundName()))) {
HorizontalPanel varName = new HorizontalPanel();
final TextBox varTxt = new BindingTextBox();
if (pattern.getBoundName() == null) {
varTxt.setText("");
} else {
varTxt.setText(pattern.getBoundName());
}
((InputElement) varTxt.getElement().cast()).setSize(6);
varName.add(varTxt);
Button bindVar = new Button(HumanReadableConstants.INSTANCE.Set());
bindVar.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varTxt.getText();
if (modeller.isVariableNameUsed(var)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
pattern.setBoundName(varTxt.getText());
modeller.refreshWidget();
popup.hide();
}
});
varName.add(bindVar);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.VariableName(), varName);
}
}
use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.
the class RuleModellerActionSelectorPopup method getContent.
@Override
public Widget getContent() {
if (position == null) {
positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length));
positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0");
for (int i = 1; i < model.rhs.length; i++) {
positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i));
}
} else {
// if position is fixed, we just add one element to the drop down.
positionCbo.addItem(String.valueOf(position));
positionCbo.setSelectedIndex(0);
}
if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) {
layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>"));
}
// only show the drop down if we are not using fixed position.
if (position == null) {
HorizontalPanel hp0 = new HorizontalPanel();
hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon()));
hp0.add(positionCbo);
hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation()));
layoutPanel.addRow(hp0);
layoutPanel.addRow(new HTML("<hr/>"));
}
choices = makeChoicesListBox();
choicesPanel.add(choices);
layoutPanel.addRow(choicesPanel);
// DSL might be prohibited (e.g. editing a DRL file. Only DSLR files can contain DSL)
if (ruleModeller.isDSLEnabled()) {
CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions());
chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements);
chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
onlyShowDSLStatements = event.getValue();
choicesPanel.setWidget(makeChoicesListBox());
}
});
layoutPanel.addRow(chkOnlyDisplayDSLConditions);
}
return layoutPanel;
}
use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.
the class ActionInsertFactWidget method showAddFieldPopup.
protected void showAddFieldPopup(Widget w) {
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddAField());
final ListBox box = new ListBox();
box.addItem("...");
final ModelField[] availableFieldCompletions = ModelFieldUtil.getAvailableFieldCompletions(fieldCompletions, model);
final boolean isEnabled = !isReadOnly() && availableFieldCompletions.length > 0;
if (availableFieldCompletions.length > 0) {
for (int i = 0; i < availableFieldCompletions.length; i++) {
box.addItem(availableFieldCompletions[i].getName());
}
}
box.setSelectedIndex(0);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddField(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String fieldName = box.getItemText(box.getSelectedIndex());
String fieldType = oracle.getFieldType(model.getFactType(), fieldName);
model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
/*
* Propose a textBox to the user to make him set a variable name
*/
final HorizontalPanel vn = new HorizontalPanel();
final TextBox varName = new TextBox();
if (this.model.getBoundName() != null) {
varName.setText(this.model.getBoundName());
}
final Button ok = new Button(HumanReadableConstants.INSTANCE.Set());
vn.add(varName);
vn.add(ok);
ok.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varName.getText();
if (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
model.setBoundName(var);
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable(), vn);
box.setEnabled(isEnabled);
varName.setEnabled(isEnabled);
ok.setEnabled(isEnabled);
popup.show();
}
use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.
the class ActionSetFieldWidget method doLayout.
private void doLayout() {
layout.clear();
for (int i = 0; i < model.getFieldValues().length; i++) {
ActionFieldValue val = model.getFieldValues()[i];
layout.setWidget(i, 0, getSetterLabel());
layout.setWidget(i, 1, fieldSelector(val));
layout.setWidget(i, 2, valueEditor(val));
final int idx = i;
Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
remove.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisItem())) {
model.removeField(idx);
setModified(true);
getModeller().refreshWidget();
// Signal possible change in Template variables
TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(getModeller().getModel());
getEventBus().fireEventFromSource(tvce, getModeller().getModel());
}
}
});
if (!this.readOnly) {
layout.setWidget(i, 3, remove);
}
}
if (model.getFieldValues().length == 0) {
HorizontalPanel h = new HorizontalPanel();
h.add(getSetterLabel());
if (!this.readOnly) {
Image image = GuidedRuleEditorImages508.INSTANCE.Edit();
image.setAltText(GuidedRuleEditorResources.CONSTANTS.AddFirstNewField());
image.setTitle(GuidedRuleEditorResources.CONSTANTS.AddFirstNewField());
image.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent sender) {
showAddFieldPopup(sender);
}
});
h.add(image);
}
layout.setWidget(0, 0, h);
}
// layout.setWidget( 0, 1, inner );
}
use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.
the class DSLSentenceWidget method addWidget.
private void addWidget(Widget currentBox) {
if (currentBox instanceof NewLine) {
currentRow = new HorizontalPanel();
layout.add(currentRow);
layout.setCellWidth(currentRow, "100%");
} else {
currentRow.add(currentBox);
}
widgets.add(currentBox);
}
Aggregations