use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class NewPackagePopupTest method showAndCreateValidPackageTest.
@Test
public void showAndCreateValidPackageTest() {
NewPackagePopup newPackagePopup = new NewPackagePopup(view, validatorService);
final boolean[] commandExecuted = { false };
newPackagePopup.show(new Command() {
@Override
public void execute() {
commandExecuted[0] = true;
}
});
Map<String, Boolean> validationResult = new HashMap<String, Boolean>();
validationResult.put("somePackageName", true);
when(validationService.evaluateJavaIdentifiers(any(String[].class))).thenReturn(validationResult);
when(view.getPackageName()).thenReturn("somePackageName");
newPackagePopup.onCreatePackage();
// the command is executed only when a valid package name was provided.
verify(view, times(1)).hide();
assertEquals(true, commandExecuted[0]);
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DefEditorBaseViewImpl method init.
protected void init(DefEditorActionsPanelView.Presenter presenter) {
actionsPanel.setSaveCommand(new Command() {
@Override
public void execute() {
presenter.onSave();
}
});
actionsPanel.setCancelCommand(new Command() {
@Override
public void execute() {
presenter.onCancel();
}
});
actionsPanel.setDeleteCommand(new Command() {
@Override
public void execute() {
presenter.onDelete();
}
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class PopupsUtil method showOkButtonPopup.
private static void showOkButtonPopup(final String title, final String message) {
YesNoCancelPopup yesNoCancelPopup = YesNoCancelPopup.newYesNoCancelPopup(title, message, new Command() {
@Override
public void execute() {
}
}, CommonConstants.INSTANCE.OK(), null, null, null, null);
yesNoCancelPopup.setClosable(false);
yesNoCancelPopup.show();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DroolsDataObjectEditor method onExpiresChange.
@Override
public void onExpiresChange() {
if (getDataObject() != null) {
view.setExpiresOnError(false);
final Command afterCloseCommand = new Command() {
@Override
public void execute() {
view.setExpiresOnError(true);
view.selectAllExpiresText();
}
};
final String newValue = view.getExpires();
// Otherwise validate
validatorService.isValidTimerInterval(newValue, new ValidatorCallback() {
@Override
public void onFailure() {
view.showErrorPopup(Constants.INSTANCE.validation_error_invalid_timer_expression(newValue), null, afterCloseCommand);
}
@Override
public void onSuccess() {
commandBuilder.buildDataObjectAnnotationValueChangeCommand(getContext(), getName(), getDataObject(), DroolsDomainAnnotations.EXPIRES_ANNOTATION, DroolsDomainAnnotations.VALUE_PARAM, DataModelerUtils.nullTrim(newValue), true).execute();
}
});
}
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DroolsDataObjectFieldEditor method onPositionChange.
@Override
public void onPositionChange() {
if (getDataObject() != null) {
view.setPositionOnError(false);
final Command afterCloseCommand = new Command() {
@Override
public void execute() {
view.setPositionOnError(true);
view.selectAllPositionText();
}
};
final String newValue = DataModelerUtils.nullTrim(view.getPosition());
if (newValue != null && !"".equals(newValue)) {
// validate that entered value is a valid position.
int newPosition;
String error = null;
try {
newPosition = Integer.parseInt(newValue);
} catch (NumberFormatException e) {
newPosition = -1;
}
if (newPosition < 0 || newPosition >= MAX_CLASS_FIELDS) {
error = Constants.INSTANCE.validation_error_position_greater_or_equal_than_and_lower_than(newValue, "0", MAX_CLASS_FIELDS + "");
} else {
List<ObjectProperty> fieldsUsingPosition = getFieldsUsingPosition(newPosition);
if (fieldsUsingPosition.size() > 0) {
String fieldsUsingPositionNames = listNames(fieldsUsingPosition);
error = Constants.INSTANCE.validation_error_position_already_used_by_fields(newPosition + "", fieldsUsingPositionNames);
}
}
if (error != null) {
view.showErrorPopup(error, null, afterCloseCommand);
} else {
// just proceed to change the position
commandBuilder.buildFieldAnnotationValueChangeCommand(getContext(), getName(), getDataObject(), getObjectField(), DroolsDomainAnnotations.POSITION_ANNOTATION, DroolsDomainAnnotations.VALUE_PARAM, newPosition, false).execute();
view.setPosition(newPosition + "");
}
} else {
commandBuilder.buildFieldAnnotationRemoveCommand(getContext(), getName(), getDataObject(), getObjectField(), DroolsDomainAnnotations.POSITION_ANNOTATION).execute();
view.setPosition(null);
}
}
}
Aggregations