// Tell the context menu listeners that we are about to display a
// context menu, giving listeners an opportunity to make adjustments
ContextMenuManager.getContextMenuManager().fireContextMenuEvent(ctxEvent);
// get the settings from the event, possibly adjusted by listeners
ContextMenuInvocationSettings settings = ctxEvent.getSettings();
// Adjust name of menu (by default, this is the cell's name)
JPanel titlePanel = new JPanel();
titlePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
titlePanel.setBackground(WL_BLUE);
JLabel title = new JLabel("<html><b>" + settings.getMenuName() + "</b></html>");
title.setForeground(Color.WHITE);
title.setBackground(Color.GRAY);
titlePanel.add(title);
contextPanel.add(titlePanel);
contextPanel.invalidate();
// Fetch the manager of the context menu
ContextMenuManager cmm = ContextMenuManager.getContextMenuManager();
// fetch context menu component
ContextMenuComponent cmc = cell.getComponent(ContextMenuComponent.class);
// show standard menu items?
if (settings.isDisplayStandard() == true) {
// fetch standard items from CMM
List<ContextMenuFactorySPI> factoryList = cmm.getContextMenuFactoryList();
// add each item to the menu
for (ContextMenuFactorySPI factory : factoryList) {
ContextMenuItem items[] = factory.getContextMenuItems(event);
for (ContextMenuItem item : items) {
addContextMenuItem(item, cell);
}
}
}
// show cell-specific standard items?
if (settings.isDisplayCellStandard() && cmc != null) {
// fetch standard factories from CMC
ContextMenuFactorySPI factories[] = cmc.getContextMenuFactories();
// add each item to the menu
for (ContextMenuFactorySPI factory : factories) {
ContextMenuItem items[] = factory.getContextMenuItems(event);
for (ContextMenuItem item : items) {
addContextMenuItem(item, cell);
}
}
}
// show temporary items?
if (settings.isDisplayTemporaryFactories()) {
// fetch standard factories from CMC
List<ContextMenuFactorySPI> factoryList = settings.getFactoryList();
// add each item to the menu
for (ContextMenuFactorySPI factory : factoryList) {
ContextMenuItem items[] = factory.getContextMenuItems(event);
for (ContextMenuItem item : items) {
addContextMenuItem(item, cell);