Search in sources :

Example 1 with PropertyEditorPanel

use of io.flutter.editor.PropertyEditorPanel in project flutter-intellij by flutter.

the class TextOnlyActionWrapper method updateOutline.

private void updateOutline(@NotNull FlutterOutline outline) {
    currentOutline = outline;
    final DefaultMutableTreeNode rootNode = getRootNode();
    rootNode.removeAllChildren();
    outlinesWithWidgets.clear();
    outlineToNodeMap.clear();
    if (outline.getChildren() != null) {
        computeOutlinesWithWidgets(outline);
        updateOutlineImpl(rootNode, outline.getChildren());
    }
    getTreeModel().reload(rootNode);
    tree.expandAll();
    if (currentEditor != null) {
        final Caret caret = currentEditor.getCaretModel().getPrimaryCaret();
        applyEditorSelectionToTree(caret);
    }
    if (FlutterSettings.getInstance().isEnableHotUi() && propertyEditPanel == null) {
        propertyEditSplitter = new Splitter(false, 0.75f);
        propertyEditPanel = new PropertyEditorPanel(inspectorGroupManagerService, project, flutterAnalysisServer, false, false, project);
        propertyEditPanel.initalize(null, activeOutlines, currentFile);
        propertyEditToolbarGroup = new DefaultActionGroup();
        final ActionToolbar windowToolbar = ActionManager.getInstance().createActionToolbar("PropertyArea", propertyEditToolbarGroup, true);
        final SimpleToolWindowPanel window = new SimpleToolWindowPanel(true, true);
        window.setToolbar(windowToolbar.getComponent());
        final JScrollPane propertyScrollPane = ScrollPaneFactory.createScrollPane(propertyEditPanel);
        window.setContent(propertyScrollPane);
        propertyEditSplitter.setFirstComponent(window.getComponent());
        final InspectorGroupManagerService.Client inspectorStateServiceClient = new InspectorGroupManagerService.Client(project) {

            @Override
            public void onInspectorAvailabilityChanged() {
                super.onInspectorAvailabilityChanged();
                // the inspector supports the neccessary apis.
                if (getInspectorService() != null && getInspectorService().isHotUiScreenMirrorSupported()) {
                    // Wait to create the preview area until it is needed.
                    if (previewArea == null) {
                        previewArea = new PreviewArea(project, outlinesWithWidgets, project);
                    }
                    propertyEditSplitter.setSecondComponent(previewArea.getComponent());
                } else {
                    propertyEditSplitter.setSecondComponent(null);
                }
            }
        };
        inspectorGroupManagerService.addListener(inspectorStateServiceClient, project);
        splitter.setSecondComponent(propertyEditSplitter);
    }
    // TODO(jacobr): this is the wrong spot.
    if (propertyEditToolbarGroup != null) {
        final TitleAction propertyTitleAction = new TitleAction("Properties");
        propertyEditToolbarGroup.removeAll();
        propertyEditToolbarGroup.add(propertyTitleAction);
    }
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) PropertyEditorPanel(io.flutter.editor.PropertyEditorPanel) InspectorGroupManagerService(io.flutter.inspector.InspectorGroupManagerService) Caret(com.intellij.openapi.editor.Caret)

Aggregations

Caret (com.intellij.openapi.editor.Caret)1 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)1 Splitter (com.intellij.openapi.ui.Splitter)1 PropertyEditorPanel (io.flutter.editor.PropertyEditorPanel)1 InspectorGroupManagerService (io.flutter.inspector.InspectorGroupManagerService)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1