JXMLPad - Tutorial
Creating a JSP 1.2 editor
STEP 5/5 : Adding a custom
popup, toolbar action
Previous step
Here an inner class that inserts a useBean tag :
/** Sample adding a useBean Tag */
class InsertUseBeanAction extends XMLAction {
public InsertUseBeanAction() {
super();
// For popup menu
: It will create a sub-menu
groupName = "JSP";
}
public boolean notifyAction() {
editor.insertText("<jsp:useBean
id=\"\"/>");
return VALID_ACTION;
}
// Default popupModel/menu label
public String getDefaultLabel() {
return "UseBean"; }
}
Here a code for adding this last action on the current toolbar and popup
:
// Add a new Action in the default toolBar
container.getToolBarModel().addSeparator();
Action a = new InsertUseBeanAction();
container.getToolBarModel().addAction( a );
// Add it to the default popup
container.getPopupModel().addAction( a );