Added popup menu and fixed NPE

This commit is contained in:
Georgy Litvinov 2020-04-16 16:20:53 +02:00
parent 90617b8120
commit faa9cf856d
2 changed files with 13 additions and 1 deletions
source/pro/litvinovg/libreoffice/metadata/views

View file

@ -245,6 +245,17 @@ public class EditorGUI extends JFrame {
.addComponent(btnOutlineSave)
.addGap(43))
);
JPopupMenu popupMenu = new JPopupMenu();
addPopup(tableOutline, popupMenu);
JMenuItem menuItem = new JMenuItem("Добавить строку");
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
outlineTableModel.addRow(new Object[] {null, null});
}
});
popupMenu.add(menuItem);
panelOutline.setLayout(groupLayoutOutlineMetadata);
tabbedPane.addTab(element.getName(), null, panelOutline, null);
}

View file

@ -25,7 +25,8 @@ public class MetadataTableModel extends DefaultTableModel {
Vector row = (Vector) elements.nextElement();
String name = (String) row.get(0);
String value = (String) row.get(1);
if (!name.isEmpty() && !value.isEmpty()) {
if (name != null && !name.isEmpty() && value != null && !value.isEmpty()) {
metadata.add(new MetadataElement(name, value));
}
}