Aspect lists in Action wizards are now configured separately i.e. one for add, one for remove and one for test.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3437 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-07-31 13:43:26 +00:00
parent cf80a2e112
commit b78a266d20
8 changed files with 194 additions and 50 deletions

View File

@@ -239,6 +239,7 @@
<!-- The list of content and/or folder types shown in the specialise-type action --> <!-- The list of content and/or folder types shown in the specialise-type action -->
<specialise-types> <specialise-types>
</specialise-types> </specialise-types>
<!-- The list of aspects to show in the add/remove features action --> <!-- The list of aspects to show in the add/remove features action -->
<!-- and the has-aspect condition --> <!-- and the has-aspect condition -->
<aspects> <aspects>
@@ -253,6 +254,16 @@
<aspect name="localizable"/> <aspect name="localizable"/>
<aspect name="emailed"/> <aspect name="emailed"/>
</aspects> </aspects>
<!-- List of aspects to only show in the add features action -->
<aspects-add>
</aspects-add>
<!-- List of aspects to only show in the remove features action -->
<aspects-remove>
</aspects-remove>
<!-- List of aspects to only show in the has aspect condition -->
<aspects-test>
</aspects-test>
<!-- The list of transformers to show in the transform actions --> <!-- The list of transformers to show in the transform actions -->
<transformers> <transformers>
<transformer name="application/vnd.oasis.opendocument.text"/> <transformer name="application/vnd.oasis.opendocument.text"/>

View File

@@ -63,7 +63,10 @@ public abstract class BaseActionWizard extends BaseWizardBean
protected List<SelectItem> actions; protected List<SelectItem> actions;
protected List<SelectItem> transformers; protected List<SelectItem> transformers;
protected List<SelectItem> imageTransformers; protected List<SelectItem> imageTransformers;
protected List<SelectItem> aspects; protected List<SelectItem> commonAspects;
protected List<SelectItem> removableAspects;
protected List<SelectItem> addableAspects;
protected List<SelectItem> testableAspects;
protected List<SelectItem> users; protected List<SelectItem> users;
protected List<SelectItem> encodings; protected List<SelectItem> encodings;
protected List<SelectItem> objectTypes; protected List<SelectItem> objectTypes;
@@ -209,70 +212,129 @@ public abstract class BaseActionWizard extends BaseWizardBean
} }
/** /**
* Returns the aspects that are available * Returns a list of aspects that can be removed
* *
* @return List of SelectItem objects representing the available aspects * @return List of SelectItem objects representing the aspects that can be removed
*/ */
public List<SelectItem> getAspects() public List<SelectItem> getRemovableAspects()
{ {
if (this.aspects == null) if (this.removableAspects == null)
{ {
// get the list of common aspects
this.removableAspects = new ArrayList<SelectItem>();
this.removableAspects.addAll(getCommonAspects());
// get those aspects configured to appear only in the remove aspect action
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance()); ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards"); Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) if (wizardCfg != null)
{ {
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects"); ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-remove");
if (aspectsCfg != null) if (aspectsCfg != null)
{ {
FacesContext context = FacesContext.getCurrentInstance(); List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
this.aspects = new ArrayList<SelectItem>(); this.removableAspects.addAll(aspects);
for (ConfigElement child : aspectsCfg.getChildren())
{
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
if (idQName != null)
{
// try and get the display label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label try and get it from the dictionary
if (label == null)
{
AspectDefinition aspectDef = this.dictionaryService.getAspect(idQName);
if (aspectDef != null)
{
label = aspectDef.getTitle();
}
else
{
label = idQName.getLocalName();
}
}
this.aspects.add(new SelectItem(idQName.toString(), label));
}
else
{
logger.warn("Failed to resolve aspect '" + child.getAttribute("name") + "'");
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.aspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
} }
else else
{ {
logger.warn("Could not find 'aspects' configuration element"); logger.warn("Could not find 'aspects-remove' configuration element");
} }
} }
else else
{ {
logger.warn("Could not find 'Action Wizards' configuration section"); logger.warn("Could not find 'Action Wizards' configuration section");
} }
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.removableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
} }
return this.aspects; return this.removableAspects;
}
/**
* Returns a list of aspects that can be added
*
* @return List of SelectItem objects representing the aspects that can be added
*/
public List<SelectItem> getAddableAspects()
{
if (this.addableAspects == null)
{
// get the list of common aspects
this.addableAspects = new ArrayList<SelectItem>();
this.addableAspects.addAll(getCommonAspects());
// get those aspects configured to appear only in the remove aspect action
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null)
{
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-add");
if (aspectsCfg != null)
{
List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
this.addableAspects.addAll(aspects);
}
else
{
logger.warn("Could not find 'aspects-add' configuration element");
}
}
else
{
logger.warn("Could not find 'Action Wizards' configuration section");
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.addableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.addableAspects;
}
/**
* Returns a list of aspects that can be tested i.e. hasAspect
*
* @return List of SelectItem objects representing the aspects that can be tested for
*/
public List<SelectItem> getTestableAspects()
{
if (this.testableAspects == null)
{
// get the list of common aspects
this.testableAspects = new ArrayList<SelectItem>();
this.testableAspects.addAll(getCommonAspects());
// get those aspects configured to appear only in the remove aspect action
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null)
{
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-test");
if (aspectsCfg != null)
{
List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
this.testableAspects.addAll(aspects);
}
else
{
logger.warn("Could not find 'aspects-test' configuration element");
}
}
else
{
logger.warn("Could not find 'Action Wizards' configuration section");
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.testableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.testableAspects;
} }
/** /**
@@ -846,6 +908,77 @@ public abstract class BaseActionWizard extends BaseWizardBean
} }
} }
/**
* Returns the aspects that are available in all scenarios i.e. add, remove and test
*
* @return List of SelectItem objects representing the available aspects
*/
protected List<SelectItem> getCommonAspects()
{
if (this.commonAspects == null)
{
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null)
{
ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects");
if (aspectsCfg != null)
{
this.commonAspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
}
else
{
logger.warn("Could not find 'aspects' configuration element");
}
}
else
{
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.commonAspects;
}
protected List<SelectItem> readAspectsConfig(FacesContext context, ConfigElement aspectsCfg)
{
List<SelectItem> aspects = new ArrayList<SelectItem>();
for (ConfigElement child : aspectsCfg.getChildren())
{
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
if (idQName != null)
{
// try and get the display label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label try and get it from the dictionary
if (label == null)
{
AspectDefinition aspectDef = this.dictionaryService.getAspect(idQName);
if (aspectDef != null)
{
label = aspectDef.getTitle();
}
else
{
label = idQName.getLocalName();
}
}
aspects.add(new SelectItem(idQName.toString(), label));
}
else
{
logger.warn("Failed to resolve aspect '" + child.getAttribute("name") + "'");
}
}
return aspects;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Inner classes // Inner classes

View File

@@ -49,7 +49,7 @@ public class AddFeaturesHandler extends BaseActionHandler
String aspect = (String)actionProps.get(PROP_ASPECT); String aspect = (String)actionProps.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list // find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getAspects()) for (SelectItem item : ((BaseActionWizard)wizard).getAddableAspects())
{ {
if (item.getValue().equals(aspect)) if (item.getValue().equals(aspect))
{ {

View File

@@ -49,7 +49,7 @@ public class RemoveFeaturesHandler extends BaseActionHandler
String aspect = (String)actionProps.get(PROP_ASPECT); String aspect = (String)actionProps.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list // find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getAspects()) for (SelectItem item : ((BaseActionWizard)wizard).getRemovableAspects())
{ {
if (item.getValue().equals(aspect)) if (item.getValue().equals(aspect))
{ {

View File

@@ -49,7 +49,7 @@ public class HasAspectHandler extends BaseConditionHandler
String label = null; String label = null;
String aspectName = (String)conditionProps.get(PROP_ASPECT); String aspectName = (String)conditionProps.get(PROP_ASPECT);
for (SelectItem item : ((CreateRuleWizard)wizard).getAspects()) for (SelectItem item : ((CreateRuleWizard)wizard).getTestableAspects())
{ {
if (item.getValue().equals(aspectName)) if (item.getValue().equals(aspectName))
{ {

View File

@@ -106,7 +106,7 @@
<td><nobr><h:outputText value="#{msg.select_feature}"/></nobr></td> <td><nobr><h:outputText value="#{msg.select_feature}"/></nobr></td>
<td width="90%"> <td width="90%">
<h:selectOneMenu value="#{WizardManager.bean.actionProperties.aspect}"> <h:selectOneMenu value="#{WizardManager.bean.actionProperties.aspect}">
<f:selectItems value="#{WizardManager.bean.aspects}" /> <f:selectItems value="#{WizardManager.bean.addableAspects}" />
</h:selectOneMenu> </h:selectOneMenu>
</td> </td>
</tr> </tr>

View File

@@ -106,7 +106,7 @@
<td><nobr><h:outputText value="#{msg.select_feature}"/></nobr></td> <td><nobr><h:outputText value="#{msg.select_feature}"/></nobr></td>
<td width="90%"> <td width="90%">
<h:selectOneMenu value="#{WizardManager.bean.actionProperties.aspect}"> <h:selectOneMenu value="#{WizardManager.bean.actionProperties.aspect}">
<f:selectItems value="#{WizardManager.bean.aspects}" /> <f:selectItems value="#{WizardManager.bean.removableAspects}" />
</h:selectOneMenu> </h:selectOneMenu>
</td> </td>
</tr> </tr>

View File

@@ -106,7 +106,7 @@
<td><nobr><h:outputText value="#{msg.aspect}"/>:</nobr></td> <td><nobr><h:outputText value="#{msg.aspect}"/>:</nobr></td>
<td width="98%"> <td width="98%">
<h:selectOneMenu value="#{WizardManager.bean.conditionProperties.aspect}"> <h:selectOneMenu value="#{WizardManager.bean.conditionProperties.aspect}">
<f:selectItems value="#{WizardManager.bean.aspects}" /> <f:selectItems value="#{WizardManager.bean.testableAspects}" />
</h:selectOneMenu> </h:selectOneMenu>
</td> </td>
</tr> </tr>