Search in sources :

Example 1 with HubModel

use of com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel 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)

Example 2 with HubModel

use of com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel in project intellij-tekton by redhat-developer.

the class TektonHubAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "tekton hub");
    ExecHelper.submit(() -> {
        ParentableNode element = getElement(selected);
        Project project = getEventProject(anActionEvent);
        HubModel model = new HubModel(project, tkncli, element);
        telemetry.send();
        UIHelper.executeInUI(() -> {
            HubDialog wizard = new HubDialog(project, model);
            wizard.setModal(false);
            wizard.show();
            return wizard;
        });
    });
}
Also used : Project(com.intellij.openapi.project.Project) ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) HubDialog(com.redhat.devtools.intellij.tektoncd.ui.hub.HubDialog) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) HubModel(com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel)

Aggregations

HubModel (com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel)2 NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 Project (com.intellij.openapi.project.Project)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 ParentableNode (com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)1 TektonTreeStructure (com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure)1 HubDialog (com.redhat.devtools.intellij.tektoncd.ui.hub.HubDialog)1 HubItemPanelsBoard (com.redhat.devtools.intellij.tektoncd.ui.hub.HubItemPanelsBoard)1 ActionMessage (com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JPanel (javax.swing.JPanel)1