/** Wraps a RuleModellerWidget with an icon to delete the pattern */ private Widget wrapLHSWidget(final CompositeFactPattern model, int i, RuleModellerWidget w) { DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); final Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall(); remove.setTitle( Constants.INSTANCE.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt()); final int idx = i; remove.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { if (Window.confirm(Constants.INSTANCE.RemoveThisEntireConditionQ())) { if (pattern.removeFactPattern(idx)) { getModeller().refreshWidget(); } } } }); horiz.setWidth("100%"); w.setWidth("100%"); horiz.add(w); if (!(getModeller().lockLHS() || w.isReadOnly())) { horiz.add(remove); } return horiz; }
protected Widget addRemoveButton(Widget w, ClickHandler listener) { DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); final Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall(); remove.setAltText(Constants.INSTANCE.RemoveThisBlockOfData()); remove.setTitle(Constants.INSTANCE.RemoveThisBlockOfData()); remove.addClickHandler(listener); horiz.setWidth("100%"); w.setWidth("100%"); horiz.add(w); if (!this.readOnly) { horiz.add(remove); } return horiz; }
private Widget getEditorWidget(final RuleMetadata rm, final int idx, final boolean isReadOnly) { Widget editor; if (rm.getAttributeName().equals(LOCK_LHS) || rm.getAttributeName().equals(LOCK_RHS)) { editor = new InfoPopup(Constants.INSTANCE.FrozenAreas(), Constants.INSTANCE.FrozenExplanation()); } else { editor = textBoxEditor(rm, isReadOnly); } DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); horiz.add(editor); if (!isReadOnly) { horiz.add(getRemoveMetaIcon(idx)); } return horiz; }
private Widget getEditorWidget(final RuleAttribute at, final int idx, final boolean isReadOnly) { Widget editor = null; final String attributeName = at.getAttributeName(); if (attributeName.equals(RULEFLOW_GROUP_ATTR) || attributeName.equals(AGENDA_GROUP_ATTR) || attributeName.equals(ACTIVATION_GROUP_ATTR) || attributeName.equals(TIMER_ATTR) || attributeName.equals(CALENDARS_ATTR)) { final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING); tb.setValue(at.getValue()); tb.setEnabled(!isReadOnly); if (!isReadOnly) { tb.addValueChangeHandler( new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { at.setValue(tb.getValue()); } }); } editor = tb; } else if (attributeName.equals(SALIENCE_ATTR)) { final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER); tb.setValue(at.getValue()); tb.setEnabled(!isReadOnly); if (!isReadOnly) { tb.addValueChangeHandler( new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { at.setValue(tb.getValue()); } }); } editor = tb; } else if (attributeName.equals(DURATION_ATTR)) { final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG); tb.setValue(at.getValue()); tb.setEnabled(!isReadOnly); if (!isReadOnly) { tb.addValueChangeHandler( new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { at.setValue(tb.getValue()); } }); } editor = tb; } else if (attributeName.equals(NO_LOOP_ATTR) || attributeName.equals(LOCK_ON_ACTIVE_ATTR) || attributeName.equals(AUTO_FOCUS_ATTR) || attributeName.equals(ENABLED_ATTR)) { editor = checkBoxEditor(at, isReadOnly); } else if (attributeName.equals(DATE_EFFECTIVE_ATTR) || attributeName.equals(DATE_EXPIRES_ATTR)) { if (isReadOnly) { final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING); tb.setValue(at.getValue()); tb.setEnabled(false); } else { final PopupDatePicker dp = new PopupDatePicker(false); dp.setValue(at.getValue()); dp.addValueChangeHandler( new ValueChangeHandler<Date>() { public void onValueChange(ValueChangeEvent<Date> event) { at.setValue(PopupDatePicker.convertToString(event)); } }); editor = dp; } } else if (attributeName.equals(DIALECT_ATTR)) { final ListBox lb = new ListBox(); lb.addItem(DIALECTS[0]); lb.addItem(DIALECTS[1]); lb.setEnabled(!isReadOnly); if (!isReadOnly) { lb.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { final int selectedIndex = lb.getSelectedIndex(); if (selectedIndex < 0) { return; } at.setValue(lb.getValue(selectedIndex)); } }); } if (at.getValue() == null || at.getValue().isEmpty()) { lb.setSelectedIndex(1); at.setValue(DIALECTS[1]); } else if (at.getValue().equals(DIALECTS[0])) { lb.setSelectedIndex(0); } else if (at.getValue().equals(DIALECTS[1])) { lb.setSelectedIndex(1); } else { lb.setSelectedIndex(1); at.setValue(DIALECTS[1]); } editor = lb; } DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); if (editor != null) { horiz.add(editor); if (!isReadOnly) { horiz.add(getRemoveIcon(idx)); } } return horiz; }