use of com.intellij.ui.table.TableView 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.ui.table.TableView in project intellij-community by JetBrains.
the class ShowFeatureUsageStatisticsDialog method createCenterPanel.
protected JComponent createCenterPanel() {
Splitter splitter = new Splitter(true);
splitter.setShowDividerControls(true);
ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
ArrayList<FeatureDescriptor> features = new ArrayList<>();
for (String id : registry.getFeatureIds()) {
features.add(registry.getFeatureDescriptor(id));
}
final TableView table = new TableView<>(new ListTableModel<>(COLUMNS, features, 0));
new TableViewSpeedSearch<FeatureDescriptor>(table) {
@Override
protected String getItemText(@NotNull FeatureDescriptor element) {
return element.getDisplayName();
}
};
JPanel controlsPanel = new JPanel(new VerticalFlowLayout());
Application app = ApplicationManager.getApplication();
long uptime = System.currentTimeMillis() - app.getStartTime();
long idleTime = app.getIdleTime();
final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime", ApplicationNamesInfo.getInstance().getFullProductName(), DateFormatUtil.formatDuration(uptime));
final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time", DateFormatUtil.formatDuration(idleTime));
String labelText = uptimeS + ", " + idleTimeS;
CompletionStatistics stats = ((FeatureUsageTrackerImpl) FeatureUsageTracker.getInstance()).getCompletionStatistics();
if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
String total = formatCharacterCount(stats.sparedCharacters, true);
String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) + " (~" + perDay + " per working day)";
}
CumulativeStatistics fstats = ((FeatureUsageTrackerImpl) FeatureUsageTracker.getInstance()).getFixesStats();
if (fstats.dayCount > 0 && fstats.invocations > 0) {
labelText += "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) + " (~" + fstats.invocations / fstats.dayCount + " per working day)";
}
controlsPanel.add(new JLabel(XmlStringUtil.wrapInHtml(labelText)), BorderLayout.NORTH);
JPanel topPanel = new JPanel(new BorderLayout());
topPanel.add(controlsPanel, BorderLayout.NORTH);
topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);
splitter.setFirstComponent(topPanel);
final JEditorPane browser = TipUIUtil.createTipBrowser();
splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
Collection selection = table.getSelection();
try {
if (selection.isEmpty()) {
browser.read(new StringReader(""), null);
} else {
FeatureDescriptor feature = (FeatureDescriptor) selection.iterator().next();
TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
}
} catch (IOException ex) {
LOG.info(ex);
}
}
});
return splitter;
}
use of com.intellij.ui.table.TableView in project intellij-community by JetBrains.
the class JsonSchemaMappingsView method createUI.
private void createUI(final Project project) {
myProject = project;
myTableView = new TableView<>();
myTableView.getTableHeader().setVisible(false);
myDecorator = ToolbarDecorator.createDecorator(myTableView);
myDecorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final int[] rows = myTableView.getSelectedRows();
if (rows != null && rows.length > 0) {
int cnt = 0;
for (int row : rows) {
myTableView.getListTableModel().removeRow(row - cnt);
++cnt;
}
myTableView.getListTableModel().fireTableDataChanged();
myTreeUpdater.run();
}
}
}).setAddAction(new MyAddActionButtonRunnable(project)).disableUpDownActions();
mySchemaField = new TextFieldWithBrowseButton();
SwingHelper.installFileCompletionAndBrowseDialog(myProject, mySchemaField, JsonBundle.message("json.schema.add.schema.chooser.title"), FileChooserDescriptorFactory.createSingleFileDescriptor());
attachNavigateToSchema();
myError = SwingHelper.createHtmlLabel("Warning: conflicting mappings. <a href=\"#\">Show details</a>", null, s -> {
final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(myErrorText, UIUtil.getBalloonWarningIcon(), MessageType.WARNING.getPopupBackground(), null);
builder.setDisposable(this);
builder.setHideOnClickOutside(true);
builder.setCloseButtonEnabled(true);
builder.createBalloon().showInCenterOf(myError);
});
final FormBuilder builder = FormBuilder.createFormBuilder();
final JBLabel label = new JBLabel("JSON schema file:");
builder.addLabeledComponent(label, mySchemaField);
label.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
mySchemaField.setBorder(JBUI.Borders.empty(0, 0, 0, 10));
final JPanel wrapper = new JPanel(new BorderLayout());
wrapper.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
myErrorIcon = new JBLabel(UIUtil.getBalloonWarningIcon());
wrapper.add(myErrorIcon, BorderLayout.WEST);
wrapper.add(myError, BorderLayout.CENTER);
builder.addComponent(wrapper);
builder.addComponentFillVertically(myDecorator.createPanel(), 5);
myComponent = builder.getPanel();
}
Aggregations