Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit ad600f4

Browse files
authored
fix: removed usage of PopupHandlerAdapter (#872)
Signed-off-by: Andre Dietisheim <[email protected]>
1 parent e31d94f commit ad600f4

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

src/main/java/org/jboss/tools/intellij/openshift/WindowToolFactory.java

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,49 @@
1717
import com.intellij.openapi.project.Project;
1818
import com.intellij.openapi.wm.ToolWindow;
1919
import com.intellij.openapi.wm.ToolWindowFactory;
20+
import com.intellij.ui.PopupHandler;
2021
import com.intellij.ui.components.JBPanel;
2122
import com.intellij.ui.components.JBScrollPane;
2223
import com.intellij.ui.content.Content;
2324
import com.intellij.ui.content.ContentFactory;
2425
import com.intellij.ui.tree.AsyncTreeModel;
2526
import com.intellij.ui.tree.StructureTreeModel;
2627
import com.intellij.ui.treeStructure.Tree;
27-
import com.redhat.devtools.intellij.common.compat.PopupHandlerAdapter;
2828
import com.redhat.devtools.intellij.common.tree.MutableModelSynchronizer;
2929
import com.redhat.devtools.intellij.common.tree.TreeHelper;
3030
import com.redhat.devtools.intellij.common.utils.IDEAContentFactory;
31+
import java.awt.BorderLayout;
32+
import java.util.ArrayList;
3133
import org.jboss.tools.intellij.openshift.tree.application.ApplicationsTreeStructure;
3234
import org.jetbrains.annotations.NotNull;
3335
import org.slf4j.Logger;
3436
import org.slf4j.LoggerFactory;
3537

36-
import java.awt.*;
37-
import java.lang.reflect.InvocationTargetException;
38-
import java.util.ArrayList;
39-
4038

4139
public class WindowToolFactory implements ToolWindowFactory {
4240

4341
private static final Logger LOGGER = LoggerFactory.getLogger(WindowToolFactory.class);
4442

4543
@Override
4644
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
47-
try {
48-
ContentFactory contentFactory = IDEAContentFactory.getInstance();
49-
JBPanel<JBPanel> panel = new JBPanel<>();
50-
panel.setLayout(new BorderLayout());
51-
Content content = contentFactory.createContent(panel, "", false);
52-
ApplicationsTreeStructure structure = new ApplicationsTreeStructure(project);
53-
StructureTreeModel<ApplicationsTreeStructure> model = new StructureTreeModel<>(structure, content);
54-
content.setDisposer(structure);
55-
new MutableModelSynchronizer<>(model, structure, structure);
56-
Tree tree = new Tree(new AsyncTreeModel(model, content));
57-
tree.putClientProperty(Constants.STRUCTURE_PROPERTY, structure);
58-
tree.setCellRenderer(new NodeRenderer());
59-
tree.setRootVisible(false);
60-
PopupHandlerAdapter.install(tree, "org.jboss.tools.intellij.tree", ActionPlaces.MAIN_MENU);
61-
panel.add(new JBScrollPane(tree), BorderLayout.CENTER);
62-
toolWindow.getContentManager().addContent(content);
63-
ArrayList<AnAction> actions = new ArrayList<>();
64-
actions.add(ActionManager.getInstance().getAction("org.jboss.tools.intellij.openshift.actions.toolwindow.FeedBackAction"));
65-
toolWindow.setTitleActions(actions);
66-
TreeHelper.addLinkSupport(tree);
67-
} catch (IllegalAccessException | InvocationTargetException e) {
68-
LOGGER.error(e.getMessage(), e);
69-
}
45+
ContentFactory contentFactory = IDEAContentFactory.getInstance();
46+
JBPanel<JBPanel> panel = new JBPanel<>();
47+
panel.setLayout(new BorderLayout());
48+
Content content = contentFactory.createContent(panel, "", false);
49+
ApplicationsTreeStructure structure = new ApplicationsTreeStructure(project);
50+
StructureTreeModel<ApplicationsTreeStructure> model = new StructureTreeModel<>(structure, content);
51+
content.setDisposer(structure);
52+
new MutableModelSynchronizer<>(model, structure, structure);
53+
Tree tree = new Tree(new AsyncTreeModel(model, content));
54+
tree.putClientProperty(Constants.STRUCTURE_PROPERTY, structure);
55+
tree.setCellRenderer(new NodeRenderer());
56+
tree.setRootVisible(false);
57+
PopupHandler.installPopupMenu(tree, "org.jboss.tools.intellij.tree", ActionPlaces.MAIN_MENU);
58+
panel.add(new JBScrollPane(tree), BorderLayout.CENTER);
59+
toolWindow.getContentManager().addContent(content);
60+
ArrayList<AnAction> actions = new ArrayList<>();
61+
actions.add(ActionManager.getInstance().getAction("org.jboss.tools.intellij.openshift.actions.toolwindow.FeedBackAction"));
62+
toolWindow.setTitleActions(actions);
63+
TreeHelper.addLinkSupport(tree);
7064
}
7165
}

0 commit comments

Comments
 (0)