use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class CreateCompositeRuleWizard method cancelAddCondition.
@Override
public void cancelAddCondition() {
this.editCurrentCompositeCondition = false;
this.rowIndex = -1;
if (isAddingCompositeCondition()) {
// don't clear when editing, since we are looking at a REFERENCE to an existing condition
if (this.editingCondition == false) {
this.currentConditionProperties.clear();
}
// reset the action drop down
this.selectedCondition = null;
// determine what page to go back to
FacesContext context = FacesContext.getCurrentInstance();
String currentViewId = context.getViewRoot().getViewId();
IHandler handler = this.conditionHandlers.get(CompositeConditionHandler.NAME);
String compositePage = handler.getJSPPath();
if (currentViewId.equals(compositePage)) {
this.returnViewId = getWizardContainerViewId(context);
}
goToPage(FacesContext.getCurrentInstance(), this.returnViewId);
} else {
super.cancelAddCondition();
return;
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class CreateCompositeRuleWizard method addCondition.
/**
* Adds the condition just setup by the user to the list of composite
* conditions This gathers the composite conditions in the
*/
@Override
public void addCondition() {
if (!isAddingCompositeCondition()) {
super.addCondition();
printConditionState();
return;
}
if (logger.isDebugEnabled())
logger.debug("Adding Condition to Composite Condition. ");
FacesContext context = FacesContext.getCurrentInstance();
// this is called from the actions page so there must be a handler
// present so there's no need to check for null
IHandler handler = this.conditionHandlers.get(this.selectedCondition);
if (handler != null) {
String summary = handler.generateSummary(context, this, this.currentConditionProperties);
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, summary);
} else {
if (logger.isWarnEnabled())
logger.warn("No Summary could be generated for rule condition " + this.selectedCondition);
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, "ERROR - No Summary for " + this.selectedCondition);
}
if (editingCondition == false) {
// this check is needed to prevent an condition when you are editing a composite, to prevent it from adding twice
currentCompositeConditionPropertiesList.add(this.currentConditionProperties);
if (logger.isDebugEnabled())
logger.debug("\tAdded condition to Composite condition.");
} else {
if (logger.isDebugEnabled())
logger.debug("\tEdited composite condition. ");
}
this.currentConditionProperties = new HashMap<String, Serializable>(3);
// resetting it for composite condition
// TODO: this is not persistent currently, which causes a minor bug
this.currentConditionProperties.put(PROP_CONDITION_NAME, CompositeConditionHandler.NAME);
this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
// reset the action drop down
this.selectedCondition = null;
// refresh the wizard
printConditionState();
goToPage(context, this.returnViewId);
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class CreateCompositeRuleWizard method finishAddingCompositeCondition.
public void finishAddingCompositeCondition() {
if (logger.isDebugEnabled())
logger.debug("Finishing Adding Composite Condition.");
// reset the effective chosen condition to composite-condition
this.selectedCondition = CompositeConditionHandler.NAME;
FacesContext context = FacesContext.getCurrentInstance();
returnViewId = getWizardContainerViewId(context);
printConditionState();
if (logger.isDebugEnabled())
logger.debug("\tAdding Condition '" + selectedCondition + "'");
IHandler handler = this.conditionHandlers.get(this.selectedCondition);
// creating object temporarily so we can pass it to CompositeConditionHandler
currentConditionProperties.put(CompositeConditionHandler.PROP_COMPOSITE_CONDITION, (Serializable) this.currentCompositeConditionPropertiesList);
currentConditionProperties.put(PROP_CONDITION_NAME, this.selectedCondition);
// this is called from the actions page so there must be a handler
// present so there's no need to check for null
String summary = handler.generateSummary(context, this, currentConditionProperties);
if (summary != null) {
currentConditionProperties.put(PROP_CONDITION_SUMMARY, summary);
}
if (logger.isDebugEnabled())
logger.debug("Generated Summary - [" + summary + "] + selectedCondition " + this.selectedCondition);
if (this.editCurrentCompositeCondition == true) {
if (rowIndex != -1) {
this.allConditionsPropertiesList.remove(rowIndex);
this.allConditionsPropertiesList.add(rowIndex, currentConditionProperties);
}
} else {
this.allConditionsPropertiesList.add(currentConditionProperties);
}
this.editCurrentCompositeCondition = false;
this.rowIndex = -1;
clearCompositeConditionMode();
// refresh the wizard
goToPage(context, this.returnViewId);
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class CreateRuleWizard method promptForConditionValues.
// ------------------------------------------------------------------------------
// Action event handlers
/**
* Displays the settings page for the current condition being added (if required)
*/
public void promptForConditionValues() {
// set the flag to show we are creating a new condition
this.editingCondition = false;
FacesContext context = FacesContext.getCurrentInstance();
this.returnViewId = context.getViewRoot().getViewId();
String viewId = null;
this.currentConditionProperties = new HashMap<String, Serializable>(3);
this.currentConditionProperties.put(PROP_CONDITION_NAME, this.selectedCondition);
this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
// get the handler for the condition, if there isn't one we presume it
// is a no-parameter condition
IHandler handler = this.conditionHandlers.get(this.selectedCondition);
if (handler != null) {
if (logger.isDebugEnabled())
logger.debug("Found Handler for selected condition - '" + this.selectedCondition + "'");
// setup any UI defaults the condition may have and get the location of
// the JSP used to collect the parameters
handler.setupUIDefaults(this.currentConditionProperties);
viewId = handler.getJSPPath();
if (logger.isDebugEnabled())
logger.debug("Handler returned JSP page- '" + viewId + "' Handler Type " + handler.getClass().toString());
} else {
if (logger.isDebugEnabled())
logger.debug("Did Not Find a handler for selected condition - '" + this.selectedCondition + "'");
// just add the action to the list and use the title as the summary
ActionConditionDefinition conditionDef = this.getActionService().getActionConditionDefinition(this.selectedCondition);
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, conditionDef.getTitle());
this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
// add the no params marker so we can disable the edit action
this.currentConditionProperties.put(NO_PARAMS_MARKER, "no-params");
this.allConditionsPropertiesList.add(this.currentConditionProperties);
// come back to the same page we're on now as there are no params to collect
viewId = this.returnViewId;
}
if (logger.isDebugEnabled())
logger.debug("Currently creating '" + this.selectedCondition + "' condition");
// go to the page to collect the settings
goToPage(context, viewId);
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class CreateRuleWizard method editCondition.
protected void editCondition(Map conditionToEdit) {
// set the flag to show we are editing a condition
this.editingCondition = true;
// use the built in JSF support for retrieving the object for the
// row that was clicked by the user
this.selectedCondition = (String) conditionToEdit.get(PROP_CONDITION_NAME);
this.currentConditionProperties = conditionToEdit;
if (logger.isDebugEnabled())
logger.debug("Editing Condition '" + selectedCondition + "'");
// remember the page we're on
FacesContext context = FacesContext.getCurrentInstance();
this.returnViewId = context.getViewRoot().getViewId();
// go to the condition page (as there is an edit option visible,
// there must be a handler for the condition so we don't check)
goToPage(context, this.conditionHandlers.get(this.selectedCondition).getJSPPath());
}
Aggregations