/** * Gets he application translation provider out of the action context. This * method simply delegates to the context backend controller. * * @param context * the action context. * @return the translation provider. */ protected ITranslationProvider getTranslationProvider(Map<String, Object> context) { return getBackendController(context); }
/** * Gets the model this action was triggered on. * * @param <T> * type inference return. * @param context * the action context. * @return the model. */ protected <T> T getModel(Map<String, Object> context) { return getModel(null, context); }
/** * Gets the selected indices out of the UI component if it is a collection * component (table, list, ...). More accurately, the selected indices are * taken from the view connector that adapts the UI component to the Jspresso * binding architecture. * * @param context * the action context. * @return the selected indices stored in the action context. */ protected int[] getSelectedIndices(Map<String, Object> context) { return getSelectedIndices(null, context); }
/** * Starts the plugin. * * @param context * the context */ @Override public synchronized void start(Map<String, Object> context) { if (!started) { IFrontendController<?, ?, ?> frontendController = getFrontendController(context); ActionsDirectoryBuilder actionsDirectoryBuilder = new ActionsDirectoryBuilder(); actionsDirectoryBuilder.process(frontendController); traceUserActionsInventory(actionsDirectoryBuilder.getUserActions(), actionsDirectoryBuilder.getLovActions(), frontendController); started = true; } } }
/** * Gets the model descriptor this action was triggered on. * * @param viewPermId * the view permId to search for. The view hierarchy is climed to the top and then a chid view with the searched * permId is recursively searched. * @param context * the action context. * @return the model connector this action was triggered on. */ protected IModelDescriptor getModelDescriptorFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getModelDescriptor(viewPathFromPermId, context); }
/** * Gets the model this action was triggered on. * * @param <T> * type inference return. * @param viewPermId * the view permId to search for. The view hierarchy is climed to the top and then a chid view with the searched * permId is recursively searched. * @param context * the action context. * @return the model. */ protected <T> T getModelFromPermId(String viewPermId, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); return getModel(viewPathFromPermId, context); }
/** * Retrieves the selected models indices out of the model connector if it's a * collection connector and set them as selected indices in the action * context. * * @param viewPermId * the view permId to search for. The view hierarchy is climed to the top and then a chid view with the searched * permId is recursively searched. * @param selectedModels * the list of models to select in the view connector. * @param context * the action context. */ protected void setSelectedModelsFromPermId(String viewPermId, Collection<?> selectedModels, Map<String, Object> context) { int[] viewPathFromPermId = ViewHelper.getViewPathFromPermId(viewPermId, getView(context)); setSelectedModels(viewPathFromPermId, selectedModels, context); }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { if (actionHandler.execute(getWrappedAction(context), context)) { return actionHandler.execute(getNextAction(context), context); } return false; }
/** * Gets the model connector this action was triggered on. The model connector * is the versatile binding structure that adapts the actual model to the * Jspresso binding architecture. The actual model is stored in the model * connector value. Unless developing very generic actions, this method will * rarely be used in favor of the more concrete {@code getXXXModel} * context accessors. * * @param context * the action context. * @return the model connector this action was triggered on. */ protected IValueConnector getModelConnector(Map<String, Object> context) { return getModelConnector((int[]) null, context); }
/** * Retrieves the selected models indices out of the model connector if it's a * collection connector and set them as selected indices in the action * context. * * @param selectedModels * the list of models to select in the view connector. * @param context * the action context. */ protected void setSelectedModels(Collection<?> selectedModels, Map<String, Object> context) { setSelectedModels(null, selectedModels, context); }
/** * This is a versatile helper method that retrieves the selected models model * either from the selected child connectors if the action was triggered on a * collection connector or from the connector itself. * * @param <T> * type inference return. * @param context * the action context. * @return the list of selected models. */ protected <T> List<T> getSelectedModels(Map<String, Object> context) { return getSelectedModels(null, context); }
/** * Sets the selected indices of the UI component if it is a collection * component (table, list, ...). More accurately, the selected indices are set * to the view connector that adapts the UI component to the Jspresso binding * architecture. * * @param selectedIndices * the selected indices to store in the action context. * @param context * the action context. */ protected void setSelectedIndices(int[] selectedIndices, Map<String, Object> context) { setSelectedIndices(null, selectedIndices, context); }
/** * This is a versatile helper method that retrieves the selected model either * from the 1st selected child connector if the action was triggered on a * collection connector or from the connector itself. * * @param <T> * type inference return. * @param context * the action context. * @return the selected model. */ protected <T> T getSelectedModel(Map<String, Object> context) { return getSelectedModel(null, context); }
/** * This is a utility method which is able to retrieve the view connector this * action has been executed on from its context. It uses well-known context * keys of the action context which are: * <ul> * <li> {@code ActionContextConstants.VIEW_CONNECTOR} to get the the view * value connector the action executes on. * </ul> * <p> * The returned connector mainly serves for acting on the view component the * action has to be triggered on. * * @param context * the action context. * @return the value connector this action was triggered on. */ protected IValueConnector getViewConnector(Map<String, Object> context) { return getViewConnector(null, context); }
/** * This is a utility method which is able to retrieve the view this action has * been executed on from its context. It uses well-known context keys of the * action context which are: * <ul> * <li> {@code ActionContextConstants.VIEW} to get the the view the action * executes on. * </ul> * <p> * The returned view mainly serves for acting on the view component the action * has to be triggered on. * * @param <T> * type inference return. * @param context * the action context. * @return the view this action was triggered on. */ protected <T> IView<T> getView(Map<String, Object> context) { return getView(null, context); }
/** * {@inheritDoc} */ @Override protected IValueConnector getViewConnector(int[] viewPath, Map<String, Object> context) { warnBadFrontendAccess(context); return super.getViewConnector(viewPath, context); }
/** * Gets a translation provider out of the action context. * * @param context * the action context. * @return the translation provider. */ protected ITranslationProvider getTranslationProvider( Map<String, Object> context) { return getController(context).getTranslationProvider(); } }
/** * {@inheritDoc} */ @Override protected <T> IView<T> getView(int[] viewPath, Map<String, Object> context) { warnBadFrontendAccess(context); return super.getView(viewPath, context); }
/** * Gets the permId. * * @return the permId. */ @Override public String getPermId() { String permId = super.getPermId(); if (permId == null) { return getName(); } return permId; }
/** * Gets the model descriptor this action was triggered on. * * @param modelPath * the model path to follow as a dotted string. * @param context * the action context. * @return the model descriptor this action was triggered on. */ protected IModelDescriptor getModelDescriptor(String modelPath, Map<String, Object> context) { IValueConnector modelConnector = getModelConnector(modelPath, context); if (modelConnector != null) { return modelConnector.getModelDescriptor(); } return null; }