use of com.mercedesbenz.sechub.developertools.admin.ui.TableRendersupport in project sechub by mercedes-benz.
the class ExecutionProfileDialogUI method createMainPanel.
private void createMainPanel() {
mainPanel = new JPanel(new GridBagLayout());
int row = 0;
/* id */
idTextField = new JTextField(profile.id);
mainPanel.add(new JLabel("Id"), createLabelConstraint(row));
mainPanel.add(idTextField, createComponentConstraint(row++));
if (idEditAllowed) {
idTextField.setBorder(BorderFactory.createLineBorder(Color.ORANGE, 2));
idTextField.setToolTipText("mandatory field");
} else {
idTextField.setEditable(false);
}
descriptionTextArea = new JTextArea(profile.description);
mainPanel.add(new JLabel("Description"), createLabelConstraint(row));
mainPanel.add(descriptionTextArea, createComponentConstraint(row++));
/* enabled */
enabledCheckBox = new JCheckBox("", profile.enabled);
mainPanel.add(new JLabel("Enabled"), createLabelConstraint(row));
mainPanel.add(enabledCheckBox, createComponentConstraint(row++));
/* configurations */
model = new DefaultTableModel() {
private static final long serialVersionUID = 1L;
public boolean isCellEditable(int row, int column) {
return false;
}
};
model.addColumn("Executor config name");
model.addColumn("enabled");
model.addColumn("uuid");
configurationTable = new JTable(model);
configurationTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
int row = configurationTable.getSelectedRow();
Object selectedValue = model.getValueAt(row, 2);
if (selectedValue instanceof UUID) {
UUID uuid = (UUID) selectedValue;
boolean changed = editConfigurationAction.executeDirectly(uuid);
if (!changed) {
return;
}
reloadChangedDataIntoLocalProfile(uuid);
} else {
throw new IllegalStateException("not a uuid:" + selectedValue);
}
}
}
private void reloadChangedDataIntoLocalProfile(UUID uuid) {
TestExecutorConfig found = null;
for (TestExecutorConfig config : profile.configurations) {
if (uuid.equals(config.uuid)) {
found = config;
break;
}
}
if (found == null) {
getContext().getOutputUI().error("Did not found config again with uuid:" + uuid);
return;
}
profile.configurations.remove(found);
TestExecutorConfig newConfig = getContext().getAdministration().fetchExecutorConfiguration(uuid);
profile.configurations.add(newConfig);
rebuildTableModelRows();
}
});
rebuildTableModelRows();
if (model.getRowCount() > 0) {
configurationTable.setRowSelectionInterval(0, 0);
}
new TableRendersupport().addStandardTableCellRender(configurationTable);
GridBagConstraints tableConstraint = createComponentConstraint(row++);
tableConstraint.gridx = 0;
tableConstraint.gridwidth++;
tableConstraint.weighty = 0.5;
JScrollPane tableScrollPane = new JScrollPane(configurationTable);
tableScrollPane.setPreferredSize(new Dimension(600, 200));
mainPanel.add(tableScrollPane, tableConstraint);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
buttonPanel.add(new JButton(new AddConfigAction()));
buttonPanel.add(new JButton(new RemoveConfigAction()));
mainPanel.add(buttonPanel, createComponentConstraint(row++));
/* project ids - label */
projectIdsLabel = new JLabel();
GridBagConstraints projectIdLabelConstraint = createComponentConstraint(row++);
projectIdLabelConstraint.ipady = 0;
projectIdLabelConstraint.gridx = 0;
projectIdLabelConstraint.gridwidth++;
mainPanel.add(projectIdsLabel, projectIdLabelConstraint);
/* text area for project ids */
projectIdsTextArea = new JTextArea();
projectIdsTextArea.setLineWrap(true);
projectIdsTextArea.setEditable(false);
projectIdsTextArea.setColumns(200);
GridBagConstraints textAreaConstraint = createComponentConstraint(row++);
textAreaConstraint.gridx = 0;
textAreaConstraint.gridwidth++;
textAreaConstraint.weighty = 0.5;
JScrollPane textAreaScrollPane = new JScrollPane(projectIdsTextArea);
textAreaScrollPane.setPreferredSize(new Dimension(600, 200));
mainPanel.add(textAreaScrollPane, textAreaConstraint);
updateProjectIdsAtUI();
}
Aggregations