/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pdfdb.data.filetable;
import javax.swing.JCheckBoxMenuItem;
import pdfdb.app.EventController;
/** Provides menu items by accessing configuration data through the
* ColumnManager. Note: This is simply in a separate class as it doesn't
* belong as a part of the main FileTableMenu class as it does a different
* job.
* @author ug22cmg */
public class TableMenuImplementation
{
/** Registers this class as the implementation class controlling the
* MenuManager. */
public static void assertAsMenuController()
{
ColumnData data = ColumnData.getInstance();
for (String key : data.getKeys(false))
{
MenuManager.addItem(toMenuItem(key, data));
}
}
/** Converts a key to a JCheckBoxItem using data from the ColumnData class.
* @param key The key for the menu item.
* @param data The ColumnData instance responsible for providing data.
* @return A JCheckBoxMenuItem instance. */
private static JCheckBoxMenuItem toMenuItem(String key, ColumnData data)
{
int index = data.indexOf(key, false);
String label = data.getColumnLabel(index, false);
boolean visible = data.isVisible(key);
JCheckBoxMenuItem item = new JCheckBoxMenuItem(label, visible);
String cmd = String.valueOf(EventController.OP_TABLEMENU_CLICKED);
item.setActionCommand(cmd + ">>" + key);
item.addActionListener(EventController.getActionListener());
return item;
}
}