use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class CodeStyleImportsPanelBase method resetLayoutSettings.
public void resetLayoutSettings(ImportsLayoutSettings settings) {
myCbUseFQClassNames.setSelected(settings.isUseFqClassNames());
myCbUseSingleClassImports.setSelected(settings.isUseSingleClassImports());
myCbInsertInnerClassImports.setSelected(settings.isInsertInnerClassImports());
myClassCountField.setText(Integer.toString(settings.getClassCountToUseImportOnDemand()));
myNamesCountField.setText(Integer.toString(settings.getNamesCountToUseImportOnDemand()));
myImportLayoutPanel.getImportLayoutList().copyFrom(settings.getImportLayoutTable());
myPackageList.copyFrom(settings.getPackagesToUseImportOnDemand());
myImportLayoutPanel.getCbLayoutStaticImportsSeparately().setSelected(settings.isLayoutStaticImportsSeparately());
final JBTable importLayoutTable = myImportLayoutPanel.getImportLayoutTable();
AbstractTableModel model = (AbstractTableModel) importLayoutTable.getModel();
model.fireTableDataChanged();
model = (AbstractTableModel) myPackageTable.getModel();
model.fireTableDataChanged();
if (importLayoutTable.getRowCount() > 0) {
importLayoutTable.getSelectionModel().setSelectionInterval(0, 0);
}
if (myPackageTable.getRowCount() > 0) {
myPackageTable.getSelectionModel().setSelectionInterval(0, 0);
}
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class TableWithButtons method createUIComponents.
private void createUIComponents() {
myTable = new JBTable(myModel);
myTable.setPreferredScrollableViewportSize(new Dimension(450, myTable.getRowHeight() * 8));
}
use of com.intellij.ui.table.JBTable 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 com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class ConfigureClientPropertiesDialog method createCenterPanel.
@Nullable
protected JComponent createCenterPanel() {
myClassTree = new Tree();
myClassTree.setRootVisible(false);
myClassTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
final TreePath leadSelectionPath = e.getNewLeadSelectionPath();
if (leadSelectionPath == null)
return;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) leadSelectionPath.getLastPathComponent();
mySelectedClass = (Class) node.getUserObject();
updateSelectedProperties();
}
});
myClassTree.setCellRenderer(new ColoredTreeCellRenderer() {
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getUserObject() instanceof Class) {
Class cls = (Class) node.getUserObject();
if (cls != null) {
append(cls.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
}
});
fillClassTree();
myPropertiesTable = new JBTable();
myPropertiesTable.setModel(myTableModel);
mySplitter = new JBSplitter("ConfigureClientPropertiesDialog.splitterProportion", 0.5f);
mySplitter.setFirstComponent(ToolbarDecorator.createDecorator(myClassTree).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
ClassNameInputDialog dlg = new ClassNameInputDialog(myProject, mySplitter);
dlg.show();
if (dlg.getExitCode() == OK_EXIT_CODE) {
String className = dlg.getClassName();
if (className.length() == 0)
return;
final Class aClass;
try {
aClass = Class.forName(className);
} catch (ClassNotFoundException ex) {
Messages.showErrorDialog(mySplitter, UIDesignerBundle.message("client.properties.class.not.found", className), UIDesignerBundle.message("client.properties.title"));
return;
}
if (!JComponent.class.isAssignableFrom(aClass)) {
Messages.showErrorDialog(mySplitter, UIDesignerBundle.message("client.properties.class.not.component", className), UIDesignerBundle.message("client.properties.title"));
return;
}
myManager.addClientPropertyClass(className);
fillClassTree();
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
if (mySelectedClass != null) {
myManager.removeClientPropertyClass(mySelectedClass);
fillClassTree();
}
}
}).setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT).createPanel());
mySplitter.setSecondComponent(ToolbarDecorator.createDecorator(myPropertiesTable).disableUpDownActions().setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
AddClientPropertyDialog dlg = new AddClientPropertyDialog(myProject);
dlg.show();
if (dlg.getExitCode() == OK_EXIT_CODE) {
ClientPropertiesManager.ClientProperty[] props = myManager.getClientProperties(mySelectedClass);
for (ClientPropertiesManager.ClientProperty prop : props) {
if (prop.getName().equalsIgnoreCase(dlg.getEnteredProperty().getName())) {
Messages.showErrorDialog(mySplitter, UIDesignerBundle.message("client.properties.already.defined", prop.getName()), UIDesignerBundle.message("client.properties.title"));
return;
}
}
myManager.addConfiguredProperty(mySelectedClass, dlg.getEnteredProperty());
updateSelectedProperties();
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int row = myPropertiesTable.getSelectedRow();
if (row >= 0 && row < mySelectedProperties.length) {
myManager.removeConfiguredProperty(mySelectedClass, mySelectedProperties[row].getName());
updateSelectedProperties();
if (mySelectedProperties.length > 0) {
if (row >= mySelectedProperties.length)
row--;
myPropertiesTable.getSelectionModel().setSelectionInterval(row, row);
}
}
}
}).createPanel());
return mySplitter;
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class EditVariableDialog method createVariablesTable.
private JComponent createVariablesTable() {
final String[] names = { CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined") };
// Create a model of the data.
TableModel dataModel = new VariablesModel(names);
// Create the table
myTable = new JBTable(dataModel);
myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
myTable.getColumn(names[0]).setPreferredWidth(120);
myTable.getColumn(names[1]).setPreferredWidth(200);
myTable.getColumn(names[2]).setPreferredWidth(200);
myTable.getColumn(names[3]).setPreferredWidth(100);
if (myVariables.size() > 0) {
myTable.getSelectionModel().setSelectionInterval(0, 0);
}
Predicate<Macro> isAcceptableInContext = macro -> myContextTypes.stream().anyMatch(macro::isAcceptableInContext);
Stream<String> availableMacroNames = Arrays.stream(MacroFactory.getMacros()).filter(isAcceptableInContext).map(Macro::getPresentableName).sorted();
Set<String> uniqueNames = availableMacroNames.collect(Collectors.toCollection(LinkedHashSet::new));
ComboBox comboField = new ComboBox();
uniqueNames.forEach(comboField::addItem);
comboField.setEditable(true);
DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
cellEditor.setClickCountToStart(1);
myTable.getColumn(names[1]).setCellEditor(cellEditor);
myTable.setRowHeight(comboField.getPreferredSize().height);
JTextField textField = new JTextField();
/*textField.addMouseListener(
new PopupHandler(){
public void invokePopup(Component comp,int x,int y){
showCellPopup((JTextField)comp,x,y);
}
}
);*/
cellEditor = new DefaultCellEditor(textField);
cellEditor.setClickCountToStart(1);
myTable.setDefaultEditor(String.class, cellEditor);
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
return decorator.createPanel();
}
Aggregations