mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- Added ability to hide actions
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2862 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,7 @@ package org.alfresco.web.config;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,6 +29,7 @@ import org.alfresco.config.ConfigElement;
|
|||||||
import org.alfresco.config.ConfigException;
|
import org.alfresco.config.ConfigException;
|
||||||
import org.alfresco.config.element.ConfigElementAdapter;
|
import org.alfresco.config.element.ConfigElementAdapter;
|
||||||
import org.alfresco.web.action.ActionEvaluator;
|
import org.alfresco.web.action.ActionEvaluator;
|
||||||
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action config element.
|
* Action config element.
|
||||||
@@ -89,24 +91,30 @@ public class ActionsConfigElement extends ConfigElementAdapter
|
|||||||
{
|
{
|
||||||
// there is already a group with this id, combine it
|
// there is already a group with this id, combine it
|
||||||
// with the new one
|
// with the new one
|
||||||
ActionGroup existingGroup = combinedElement.actionGroups.get(newGroup.getId());
|
ActionGroup combinedGroup = combinedElement.actionGroups.get(newGroup.getId());
|
||||||
if (newGroup.ShowLink != existingGroup.ShowLink)
|
if (newGroup.ShowLink != combinedGroup.ShowLink)
|
||||||
{
|
{
|
||||||
existingGroup.ShowLink = newGroup.ShowLink;
|
combinedGroup.ShowLink = newGroup.ShowLink;
|
||||||
}
|
}
|
||||||
if (newGroup.Style != null)
|
if (newGroup.Style != null)
|
||||||
{
|
{
|
||||||
existingGroup.Style = newGroup.Style;
|
combinedGroup.Style = newGroup.Style;
|
||||||
}
|
}
|
||||||
if (newGroup.StyleClass != null)
|
if (newGroup.StyleClass != null)
|
||||||
{
|
{
|
||||||
existingGroup.StyleClass = newGroup.StyleClass;
|
combinedGroup.StyleClass = newGroup.StyleClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the new groups to the existing set
|
// add all the actions from the new group to the combined one
|
||||||
for (String actionRef : newGroup.actions)
|
for (String actionRef : newGroup.getAllActions())
|
||||||
{
|
{
|
||||||
existingGroup.actions.add(actionRef);
|
combinedGroup.addAction(actionRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add all the hidden actions from the new group to the combined one
|
||||||
|
for (String actionRef : newGroup.getHiddenActions())
|
||||||
|
{
|
||||||
|
combinedGroup.hideAction(actionRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -246,17 +254,43 @@ public class ActionsConfigElement extends ConfigElementAdapter
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAction(String actionId)
|
/**
|
||||||
|
* @return Iterator over the visible ActionDefinition IDs referenced by this group
|
||||||
|
*/
|
||||||
|
public Iterator<String> iterator()
|
||||||
|
{
|
||||||
|
// create a list of the visible actions and return it's iterator
|
||||||
|
ArrayList<String> visibleActions = new ArrayList<String>(
|
||||||
|
this.actions.size() - this.hiddenActions.size());
|
||||||
|
for (String actionId : this.actions)
|
||||||
|
{
|
||||||
|
if (this.hiddenActions.contains(actionId) == false)
|
||||||
|
{
|
||||||
|
visibleActions.add(actionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return visibleActions.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ void addAction(String actionId)
|
||||||
{
|
{
|
||||||
actions.add(actionId);
|
actions.add(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*package*/ void hideAction(String actionId)
|
||||||
* @return Iterator over the ActionDefinition IDs referenced by this group
|
|
||||||
*/
|
|
||||||
public Iterator<String> iterator()
|
|
||||||
{
|
{
|
||||||
return actions.iterator();
|
this.hiddenActions.add(actionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ Set<String> getAllActions()
|
||||||
|
{
|
||||||
|
return this.actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*pacakge*/ Set<String> getHiddenActions()
|
||||||
|
{
|
||||||
|
return this.hiddenActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
@@ -265,6 +299,9 @@ public class ActionsConfigElement extends ConfigElementAdapter
|
|||||||
than one action with the same Id and that the insertion order is preserved */
|
than one action with the same Id and that the insertion order is preserved */
|
||||||
private Set<String> actions = new LinkedHashSet<String>(16, 1.0f);
|
private Set<String> actions = new LinkedHashSet<String>(16, 1.0f);
|
||||||
|
|
||||||
|
/** the actions that have been hidden */
|
||||||
|
private Set<String> hiddenActions = new HashSet<String>(4, 1.0f);
|
||||||
|
|
||||||
public boolean ShowLink;
|
public boolean ShowLink;
|
||||||
public String Style;
|
public String Style;
|
||||||
public String StyleClass;
|
public String StyleClass;
|
||||||
|
@@ -56,7 +56,7 @@ public class ActionsElementReader implements ConfigElementReader
|
|||||||
public static final String ATTRIBUTE_IDREF = "idref";
|
public static final String ATTRIBUTE_IDREF = "idref";
|
||||||
public static final String ATTRIBUTE_NAME = "name";
|
public static final String ATTRIBUTE_NAME = "name";
|
||||||
public static final String ATTRIBUTE_ALLOW = "allow";
|
public static final String ATTRIBUTE_ALLOW = "allow";
|
||||||
|
public static final String ATTRIBUTE_HIDE = "hide";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
|
* @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
|
||||||
@@ -122,11 +122,20 @@ public class ActionsElementReader implements ConfigElementReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// look for the hide attribute
|
||||||
|
String hide = actionRefElement.attributeValue(ATTRIBUTE_HIDE);
|
||||||
|
if (hide != null && Boolean.parseBoolean(hide))
|
||||||
|
{
|
||||||
|
actionGroup.hideAction(idRef);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// add the action definition ID to the group
|
// add the action definition ID to the group
|
||||||
actionGroup.addAction(idRef);
|
actionGroup.addAction(idRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get simple string properties for the action group
|
// get simple string properties for the action group
|
||||||
actionGroup.Style = groupElement.elementTextTrim(ELEMENT_STYLE);
|
actionGroup.Style = groupElement.elementTextTrim(ELEMENT_STYLE);
|
||||||
|
@@ -896,19 +896,18 @@ public class WebClientConfigTest extends BaseTest
|
|||||||
assertEquals("document_browse group style class", "inlineAction", group.StyleClass);
|
assertEquals("document_browse group style class", "inlineAction", group.StyleClass);
|
||||||
assertNull("Style for document_browse group should be null", group.Style);
|
assertNull("Style for document_browse group should be null", group.Style);
|
||||||
|
|
||||||
// make sure there are 3 items
|
// make sure there are 2 items (as one was hidden in the override)
|
||||||
ArrayList<String> actions = new ArrayList<String>(3);
|
ArrayList<String> actions = new ArrayList<String>(3);
|
||||||
for (String actionId : group)
|
for (String actionId : group)
|
||||||
{
|
{
|
||||||
actions.add(actionId);
|
actions.add(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("number of items in document_browse group", 3, actions.size());
|
assertEquals("number of items in document_browse group", 2, actions.size());
|
||||||
|
|
||||||
// make sure they are in the correct order
|
// make sure they are in the correct order
|
||||||
assertEquals("first action", "details_doc", actions.get(0));
|
assertEquals("first action", "details_doc", actions.get(0));
|
||||||
assertEquals("second action", "details_space", actions.get(1));
|
assertEquals("second action", "custom_action", actions.get(1));
|
||||||
assertEquals("third action", "custom_action", actions.get(2));
|
|
||||||
|
|
||||||
// get the new_group action group
|
// get the new_group action group
|
||||||
ActionGroup newGroup = actionsConfig.getActionGroup("new_group");
|
ActionGroup newGroup = actionsConfig.getActionGroup("new_group");
|
||||||
|
@@ -117,7 +117,8 @@
|
|||||||
<!-- Add the custom action to the existing document_browse group -->
|
<!-- Add the custom action to the existing document_browse group -->
|
||||||
<action-group id="document_browse">
|
<action-group id="document_browse">
|
||||||
<show-link>true</show-link>
|
<show-link>true</show-link>
|
||||||
<action idref="custom_action" />
|
<action idref="custom_action" hide="false" />
|
||||||
|
<action idref="details_space" hide="true" />
|
||||||
</action-group>
|
</action-group>
|
||||||
|
|
||||||
<action-group id="new_group">
|
<action-group id="new_group">
|
||||||
|
@@ -62,11 +62,18 @@
|
|||||||
<action>dialog:showSpaceDetails</action>
|
<action>dialog:showSpaceDetails</action>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
<action id="always_hidden">
|
||||||
|
<label-id>view_details</label-id>
|
||||||
|
<image>/images/icons/View_details.gif</image>
|
||||||
|
<action>dialog:showSpaceDetails</action>
|
||||||
|
</action>
|
||||||
|
|
||||||
<action-group id="document_browse">
|
<action-group id="document_browse">
|
||||||
<show-link>false</show-link>
|
<show-link>false</show-link>
|
||||||
<style-class>inlineAction</style-class>
|
<style-class>inlineAction</style-class>
|
||||||
<action idref="details_doc" />
|
<action idref="details_doc" />
|
||||||
<action idref="details_space" />
|
<action idref="details_space" />
|
||||||
|
<action idref="always_hidden" hide="true" />
|
||||||
</action-group>
|
</action-group>
|
||||||
</actions>
|
</actions>
|
||||||
</config>
|
</config>
|
||||||
|
Reference in New Issue
Block a user