Search in sources :

Example 1 with CTXMENU_TREE_EXPANDFIRSTONLY

use of com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPANDFIRSTONLY in project honest-profiler by jvm-profiling-tools.

the class ContextMenuUtil method getContextMenu.

/**
 * Constructs the {@link ContextMenu} for a {@link TreeItem}.
 * <p>
 * Based on the type of the Object contained in the {@link TreeItem}, menu options can be added.
 * <p>
 * The following options are always provided : Expand All (selected node and all its descendants), Expand First Only
 * (recursively expand only the first child) and Collapse All (collapse the entire subtree).
 * <p>
 * For {@link Node}s, the menu will (when fixed) add an Export To File option.
 * <p>
 *
 * @param <T> the type of the item contained in the {@link TreeItem}
 * @param appCtx the {@link ApplicationContext} of the application
 * @param treeItem the {@link TreeItem} for which the {@link ContextMenu} is constructed
 * @return the constructed {@link ContextMenu}
 */
private static <T> ContextMenu getContextMenu(ApplicationContext appCtx, TreeItem<T> treeItem) {
    ContextMenu menu = new ContextMenu();
    addMenuItem(menu.getItems(), appCtx.textFor(CTXMENU_TREE_EXPANDFULLY), info -> expandFully(treeItem));
    addMenuItem(menu.getItems(), appCtx.textFor(CTXMENU_TREE_EXPANDFIRSTONLY), info -> expandFirstOnly(treeItem));
    addMenuItem(menu.getItems(), appCtx.textFor(CTXMENU_TREE_COLLAPSE), info -> collapseFully(treeItem));
    // TODO FIX - ProfileNodes are no longer used.
    if (treeItem.getValue() instanceof Node) {
        addMenuItem(menu.getItems(), appCtx.textFor(CTXMENU_TREE_EXPORTSUBTREE), info -> showExportDialog(appCtx, menu.getScene().getWindow(), "stack_profile.txt", out -> writeStack(out, (Node) treeItem.getValue())));
    }
    return menu;
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) CTXMENU_TREE_EXPANDFIRSTONLY(com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPANDFIRSTONLY) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) CTXMENU_TREE_COLLAPSE(com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_COLLAPSE) TreeItem(javafx.scene.control.TreeItem) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node) ObjectBinding(javafx.beans.binding.ObjectBinding) Property(javafx.beans.property.Property) CTXMENU_TREE_EXPANDFULLY(com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPANDFULLY) TreeUtil.expandFully(com.insightfullogic.honest_profiler.ports.javafx.util.TreeUtil.expandFully) ApplicationContext(com.insightfullogic.honest_profiler.ports.javafx.model.ApplicationContext) DialogUtil.showExportDialog(com.insightfullogic.honest_profiler.ports.javafx.util.DialogUtil.showExportDialog) TreeUtil.expandFirstOnly(com.insightfullogic.honest_profiler.ports.javafx.util.TreeUtil.expandFirstOnly) TreeTableRow(javafx.scene.control.TreeTableRow) TreeTableView(javafx.scene.control.TreeTableView) ContextMenu(javafx.scene.control.ContextMenu) TreeTableCell(javafx.scene.control.TreeTableCell) TreeCell(javafx.scene.control.TreeCell) TreeUtil.collapseFully(com.insightfullogic.honest_profiler.ports.javafx.util.TreeUtil.collapseFully) CTXMENU_TREE_EXPORTSUBTREE(com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPORTSUBTREE) MenuUtil.addMenuItem(com.insightfullogic.honest_profiler.ports.javafx.util.MenuUtil.addMenuItem) ReportUtil.writeStack(com.insightfullogic.honest_profiler.ports.javafx.util.report.ReportUtil.writeStack) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node) ContextMenu(javafx.scene.control.ContextMenu)

Aggregations

Node (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)1 ApplicationContext (com.insightfullogic.honest_profiler.ports.javafx.model.ApplicationContext)1 DialogUtil.showExportDialog (com.insightfullogic.honest_profiler.ports.javafx.util.DialogUtil.showExportDialog)1 MenuUtil.addMenuItem (com.insightfullogic.honest_profiler.ports.javafx.util.MenuUtil.addMenuItem)1 CTXMENU_TREE_COLLAPSE (com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_COLLAPSE)1 CTXMENU_TREE_EXPANDFIRSTONLY (com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPANDFIRSTONLY)1 CTXMENU_TREE_EXPANDFULLY (com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPANDFULLY)1 CTXMENU_TREE_EXPORTSUBTREE (com.insightfullogic.honest_profiler.ports.javafx.util.ResourceUtil.CTXMENU_TREE_EXPORTSUBTREE)1 TreeUtil.collapseFully (com.insightfullogic.honest_profiler.ports.javafx.util.TreeUtil.collapseFully)1 TreeUtil.expandFirstOnly (com.insightfullogic.honest_profiler.ports.javafx.util.TreeUtil.expandFirstOnly)1 TreeUtil.expandFully (com.insightfullogic.honest_profiler.ports.javafx.util.TreeUtil.expandFully)1 ReportUtil.writeStack (com.insightfullogic.honest_profiler.ports.javafx.util.report.ReportUtil.writeStack)1 ObjectBinding (javafx.beans.binding.ObjectBinding)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 Property (javafx.beans.property.Property)1 ReadOnlyObjectProperty (javafx.beans.property.ReadOnlyObjectProperty)1 ContextMenu (javafx.scene.control.ContextMenu)1 TreeCell (javafx.scene.control.TreeCell)1 TreeItem (javafx.scene.control.TreeItem)1 TreeTableCell (javafx.scene.control.TreeTableCell)1