Search in sources :

Example 1 with TreeTable

use of com.intellij.ui.treeStructure.treetable.TreeTable in project intellij-community by JetBrains.

the class GrDynamicImplicitProperty method navigate.

@Override
public void navigate(boolean requestFocus) {
    if (canNavigateToSource()) {
        super.navigate(requestFocus);
        return;
    }
    DynamicToolWindowWrapper.getInstance(myProject).getToolWindow().activate(() -> {
        DynamicToolWindowWrapper toolWindowWrapper = DynamicToolWindowWrapper.getInstance(myProject);
        final TreeTable treeTable = toolWindowWrapper.getTreeTable();
        final ListTreeTableModelOnColumns model = toolWindowWrapper.getTreeTableModel();
        Object root = model.getRoot();
        if (root == null || !(root instanceof DefaultMutableTreeNode))
            return;
        DefaultMutableTreeNode treeRoot = ((DefaultMutableTreeNode) root);
        final PsiClass psiClass = getContainingClassElement();
        if (psiClass == null)
            return;
        final DefaultMutableTreeNode desiredNode;
        DPropertyElement dynamicProperty = null;
        PsiClass trueSuper = null;
        for (PsiClass aSuper : PsiUtil.iterateSupers(psiClass, true)) {
            dynamicProperty = DynamicManager.getInstance(myProject).findConcreteDynamicProperty(aSuper.getQualifiedName(), getName());
            if (dynamicProperty != null) {
                trueSuper = aSuper;
                break;
            }
        }
        if (trueSuper == null)
            return;
        final DefaultMutableTreeNode classNode = TreeUtil.findNodeWithObject(treeRoot, new DClassElement(myProject, trueSuper.getQualifiedName()));
        if (classNode == null)
            return;
        desiredNode = TreeUtil.findNodeWithObject(classNode, dynamicProperty);
        if (desiredNode == null)
            return;
        final TreePath path = TreeUtil.getPathFromRoot(desiredNode);
        treeTable.getTree().expandPath(path);
        treeTable.getTree().setSelectionPath(path);
        treeTable.getTree().fireTreeExpanded(path);
        ToolWindowManager.getInstance(myProject).getFocusManager().requestFocus(treeTable, true);
        treeTable.revalidate();
        treeTable.repaint();
    }, true);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DPropertyElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DPropertyElement) DClassElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DClassElement) TreePath(javax.swing.tree.TreePath) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable)

Example 2 with TreeTable

use of com.intellij.ui.treeStructure.treetable.TreeTable in project android by JetBrains.

the class TraceViewPanel method createUIComponents.

private void createUIComponents() {
    MouseAdapter l = new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getSource() == myCloseLabel) {
                closeSearchComponent();
            } else if (e.getSource() == mySearchLabel) {
                showSearchComponent();
            } else if (e.getSource() == myZoomFitLabel) {
                myTraceViewCanvas.zoomFit();
            }
        }
    };
    myDefaultHeaderPanel = new EditorHeaderComponent();
    mySearchLabel = new JLabel(AllIcons.Actions.Search);
    mySearchLabel.addMouseListener(l);
    mySearchLabel.setToolTipText("Find (Ctrl + F)");
    myZoomFitLabel = new JLabel(AndroidIcons.ZoomFit);
    myZoomFitLabel.setToolTipText("Zoom Fit");
    myZoomFitLabel.addMouseListener(l);
    myFindPanel = new EditorHeaderComponent();
    myFindFieldWrapper = new NonOpaquePanel(new BorderLayout());
    mySearchField = createSearchField();
    myFindFieldWrapper.add(mySearchField);
    myCloseLabel = new JLabel(AllIcons.Actions.Cross);
    myCloseLabel.addMouseListener(l);
    myVmStatsTreeTableModel = new VmStatsTreeTableModel();
    myTreeTable = new TreeTable(myVmStatsTreeTableModel);
    myTraceViewCanvas = new TraceViewCanvasWrapper();
    JBScrollPane scrollPane = new JBScrollPane(myTreeTable);
    mySplitter = new JBSplitter(true, 0.75f);
    mySplitter.setShowDividerControls(true);
    mySplitter.setShowDividerIcon(true);
    mySplitter.setFirstComponent(myTraceViewCanvas);
    mySplitter.setSecondComponent(scrollPane);
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) EditorHeaderComponent(com.intellij.openapi.editor.impl.EditorHeaderComponent) JBSplitter(com.intellij.ui.JBSplitter) JBScrollPane(com.intellij.ui.components.JBScrollPane) VmStatsTreeTableModel(com.android.tools.idea.editors.vmtrace.treemodel.VmStatsTreeTableModel)

Example 3 with TreeTable

use of com.intellij.ui.treeStructure.treetable.TreeTable in project intellij-community by JetBrains.

the class OptionTableWithPreviewPanel method createOptionsTree.

protected TreeTable createOptionsTree(CodeStyleSettings settings) {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    Map<String, DefaultMutableTreeNode> groupsMap = new THashMap<>();
    List<Option> sorted = sortOptions(ContainerUtil.concat(myOptions, myCustomOptions));
    for (Option each : sorted) {
        if (!(myCustomOptions.contains(each) || myAllowedOptions.contains(each.field.getName()) || myShowAllStandardOptions))
            continue;
        String group = each.groupName;
        MyTreeNode newNode = new MyTreeNode(each, each.title, settings);
        DefaultMutableTreeNode groupNode = groupsMap.get(group);
        if (groupNode != null) {
            groupNode.add(newNode);
        } else {
            String groupName;
            if (group == null) {
                groupName = each.title;
                groupNode = newNode;
            } else {
                groupName = group;
                groupNode = new DefaultMutableTreeNode(groupName);
                groupNode.add(newNode);
            }
            groupsMap.put(groupName, groupNode);
            rootNode.add(groupNode);
        }
    }
    ListTreeTableModel model = new ListTreeTableModel(rootNode, COLUMNS);
    TreeTable treeTable = new TreeTable(model) {

        @Override
        public TreeTableCellRenderer createTableRenderer(TreeTableModel treeTableModel) {
            TreeTableCellRenderer tableRenderer = super.createTableRenderer(treeTableModel);
            UIUtil.setLineStyleAngled(tableRenderer);
            tableRenderer.setRootVisible(false);
            tableRenderer.setShowsRootHandles(true);
            return tableRenderer;
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            TreePath treePath = getTree().getPathForRow(row);
            if (treePath == null)
                return super.getCellRenderer(row, column);
            Object node = treePath.getLastPathComponent();
            @SuppressWarnings("unchecked") TableCellRenderer renderer = COLUMNS[column].getRenderer(node);
            return renderer == null ? super.getCellRenderer(row, column) : renderer;
        }

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            TreePath treePath = getTree().getPathForRow(row);
            if (treePath == null)
                return super.getCellEditor(row, column);
            Object node = treePath.getLastPathComponent();
            @SuppressWarnings("unchecked") TableCellEditor editor = COLUMNS[column].getEditor(node);
            return editor == null ? super.getCellEditor(row, column) : editor;
        }
    };
    new TreeTableSpeedSearch(treeTable).setComparator(new SpeedSearchComparator(false));
    treeTable.setRootVisible(false);
    final JTree tree = treeTable.getTree();
    tree.setCellRenderer(myTitleRenderer);
    tree.setShowsRootHandles(true);
    //myTreeTable.setRowHeight(new JComboBox(new String[]{"Sample Text"}).getPreferredSize().height);
    treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.setTableHeader(null);
    TreeUtil.expandAll(tree);
    treeTable.getColumnModel().getSelectionModel().setAnchorSelectionIndex(1);
    treeTable.getColumnModel().getSelectionModel().setLeadSelectionIndex(1);
    int maxWidth = tree.getPreferredScrollableViewportSize().width + 10;
    final TableColumn titleColumn = treeTable.getColumnModel().getColumn(0);
    titleColumn.setPreferredWidth(maxWidth);
    titleColumn.setMinWidth(maxWidth);
    titleColumn.setMaxWidth(maxWidth);
    titleColumn.setResizable(false);
    //final TableColumn levelColumn = treeTable.getColumnModel().getColumn(1);
    //TODO[max]: better preffered size...
    //TODO[kb]: Did I fixed it by making the last column floating?
    //levelColumn.setPreferredWidth(valueSize.width);
    //levelColumn.setMaxWidth(valueSize.width);
    //levelColumn.setMinWidth(valueSize.width);
    //levelColumn.setResizable(false);
    final Dimension valueSize = new JLabel(ApplicationBundle.message("option.table.sizing.text")).getPreferredSize();
    treeTable.setPreferredScrollableViewportSize(new Dimension(maxWidth + valueSize.width + 10, 20));
    return treeTable;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) TreeTableCellRenderer(com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer) TreeTableSpeedSearch(com.intellij.ui.TreeTableSpeedSearch) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel) TableColumn(javax.swing.table.TableColumn) TreeTableCellRenderer(com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer) THashMap(gnu.trove.THashMap) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) TableCellEditor(javax.swing.table.TableCellEditor) SpeedSearchComparator(com.intellij.ui.SpeedSearchComparator)

Example 4 with TreeTable

use of com.intellij.ui.treeStructure.treetable.TreeTable in project intellij-plugins by JetBrains.

the class CompilerOptionsConfigurable method createTreeTable.

private TreeTable createTreeTable() {
    final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    final TreeTableModel model = new ListTreeTableModel(rootNode, createColumns());
    final TreeTable treeTable = new TreeTable(model);
    treeTable.getColumnModel().getColumn(1).setCellRenderer(createValueRenderer());
    treeTable.getColumnModel().getColumn(1).setCellEditor(createValueEditor());
    final TreeTableTree tree = treeTable.getTree();
    tree.setRootVisible(false);
    tree.setLineStyleAngled();
    tree.setShowsRootHandles(true);
    tree.setCellRenderer(createTreeCellRenderer());
    treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.setRowHeight(new JTextField("Fake").getPreferredSize().height + 3);
    //treeTable.setTableHeader(null);
    final DefaultActionGroup group = new DefaultActionGroup();
    group.add(new RestoreDefaultValueAction(tree));
    PopupHandler.installPopupHandler(treeTable, group, ActionPlaces.UNKNOWN, ActionManager.getInstance());
    new TreeTableSpeedSearch(treeTable, o -> {
        final Object userObject = ((DefaultMutableTreeNode) o.getLastPathComponent()).getUserObject();
        return userObject instanceof CompilerOptionInfo ? ((CompilerOptionInfo) userObject).DISPLAY_NAME : "";
    }).setComparator(new SpeedSearchComparator(false));
    return treeTable;
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) EventDispatcher(com.intellij.util.EventDispatcher) HyperlinkEvent(javax.swing.event.HyperlinkEvent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ColumnInfo(com.intellij.util.ui.ColumnInfo) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) THashMap(gnu.trove.THashMap) TableCellRenderer(javax.swing.table.TableCellRenderer) CompilerUIConfigurable(com.intellij.compiler.options.CompilerUIConfigurable) BCUtils(com.intellij.lang.javascript.flex.projectStructure.options.BCUtils) Nls(org.jetbrains.annotations.Nls) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) CompilerOptionsListener(com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptionsListener) Disposer(com.intellij.openapi.util.Disposer) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileUtil(com.intellij.openapi.util.io.FileUtil) ChangeListener(javax.swing.event.ChangeListener) Module(com.intellij.openapi.module.Module) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ChangeEvent(javax.swing.event.ChangeEvent) TreePath(javax.swing.tree.TreePath) ActionCallback(com.intellij.openapi.util.ActionCallback) ValueSource(com.intellij.flex.model.bc.ValueSource) TreeTableTree(com.intellij.ui.treeStructure.treetable.TreeTableTree) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) com.intellij.ui(com.intellij.ui) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) TreeCellRenderer(javax.swing.tree.TreeCellRenderer) CompilerOptions(com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptions) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) NotNull(org.jetbrains.annotations.NotNull) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) FlexUtils(com.intellij.lang.javascript.flex.FlexUtils) java.util(java.util) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) ActionListener(java.awt.event.ActionListener) FlexProjectLevelCompilerOptionsHolder(com.intellij.lang.javascript.flex.projectStructure.FlexProjectLevelCompilerOptionsHolder) ContainerUtil(com.intellij.util.containers.ContainerUtil) History(com.intellij.ui.navigation.History) FlexSdkType2(com.intellij.lang.javascript.flex.sdk.FlexSdkType2) TableCellEditor(javax.swing.table.TableCellEditor) Project(com.intellij.openapi.project.Project) DocumentEvent(javax.swing.event.DocumentEvent) PlatformIcons(com.intellij.util.PlatformIcons) TreeUtil(com.intellij.util.ui.tree.TreeUtil) StringUtil(com.intellij.openapi.util.text.StringUtil) ActionEvent(java.awt.event.ActionEvent) Disposable(com.intellij.openapi.Disposable) Sdk(com.intellij.openapi.projectRoots.Sdk) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Place(com.intellij.ui.navigation.Place) ResourceFilesMode(com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptions.ResourceFilesMode) ModifiableCompilerOptions(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableCompilerOptions) Pair(com.intellij.openapi.util.Pair) PathUtil(com.intellij.util.PathUtil) CompilerOptionInfo(com.intellij.flex.model.bc.CompilerOptionInfo) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel) javax.swing(javax.swing) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CompilerOptionInfo(com.intellij.flex.model.bc.CompilerOptionInfo) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) TreeTableTree(com.intellij.ui.treeStructure.treetable.TreeTableTree)

Example 5 with TreeTable

use of com.intellij.ui.treeStructure.treetable.TreeTable in project intellij-community by JetBrains.

the class GrDynamicImplicitMethod method navigate.

@Override
public void navigate(boolean requestFocus) {
    DynamicToolWindowWrapper.getInstance(getProject()).getToolWindow().activate(() -> {
        DynamicToolWindowWrapper toolWindowWrapper = DynamicToolWindowWrapper.getInstance(getProject());
        final TreeTable treeTable = toolWindowWrapper.getTreeTable();
        final ListTreeTableModelOnColumns model = toolWindowWrapper.getTreeTableModel();
        Object root = model.getRoot();
        if (root == null || !(root instanceof DefaultMutableTreeNode))
            return;
        DefaultMutableTreeNode treeRoot = ((DefaultMutableTreeNode) root);
        DefaultMutableTreeNode desiredNode;
        JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
        final PsiClassType fqClassName = facade.getElementFactory().createTypeByFQClassName(myContainingClassName, ProjectScope.getAllScope(getProject()));
        final PsiClass psiClass = fqClassName.resolve();
        if (psiClass == null)
            return;
        PsiClass trueClass = null;
        DMethodElement methodElement = null;
        final GrParameter[] parameters = getParameters();
        List<String> parameterTypes = new ArrayList<>();
        for (GrParameter parameter : parameters) {
            final String type = parameter.getType().getCanonicalText();
            parameterTypes.add(type);
        }
        for (PsiClass aSuper : PsiUtil.iterateSupers(psiClass, true)) {
            methodElement = DynamicManager.getInstance(getProject()).findConcreteDynamicMethod(aSuper.getQualifiedName(), getName(), ArrayUtil.toStringArray(parameterTypes));
            if (methodElement != null) {
                trueClass = aSuper;
                break;
            }
        }
        if (trueClass == null)
            return;
        final DefaultMutableTreeNode classNode = TreeUtil.findNodeWithObject(treeRoot, new DClassElement(getProject(), trueClass.getQualifiedName()));
        if (classNode == null)
            return;
        desiredNode = TreeUtil.findNodeWithObject(classNode, methodElement);
        if (desiredNode == null)
            return;
        final TreePath path = TreeUtil.getPathFromRoot(desiredNode);
        treeTable.getTree().expandPath(path);
        treeTable.getTree().setSelectionPath(path);
        treeTable.getTree().fireTreeExpanded(path);
        //        ToolWindowManager.getInstance(myProject).getFocusManager().requestFocus(treeTable, true);
        treeTable.revalidate();
        treeTable.repaint();
    }, true);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) ArrayList(java.util.ArrayList) DMethodElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DMethodElement) GrParameter(org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter) DClassElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DClassElement) TreePath(javax.swing.tree.TreePath)

Aggregations

TreeTable (com.intellij.ui.treeStructure.treetable.TreeTable)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 TreePath (javax.swing.tree.TreePath)3 ListTreeTableModel (com.intellij.ui.treeStructure.treetable.ListTreeTableModel)2 TreeTableModel (com.intellij.ui.treeStructure.treetable.TreeTableModel)2 AbstractTableCellEditor (com.intellij.util.ui.AbstractTableCellEditor)2 THashMap (gnu.trove.THashMap)2 TableCellEditor (javax.swing.table.TableCellEditor)2 TableCellRenderer (javax.swing.table.TableCellRenderer)2 VmStatsTreeTableModel (com.android.tools.idea.editors.vmtrace.treemodel.VmStatsTreeTableModel)1 CompilerUIConfigurable (com.intellij.compiler.options.CompilerUIConfigurable)1 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 CompilerOptionInfo (com.intellij.flex.model.bc.CompilerOptionInfo)1 ValueSource (com.intellij.flex.model.bc.ValueSource)1 FlexBundle (com.intellij.lang.javascript.flex.FlexBundle)1 FlexUtils (com.intellij.lang.javascript.flex.FlexUtils)1 FlexProjectLevelCompilerOptionsHolder (com.intellij.lang.javascript.flex.projectStructure.FlexProjectLevelCompilerOptionsHolder)1 CompilerOptions (com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptions)1 ResourceFilesMode (com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptions.ResourceFilesMode)1 CompilerOptionsListener (com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptionsListener)1