コード例 #1
0
 @Override
 public void doAction() {
   DataPanel context = ActionManager.getInstance().getContext();
   int row = context.getSelectedRow();
   if (row > 0) {
     row--;
     context.setSelectedRow(row);
   }
 }
コード例 #2
0
  @Override
  protected void doAction() {
    DataPanel context = ActionManager.getInstance().getContext();

    if (context.getSelectedRow() != -1) {

      int selected =
          JOptionPane.showConfirmDialog(
              null,
              "Da li ste sigurni da zelite da obrisete selektovani slog?",
              "Brisanje",
              JOptionPane.YES_NO_OPTION);

      if (selected == JOptionPane.NO_OPTION) {
        return;
      } else {
        HashMap<String, Object> map =
            (HashMap<String, Object>) context.getSingleRecordPanel().getFields();
        boolean deletedObject =
            DatabaseDAO.getInstance()
                .deleteObject(
                    context.getTable().getCode(),
                    TableHelper.getPrimaryKeyValues(context.getTable(), map));
        if (deletedObject) {
          context.getModel().removeRow(context.getSelectedRow());
          context.getDataGrid().setRowSelectionInterval(0, 0);
        }
      }

    } else {
      JOptionPane.showMessageDialog(
          null,
          "Nije selektovan ni jedan red, selektuje zeljeni red pre nego sto zapocnete brisanje");
    }
  }