Search in sources :

Example 1 with TektonTreePopupMenuListener

use of com.redhat.devtools.intellij.tektoncd.listener.TektonTreePopupMenuListener in project intellij-tekton by redhat-developer.

the class WindowToolFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    try {
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        TektonTreeStructure structure = new TektonTreeStructure(project);
        StructureTreeModel<TektonTreeStructure> model = buildModel(structure, project);
        new MutableTektonModelSynchronizer<>(model, structure, structure);
        Tree tree = new Tree(new AsyncTreeModel(model, project));
        tree.putClientProperty(Constants.STRUCTURE_PROPERTY, structure);
        tree.setCellRenderer(new NodeRenderer());
        ActionManager actionManager = ActionManager.getInstance();
        ActionGroup group = (ActionGroup) actionManager.getAction("com.redhat.devtools.intellij.tektoncd.tree");
        PopupHandler.installPopupHandler(tree, group, ActionPlaces.POPUP, actionManager, new TektonTreePopupMenuListener());
        new TektonTreeDoubleClickListener(tree);
        TknCliFactory.getInstance().getTkn(project).whenComplete((tkn, err) -> {
            HubModel hubModel = new HubModel(project, tkn, null);
            JPanel hubItemsListPanel = new HubItemPanelsBoard(hubModel, getDoSelectAction(project, hubModel)).withRecommended().withInstalled().build(Optional.empty());
            OnePixelSplitter tabPanel = createTabPanel(new JBScrollPane(tree), hubItemsListPanel);
            toolWindow.getContentManager().addContent(contentFactory.createContent(tabPanel, "", false));
            executeOnProjectClosing(project, () -> {
                structure.dispose();
                hubModel.dispose();
            });
        });
    } catch (IllegalAccessException | InvocationTargetException | InstantiationException | NoSuchMethodException e) {
        throw new RuntimeException((e));
    }
}
Also used : JPanel(javax.swing.JPanel) AsyncTreeModel(com.intellij.ui.tree.AsyncTreeModel) TektonTreeStructure(com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure) TektonTreeDoubleClickListener(com.redhat.devtools.intellij.tektoncd.listener.TektonTreeDoubleClickListener) HubItemPanelsBoard(com.redhat.devtools.intellij.tektoncd.ui.hub.HubItemPanelsBoard) OnePixelSplitter(com.intellij.ui.OnePixelSplitter) HubModel(com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel) ContentFactory(com.intellij.ui.content.ContentFactory) MutableTektonModelSynchronizer(com.redhat.devtools.intellij.tektoncd.tree.MutableTektonModelSynchronizer) InvocationTargetException(java.lang.reflect.InvocationTargetException) NodeRenderer(com.intellij.ide.util.treeView.NodeRenderer) ActionManager(com.intellij.openapi.actionSystem.ActionManager) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) Tree(com.intellij.ui.treeStructure.Tree) TektonTreePopupMenuListener(com.redhat.devtools.intellij.tektoncd.listener.TektonTreePopupMenuListener) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Aggregations

NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 OnePixelSplitter (com.intellij.ui.OnePixelSplitter)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 ContentFactory (com.intellij.ui.content.ContentFactory)1 AsyncTreeModel (com.intellij.ui.tree.AsyncTreeModel)1 Tree (com.intellij.ui.treeStructure.Tree)1 TektonTreeDoubleClickListener (com.redhat.devtools.intellij.tektoncd.listener.TektonTreeDoubleClickListener)1 TektonTreePopupMenuListener (com.redhat.devtools.intellij.tektoncd.listener.TektonTreePopupMenuListener)1 MutableTektonModelSynchronizer (com.redhat.devtools.intellij.tektoncd.tree.MutableTektonModelSynchronizer)1 TektonTreeStructure (com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure)1 HubItemPanelsBoard (com.redhat.devtools.intellij.tektoncd.ui.hub.HubItemPanelsBoard)1 HubModel (com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JPanel (javax.swing.JPanel)1