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 }));
}
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);
}
}
}
}
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);
}
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));
}
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()]);
}
Aggregations