use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class JavadocEditor method moduleStateChanged.
@Override
public void moduleStateChanged() {
if (myTable != null) {
final DefaultTableModel tableModel = createModel();
myTable.setModel(tableModel);
}
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class PropertiesComponent method init.
public void init() {
setLayout(new BorderLayout());
myTable = new JBTable();
myTextArea = new JTextArea(0, 0);
myTextArea.setEditable(false);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
mySplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, scrollPane, ScrollPaneFactory.createScrollPane(myTextArea));
add(mySplitPane, BorderLayout.CENTER);
add(createToolbar(), BorderLayout.WEST);
final DefaultTableModel model = new DefaultTableModel(createTableModel(new HashMap<>()), new Object[] { "Name", "Value" }) {
public boolean isCellEditable(final int row, final int column) {
return false;
}
};
myTable.setModel(model);
myTable.setShowVerticalLines(true);
myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.getSelectionModel().addListSelectionListener(e -> {
int index = myTable.getSelectedRow();
if (index >= 0) {
Object value = myTable.getValueAt(index, 1);
if (value instanceof String) {
myTextArea.setText(((String) value));
} else {
myTextArea.setText("");
}
} else {
myTextArea.setText("");
}
});
myPopupActionGroup = createPopup();
PopupHandler.installPopupHandler(myTable, myPopupActionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance());
PopupHandler.installPopupHandler(scrollPane, myPopupActionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance());
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_CLOSE_ACTIVE_TAB);
myCloseAction.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), this);
myRefreshAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this);
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class RadTable method initDefaultModel.
private void initDefaultModel() {
@NonNls Object[][] data = new Object[][] { new Object[] { "round", "red" }, new Object[] { "square", "green" } };
@NonNls Object[] columnNames = new Object[] { "Shape", "Color" };
try {
((JTable) getDelegee()).setModel(new DefaultTableModel(data, columnNames));
} catch (Exception | AssertionError ex) {
// a custom table subclass may not like our model, so ignore the exception if thrown here
}
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class FindDialog method findSettingsChanged.
private void findSettingsChanged() {
if (haveResultsPreview()) {
final ModalityState state = ModalityState.current();
// skip initial changes
if (state == ModalityState.NON_MODAL)
return;
finishPreviousPreviewSearch();
mySearchRescheduleOnCancellationsAlarm.cancelAllRequests();
final FindModel findModel = myHelper.getModel().clone();
applyTo(findModel, false);
ValidationInfo result = getValidationInfo(findModel);
final ProgressIndicatorBase progressIndicatorWhenSearchStarted = new ProgressIndicatorBase();
myResultsPreviewSearchProgress = progressIndicatorWhenSearchStarted;
final DefaultTableModel model = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
// Use previously shown usage files as hint for faster search and better usage preview performance if pattern length increased
final LinkedHashSet<VirtualFile> filesToScanInitially = new LinkedHashSet<>();
if (myHelper.myPreviousModel != null && myHelper.myPreviousModel.getStringToFind().length() < findModel.getStringToFind().length()) {
final DefaultTableModel previousModel = (DefaultTableModel) myResultsPreviewTable.getModel();
for (int i = 0, len = previousModel.getRowCount(); i < len; ++i) {
final UsageInfo2UsageAdapter usage = (UsageInfo2UsageAdapter) previousModel.getValueAt(i, 0);
final VirtualFile file = usage.getFile();
if (file != null)
filesToScanInitially.add(file);
}
}
myHelper.myPreviousModel = findModel;
model.addColumn("Usages");
myResultsPreviewTable.setModel(model);
if (result != null) {
myResultsPreviewTable.getEmptyText().setText(UIBundle.message("message.nothingToShow"));
myContent.setTitleAt(RESULTS_PREVIEW_TAB_INDEX, PREVIEW_TITLE);
return;
}
myResultsPreviewTable.getColumnModel().getColumn(0).setCellRenderer(new UsageTableCellRenderer(false, true));
myResultsPreviewTable.getEmptyText().setText("Searching...");
myContent.setTitleAt(RESULTS_PREVIEW_TAB_INDEX, PREVIEW_TITLE);
final Component component = myInputComboBox.getEditor().getEditorComponent();
// (UsagePreviewPanel.highlight)
if (component instanceof EditorTextField) {
final Document document = ((EditorTextField) component).getDocument();
if (document != null) {
PsiDocumentManager.getInstance(myProject).commitDocument(document);
}
}
final AtomicInteger resultsCount = new AtomicInteger();
final AtomicInteger resultsFilesCount = new AtomicInteger();
ProgressIndicatorUtils.scheduleWithWriteActionPriority(myResultsPreviewSearchProgress, new ReadTask() {
@Nullable
@Override
public Continuation performInReadAction(@NotNull ProgressIndicator indicator) throws ProcessCanceledException {
final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(FindSettings.getInstance().isShowResultsInSeparateView(), findModel);
final boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
Ref<VirtualFile> lastUsageFileRef = new Ref<>();
FindInProjectUtil.findUsages(findModel, myProject, info -> {
final Usage usage = UsageInfo2UsageAdapter.CONVERTER.fun(info);
usage.getPresentation().getIcon();
VirtualFile file = lastUsageFileRef.get();
VirtualFile usageFile = info.getVirtualFile();
if (file == null || !file.equals(usageFile)) {
resultsFilesCount.incrementAndGet();
lastUsageFileRef.set(usageFile);
}
ApplicationManager.getApplication().invokeLater(() -> {
model.addRow(new Object[] { usage });
}, state);
return resultsCount.incrementAndGet() < ShowUsagesAction.USAGES_PAGE_SIZE;
}, processPresentation, filesToScanInitially);
boolean succeeded = !progressIndicatorWhenSearchStarted.isCanceled();
if (succeeded) {
return new Continuation(() -> {
if (progressIndicatorWhenSearchStarted == myResultsPreviewSearchProgress && !myResultsPreviewSearchProgress.isCanceled()) {
int occurrences = resultsCount.get();
int filesWithOccurrences = resultsFilesCount.get();
if (occurrences == 0)
myResultsPreviewTable.getEmptyText().setText(UIBundle.message("message.nothingToShow"));
boolean foundAllUsages = occurrences < ShowUsagesAction.USAGES_PAGE_SIZE;
myContent.setTitleAt(RESULTS_PREVIEW_TAB_INDEX, PREVIEW_TITLE + " (" + (foundAllUsages ? Integer.valueOf(occurrences) : occurrences + "+") + UIBundle.message("message.matches", occurrences) + " in " + (foundAllUsages ? Integer.valueOf(filesWithOccurrences) : filesWithOccurrences + "+") + UIBundle.message("message.files", filesWithOccurrences) + ")");
}
}, state);
}
return null;
}
@Override
public void onCanceled(@NotNull ProgressIndicator indicator) {
if (isShowing() && progressIndicatorWhenSearchStarted == myResultsPreviewSearchProgress) {
scheduleResultsUpdate();
}
}
});
}
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class CreateTestDialog method methodsSize.
public void methodsSize(int methods) {
myTableModel = new DefaultTableModel(methods, 2);
myMethodsTable.setModel(myTableModel);
TableColumn checkColumn = myMethodsTable.getColumnModel().getColumn(0);
TableUtil.setupCheckboxColumn(checkColumn);
checkColumn.setCellRenderer(new BooleanTableCellRenderer());
checkColumn.setCellEditor(new DefaultCellEditor(new JCheckBox()));
myMethodsTable.getColumnModel().getColumn(1).setHeaderValue("Test method");
checkColumn.setHeaderValue("");
getOKAction().setEnabled(true);
}
Aggregations