use of com.biglybt.pif.ui.menus.MenuBuilder in project BiglyBT by BiglySoftware.
the class TorrentMenuFancy method addPluginItem.
private void addPluginItem(Composite detailArea, final com.biglybt.pif.ui.menus.MenuItem item) {
// menuWillBeShown listeners might change the visibility, so run before check
MenuItemImpl menuImpl = ((MenuItemImpl) item);
menuImpl.invokeMenuWillBeShownListeners(getTarget(item));
if (!item.isVisible()) {
if (DEBUG_MENU) {
System.out.println("Menu Not Visible: " + item.getText() + ": " + item.getMenuID());
}
return;
}
Graphic graphic = item.getGraphic();
FancyRowInfo row;
if (DEBUG_MENU) {
System.out.println("Menu " + item.getText() + ": " + item.getMenuID());
}
if (item.getStyle() == com.biglybt.pif.ui.menus.MenuItem.STYLE_MENU) {
row = createMenuRow(detailArea, item.getResourceKey(), null, new FancyMenuRowInfoListener() {
@Override
public void buildMenu(Menu menu) {
if (dms.length != 0) {
MenuBuilder submenuBuilder = ((MenuItemImpl) item).getSubmenuBuilder();
if (submenuBuilder != null) {
try {
item.removeAllChildItems();
submenuBuilder.buildSubmenu(item, getTarget(item));
} catch (Throwable t) {
Debug.out(t);
}
}
MenuBuildUtils.addPluginMenuItems(item.getItems(), menu, false, true, new MenuBuildUtils.PluginMenuController() {
@Override
public Listener makeSelectionListener(final com.biglybt.pif.ui.menus.MenuItem plugin_menu_item) {
return new TableSelectedRowsListener(tv, false) {
@Override
public boolean run(TableRowCore[] rows) {
if (rows.length != 0) {
((MenuItemImpl) plugin_menu_item).invokeListenersMulti(getTarget(item));
}
return true;
}
};
}
@Override
public void notifyFillListeners(com.biglybt.pif.ui.menus.MenuItem menu_item) {
((MenuItemImpl) menu_item).invokeMenuWillBeShownListeners(getTarget(item));
}
// @see com.biglybt.ui.swt.MenuBuildUtils.PluginMenuController#buildSubmenu(com.biglybt.pif.ui.menus.MenuItem)
@Override
public void buildSubmenu(com.biglybt.pif.ui.menus.MenuItem parent) {
com.biglybt.pif.ui.menus.MenuBuilder submenuBuilder = ((MenuItemImpl) parent).getSubmenuBuilder();
if (submenuBuilder != null) {
try {
parent.removeAllChildItems();
submenuBuilder.buildSubmenu(parent, getTarget(item));
} catch (Throwable t) {
Debug.out(t);
}
}
}
});
}
}
});
} else {
row = createRow(detailArea, item.getResourceKey(), null, new TableSelectedRowsListener(tv, false) {
@Override
public boolean run(TableRowCore[] rows) {
if (rows.length != 0) {
((MenuItemImpl) item).invokeListenersMulti(getTarget(item));
}
return true;
}
});
}
row.setEnabled(item.isEnabled());
if (graphic instanceof UISWTGraphic) {
row.getIconLabel().setImage(((UISWTGraphic) graphic).getImage());
} else if (graphic instanceof GraphicURI) {
ImageLoader.getInstance().setLabelImage(row.getIconLabel(), ((GraphicURI) graphic).getURI().toString());
}
}
Aggregations