|
55 | 55 | import javax.swing.*;
|
56 | 56 | import javax.swing.event.TreeSelectionEvent;
|
57 | 57 | import javax.swing.event.TreeSelectionListener;
|
| 58 | +import javax.swing.text.SimpleAttributeSet; |
| 59 | +import javax.swing.text.StyleConstants; |
| 60 | +import javax.swing.text.StyleContext; |
58 | 61 | import javax.swing.tree.DefaultMutableTreeNode;
|
59 | 62 | import javax.swing.tree.DefaultTreeModel;
|
60 | 63 | import javax.swing.tree.TreeNode;
|
@@ -192,92 +195,102 @@ public void initToolWindow(@NotNull ToolWindow toolWindow) {
|
192 | 195 | final ContentFactory contentFactory = ContentFactory.getInstance();
|
193 | 196 | final ContentManager contentManager = toolWindow.getContentManager();
|
194 | 197 |
|
195 |
| - final Content content = contentFactory.createContent(null, null, false); |
196 |
| - content.setCloseable(false); |
197 |
| - |
198 |
| - windowPanel = new OutlineComponent(this); |
199 |
| - content.setComponent(windowPanel); |
200 |
| - |
201 |
| - windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent()); |
202 |
| - |
203 |
| - final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); |
204 |
| - |
205 |
| - tree = new OutlineTree(rootNode); |
206 |
| - tree.setCellRenderer(new OutlineTreeCellRenderer()); |
207 |
| - tree.expandAll(); |
208 |
| - |
209 |
| - initTreePopup(); |
210 |
| - |
211 |
| - // Add collapse all, expand all, and show only widgets buttons. |
212 |
| - if (toolWindow instanceof ToolWindowEx toolWindowEx) { |
213 |
| - |
214 |
| - final CommonActionsManager actions = CommonActionsManager.getInstance(); |
215 |
| - final TreeExpander expander = new DefaultTreeExpander(tree); |
216 |
| - |
217 |
| - final AnAction expandAllAction = actions.createExpandAllAction(expander, tree); |
218 |
| - expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall); |
219 |
| - |
220 |
| - final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree); |
221 |
| - collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall); |
222 |
| - |
223 |
| - final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction(); |
224 |
| - |
225 |
| - toolWindowEx.setTitleActions(Arrays.asList(expandAllAction, collapseAllAction, showOnlyWidgetsAction)); |
226 |
| - } |
227 |
| - |
228 |
| - new TreeSpeedSearch(tree) { |
229 |
| - @Override |
230 |
| - protected String getElementText(Object element) { |
231 |
| - final TreePath path = (TreePath)element; |
232 |
| - final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); |
233 |
| - final Object object = node.getUserObject(); |
234 |
| - if (object instanceof OutlineObject) { |
235 |
| - return ((OutlineObject)object).getSpeedSearchString(); |
236 |
| - } |
237 |
| - return null; |
238 |
| - } |
239 |
| - }; |
240 |
| - |
241 |
| - tree.addMouseListener(new MouseAdapter() { |
242 |
| - @Override |
243 |
| - public void mouseClicked(MouseEvent e) { |
244 |
| - if (e.getClickCount() > 1) { |
245 |
| - final TreePath selectionPath = tree.getSelectionPath(); |
246 |
| - if (selectionPath != null) { |
247 |
| - selectPath(selectionPath, true); |
248 |
| - } |
249 |
| - } |
250 |
| - } |
251 |
| - }); |
252 |
| - |
253 |
| - tree.addTreeSelectionListener(treeSelectionListener); |
254 |
| - |
255 |
| - scrollPane = ScrollPaneFactory.createScrollPane(tree); |
256 |
| - content.setPreferredFocusableComponent(tree); |
257 |
| - |
258 |
| - contentManager.addContent(content); |
259 |
| - contentManager.setSelectedContent(content); |
260 |
| - |
261 |
| - splitter = new Splitter(true); |
262 |
| - setSplitterProportion(getState().getSplitterProportion()); |
263 |
| - getState().addListener(e -> { |
264 |
| - final float newProportion = getState().getSplitterProportion(); |
265 |
| - if (splitter.getProportion() != newProportion) { |
266 |
| - setSplitterProportion(newProportion); |
267 |
| - } |
268 |
| - }); |
269 |
| - //noinspection Convert2Lambda |
270 |
| - splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() { |
271 |
| - @Override |
272 |
| - public void propertyChange(PropertyChangeEvent evt) { |
273 |
| - if (!isSettingSplitterProportion) { |
274 |
| - getState().setSplitterProportion(splitter.getProportion()); |
275 |
| - } |
276 |
| - } |
277 |
| - }); |
278 |
| - scrollPane.setMinimumSize(new Dimension(1, 1)); |
279 |
| - splitter.setFirstComponent(scrollPane); |
280 |
| - windowPanel.setContent(splitter); |
| 198 | + final JPanel warning = new JPanel(new BorderLayout(50, 50)); |
| 199 | + JTextPane text = new JTextPane(); |
| 200 | + text.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); |
| 201 | + text.setCharacterAttributes( |
| 202 | + StyleContext.getDefaultStyleContext().addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, new Color(234, 57, 35)), false); |
| 203 | + text.setText("The Flutter Outline window is being removed soon. Use the Structure view instead: View -> Tool Windows -> Structure"); |
| 204 | + text.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD)); |
| 205 | + warning.add(text); |
| 206 | + contentManager.getComponent().add(warning); |
| 207 | + |
| 208 | + //final Content content = contentFactory.createContent(null, null, false); |
| 209 | + //content.setCloseable(false); |
| 210 | + // |
| 211 | + //windowPanel = new OutlineComponent(this); |
| 212 | + //content.setComponent(windowPanel); |
| 213 | + // |
| 214 | + //windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent()); |
| 215 | + // |
| 216 | + //final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); |
| 217 | + // |
| 218 | + //tree = new OutlineTree(rootNode); |
| 219 | + //tree.setCellRenderer(new OutlineTreeCellRenderer()); |
| 220 | + //tree.expandAll(); |
| 221 | + // |
| 222 | + //initTreePopup(); |
| 223 | + // |
| 224 | + //// Add collapse all, expand all, and show only widgets buttons. |
| 225 | + //if (toolWindow instanceof ToolWindowEx toolWindowEx) { |
| 226 | + // |
| 227 | + // final CommonActionsManager actions = CommonActionsManager.getInstance(); |
| 228 | + // final TreeExpander expander = new DefaultTreeExpander(tree); |
| 229 | + // |
| 230 | + // final AnAction expandAllAction = actions.createExpandAllAction(expander, tree); |
| 231 | + // expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall); |
| 232 | + // |
| 233 | + // final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree); |
| 234 | + // collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall); |
| 235 | + // |
| 236 | + // final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction(); |
| 237 | + // |
| 238 | + // toolWindowEx.setTitleActions(Arrays.asList(expandAllAction, collapseAllAction, showOnlyWidgetsAction)); |
| 239 | + //} |
| 240 | + // |
| 241 | + //new TreeSpeedSearch(tree) { |
| 242 | + // @Override |
| 243 | + // protected String getElementText(Object element) { |
| 244 | + // final TreePath path = (TreePath)element; |
| 245 | + // final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); |
| 246 | + // final Object object = node.getUserObject(); |
| 247 | + // if (object instanceof OutlineObject) { |
| 248 | + // return ((OutlineObject)object).getSpeedSearchString(); |
| 249 | + // } |
| 250 | + // return null; |
| 251 | + // } |
| 252 | + //}; |
| 253 | + // |
| 254 | + //tree.addMouseListener(new MouseAdapter() { |
| 255 | + // @Override |
| 256 | + // public void mouseClicked(MouseEvent e) { |
| 257 | + // if (e.getClickCount() > 1) { |
| 258 | + // final TreePath selectionPath = tree.getSelectionPath(); |
| 259 | + // if (selectionPath != null) { |
| 260 | + // selectPath(selectionPath, true); |
| 261 | + // } |
| 262 | + // } |
| 263 | + // } |
| 264 | + //}); |
| 265 | + // |
| 266 | + //tree.addTreeSelectionListener(treeSelectionListener); |
| 267 | + // |
| 268 | + //scrollPane = ScrollPaneFactory.createScrollPane(tree); |
| 269 | + //content.setPreferredFocusableComponent(tree); |
| 270 | + // |
| 271 | + //contentManager.addContent(content); |
| 272 | + //contentManager.setSelectedContent(content); |
| 273 | + // |
| 274 | + //splitter = new Splitter(true); |
| 275 | + //setSplitterProportion(getState().getSplitterProportion()); |
| 276 | + //getState().addListener(e -> { |
| 277 | + // final float newProportion = getState().getSplitterProportion(); |
| 278 | + // if (splitter.getProportion() != newProportion) { |
| 279 | + // setSplitterProportion(newProportion); |
| 280 | + // } |
| 281 | + //}); |
| 282 | + ////noinspection Convert2Lambda |
| 283 | + //splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() { |
| 284 | + // @Override |
| 285 | + // public void propertyChange(PropertyChangeEvent evt) { |
| 286 | + // if (!isSettingSplitterProportion) { |
| 287 | + // getState().setSplitterProportion(splitter.getProportion()); |
| 288 | + // } |
| 289 | + // } |
| 290 | + //}); |
| 291 | + //scrollPane.setMinimumSize(new Dimension(1, 1)); |
| 292 | + //splitter.setFirstComponent(scrollPane); |
| 293 | + //windowPanel.setContent(splitter); |
281 | 294 | }
|
282 | 295 |
|
283 | 296 | private void initTreePopup() {
|
|
0 commit comments