KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > navigation > itemactions > RemoveFavoriteAction


1 /**
2  *
3  */

4 package com.sslexplorer.navigation.itemactions;
5
6 import java.text.MessageFormat JavaDoc;
7
8 import org.apache.struts.action.ActionMapping;
9
10 import com.sslexplorer.navigation.AbstractFavoriteItem;
11 import com.sslexplorer.navigation.WrappedFavoriteItem;
12 import com.sslexplorer.policyframework.itemactions.AbstractPathAction;
13 import com.sslexplorer.security.Constants;
14 import com.sslexplorer.table.AvailableTableItemAction;
15
16 public final class RemoveFavoriteAction extends AbstractPathAction {
17     public RemoveFavoriteAction() {
18         super("remove", "navigation", 100, true, "{2}.do?actionTarget=confirmRemove&selectedItem={0}");
19     }
20
21     public boolean isEnabled(AvailableTableItemAction availableItem) {
22         WrappedFavoriteItem item = (WrappedFavoriteItem) availableItem.getRowItem();
23         return !item.getFavoriteType().equals(AbstractFavoriteItem.GLOBAL_FAVORITE);
24     }
25
26     /*
27      * (non-Javadoc)
28      *
29      * @see com.sslexplorer.table.TableItemAction#getPath(com.sslexplorer.table.AvailableTableItemAction)
30      */

31     public String JavaDoc getPath(AvailableTableItemAction availableItem) {
32         WrappedFavoriteItem item = (WrappedFavoriteItem) availableItem.getRowItem();
33         return MessageFormat.format(requiredPath, new Object JavaDoc[] { item.getFavoriteItem()
34                         .getResource()
35                         .getResourceType()
36                         .getResourceTypeId() + "_"
37             + item.getFavoriteItem().getResource().getResourceId(),
38             ((ActionMapping) availableItem.getRequest().getAttribute(Constants.REQ_ATTR_ACTION_MAPPING)).getName(),
39             ((ActionMapping) availableItem.getRequest().getAttribute(Constants.REQ_ATTR_ACTION_MAPPING)).getPath() });
40     }
41 }
Popular Tags