use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.
the class AddMultipleFilesOptionsDialog method createTree.
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);
}
use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.
the class CompareWithSelectedRevisionAction method showTreePopup.
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));
}
use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.
the class DynamicManagerImpl method removeItemFromTree.
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);
}
use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns in project intellij-community by JetBrains.
the class DynamicManagerImpl method addItemInTree.
private void addItemInTree(final DClassElement classElement, final DItemElement itemElement, final ToolWindow window) {
final ListTreeTableModelOnColumns myTreeTableModel = DynamicToolWindowWrapper.getInstance(myProject).getTreeTableModel();
window.activate(() -> {
final Object rootObject = myTreeTableModel.getRoot();
if (!(rootObject instanceof DefaultMutableTreeNode))
return;
final DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) rootObject;
DefaultMutableTreeNode node = new DefaultMutableTreeNode(itemElement);
if (rootNode.getChildCount() > 0) {
for (DefaultMutableTreeNode classNode = (DefaultMutableTreeNode) rootNode.getFirstChild(); classNode != null; classNode = (DefaultMutableTreeNode) rootNode.getChildAfter(classNode)) {
final Object classRow = classNode.getUserObject();
if (!(classRow instanceof DClassElement))
return;
DClassElement otherClassName = (DClassElement) classRow;
if (otherClassName.equals(classElement)) {
int index = getIndexToInsert(classNode, itemElement);
classNode.insert(node, index);
myTreeTableModel.nodesWereInserted(classNode, new int[] { index });
DynamicToolWindowWrapper.getInstance(myProject).setSelectedNode(node);
return;
}
}
}
// if there is no such class in tree
int index = getIndexToInsert(rootNode, classElement);
DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(classElement);
rootNode.insert(classNode, index);
myTreeTableModel.nodesWereInserted(rootNode, new int[] { index });
classNode.add(node);
myTreeTableModel.nodesWereInserted(classNode, new int[] { 0 });
DynamicToolWindowWrapper.getInstance(myProject).setSelectedNode(node);
}, true);
}
use of com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns 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);
}
Aggregations