use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class MainDataObjectFieldEditor method doFieldNameChange.
private void doFieldNameChange(final String oldValue, final String newValue) {
final Command afterCloseCommand = new Command() {
@Override
public void execute() {
view.setNameOnError(true);
view.selectAllNameText();
}
};
// In case an invalid name (entered before), was corrected to the original value, don't do anything but reset the label style
if (oldValue.equalsIgnoreCase(view.getName())) {
view.setName(oldValue);
view.setNameOnError(false);
return;
}
validatorService.isValidIdentifier(newValue, new ValidatorCallback() {
@Override
public void onFailure() {
view.showErrorPopup(Constants.INSTANCE.validation_error_invalid_object_attribute_identifier(newValue), null, afterCloseCommand);
}
@Override
public void onSuccess() {
validatorService.isUniqueAttributeName(newValue, getDataObject(), new ValidatorWithReasonCallback() {
@Override
public void onFailure() {
showFailure(ValidatorService.MANAGED_PROPERTY_EXISTS);
}
@Override
public void onFailure(String reason) {
showFailure(reason);
}
private void showFailure(String reason) {
if (ValidatorService.UN_MANAGED_PROPERTY_EXISTS.equals(reason)) {
ObjectProperty unmanagedProperty = getDataObject().getUnManagedProperty(newValue);
view.showErrorPopup(Constants.INSTANCE.validation_error_object_un_managed_attribute_already_exists(unmanagedProperty.getName(), unmanagedProperty.getClassName()));
} else {
view.showErrorPopup(Constants.INSTANCE.validation_error_object_attribute_already_exists(newValue));
}
}
@Override
public void onSuccess() {
view.setNameOnError(false);
objectField.setName(newValue);
notifyChange(createFieldChangeEvent(ChangeType.FIELD_NAME_CHANGE).withOldValue(oldValue).withNewValue(newValue));
}
});
}
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DataModelerScreenViewImpl method showYesNoCancelPopup.
@Override
public void showYesNoCancelPopup(String title, String message, Command yesCommand, String yesButtonText, ButtonType yesButtonType, Command noCommand, String noButtonText, ButtonType noButtonType) {
YesNoCancelPopup yesNoCancelPopup = YesNoCancelPopup.newYesNoCancelPopup(title, message, yesCommand, yesButtonText, yesButtonType, noCommand, noButtonText, noButtonType, new Command() {
@Override
public void execute() {
// do nothing, but let the cancel button be shown.
}
}, null, null);
yesNoCancelPopup.setClosable(false);
yesNoCancelPopup.show();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DataModelerScreenViewImpl method showYesNoCancelPopup.
@Override
public void showYesNoCancelPopup(String title, String message, Command yesCommand, Command noCommand) {
YesNoCancelPopup yesNoCancelPopup = YesNoCancelPopup.newYesNoCancelPopup(title, message, yesCommand, noCommand, new Command() {
@Override
public void execute() {
// do nothing, but let the cancel button be shown.
}
});
yesNoCancelPopup.setClosable(false);
yesNoCancelPopup.show();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DefaultNewResourceHandlerTest method testGetCommand.
@Test
public void testGetCommand() {
final NewResourcePresenter presenter = mock(NewResourcePresenter.class);
final Command command = handler.getCommand(presenter);
assertNotNull(command);
command.execute();
verify(presenter, times(1)).show(handler);
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class PackageListBoxTest method setContextTest.
@Test
public void setContextTest() {
final List<Package> packages = new ArrayList<>();
packages.add(createPackage("com"));
packages.add(createPackage("com.myteam"));
packages.add(createPackage("com.myteam.mymodule"));
packages.add(createPackage("com.myteam.mymodule.mypackage"));
final Command packagesLoadedCommand = mock(Command.class);
doReturn(new HashSet<>(packages)).when(moduleService).resolvePackages(any(Module.class));
doReturn(packages.get(2)).when(moduleService).resolveDefaultWorkspacePackage(any());
packageListBox.setUp(true, packagesLoadedCommand);
verify(packageListBox, times(4)).addPackage(any(), any());
verify(packageListBox).addPackage(packages.get(0), packages.get(2));
verify(packageListBox).addPackage(packages.get(1), packages.get(2));
verify(packageListBox).addPackage(packages.get(2), packages.get(2));
verify(packageListBox).addPackage(packages.get(3), packages.get(2));
verify(packagesLoadedCommand).execute();
}
Aggregations