use of com.vaadin.terminal.UserError in project Activiti by Activiti.
the class CopyModelPopupWindow method addButtons.
protected void addButtons() {
// Cancel
Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
cancelButton.addStyleName(Reindeer.BUTTON_SMALL);
cancelButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
close();
}
});
// Create
Button createButton = new Button(i18nManager.getMessage(Messages.PROCESS_NEW_POPUP_CREATE_BUTTON));
createButton.addStyleName(Reindeer.BUTTON_SMALL);
createButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
if (StringUtils.isEmpty((String) nameTextField.getValue())) {
form.setComponentError(new UserError("The name field is required."));
return;
}
Model newModelData = repositoryService.newModel();
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
modelObjectNode.put(MODEL_NAME, (String) nameTextField.getValue());
String description = null;
if (StringUtils.isNotEmpty((String) descriptionTextArea.getValue())) {
description = (String) descriptionTextArea.getValue();
} else {
description = "";
}
modelObjectNode.put(MODEL_DESCRIPTION, description);
newModelData.setMetaInfo(modelObjectNode.toString());
newModelData.setName((String) nameTextField.getValue());
repositoryService.saveModel(newModelData);
repositoryService.addModelEditorSource(newModelData.getId(), repositoryService.getModelEditorSource(modelData.getId()));
repositoryService.addModelEditorSourceExtra(newModelData.getId(), repositoryService.getModelEditorSourceExtra(modelData.getId()));
close();
ExplorerApp.get().getViewManager().showEditorProcessDefinitionPage(newModelData.getId());
}
});
// Alignment
HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.setSpacing(true);
buttonLayout.addComponent(cancelButton);
buttonLayout.addComponent(createButton);
addComponent(buttonLayout);
windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
}
use of com.vaadin.terminal.UserError in project Activiti by Activiti.
the class NewModelPopupWindow method addButtons.
protected void addButtons() {
// Create
Button createButton = new Button(i18nManager.getMessage(Messages.PROCESS_NEW_POPUP_CREATE_BUTTON));
createButton.setWidth("200px");
createButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
if (StringUtils.isEmpty((String) nameTextField.getValue())) {
nameTextField.setComponentError(new UserError("The name field is required."));
return;
}
if (selectEditorComponent.isModelerPreferred()) {
try {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode editorNode = objectMapper.createObjectNode();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
editorNode.put("stencilset", stencilSetNode);
Model modelData = repositoryService.newModel();
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put(MODEL_NAME, (String) nameTextField.getValue());
modelObjectNode.put(MODEL_REVISION, 1);
String description = null;
if (StringUtils.isNotEmpty((String) descriptionTextArea.getValue())) {
description = (String) descriptionTextArea.getValue();
} else {
description = "";
}
modelObjectNode.put(MODEL_DESCRIPTION, description);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName((String) nameTextField.getValue());
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
close();
ExplorerApp.get().getViewManager().showEditorProcessDefinitionPage(modelData.getId());
URL explorerURL = ExplorerApp.get().getURL();
URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "modeler.html?modelId=" + modelData.getId());
ExplorerApp.get().getMainWindow().open(new ExternalResource(url));
} catch (Exception e) {
notificationManager.showErrorNotification("error", e);
}
} else {
close();
ExplorerApp.get().getViewManager().showSimpleTableProcessEditor((String) nameTextField.getValue(), (String) descriptionTextArea.getValue());
}
}
});
// Alignment
HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.setSpacing(true);
buttonLayout.addComponent(createButton);
addComponent(buttonLayout);
windowLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
}
Aggregations