|
17 | 17 | import com.intellij.openapi.project.Project;
|
18 | 18 | import com.intellij.openapi.wm.ToolWindow;
|
19 | 19 | import com.intellij.openapi.wm.ToolWindowFactory;
|
| 20 | +import com.intellij.ui.PopupHandler; |
20 | 21 | import com.intellij.ui.components.JBPanel;
|
21 | 22 | import com.intellij.ui.components.JBScrollPane;
|
22 | 23 | import com.intellij.ui.content.Content;
|
23 | 24 | import com.intellij.ui.content.ContentFactory;
|
24 | 25 | import com.intellij.ui.tree.AsyncTreeModel;
|
25 | 26 | import com.intellij.ui.tree.StructureTreeModel;
|
26 | 27 | import com.intellij.ui.treeStructure.Tree;
|
27 |
| -import com.redhat.devtools.intellij.common.compat.PopupHandlerAdapter; |
28 | 28 | import com.redhat.devtools.intellij.common.tree.MutableModelSynchronizer;
|
29 | 29 | import com.redhat.devtools.intellij.common.tree.TreeHelper;
|
30 | 30 | import com.redhat.devtools.intellij.common.utils.IDEAContentFactory;
|
| 31 | +import java.awt.BorderLayout; |
| 32 | +import java.util.ArrayList; |
31 | 33 | import org.jboss.tools.intellij.openshift.tree.application.ApplicationsTreeStructure;
|
32 | 34 | import org.jetbrains.annotations.NotNull;
|
33 | 35 | import org.slf4j.Logger;
|
34 | 36 | import org.slf4j.LoggerFactory;
|
35 | 37 |
|
36 |
| -import java.awt.*; |
37 |
| -import java.lang.reflect.InvocationTargetException; |
38 |
| -import java.util.ArrayList; |
39 |
| - |
40 | 38 |
|
41 | 39 | public class WindowToolFactory implements ToolWindowFactory {
|
42 | 40 |
|
43 | 41 | private static final Logger LOGGER = LoggerFactory.getLogger(WindowToolFactory.class);
|
44 | 42 |
|
45 | 43 | @Override
|
46 | 44 | 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); |
70 | 64 | }
|
71 | 65 | }
|
0 commit comments