use of com.intellij.ui.table.TableView in project intellij-community by JetBrains.
the class ToBeMergedDialog method initUI.
private void initUI() {
final ListSelectionListener selectionListener = e -> {
List<SvnChangeList> changeLists = myRevisionsList.getSelectedObjects();
myAlreadyMerged.clear();
for (SvnChangeList changeList : changeLists) {
myAlreadyMerged.addAll(getAlreadyMergedPaths(changeList));
}
myRepositoryChangesBrowser.setChangesToDisplay(collectChanges(changeLists, false));
mySplitter.doLayout();
myRepositoryChangesBrowser.repaint();
};
final MyListCellRenderer listCellRenderer = new MyListCellRenderer();
myRevisionsList = new TableView<SvnChangeList>() {
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
return listCellRenderer;
}
@Override
public void valueChanged(ListSelectionEvent e) {
super.valueChanged(e);
selectionListener.valueChanged(e);
}
};
myRevisionsList.setExpandableItemsEnabled(false);
new TableViewSpeedSearch<SvnChangeList>(myRevisionsList) {
@Override
protected String getItemText(@NotNull SvnChangeList element) {
return element.getComment();
}
};
myRevisionsList.setModelAndUpdateColumns(myRevisionsModel);
myRevisionsList.setTableHeader(null);
myRevisionsList.setShowGrid(false);
final AbstractBaseTagMouseListener mouseListener = new AbstractBaseTagMouseListener() {
@Override
public Object getTagAt(@NotNull MouseEvent e) {
JTable table = (JTable) e.getSource();
int row = table.rowAtPoint(e.getPoint());
int column = table.columnAtPoint(e.getPoint());
if (row == -1 || column == -1)
return null;
listCellRenderer.customizeCellRenderer(table, table.getValueAt(row, column), table.isRowSelected(row));
return listCellRenderer.myRenderer.getFragmentTagAt(e.getPoint().x - table.getCellRect(row, column, false).x);
}
};
mouseListener.installOn(myRevisionsList);
myMore100Action = new MoreXAction(100);
myMore500Action = new MoreXAction(500);
BorderLayoutPanel panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(myRevisionsList)).addToTop(createToolbar().getComponent());
mySplitter = new Splitter(false, 0.7f);
mySplitter.setFirstComponent(panel);
myRepositoryChangesBrowser = new RepositoryChangesBrowser(myMergeContext.getProject(), Collections.<SvnChangeList>emptyList(), emptyList(), null);
myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(myRepositoryChangesBrowser.getDiffAction().getShortcutSet(), myRevisionsList);
setChangesDecorator();
mySplitter.setSecondComponent(myRepositoryChangesBrowser);
mySplitter.setDividerWidth(2);
addRevisionListListeners();
myPanel.add(mySplitter, BorderLayout.CENTER);
}
use of com.intellij.ui.table.TableView in project intellij-community by JetBrains.
the class TestNGConfigurationEditor method createView.
private void createView() {
commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);
classField.setComponent(new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {
@Override
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
if (declaration instanceof PsiClass && place.getParent() instanceof PsiJavaCodeReferenceElement) {
return Visibility.VISIBLE;
}
try {
if (declaration instanceof PsiClass && new TestClassBrowser(project, TestNGConfigurationEditor.this).getFilter().isAccepted((PsiClass) declaration)) {
return Visibility.VISIBLE;
}
} catch (MessageInfoException e) {
return Visibility.NOT_VISIBLE;
}
return Visibility.NOT_VISIBLE;
}
}));
final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, PlainTextLanguage.INSTANCE.getAssociatedFileType());
methodField.setComponent(methodEditorTextField);
groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
suiteField.setComponent(new TextFieldWithBrowseButton());
packageField.setVisible(true);
packageField.setEnabled(true);
packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));
TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
outputDirectory.setComponent(outputDirectoryButton);
outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
moduleClasspath.setEnabled(true);
moduleClasspath.setComponent(new ModulesComboBox());
propertiesTableModel = new TestNGParametersTableModel();
listenerModel = new TestNGListenersTableModel();
TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
propertiesFile.setComponent(textFieldWithBrowseButton);
FileChooserDescriptor propertiesFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
if (!showHidden && virtualFile.getName().charAt(0) == '.')
return false;
return virtualFile.isDirectory() || "properties".equals(virtualFile.getExtension());
}
};
textFieldWithBrowseButton.addBrowseFolderListener("TestNG", "Select .properties file for test properties", project, propertiesFileDescriptor);
propertiesTableView = new TableView(propertiesTableModel);
myPropertiesPanel.add(ToolbarDecorator.createDecorator(propertiesTableView).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
propertiesTableModel.addParameter();
int index = propertiesTableModel.getRowCount() - 1;
propertiesTableView.setRowSelectionInterval(index, index);
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int idx = propertiesTableView.getSelectedRow() - 1;
for (int row : propertiesTableView.getSelectedRows()) {
propertiesTableModel.removeProperty(row);
}
if (idx > -1)
propertiesTableView.setRowSelectionInterval(idx, idx);
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
myListenersList = new JBList(listenerModel);
myListenersPanel.add(ToolbarDecorator.createDecorator(myListenersList).setAddAction(new AddActionButtonRunnable()).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int idx = myListenersList.getSelectedIndex() - 1;
for (int row : myListenersList.getSelectedIndices()) {
listenerModel.removeListener(row);
}
if (idx > -1)
myListenersList.setSelectedIndex(idx);
}
}).setAddActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return !project.isDefault();
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
use of com.intellij.ui.table.TableView in project intellij-community by JetBrains.
the class DualView method createFlatComponent.
private Component createFlatComponent(DualViewColumnInfo[] columns) {
ArrayList<ColumnInfo> shownColumns = new ArrayList<>();
for (DualViewColumnInfo column : columns) {
if (column.shouldBeShownIsTheTable()) {
shownColumns.add(column);
}
}
ListTableModel flatModel = new ListTableModel(shownColumns.toArray(new ColumnInfo[shownColumns.size()]));
//noinspection unchecked
myFlatView = new TableView(flatModel) {
public TableCellRenderer getCellRenderer(int row, int column) {
return createWrappedRenderer(super.getCellRenderer(row, column));
}
@NotNull
@Override
public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) {
final Component c = super.prepareRenderer(renderer, row, column);
if (c instanceof JComponent && !myFlatView.getCellSelectionEnabled()) {
((JComponent) c).setBorder(null);
}
return c;
}
@Override
public void doLayout() {
try {
mySuppressStore = true;
super.doLayout();
} finally {
mySuppressStore = false;
}
}
@Override
public void updateColumnSizes() {
// suppress automatic layout, use stored values instead
}
};
myFlatView.setCellSelectionEnabled(false);
myFlatView.setColumnSelectionAllowed(false);
myFlatView.setRowSelectionAllowed(true);
refreshFlatModel();
JPanel result = new JPanel(new BorderLayout());
result.add(ScrollPaneFactory.createScrollPane(myFlatView), BorderLayout.CENTER);
return result;
}
use of com.intellij.ui.table.TableView in project intellij-community by JetBrains.
the class FileHistoryColumnWrapper method getMaxValue.
@Nullable
private String getMaxValue(@NotNull String columnHeader) {
TableView table = getDualView().getFlatView();
if (table.getRowCount() == 0)
return null;
final Enumeration<TableColumn> columns = table.getColumnModel().getColumns();
int idx = 0;
while (columns.hasMoreElements()) {
TableColumn column = columns.nextElement();
if (columnHeader.equals(column.getHeaderValue())) {
break;
}
++idx;
}
if (idx >= table.getColumnModel().getColumnCount() - 1)
return null;
final FontMetrics fm = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD));
final Object header = table.getColumnModel().getColumn(idx).getHeaderValue();
double maxValue = fm.stringWidth((String) header);
String value = (String) header;
for (int i = 0; i < table.getRowCount(); i++) {
final Object at = table.getValueAt(i, idx);
if (at instanceof String) {
final int newWidth = fm.stringWidth((String) at);
if (newWidth > maxValue) {
maxValue = newWidth;
value = (String) at;
}
}
}
return value + "ww";
}
use of com.intellij.ui.table.TableView in project intellij-community by JetBrains.
the class FileHistoryPanelImpl method setupDualView.
private void setupDualView(@NotNull DefaultActionGroup group) {
myDualView.setShowGrid(true);
PopupHandler.installPopupHandler(myDualView.getTreeView(), group, ActionPlaces.UPDATE_POPUP, ActionManager.getInstance());
PopupHandler.installPopupHandler(myDualView.getFlatView(), group, ActionPlaces.UPDATE_POPUP, ActionManager.getInstance());
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myDualView, true);
});
myDualView.addListSelectionListener(e -> updateMessage());
myDualView.setRootVisible(false);
myDualView.expandAll();
final TreeCellRenderer defaultCellRenderer = myDualView.getTree().getCellRenderer();
final Getter<VcsHistorySession> sessionGetter = () -> myHistorySession;
myDualView.setTreeCellRenderer(new MyTreeCellRenderer(defaultCellRenderer, sessionGetter));
myDualView.setCellWrapper(new MyCellWrapper(sessionGetter));
myDualView.installDoubleClickHandler(new MyDiffAction());
final TableView flatView = myDualView.getFlatView();
TableViewModel sortableModel = flatView.getTableViewModel();
sortableModel.setSortable(true);
final RowSorter<? extends TableModel> rowSorter = flatView.getRowSorter();
if (rowSorter != null) {
rowSorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(0, SortOrder.DESCENDING)));
}
}
Aggregations