use of org.activiti.editor.ui.SelectEditorComponent in project Activiti by Activiti.
the class EditModelClickListener method showSelectEditorPopupWindow.
protected void showSelectEditorPopupWindow() {
final PopupWindow selectEditorPopupWindow = new PopupWindow();
selectEditorPopupWindow.setModal(true);
selectEditorPopupWindow.setResizable(false);
selectEditorPopupWindow.setWidth("350px");
selectEditorPopupWindow.setHeight("250px");
selectEditorPopupWindow.addStyleName(Reindeer.PANEL_LIGHT);
selectEditorPopupWindow.center();
final SelectEditorComponent selectEditorComponent = new SelectEditorComponent(false);
selectEditorComponent.getModelerDescriptionLabel().setValue(ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_CONVERSION_WARNING_MODELER));
selectEditorComponent.getModelerDescriptionLabel().addStyleName(ExplorerLayout.STYLE_LABEL_RED);
selectEditorComponent.preferTableDrivenEditor();
selectEditorPopupWindow.getContent().addComponent(selectEditorComponent);
selectEditorComponent.setEditorSelectedListener(new EditorSelectedListener() {
public void editorSelectionChanged() {
try {
WorkflowDefinition workflowDefinition = loadWorkflowDefinition();
// When using the modeler, the format must first be converted to the modeler json format
if (selectEditorComponent.isModelerPreferred()) {
WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
conversion.convert();
RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
model.setCategory(null);
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode metaInfoJson = objectMapper.createObjectNode();
metaInfoJson.put("name", model.getName());
model.setMetaInfo(metaInfoJson.toString());
repositoryService.saveModel(model);
BpmnJsonConverter bpmnJsonConverter = new BpmnJsonConverter();
ObjectNode json = bpmnJsonConverter.convertToJson(conversion.getBpmnModel());
repositoryService.addModelEditorSource(model.getId(), json.toString().getBytes("utf-8"));
// Show modeler
showModeler();
} else {
// Load and show table editor
ExplorerApp.get().getViewManager().showSimpleTableProcessEditor(model.getId(), workflowDefinition);
}
} catch (Exception e) {
LOGGER.error("Error showing editor", e);
ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_EDITOR_LOADING_ERROR, e);
} finally {
ExplorerApp.get().getMainWindow().removeWindow(selectEditorPopupWindow);
}
}
});
ExplorerApp.get().getViewManager().showPopupWindow(selectEditorPopupWindow);
}
Aggregations