Ejemplo n.º 1
0
 private void performEditing(Object object) {
   refreshDialogs(object);
   String singular = StringUtil.getSingular(name);
   int result =
       JOptionPane.showConfirmDialog(
           null,
           dialogInputs,
           "Edit " + singular,
           JOptionPane.OK_CANCEL_OPTION,
           JOptionPane.PLAIN_MESSAGE,
           null);
   if (result == JOptionPane.OK_OPTION) {
     int index = removeFromList(object);
     try {
       inputPanel.getList(name).add(index, constructor.newInstance(getValuesFromInputs()));
     } catch (InstantiationException ignored) {
     } catch (IllegalAccessException ignored) {
     } catch (InvocationTargetException ignored) {
     }
   }
   inputPanel.refresh();
 }
Ejemplo n.º 2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   List<?> list = inputPanel.getList(name);
   if (list.isEmpty()) {
     GUI.getInstance().showAttentionMessageDialog("Nothing to edit");
   } else {
     Object[] possibilities = list.toArray();
     String singular = StringUtil.getSingular(name);
     Object result =
         JOptionPane.showInputDialog(
             null,
             "Select " + singular + " to edit:",
             "Edit " + singular,
             JOptionPane.PLAIN_MESSAGE,
             null,
             possibilities,
             list.get(0));
     if (result != null) {
       performEditing(result);
     }
   }
   inputPanel.refresh();
 }