public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { List<?> selectedModels = getActionParameter(context); if (selectedModels == null) { selectedModels = getSelectedModels(context); for (Object nextSelectedModuleObject : selectedModels) { preSelectModuleObject(nextSelectedModuleObject, context); Module parentModule = findDestinationModule(nextSelectedModuleObject, context); if (parentModule == null) { Workspace parentWorkspace = getParentWorkspace(context); String parentWorkspaceName = parentWorkspace!=null ? parentWorkspace.getName() : "null"; throw new BackendException("Destination module not found for workpace '" + parentWorkspaceName + "' and module '" + getParentModuleName(context) + "'"); IComponentDescriptor<?> beanComponentDescriptor = getBeanComponentDescriptor( parentModule, context); Module nextSubModule = createChildModule(parentModule, beanComponentDescriptor, nextSelectedModuleObject, context); int nextSubModuleIndex = -1; postSelectModuleObject(nextSelectedModuleObject, context); setActionParameter(moduleToSelect, context); return super.execute(actionHandler, context);
/** * Finds the existing module for a module object. * * @param rootModule * the root module to start the search from. * @param moduleObject * the module object. * @param context * the action context. * @return the stack of modules containing the found module. */ @SuppressWarnings("UnusedParameters") public Stack<Module> findCurrentModule(Module rootModule, Object moduleObject, Map<String, Object> context) { Stack<Module> stack = new Stack<>(); findCurrentModule(rootModule, moduleObject, stack); return stack; }
/** * Finds the parent module where to add the selected component. * * @param component * the component to add as module object. * @param context * the action context. * @return the parent module to add the new module to. */ @SuppressWarnings("UnusedParameters") protected Module findDestinationModule(Object component, Map<String, Object> context) { Workspace workspace = getParentWorkspace(context); String moduleName = getParentModuleName(context); if (workspace == null || moduleName == null) { return getCurrentModule(context); } for (Module m : workspace.getModules()) { Module m2 = findModule(m, moduleName, null); if (m2 != null) { return m2; } } return null; }
int[] selectedIndices = getSelectedIndices(context); ICompositeValueConnector moduleConnector = getModuleConnector(context); ICollectionConnector collectionConnector = getModelConnector(context); Module parentModule = (Module) moduleConnector.getConnectorValue(); List<Module> children;
/** * Finds the existing module for a module object or name. * * @param rootModule * the root module to start the search from. * @param moduleObject * the module object. * @param moduleName * the module name. * @return the stack of modules containing the found module. */ protected Module findModule(Module rootModule, String moduleName, Object moduleObject) { if (moduleName != null && moduleName.equals(rootModule.getName())) { return rootModule; } if (moduleObject != null && (rootModule instanceof BeanModule) && moduleObject.equals(((BeanModule) rootModule).getModuleObject())) { return rootModule; } if (rootModule.getSubModules() != null) { for (Module sub : rootModule.getSubModules()) { Module parentModule = findModule(sub, moduleName, moduleObject); if (parentModule != null) { return parentModule; } } } return null; }
/** * Retrieves the bean component descriptor to create the child bean module. * * @param parentModule * the parent module to add the child bean module to. * @param context * the action context. * @return the bean module component descriptor. */ @SuppressWarnings("UnusedParameters") protected IComponentDescriptor<?> getBeanComponentDescriptor( Module parentModule, Map<String, Object> context) { IModelDescriptor modelDescriptor = getModelDescriptor(context); IComponentDescriptor<?> childComponentDescriptor; if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { childComponentDescriptor = ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor().getElementDescriptor(); } else { childComponentDescriptor = ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor(); } return childComponentDescriptor; }
Object childModuleObject, Map<String, Object> context) { BeanModule childModule = new BeanModule(); IViewDescriptor projectedViewDescriptor = getChildModuleProjectedViewDescriptor(context); if (projectedViewDescriptor != null) { childModule.setProjectedViewDescriptor(projectedViewDescriptor);
private Module findCurrentModule(Module rootModule, Object nextSelectedModuleObject, Stack<Module> stack) { stack.push(rootModule); if (rootModule instanceof BeanModule && nextSelectedModuleObject.equals(((BeanModule) rootModule) .getModuleObject())) { return rootModule; } if (rootModule.getSubModules() != null) { for (Module sub : rootModule.getSubModules()) { Module parentModule = findCurrentModule(sub, nextSelectedModuleObject, stack); if (parentModule != null) { return parentModule; } } } stack.pop(); return null; }