Search in sources :

Example 16 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-community by JetBrains.

the class PathMappingTable method createListModel.

@Override
protected ListTableModel createListModel() {
    ColumnInfo local = new ElementsColumnInfoBase<PathMappingSettings.PathMapping>("Local path") {

        @Override
        public String valueOf(PathMappingSettings.PathMapping pathMapping) {
            return pathMapping.getLocalRoot();
        }

        @Override
        public boolean isCellEditable(PathMappingSettings.PathMapping pathMapping) {
            return canDeleteElement(pathMapping);
        }

        @Override
        public void setValue(PathMappingSettings.PathMapping pathMapping, String s) {
            if (s.equals(valueOf(pathMapping))) {
                return;
            }
            pathMapping.setLocalRoot(s);
            setModified();
        }

        @Override
        protected String getDescription(PathMappingSettings.PathMapping pathMapping) {
            return valueOf(pathMapping);
        }
    };
    ColumnInfo remote = new ElementsColumnInfoBase<PathMappingSettings.PathMapping>("Remote path") {

        @Override
        public String valueOf(PathMappingSettings.PathMapping pathMapping) {
            return pathMapping.getRemoteRoot();
        }

        @Override
        public boolean isCellEditable(PathMappingSettings.PathMapping pathMapping) {
            return canDeleteElement(pathMapping);
        }

        @Override
        public void setValue(PathMappingSettings.PathMapping pathMapping, String s) {
            if (s.equals(valueOf(pathMapping))) {
                return;
            }
            pathMapping.setRemoteRoot(s);
            setModified();
        }

        @Override
        protected String getDescription(PathMappingSettings.PathMapping pathMapping) {
            return valueOf(pathMapping);
        }
    };
    return new ListTableModel((new ColumnInfo[] { local, remote }));
}
Also used : ListTableModel(com.intellij.util.ui.ListTableModel) ColumnInfo(com.intellij.util.ui.ColumnInfo) PathMappingSettings(com.intellij.util.PathMappingSettings)

Example 17 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-community by JetBrains.

the class TreeTableView method setSizes.

private void setSizes() {
    ColumnInfo[] columns = ((ListTreeTableModelOnColumns) getTableModel()).getColumns();
    for (int i = 0; i < columns.length; i++) {
        ColumnInfo columnInfo = columns[i];
        TableColumn column = getColumnModel().getColumn(i);
        if (columnInfo.getWidth(this) > 0) {
            int width = columnInfo.getWidth(this);
            column.setMaxWidth(width);
            column.setMinWidth(width);
        } else {
            final String preferredValue = columnInfo.getPreferredStringValue();
            if (preferredValue != null) {
                int width = getFontMetrics(getFont()).stringWidth(preferredValue) + columnInfo.getAdditionalWidth();
                column.setPreferredWidth(width);
            }
        }
    }
}
Also used : ColumnInfo(com.intellij.util.ui.ColumnInfo) TableColumn(javax.swing.table.TableColumn)

Example 18 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-community by JetBrains.

the class CompareWithSelectedRevisionAction method showListPopup.

public static void showListPopup(final List<VcsFileRevision> revisions, final Project project, final Consumer<VcsFileRevision> selectedRevisionConsumer, final boolean showComments) {
    ColumnInfo[] columns = new ColumnInfo[] { REVISION_TABLE_COLUMN, DATE_TABLE_COLUMN, AUTHOR_TABLE_COLUMN };
    for (VcsFileRevision revision : revisions) {
        if (revision.getBranchName() != null) {
            columns = new ColumnInfo[] { REVISION_TABLE_COLUMN, BRANCH_TABLE_COLUMN, DATE_TABLE_COLUMN, AUTHOR_TABLE_COLUMN };
            break;
        }
    }
    final TableView<VcsFileRevision> table = new TableView<>(new ListTableModel<>(columns, revisions, 0));
    table.setShowHorizontalLines(false);
    table.setTableHeader(null);
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            VcsFileRevision revision = table.getSelectedObject();
            if (revision != null) {
                selectedRevisionConsumer.consume(revision);
            }
        }
    };
    if (table.getModel().getRowCount() == 0) {
        table.clearSelection();
    }
    new SpeedSearchBase<TableView>(table) {

        @Override
        protected int getSelectedIndex() {
            return table.getSelectedRow();
        }

        @Override
        protected int convertIndexToModel(int viewIndex) {
            return table.convertRowIndexToModel(viewIndex);
        }

        @Override
        protected Object[] getAllElements() {
            return revisions.toArray();
        }

        @Override
        protected String getElementText(Object element) {
            VcsFileRevision revision = (VcsFileRevision) element;
            return revision.getRevisionNumber().asString() + " " + revision.getBranchName() + " " + revision.getAuthor();
        }

        @Override
        protected void selectElement(Object element, String selectedText) {
            VcsFileRevision revision = (VcsFileRevision) element;
            TableUtil.selectRows(myComponent, new int[] { myComponent.convertRowIndexToView(revisions.indexOf(revision)) });
            TableUtil.scrollSelectionToVisible(myComponent);
        }
    };
    table.setMinimumSize(new Dimension(300, 50));
    final PopupChooserBuilder builder = new PopupChooserBuilder(table);
    if (showComments) {
        builder.setSouthComponent(createCommentsPanel(table));
    }
    builder.setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")).setItemChoosenCallback(runnable).setResizable(true).setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup").setMinSize(new Dimension(300, 300));
    final JBPopup popup = builder.createPopup();
    popup.showCenteredInCurrentWindow(project);
}
Also used : ColumnInfo(com.intellij.util.ui.ColumnInfo) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) JBPopup(com.intellij.openapi.ui.popup.JBPopup) TreeTableView(com.intellij.ui.dualView.TreeTableView) TableView(com.intellij.ui.table.TableView)

Example 19 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo 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));
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) ColumnInfo(com.intellij.util.ui.ColumnInfo) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) TreeTableView(com.intellij.ui.dualView.TreeTableView)

Example 20 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-community by JetBrains.

the class FileHistoryPanelImpl method createColumnList.

@NotNull
private DualViewColumnInfo[] createColumnList(@NotNull Project project, @NotNull VcsHistoryProvider provider, @Nullable ColumnInfo[] additionalColumns) {
    ArrayList<DualViewColumnInfo> columns = new ArrayList<>();
    columns.add(new RevisionColumnInfo(myRevisionsInOrderComparator));
    if (!provider.isDateOmittable())
        columns.add(new DateColumnInfo());
    columns.add(new AuthorColumnInfo());
    ArrayList<DualViewColumnInfo> additionalColumnInfo = new ArrayList<>();
    if (additionalColumns != null) {
        for (ColumnInfo additionalColumn : additionalColumns) {
            additionalColumnInfo.add(new FileHistoryColumnWrapper(additionalColumn) {

                @Override
                protected DualView getDualView() {
                    return myDualView;
                }
            });
        }
    }
    columns.addAll(additionalColumnInfo);
    columns.add(new MessageColumnInfo(project));
    return columns.toArray(new DualViewColumnInfo[columns.size()]);
}
Also used : DualView(com.intellij.ui.dualView.DualView) ColumnInfo(com.intellij.util.ui.ColumnInfo) DualViewColumnInfo(com.intellij.ui.dualView.DualViewColumnInfo) DualViewColumnInfo(com.intellij.ui.dualView.DualViewColumnInfo) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ColumnInfo (com.intellij.util.ui.ColumnInfo)27 TableCellRenderer (javax.swing.table.TableCellRenderer)7 TreeTableView (com.intellij.ui.dualView.TreeTableView)4 TreeTableModel (com.intellij.ui.treeStructure.treetable.TreeTableModel)4 ListTableModel (com.intellij.util.ui.ListTableModel)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 NotNull (org.jetbrains.annotations.NotNull)4 TableView (com.intellij.ui.table.TableView)3 ListTreeTableModelOnColumns (com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns)3 List (java.util.List)3 TableColumn (javax.swing.table.TableColumn)3 Project (com.intellij.openapi.project.Project)2 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)2 TreeColumnInfo (com.intellij.ui.treeStructure.treetable.TreeColumnInfo)2 AsyncProcessIcon (com.intellij.util.ui.AsyncProcessIcon)2 ArrayList (java.util.ArrayList)2 TableCellEditor (javax.swing.table.TableCellEditor)2 Nullable (org.jetbrains.annotations.Nullable)2 DependencyCellRenderer (com.android.tools.idea.gradle.structure.configurables.ui.dependencies.AbstractDeclaredDependenciesTableModel.DependencyCellRenderer)1 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)1