Example usage for javax.swing JPopupMenu getComponents

List of usage examples for javax.swing JPopupMenu getComponents

Introduction

In this page you can find the example usage for javax.swing JPopupMenu getComponents.

Prototype

public Component[] getComponents() 

Source Link

Document

Gets all the components in this container.

Usage

From source file:storybook.model.EntityUtil.java

public static JPopupMenu createPopupMenu(MainFrame mainFrame, AbstractEntity entity) {
    JPopupMenu menu = new JPopupMenu();
    if (entity == null) {
        return null;
    }/*from  w w  w . ja v a 2s. c  om*/
    if (entity.isTransient()) {
        return null;
    }
    JLabel lbTitle = new JLabel("   " + entity.toString());
    lbTitle.setFont(FontUtil.getBoldFont());
    menu.add(lbTitle);
    menu.add(new JPopupMenu.Separator());
    menu.add(new EditEntityAction(mainFrame, entity, false));
    if (entity instanceof Scene) {
        if (BookUtil.isUseLibreOffice(mainFrame)) {
            menu.add(new EditSceneLOAction(mainFrame, entity));
        }
    }
    menu.add(new DeleteEntityAction(mainFrame, entity));
    menu.add(new JPopupMenu.Separator());
    if (entity instanceof Scene || entity instanceof Chapter) {
        menu.add(new ShowInChronoViewAction(mainFrame, entity));
        menu.add(new ShowInBookViewAction(mainFrame, entity));
        menu.add(new ShowInManageViewAction(mainFrame, entity));
    }
    menu.add(new ShowInfoAction(mainFrame, entity));
    if (isAvailableInMemoria(entity)) {
        menu.add(new ShowInMemoriaAction(mainFrame, entity));
    }
    menu.add(new JPopupMenu.Separator());
    if (entity instanceof Scene) {
    }
    if (entity instanceof Chapter) {
        menu.add(new ChapterOrderByTimestampAction(mainFrame, (Chapter) entity));
        menu.add(new ChapterReSortAction(mainFrame, (Chapter) entity));
        menu.add(new JPopupMenu.Separator());
    }
    menu.add(new NewEntityAction(mainFrame, entity));
    if (entity instanceof Location) {
        // google maps
        menu.add(new JPopupMenu.Separator());
        menu.add(new ShowInGoogleMapsAction((Location) entity));
    }
    if (menu.getComponents().length == 0) {
        return null;
    }
    return menu;
}