use of com.intellij.ui.table.JBTable in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method createUIComponents.
private void createUIComponents() {
DefaultTableModel tableModel = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
tableModel.addColumn("Name");
tableModel.addColumn("JDK");
tableModel.addColumn("Web container");
tableModel.addColumn("Resource group");
table = new JBTable(tableModel);
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting())
return;
//System.out.println("row : " + table.getValueAt(table.getSelectedRow(), 0).toString());
fillAppServiceDetails();
}
});
AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
refreshAppServices();
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
createAppService();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
deleteAppService();
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return table.getSelectedRow() != -1;
}
}).disableUpDownActions().addExtraActions(refreshAction);
panelTable = tableToolbarDecorator.createPanel();
}
use of com.intellij.ui.table.JBTable in project azure-tools-for-java by Microsoft.
the class SparkSubmissionContentPanel method addConfigurationLineItem.
private void addConfigurationLineItem() {
JLabel jobConfigurationLabel = new JLabel("Job configurations");
add(jobConfigurationLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));
String[] columns = { "Key", "Value", "" };
jobConfigurationTable = new JBTable();
Dimension jobConfigurationTableSize = new Dimension(320, 100);
jobConfigurationTable.setPreferredScrollableViewportSize(jobConfigurationTableSize);
jobConfigurationTable.setSurrendersFocusOnKeystroke(true);
jobConfigurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jobConfigurationTable.setColumnSelectionAllowed(true);
JBScrollPane scrollPane = new JBScrollPane(jobConfigurationTable);
jobConfigurationTable.setFillsViewportHeight(true);
scrollPane.setMinimumSize(jobConfigurationTableSize);
jobConfigurationTable.addPropertyChangeListener((evt) -> {
if ((evt.getPropertyName().equals("tableCellEditor") || evt.getPropertyName().equals("model")) && jobConfigurationTable.getModel() instanceof SubmissionTableModel) {
SubmissionTableModel model = (SubmissionTableModel) jobConfigurationTable.getModel();
setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), false);
SparkSubmissionJobConfigCheckResult result = model.getFirstCheckResults();
if (result != null) {
setStatusForMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), true, result.getMessaqge(), result.getStatus() == SparkSubmissionJobConfigCheckStatus.Warning);
}
}
});
add(scrollPane, new GridBagConstraints(1, displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, 0), 0, 0));
JButton loadJobConfigurationButton = new JButton("...");
loadJobConfigurationButton.setPreferredSize(selectedArtifactTextField.getButton().getPreferredSize());
FixedSizeButton loadJobConfigurationFixedSizeButton = new FixedSizeButton(loadJobConfigurationButton);
add(loadJobConfigurationFixedSizeButton, new GridBagConstraints(2, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(margin, margin / 2, 0, margin), 0, 0));
loadJobConfigurationFixedSizeButton.setToolTipText("Load Spark config from property file");
loadJobConfigurationFixedSizeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
fileChooserDescriptor.setTitle("Select Spark property file");
VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null);
if (chooseFile != null) {
submitModel.loadJobConfigMapFromPropertyFile(chooseFile.getCanonicalPath());
}
}
});
errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] = new JLabel();
errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setVisible(false);
add(errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0));
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class GrChangeSignatureDialog method createAdditionalPanels.
@NotNull
@Override
protected List<Pair<String, JPanel>> createAdditionalPanels() {
// this method is invoked before constructor body
myExceptionsModel = new ExceptionsTableModel(myMethod.getMethod().getThrowsList());
myExceptionsModel.setTypeInfos(myMethod.getMethod());
final JBTable table = new JBTable(myExceptionsModel);
table.setStriped(true);
table.setRowHeight(20);
table.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
final JavaCodeFragmentTableCellEditor cellEditor = new JavaCodeFragmentTableCellEditor(myProject);
cellEditor.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
final int row = table.getSelectedRow();
final int col = table.getSelectedColumn();
myExceptionsModel.setValueAt(cellEditor.getCellEditorValue(), row, col);
updateSignature();
}
});
table.getColumnModel().getColumn(0).setCellEditor(cellEditor);
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().setSelectionInterval(0, 0);
table.setSurrendersFocusOnKeystroke(true);
/* myPropExceptionsButton = new AnActionButton( //todo propagate parameters
RefactoringBundle.message("changeSignature.propagate.exceptions.title"), null, PlatformIcons.NEW_EXCEPTION) {
@Override
public void actionPerformed(AnActionEvent e) {
final Ref<JavaCallerChooser> chooser = new Ref<JavaCallerChooser>();
Consumer<Set<PsiMethod>> callback = new Consumer<Set<PsiMethod>>() {
@Override
public void consume(Set<PsiMethod> psiMethods) {
myMethodsToPropagateExceptions = psiMethods;
myExceptionPropagationTree = chooser.get().getTree();
}
};
chooser.set(new JavaCallerChooser(myMethod.getMethod(),
myProject,
RefactoringBundle.message("changeSignature.exception.caller.chooser"),
myExceptionPropagationTree,
callback));
chooser.get().show();
}
};
myPropExceptionsButton.setShortcut(CustomShortcutSet.fromString("alt X"));*/
final JPanel panel = ToolbarDecorator.createDecorator(table).createPanel();
//.addExtraAction(myPropExceptionsButton).createPanel();
panel.setBorder(IdeBorderFactory.createEmptyBorder());
myExceptionsModel.addTableModelListener(mySignatureUpdater);
final ArrayList<Pair<String, JPanel>> result = new ArrayList<>();
final String message = RefactoringBundle.message("changeSignature.exceptions.panel.border.title");
result.add(Pair.create(message, panel));
return result;
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class CompoundRendererConfigurable method createChildrenListEditor.
private JComponent createChildrenListEditor(JavaDebuggerEditorsProvider editorsProvider) {
final MyTableModel tableModel = new MyTableModel();
myTable = new JBTable(tableModel);
myListChildrenEditor = new XDebuggerExpressionEditor(myProject, editorsProvider, "NamedChildrenConfigurable", null, XExpressionImpl.EMPTY_EXPRESSION, false, false, false);
JComponent editorComponent = myListChildrenEditor.getComponent();
AbstractTableCellEditor editor = new AbstractTableCellEditor() {
@Override
public Object getCellEditorValue() {
return TextWithImportsImpl.fromXExpression(myListChildrenEditor.getExpression());
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
myListChildrenEditor.setExpression(TextWithImportsImpl.toXExpression((TextWithImports) value));
return editorComponent;
}
};
editorComponent.registerKeyboardAction(e -> editor.stopCellEditing(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
editorComponent.registerKeyboardAction(e -> editor.cancelCellEditing(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
TableColumn exprColumn = myTable.getColumnModel().getColumn(EXPRESSION_TABLE_COLUMN);
exprColumn.setCellEditor(editor);
exprColumn.setCellRenderer(new DefaultTableCellRenderer() {
@NotNull
@Override
public Component getTableCellRendererComponent(@NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final TextWithImports textWithImports = (TextWithImports) value;
final String text = (textWithImports != null) ? textWithImports.getText() : "";
return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
}
});
return ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
tableModel.addRow("", DebuggerUtils.getInstance().createExpressionWithImports(""));
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int selectedRow = myTable.getSelectedRow();
if (selectedRow >= 0 && selectedRow < myTable.getRowCount()) {
getTableModel().removeRow(selectedRow);
}
}
}).setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsUp(myTable);
}
}).setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsDown(myTable);
}
}).createPanel();
}
use of com.intellij.ui.table.JBTable in project intellij-community by JetBrains.
the class CaptureConfigurable method createComponent.
@Nullable
@Override
public JComponent createComponent() {
myTableModel = new MyTableModel();
JBTable table = new JBTable(myTableModel);
table.setColumnSelectionAllowed(false);
TableColumnModel columnModel = table.getColumnModel();
TableUtil.setupCheckboxColumn(columnModel.getColumn(MyTableModel.ENABLED_COLUMN));
ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table);
decorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
myTableModel.addRow();
}
});
decorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.removeSelectedItems(table);
}
});
decorator.setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsUp(table);
}
});
decorator.setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsDown(table);
}
});
decorator.addExtraAction(new DumbAwareActionButton("Duplicate", "Duplicate", PlatformIcons.COPY_ICON) {
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() == 1;
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> {
try {
int idx = myTableModel.add(c.clone());
table.getSelectionModel().setSelectionInterval(idx, idx);
} catch (CloneNotSupportedException ex) {
LOG.error(ex);
}
});
}
});
decorator.addExtraAction(new DumbAwareActionButton("Enable Selected", "Enable Selected", PlatformIcons.SELECT_ALL_ICON) {
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() > 0;
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> c.myEnabled = true);
table.repaint();
}
});
decorator.addExtraAction(new DumbAwareActionButton("Disable Selected", "Disable Selected", PlatformIcons.UNSELECT_ALL_ICON) {
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() > 0;
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> c.myEnabled = false);
table.repaint();
}
});
new DumbAwareAction("Toggle") {
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabled(table.getSelectedRowCount() == 1);
}
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
selectedCapturePoints(table).forEach(c -> c.myEnabled = !c.myEnabled);
table.repaint();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), table);
decorator.addExtraAction(new DumbAwareActionButton("Import", "Import", AllIcons.Actions.Install) {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, true) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE);
}
@Override
public boolean isFileSelectable(VirtualFile file) {
return file.getFileType() == StdFileTypes.XML;
}
};
descriptor.setDescription("Please select a file to import.");
descriptor.setTitle("Import Capture Points");
VirtualFile[] files = FileChooser.chooseFiles(descriptor, e.getProject(), null);
if (ArrayUtil.isEmpty(files))
return;
table.getSelectionModel().clearSelection();
for (VirtualFile file : files) {
try {
Document document = JDOMUtil.loadDocument(file.getInputStream());
List<Element> children = document.getRootElement().getChildren();
children.forEach(element -> {
int idx = myTableModel.addIfNeeded(XmlSerializer.deserialize(element, CapturePoint.class));
table.getSelectionModel().addSelectionInterval(idx, idx);
});
} catch (Exception ex) {
final String msg = ex.getLocalizedMessage();
Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
}
}
}
});
decorator.addExtraAction(new DumbAwareActionButton("Export", "Export", AllIcons.Actions.Export) {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
VirtualFileWrapper wrapper = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Export Selected Capture Points to File...", "", "xml"), e.getProject()).save(null, null);
if (wrapper == null)
return;
Element rootElement = new Element("capture-points");
selectedCapturePoints(table).forEach(c -> {
try {
CapturePoint clone = c.clone();
clone.myEnabled = false;
rootElement.addContent(XmlSerializer.serialize(clone));
} catch (CloneNotSupportedException ex) {
LOG.error(ex);
}
});
try {
JDOMUtil.write(rootElement, wrapper.getFile());
} catch (Exception ex) {
final String msg = ex.getLocalizedMessage();
Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
}
}
@Override
public boolean isEnabled() {
return table.getSelectedRowCount() > 0;
}
});
BorderLayoutPanel panel = JBUI.Panels.simplePanel();
panel.addToCenter(decorator.createPanel());
myCaptureVariables = new JCheckBox(DebuggerBundle.message("label.capture.configurable.capture.variables"));
panel.addToBottom(myCaptureVariables);
return panel;
}
Aggregations