private void createUIComponents() { UpdaterTreeNode.Renderer renderer = new SummaryTreeNode.Renderer(); myPlatformLoadingIcon = new AsyncProcessIcon("Loading..."); myPlatformSummaryRootNode = new RootNode(); myPlatformDetailsRootNode = new RootNode(); ColumnInfo[] platformSummaryColumns = new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new ApiLevelColumnInfo(), new RevisionColumnInfo(), new StatusColumnInfo()}; myPlatformSummaryTable = new TreeTableView(new ListTreeTableModelOnColumns(myPlatformSummaryRootNode, platformSummaryColumns)); SdkUpdaterConfigPanel.setTreeTableProperties(myPlatformSummaryTable, renderer); MouseListener modificationListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { refreshModified(); } }; myPlatformSummaryTable.addMouseListener(modificationListener); ColumnInfo[] platformDetailColumns = new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new ApiLevelColumnInfo(), new RevisionColumnInfo(), new StatusColumnInfo()}; myPlatformDetailTable = new TreeTableView(new ListTreeTableModelOnColumns(myPlatformDetailsRootNode, platformDetailColumns)); SdkUpdaterConfigPanel.setTreeTableProperties(myPlatformDetailTable, renderer); myPlatformDetailTable.addMouseListener(modificationListener); }
private void refreshTreeStructure() { myRootNode.removeAllChildren(); final ArrayList<PsiMethod> methods = new ArrayList<PsiMethod>(myData.keySet()); Collections.sort(methods, new Comparator<PsiMethod>() { public int compare(final PsiMethod o1, final PsiMethod o2) { final int names = o1.getName().compareTo(o2.getName()); if (names != 0) return names; return o1.getParameterList().getParametersCount() - o2.getParameterList().getParametersCount(); } }); for (PsiMethod method : methods) { final PsiParameter[] params = method.getParameterList().getParameters(); final DefaultMutableTreeNode methodNode = new DefaultMutableTreeNode(method, true); myRootNode.add(methodNode); for (final PsiParameter parameter : params) { methodNode.add(new DefaultMutableTreeNode(parameter, false)); } } final ListTreeTableModelOnColumns tableModel = (ListTreeTableModelOnColumns)myParamsTable.getTableModel(); tableModel.reload(); TreeUtil.expandAll(myParamsTable.getTree()); myParamsTable.revalidate(); }
public TestRunResultsView(Project project) { this.model = new ListTreeTableModelOnColumns(null, COLUMNS.toArray(new ColumnInfo[COLUMNS.size()])); this.tree = new TreeTable(this.model); this.tree.getColumnModel().getColumn(0).setMinWidth(TestMeasureColumnInfo.MeasureProperty.GROUP.width * 2); for (TestMeasureColumnInfo.MeasureProperty prop : TestMeasureColumnInfo.MeasureProperty.values()) { //first column is name column which is not included in MeasureProperties, that's why we add 1. this.tree.getColumnModel().getColumn(prop.ordinal() + 1).setMinWidth(prop.width); } this.panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(this.tree)); //set text when no tests were fetched yet this.setEmptyText(Messages.getMessage("execution.result.ui.loading")); //add rightclick dialog DefaultActionGroup dag = new DefaultActionGroup(); dag.add(new OpenInEditorAction(() -> { TestResultNode node = this.getSelectedNode(); if (node != null) { return node.getResult(); } return null; }, project)); PopupHandler.installUnknownPopupHandler(this.tree, dag, ActionManager.getInstance()); }
public JsonTreeTableView(TreeNode rootNode, ColumnInfo[] columnInfos) { super(new ListTreeTableModelOnColumns(rootNode, columnInfos)); this.columns = columnInfos; final TreeTableTree tree = getTree(); tree.setShowsRootHandles(true); tree.setRootVisible(false); UIUtil.setLineStyleAngled(tree); setTreeCellRenderer(new KeyCellRenderer()); TreeUtil.expand(tree, 2); new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() { @Override public String convert(final TreePath path) { final NoSqlTreeNode node = (NoSqlTreeNode) path.getLastPathComponent(); NodeDescriptor descriptor = node.getDescriptor(); return descriptor.getFormattedKey(); } }); }
private Component createTreeComponent(DualViewColumnInfo[] columns, TreeNode root) { myTreeView = new TreeTableView(new ListTreeTableModelOnColumns(root, createTreeColumns(columns))) { public TableCellRenderer getCellRenderer(int row, int column) { return createWrappedRenderer(super.getCellRenderer(row, column)); } }; myTreeView.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JPanel result = new JPanel(new BorderLayout()); result.add(ScrollPaneFactory.createScrollPane(myTreeView), BorderLayout.CENTER); return result; }
public void changeColumnSet(DualViewColumnInfo[] columns) { myTreeView.setTableModel(new ListTreeTableModelOnColumns((TreeNode)myTreeView.getTreeViewModel().getRoot(), createTreeColumns(columns))); myFlatView.setModelAndUpdateColumns(new ListTableModel(columns)); if (myTreeCellRenderer != null) myTreeView.setTreeCellRenderer(myTreeCellRenderer); setRootVisible(myRootVisible); refreshFlatModel(); addWidthListenersTo(myTreeView); addWidthListenersTo(myFlatView); }
public CheckboxTreeTable(CheckedTreeNode root, CheckboxTree.CheckboxTreeCellRenderer renderer, final ColumnInfo[] columns) { super(new ListTreeTableModelOnColumns(root, columns)); final TreeTableTree tree = getTree(); myEventDispatcher = EventDispatcher.create(CheckboxTreeListener.class); CheckboxTreeHelper helper = new CheckboxTreeHelper(CheckboxTreeHelper.DEFAULT_POLICY, myEventDispatcher); helper.initTree(tree, this, renderer); tree.setSelectionRow(0); }
private static void showTreePopup(final List<TreeItem<VcsFileRevision>> roots, final VirtualFile file, final Project project, final DiffProvider diffProvider) { final TreeTableView treeTable = new TreeTableView(new ListTreeTableModelOnColumns(new TreeNodeAdapter(null, null, roots), new ColumnInfo[]{BRANCH_COLUMN, REVISION_COLUMN, DATE_COLUMN, AUTHOR_COLUMN})); Runnable runnable = new Runnable() { @Override public void run() { int index = treeTable.getSelectionModel().getMinSelectionIndex(); if (index == -1) { return; } VcsFileRevision revision = getRevisionAt(treeTable, index); if (revision != null) { DiffActionExecutor.showDiff(diffProvider, revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH); } } }; treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); new PopupChooserBuilder(treeTable). setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")). setItemChoosenCallback(runnable). setSouthComponent(createCommentsPanel(treeTable)). setResizable(true). setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup"). createPopup(). showCenteredInCurrentWindow(project); final int lastRow = treeTable.getRowCount() - 1; if (lastRow < 0) return; treeTable.getSelectionModel().addSelectionInterval(lastRow, lastRow); treeTable.scrollRectToVisible(treeTable.getCellRect(lastRow, 0, true)); }
private void createUIComponents() { myToolsLoadingIcon = new AsyncProcessIcon("Loading..."); myToolsSummaryRootNode = new RootNode(); myToolsDetailsRootNode = new RootNode(); UpdaterTreeNode.Renderer renderer = new SummaryTreeNode.Renderer(); ColumnInfo[] toolsSummaryColumns = new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new VersionColumnInfo(), new StatusColumnInfo()}; myToolsSummaryTable = new TreeTableView(new ListTreeTableModelOnColumns(myToolsSummaryRootNode, toolsSummaryColumns)); SdkUpdaterConfigPanel.setTreeTableProperties(myToolsSummaryTable, renderer); ColumnInfo[] toolsDetailColumns = new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new VersionColumnInfo(), new StatusColumnInfo()}; myToolsDetailTable = new TreeTableView(new ListTreeTableModelOnColumns(myToolsDetailsRootNode, toolsDetailColumns)); SdkUpdaterConfigPanel.setTreeTableProperties(myToolsDetailTable, renderer); MouseListener modificationListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { refreshModified(); } }; myToolsDetailTable.addMouseListener(modificationListener); myToolsSummaryTable.addMouseListener(modificationListener); }
private void removeItemFromTree(DItemElement itemElement, DClassElement classElement) { DynamicToolWindowWrapper wrapper = DynamicToolWindowWrapper.getInstance(myProject); ListTreeTableModelOnColumns model = wrapper.getTreeTableModel(); Object classNode = TreeUtil.findNodeWithObject(classElement, model, model.getRoot()); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) TreeUtil.findNodeWithObject(itemElement, model, classNode); if (node == null) return; DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); doRemove(wrapper, node, parent); }
private void removeClassFromTree(DClassElement classElement) { DynamicToolWindowWrapper wrapper = DynamicToolWindowWrapper.getInstance(myProject); ListTreeTableModelOnColumns model = wrapper.getTreeTableModel(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) TreeUtil.findNodeWithObject(classElement, model, model.getRoot()); if (node == null) return; DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); doRemove(wrapper, node, parent); }
private static <T> TreeTableModel createModel(final Collection<? extends TreeTableColumn<T>> columns, final ContentProvider<T> contentProvider) { final Collection<ColumnInfo> columnsInfos = new ArrayList<ColumnInfo>(columns.size()); boolean first = true; for (final TreeTableColumn<T> column : columns) { if (first) { columnsInfos.add(new TreeColumnInfo(column.getCaption())); } else { columnsInfos.add(new ColumnInfo(column.getCaption()) { public Object valueOf(final Object o) { return o; } public Class getColumnClass() { return TableColumnMarker.class; } }); } first = false; } final DefaultMutableTreeNode root; final Collection<? extends T> rootObjects = contentProvider.getRoots(); if (!rootObjects.isEmpty()) { if (rootObjects.size() == 1) { root = new DefaultMutableTreeNode(rootObjects.iterator().next()); addChildren(root, contentProvider); } else { root = new DefaultMutableTreeNode(HIDDEN_ROOT); for (final T rootObject : rootObjects) { final DefaultMutableTreeNode subRoot = new DefaultMutableTreeNode(rootObject); addChildren(subRoot, contentProvider); root.add(subRoot); } } } else { root = null; } return new ListTreeTableModelOnColumns(root, columnsInfos.toArray(new ColumnInfo[columnsInfos.size()])); }
private static void showTreePopup(final List<TreeItem<VcsFileRevision>> roots, final VirtualFile file, final Project project, final DiffProvider diffProvider) { final TreeTableView treeTable = new TreeTableView(new ListTreeTableModelOnColumns(new TreeNodeAdapter(null, null, roots), new ColumnInfo[]{BRANCH_COLUMN, REVISION_COLUMN, DATE_COLUMN, AUTHOR_COLUMN})); Runnable runnable = new Runnable() { public void run() { int index = treeTable.getSelectionModel().getMinSelectionIndex(); if (index == -1) { return; } VcsFileRevision revision = getRevisionAt(treeTable, index); if (revision != null) { DiffActionExecutor.showDiff(diffProvider, revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH); } } }; treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); new PopupChooserBuilder(treeTable). setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")). setItemChoosenCallback(runnable). setSouthComponent(createCommentsPanel(treeTable)). setResizable(true). setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup"). createPopup(). showCenteredInCurrentWindow(project); }
private void createTree() { DefaultMutableTreeNode root = new DefaultMutableTreeNode(); for (AddedFileInfo myRoot : myRoots) { root.add(myRoot); } myModel = new ListTreeTableModelOnColumns(root, COLUMNS); myTreeTable = new TreeTableView(myModel); int comboHeight = new JComboBox().getPreferredSize().height; int checkBoxHeight = new JCheckBox().getPreferredSize().height; myTreeTable.setMinRowHeight(Math.max(comboHeight, checkBoxHeight) + 2); myTreeTable.setRootVisible(false); final JTableHeader tableHeader = myTreeTable.getTableHeader(); tableHeader.setReorderingAllowed(false); tableHeader.setResizingAllowed(false); final TreeTableTree tree = myTreeTable.getTree(); myTreeTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { final int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_SPACE) { final int selectedColumn = myTreeTable.getSelectedColumn(); if (selectedColumn == 0) { return; } final int[] selectedRows = myTreeTable.getSelectedRows(); if (selectedRows.length == 0) { return; } final boolean included = !((AddedFileInfo)myTreeTable.getValueAt(selectedRows[0], 1)).included(); for (int selectedRow : selectedRows) { final AddedFileInfo addedFileInfo = (AddedFileInfo)myTreeTable.getValueAt(selectedRow, 1); addedFileInfo.setIncluded(included); myModel.nodeChanged(addedFileInfo); } } } }); tree.setCellRenderer(new AddedFileCellRenderer()); TreeUtil.installActions(tree); }
private void createUIComponents() { myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); myRootNode = new DefaultMutableTreeNode(null, true); myParamsTable = new MyView(new ListTreeTableModelOnColumns(myRootNode, createColumnInfos())); myAdvancedPanel = new AdvancedPanel(myProject, myOrigInjection); }
public MyView(ListTreeTableModelOnColumns treeTableModel) { super(treeTableModel); }
@Override public void navigate(boolean requestFocus) { if (canNavigateToSource()) { super.navigate(requestFocus); return; } DynamicToolWindowWrapper.getInstance(myProject).getToolWindow().activate(new Runnable() { @Override public void run() { 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); }
@Override public void navigate(boolean requestFocus) { DynamicToolWindowWrapper.getInstance(getProject()).getToolWindow().activate(new Runnable() { @Override public void run() { 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<String>(); 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); }
public ListTreeTableModelOnColumns getTreeTableModel() { getToolWindow(); return myTreeTableModel; }
public CheckboxTreeTable(CheckedTreeNode root, CheckboxTree.CheckboxTreeCellRenderer renderer, final ColumnInfo[] columns) { super(new ListTreeTableModelOnColumns(root, columns)); initTree(getTree(), renderer); }
public void navigate(boolean requestFocus) { if (canNavigateToSource()) { super.navigate(requestFocus); return; } DynamicToolWindowWrapper.getInstance(myProject).getToolWindow().activate(new Runnable() { public void run() { 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); }
public void navigate(boolean requestFocus) { DynamicToolWindowWrapper.getInstance(getProject()).getToolWindow().activate(new Runnable() { public void run() { 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<String>(); 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); }
private void createUIComponents() { myLanguagePanel = new LanguagePanel(getProject(), getOrigInjection()); myRootNode = new DefaultMutableTreeNode(null, true); myParamsTable = new MyView(new ListTreeTableModelOnColumns(myRootNode, createColumnInfos())); myAdvancedPanel = new AdvancedPanel(getProject(), getOrigInjection()); }