Example usage for javax.swing AbstractAction getValue

List of usage examples for javax.swing AbstractAction getValue

Introduction

In this page you can find the example usage for javax.swing AbstractAction getValue.

Prototype

public Object getValue(String key) 

Source Link

Document

Gets the Object associated with the specified key.

Usage

From source file:feedsplugin.FeedsPlugin.java

@Override
public ActionMenu getButtonAction() {
    if (mSettings == null) {
        return null;
    }/*from  ww  w  .  j  ava  2s .  c o  m*/
    ArrayList<String> feedTitles = mSettings.getCachedFeedTitles();
    if (feedTitles.isEmpty()) {
        return null;
    }
    ContextMenuAction mainAction = new ContextMenuAction(mLocalizer.msg("name", "Feeds"), getPluginIcon());
    ArrayList<AbstractAction> list = new ArrayList<AbstractAction>(feedTitles.size());
    for (int i = 0; i < feedTitles.size(); i++) {
        final String title = feedTitles.get(i);
        final int feedIndex = i;
        list.add(new AbstractAction(title) {

            public void actionPerformed(ActionEvent e) {
                SyndFeed selectedFeed = mFeeds.get(feedIndex);
                if (selectedFeed != null) {
                    List entries = selectedFeed.getEntries();
                    showFeedsDialog(new FeedsDialog(getParentFrame(), entries));
                }
            }
        });
    }
    Collections.sort(list, new Comparator<AbstractAction>() {

        public int compare(AbstractAction o1, AbstractAction o2) {
            return ((String) o1.getValue(AbstractAction.NAME))
                    .compareTo((String) o2.getValue(AbstractAction.NAME));
        }
    });
    return new ActionMenu(mainAction, list.toArray(new AbstractAction[list.size()]));
}