1 19 20 package org.netbeans.lib.editor.bookmarks.actions; 21 22 import javax.swing.text.JTextComponent ; 23 import java.awt.event.ActionEvent ; 24 import javax.swing.Action ; 25 26 import org.netbeans.editor.BaseAction; 27 import org.openide.util.NbBundle; 28 29 import org.netbeans.lib.editor.bookmarks.api.BookmarkList; 30 31 34 public class ClearDocumentBookmarksAction extends BaseAction { 35 36 public static final String NAME = "clear-document-bookmarks"; 37 38 public ClearDocumentBookmarksAction() { 39 super(NAME); 40 putValue(BaseAction.ICON_RESOURCE_PROPERTY, 41 "org/netbeans/modules/editor/bookmarks/resources/clear_bookmark.png"); } 43 44 public String getName() { 45 return (String ) getValue(NAME); 46 } 47 48 public void actionPerformed(ActionEvent e, JTextComponent target) { 49 BookmarkList bookmarkList = BookmarkList.get(target.getDocument()); 50 51 for (int i = bookmarkList.getBookmarkCount() - 1; i >= 0; i--) { 52 bookmarkList.removeBookmarkAtIndex(i); 53 } 54 } 55 56 protected Object getDefaultShortDescription() { 57 return NbBundle.getBundle(ClearDocumentBookmarksAction.class).getString( 58 (String )getValue(Action.NAME)); 59 } 60 61 } 62 | Popular Tags |