private static JPanel createCommentsPanel(final TreeTableView treeTable) { JPanel panel = new JPanel(new BorderLayout()); final JTextArea textArea = createTextArea(); treeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(@NotNull ListSelectionEvent e) { final int index = treeTable.getSelectionModel().getMinSelectionIndex(); if (index == -1) { textArea.setText(""); } else { final VcsFileRevision revision = getRevisionAt(treeTable, index); if (revision != null) { textArea.setText(revision.getCommitMessage()); } else { textArea.setText(""); } } } }); final JScrollPane textScrollPane = ScrollPaneFactory.createScrollPane(textArea); panel.add(textScrollPane, BorderLayout.CENTER); textScrollPane.setBorder(IdeBorderFactory.createTitledBorder(VcsBundle.message("border.selected.revision.commit.message"), false )); return panel; }
@Override @Nullable public Object getTagAt(@NotNull final MouseEvent e) { // TODO[yole]: don't update renderer on every event, like it's done in TreeLinkMouseListener Object tag; JTable table = (JTable)e.getSource(); int row = table.rowAtPoint(e.getPoint()); int column = table.columnAtPoint(e.getPoint()); if (row == -1 || column == -1) return null; TableCellRenderer cellRenderer = table.getCellRenderer(row, column); if (cellRenderer instanceof DualView.TableCellRendererWrapper) { cellRenderer = ((DualView.TableCellRendererWrapper) cellRenderer).getRenderer(); } if (cellRenderer instanceof TreeTableView.CellRendererWrapper) { cellRenderer = ((TreeTableView.CellRendererWrapper) cellRenderer).getBaseRenderer(); } if (cellRenderer instanceof ColoredTableCellRenderer) { final ColoredTableCellRenderer renderer = (ColoredTableCellRenderer)cellRenderer; tag = forColoredRenderer(e, table, row, column, renderer); } else { tag = tryGetTag(e, table, row, column); } return tag; }
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); }
/** * This instance is created by Swing. * Do not call this constructor manually. */ public LanguagesPanel() { super(new BorderLayout()); SpoofaxIdeaPlugin.injector().injectMembers(this); final LanguageTreeModel model = new LanguageTreeModel(this.iconManager); this.languagesTree = new TreeTableView(model); this.languagesTree.setTreeCellRenderer(new LanguageTreeModel.LanguageTreeCellRenderer()); this.languagesTree.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(this.languagesTree) .setAddAction(this::addLanguage) .setAddActionUpdater(e -> this.controller != null) .setRemoveAction(button -> removeLanguage(getSelectedNode())) .setRemoveActionUpdater(e -> this.controller != null && getSelectedNode() != null) .disableUpDownActions(); add(toolbarDecorator.createPanel(), BorderLayout.CENTER); setBorder(IdeBorderFactory.createTitledBorder("Loaded languages", false)); }
private static JPanel createCommentsPanel(final TreeTableView treeTable) { JPanel panel = new JPanel(new BorderLayout()); final JTextArea textArea = createTextArea(); treeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { final int index = treeTable.getSelectionModel().getMinSelectionIndex(); if (index == -1) { textArea.setText(""); } else { final VcsFileRevision revision = getRevisionAt(treeTable, index); if (revision != null) { textArea.setText(revision.getCommitMessage()); } else { textArea.setText(""); } } } }); final JScrollPane textScrollPane = ScrollPaneFactory.createScrollPane(textArea); panel.add(textScrollPane, BorderLayout.CENTER); textScrollPane.setBorder(IdeBorderFactory.createTitledBorder(VcsBundle.message("border.selected.revision.commit.message"), false )); return panel; }
@Nullable protected Object getTagAt(final MouseEvent e) { // TODO[yole]: don't update renderer on every event, like it's done in TreeLinkMouseListener Object tag = null; JTable table = (JTable)e.getSource(); int row = table.rowAtPoint(e.getPoint()); int column = table.columnAtPoint(e.getPoint()); if (row == -1 || column == -1) return null; TableCellRenderer cellRenderer = table.getCellRenderer(row, column); if (cellRenderer instanceof DualView.TableCellRendererWrapper) { cellRenderer = ((DualView.TableCellRendererWrapper) cellRenderer).getRenderer(); } if (cellRenderer instanceof TreeTableView.CellRendererWrapper) { cellRenderer = ((TreeTableView.CellRendererWrapper) cellRenderer).getBaseRenderer(); } if (cellRenderer instanceof ColoredTableCellRenderer) { final ColoredTableCellRenderer renderer = (ColoredTableCellRenderer)cellRenderer; tag = forColoredRenderer(e, table, row, column, renderer); } else { tag = tryGetTag(e, table, row, column); } return tag; }
@Nullable public Object getTagAt(final MouseEvent e) { // TODO[yole]: don't update renderer on every event, like it's done in TreeLinkMouseListener Object tag = null; JTable table = (JTable)e.getSource(); int row = table.rowAtPoint(e.getPoint()); int column = table.columnAtPoint(e.getPoint()); if (row == -1 || column == -1) return null; TableCellRenderer cellRenderer = table.getCellRenderer(row, column); if (cellRenderer instanceof DualView.TableCellRendererWrapper) { cellRenderer = ((DualView.TableCellRendererWrapper) cellRenderer).getRenderer(); } if (cellRenderer instanceof TreeTableView.CellRendererWrapper) { cellRenderer = ((TreeTableView.CellRendererWrapper) cellRenderer).getBaseRenderer(); } if (cellRenderer instanceof ColoredTableCellRenderer) { final ColoredTableCellRenderer renderer = (ColoredTableCellRenderer)cellRenderer; tag = forColoredRenderer(e, table, row, column, renderer); } else { tag = tryGetTag(e, table, row, column); } return tag; }
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)); }
@Nullable private static VcsFileRevision getRevisionAt(final TreeTableView treeTable, final int index) { final List items = treeTable.getItems(); if (items.size() <= index) { return null; } else { return ((TreeNodeAdapter)items.get(index)).getRevision(); } }
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 createUIComponents() { myWorkItemsTableModel = new WorkItemsTableModel(new WorkItemsCheckinParameters()); myWorkItemsTable = new TreeTableView(myWorkItemsTableModel) { @Override protected void onTableChanged(@NotNull TableModelEvent e) { super.onTableChanged(e); getTree().setRowHeight(calculateRowHeight()); } }; }
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); }
CheckboxClickListener(TreeTableView mainComponent, final UpdaterTreeNode.Renderer renderer) { myTreeTable = mainComponent; myRenderer = renderer; }
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); }