Hacking Alfresco, II


My second try was to create some custom action in some menu or bar and to view a simple dialog in Alfresco UI triggered by this action. There are topics covering this theme in Alfresco wiki too (see Custom Action UI and Dialog Framework) for detailed informations. But i wanted to create a simple and working example to see if it really works :-).

So, lets start with some action ;-). Actions are defined in web-client-config-custom.xml configuration file like this:

<actions>
<action id="create_session">
<label>Create session</label>
<image>/images/icons/add.gif</image>
<action>dialog:createSession</action>
<evaluator>cz.shmoula.CreateSessionEvaluator</evaluator>
</action>

<action-group id="space_browse_menu">
<action idref="create_session" />
</action-group>

</actions>

Items are self explaining, i hope :-). Action is to create dialog, which is defined in dialogs section with name createSession and evaluator is class which implements ActionEvaluator and indicates that this action is viewed or not. In my CreateSessionEvaluator i have just a simple condition.

Id attribute of action-group tag specifies a place in which is this action (a link) viewed, in my example it is space_browse_menu, which is the context menu of space object. Action groups are defined in web-client-config-actions.xml. Examples of some action groups are at following pictures:

Free Image Hosting at www.ImageShack.us

space_browse_menu action group

 

Free Image Hosting at www.ImageShack.us

1 – add_content_menu, 2 – browse_actions_menu

An action link is viewed at first image – "Create session". If evaluator is specified, action is viewed just in case of true evaluation. My simple evaluator is following:

public class CreateSessionEvaluator implements ActionEvaluator{

public boolean evaluate(Node node){
if(node.getName().equals("Archivace"))
return true;
else
return false;
}
}

It just compares space name (in case of space_browse_menu action group) with some string, nothing more :-). So, if they correspond, "Create session" link is displayed.


Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *