예제 #1
1
      public void actionPerformed(ActionEvent ev) {
        try {
          // stok
          String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk;
          int hasil1 = stm.executeUpdate(query);

          // pemasukkan
          query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk;
          int hasil2 = stm.executeUpdate(query);

          // pengeluaran
          query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk;
          int hasil3 = stm.executeUpdate(query);

          // produk
          query = "DELETE FROM produk WHERE id_produk=" + idProduk;
          int hasil4 = stm.executeUpdate(query);

          if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "berhasil hapus");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
예제 #2
0
  private void btnDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
    // TODO add your handling code here:

    if (txtKodeAbsen.getText().equals("")) {
      JOptionPane.showMessageDialog(
          null, "Isi Kode Absen yang Akan dihapus !!!", "Peringatan", JOptionPane.ERROR_MESSAGE);
      txtKodeAbsen.requestFocus();
    } else {
      try {
        Class.forName(KoneksiDatabase.driver);
        java.sql.Connection c =
            DriverManager.getConnection(
                KoneksiDatabase.database, KoneksiDatabase.user, KoneksiDatabase.pass);
        Statement s = c.createStatement();
        String sql = "DELETE FROM absensi_lembur where kd_absen ='" + txtKodeAbsen.getText() + "'";
        s.executeUpdate(sql);
        JOptionPane.showMessageDialog(null, "Data Berhasil Dihapus !");
        Baru();
      } catch (Exception e) {
        JOptionPane.showMessageDialog(
            null, "Kemungkinan terjadi kegagalan koneksi", "Warning", JOptionPane.ERROR_MESSAGE);
      }
    }
  } // GEN-LAST:event_btnDeleteActionPerformed
예제 #3
0
 public void secureDelete() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   if (JOptionPane.showConfirmDialog(
           frm,
           "Delete " + store.plainName(idx) + "?",
           "Confirm Delete",
           JOptionPane.YES_NO_OPTION)
       != JOptionPane.YES_OPTION) return;
   File del = store.delete(idx);
   store.fireTableDataChanged();
   if (del != null) {
     if (del.delete()) {
       // successful
       needsSave = true;
     } else {
       System.err.println("Delete " + del.getAbsolutePath() + " failed");
     }
   }
   updateStatus();
 }
예제 #4
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
예제 #5
0
  private void Simpan() {

    if (btnSave.getText().equals("Edit")) {
      try {
        Class.forName(KoneksiDatabase.driver);
        java.sql.Connection c =
            DriverManager.getConnection(
                KoneksiDatabase.database, KoneksiDatabase.user, KoneksiDatabase.pass);
        Statement s = c.createStatement();

        String sql;
        sql = "update absensi_lembur set tipehari = '";
        sql += cmbJenisHari.getSelectedItem() + "', tot_waktu_lembur='";
        sql += txtTotalLembur.getText() + "'";
        sql += "where kd_absen = '" + txtKodeAbsen.getText() + "'";
        s.executeQuery(sql);

        JOptionPane.showMessageDialog(
            null, "Data Berhasil Disimpan!!!", "Informasi", JOptionPane.INFORMATION_MESSAGE);
      } catch (Exception e) {
        JOptionPane.showMessageDialog(
            null,
            "Gagal Disimpan, Data Harus Lengkap !!!",
            "Peringatan",
            JOptionPane.WARNING_MESSAGE);
      }
    }
    Baru();
  }
예제 #6
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
예제 #7
0
 private void prosesEdit(String query) {
   try {
     int hasil = stm.executeUpdate(query);
     if (hasil == 1) {
       setDataTabel();
       JOptionPane.showMessageDialog(null, "edit berhasil");
     } else {
       JOptionPane.showMessageDialog(null, "gagal");
     }
   } catch (SQLException SQLerr) {
     SQLerr.printStackTrace();
   }
 }
예제 #8
0
 public void secureAnalysis() {
   int rw = tblItems.getSelectedRow();
   if (rw != -1) {
     int idx = tblItems.convertRowIndexToModel(rw);
     String desc = store.describe(idx);
     if (JOptionPane.showConfirmDialog(frm, desc, "Details", JOptionPane.OK_CANCEL_OPTION)
         == JOptionPane.CANCEL_OPTION) return;
   }
   if (JOptionPane.showConfirmDialog(frm, store.tagDesc(), "Tags", JOptionPane.OK_CANCEL_OPTION)
       == JOptionPane.CANCEL_OPTION) return;
   if (JOptionPane.showConfirmDialog(
           frm, store.storeDesc(), "Storage", JOptionPane.OK_CANCEL_OPTION)
       == JOptionPane.CANCEL_OPTION) return;
 }
 public int submit() {
   String newName = produktgruppeFormular.nameField.getText();
   if (isProdGrAlreadyKnown(newName)) {
     // not allowed: changing name to one that is already registered in DB
     JOptionPane.showMessageDialog(
         this,
         "Fehler: Produktgruppe '" + newName + "' bereits vorhanden!",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
     produktgruppeFormular.nameField.setText("");
     return 0;
   }
   Integer parentProdGrID =
       produktgruppeFormular.parentProdGrIDs.get(
           produktgruppeFormular.parentProdGrBox.getSelectedIndex());
   Vector<Integer> idsNew = produktgruppeFormular.idsOfNewProdGr(parentProdGrID);
   Integer topID = idsNew.get(0);
   Integer subID = idsNew.get(1);
   Integer subsubID = idsNew.get(2);
   Integer mwstID =
       produktgruppeFormular.mwstIDs.get(produktgruppeFormular.mwstBox.getSelectedIndex());
   Integer pfandID =
       produktgruppeFormular.pfandIDs.get(produktgruppeFormular.pfandBox.getSelectedIndex());
   return insertNewProdGr(topID, subID, subsubID, newName, mwstID, pfandID);
 }
예제 #10
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // Object o = table.getModel().getValueAt(table.getSelectedRow(), 0);
   int row = table.convertRowIndexToModel(table.getEditingRow());
   Object o = table.getModel().getValueAt(row, 0);
   JOptionPane.showMessageDialog(table, "Editing: " + o);
 }
예제 #11
0
    public void actionPerformed(java.awt.event.ActionEvent arg0) {
      if (JTable1.getSelectedRowCount() != 1) {
        Utilities.errorMessage(resourceBundle.getString("Please select a view to delete"));
        return;
      }

      if (JOptionPane.showConfirmDialog(
              null,
              resourceBundle.getString("Are you sure you want to delete the selected view "),
              resourceBundle.getString("Warning!"),
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE,
              null)
          == JOptionPane.NO_OPTION) return;

      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          AuthViewWithOperations avop = (AuthViewWithOperations) viewvec.elementAt(i);

          model.delViewOp(
              avop.getAuthorizedViewName(), avop.getViewProperties(), avop.getOperations());
        }
      }

      disableButtons();
    }
예제 #12
0
  /**
   * Make the selected line of the table to the given line, if it is displayed. Otherwise a warning
   * message is displayed.
   */
  private void gotoLine() {
    if (gotoTextField.getText().equals("")) {
      return;
    }

    int index = Integer.parseInt(gotoTextField.getText());
    ConstantPoolTableModel model = (ConstantPoolTableModel) table.getModel();

    if (model.isEmpty()) {
      gotoTextField.setText("");
      return;
    }

    if (index < 0 || (model.getFullRowCount() - 1) < index) {
      JOptionPane.showMessageDialog(
          this,
          gotoTextField.getText()
              + " is not in the allowed range [0.."
              + (model.getFullRowCount() - 1)
              + "] !",
          "Warning:",
          JOptionPane.ERROR_MESSAGE);
      gotoTextField.setText("");
      return;
    }

    int indexes[] = model.getIndexes();
    boolean found = false;
    for (int i = 0; i < indexes.length; ++i) {
      if (found = (indexes[i] == index)) {
        table.changeSelection(i, 0, false, false);
        break;
      }
    }

    if (!found) {
      JOptionPane.showMessageDialog(
          this,
          "Index " + gotoTextField.getText() + " is not present in the filtered pool!",
          "Warning:",
          JOptionPane.ERROR_MESSAGE);
      gotoTextField.setText("");
      return;
    }

    gotoTextField.setText("");
  } // gotoLine
예제 #13
0
  private void Baru() {
    btnSave.setText("Save");
    txtNip.requestFocus();
    txtNip.setText("");

    try {
      Class.forName(KoneksiDatabase.driver);
      java.sql.Connection c =
          DriverManager.getConnection(
              KoneksiDatabase.database, KoneksiDatabase.user, KoneksiDatabase.pass);
      Statement s = c.createStatement();
      String sql = "select * from absensi_lembur";
      ResultSet rs = s.executeQuery(sql);

      final String[] headers = {
        "Kd Absen",
        "NIP",
        "Tgl Absen",
        "Masuk",
        "Pulang",
        "Hari",
        "Tipe Hari",
        "Terlambat",
        "Lembur",
        "Tipe Lembur",
        "Tot Lembur",
        "Tunj Makan",
        "Tunj Transport"
      };
      rs.last();

      int n = rs.getRow();
      Object[][] data = new Object[n][13];
      int p = 0;
      rs.beforeFirst();
      while (rs.next()) {
        data[p][0] = rs.getString(1);
        data[p][1] = rs.getString(2);
        data[p][2] = rs.getString(3);
        data[p][3] = rs.getString(4);
        data[p][4] = rs.getString(5);
        data[p][5] = rs.getString(6);
        data[p][6] = rs.getString(7);
        data[p][7] = rs.getString(8);
        data[p][8] = rs.getString(9);
        data[p][9] = rs.getString(10);
        data[p][10] = rs.getString(11);
        data[p][11] = rs.getString(12);
        data[p][12] = rs.getString(13);
        p++;
      }
      tblLembur.setModel(new DefaultTableModel(data, headers));
      tblLembur.setAlignmentX(CENTER_ALIGNMENT);

    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          null, "Gagal Koneksi, Ada Kesalahan.", "Warning", JOptionPane.WARNING_MESSAGE);
    }
  }
예제 #14
0
 public void secureMove() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   String[] opts = new String[storeLocs.size()];
   for (int i = 0; i < opts.length; i++) opts[i] = storeLocs.get(i).getAbsolutePath();
   JComboBox cmbMove = new JComboBox(opts);
   cmbMove.setSelectedIndex(store.curStore(idx));
   if (JOptionPane.showConfirmDialog(frm, cmbMove, "Move item", JOptionPane.OK_CANCEL_OPTION)
       != JOptionPane.OK_OPTION) return;
   File newLoc = store.move(idx, cmbMove.getSelectedIndex());
   if (newLoc == null) System.err.println("move " + store.plainName(idx) + " unsuccessful");
   else needsSave = true;
 }
예제 #15
0
파일: CorpusEditor.java 프로젝트: kzn/gate
 public void actionPerformed(ActionEvent e) {
   List<Resource> loadedDocuments;
   try {
     // get all the documents loaded in the system
     loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
   } catch (GateException ge) {
     // gate.Document is not registered in creole.xml....what is!?
     throw new GateRuntimeException(
         "gate.Document is not registered in the creole register!\n"
             + "Something must be terribly wrong...take a vacation!");
   }
   Vector<String> docNames = new Vector<String>();
   for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) {
     if (corpus.contains(loadedDocument)) {
       loadedDocuments.remove(loadedDocument);
     } else {
       docNames.add(loadedDocument.getName());
     }
   }
   JList docList = new JList(docNames);
   docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1);
   docList.setCellRenderer(renderer);
   final JOptionPane optionPane =
       new JOptionPane(
           new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog =
       optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus");
   docList.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             optionPane.setValue(JOptionPane.OK_OPTION);
             dialog.dispose();
           }
         }
       });
   dialog.setVisible(true);
   if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) {
     int[] selectedIndices = docList.getSelectedIndices();
     for (int selectedIndice : selectedIndices) {
       corpus.add((Document) loadedDocuments.get(selectedIndice));
     }
   }
   changeMessage();
 }
예제 #16
0
 public void genSeed(ActionEvent e) {
   long seed = 0;
   boolean redo = false;
   do {
     redo = false;
     String seedString =
         JOptionPane.showInputDialog(
             this, "Enter a number:", Long.toString(rand.nextLong(), 36)
             // "Random Seed", JOptionPane.QUESTION_MESSAGE
             );
     if (seedString == null) return;
     try {
       seed = Long.parseLong(seedString, 36);
     } catch (NumberFormatException ex) {
       JOptionPane.showMessageDialog(this, "Use only letters and numbers, max 12 characters.");
       redo = true;
     }
   } while (redo);
   genSeed(seed);
 }
예제 #17
0
 public boolean edtImport(File fi, String date, String tags) {
   if (!fi.exists()) {
     System.err.println("import: file " + fi.getAbsolutePath() + " doesnt exist");
     return false;
   }
   String pname = fi.getName();
   if (store.containsEntry(pname)) {
     System.err.println("import: already have a file named " + pname);
     return false;
   }
   long size = fi.length() / KILOBYTE;
   File save = sec.encryptMainFile(fi, storeLocs.get(0), true);
   if (save == null) {
     System.err.println("import: Encryption failure");
     return false;
   }
   if (checkImports) {
     boolean success = true;
     File checkfi = new File(idx + ".check");
     File checkOut = sec.encryptSpecialFile(save, checkfi, false);
     if (checkOut == null) success = false;
     else {
       String fiHash = sec.digest(fi);
       String outHash = sec.digest(checkOut);
       if (fiHash == null || outHash == null || fiHash.length() < 1 || !fiHash.equals(outHash))
         success = false;
     }
     checkfi.delete();
     if (!success) {
       save.delete();
       if (JOptionPane.showConfirmDialog(
               frm,
               "Confirming "
                   + fi.getName()
                   + "failed\n\n - Would you like to re-import the file?",
               "Import failed",
               JOptionPane.YES_NO_OPTION)
           == JOptionPane.YES_OPTION) {
         String j = impJob(fi, date, tags);
         synchronized (jobs) {
           if (priorityExport) jobs.addLast(j);
           else jobs.addFirst(j);
         }
       }
       return false;
     }
   }
   if (!fi.delete()) {
     System.err.println("import: Couldnt delete old file - continuing");
   }
   store.add(save.getName(), pname, date, size, tags, 0);
   needsSave = true;
   return true;
 }
예제 #18
0
  void find() {
    String query = "";
    try {
      query = m_table.getCriterion();
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.getMessage());
      return;
    }

    try {
      HRMBusinessLogic logic = new HRMBusinessLogic(m_conn);
      m_panel.reset(
          logic.getEmployeeByCriteria(m_sessionid, IDBConstants.MODUL_MASTER_DATA, query));
      if (m_panel.m_panel_rptEmployeProfile != null)
        m_panel.m_panel_rptEmployeProfile.m_employee = null;
      else if (m_panel.m_panel_rptPaycheq != null) m_panel.m_panel_rptPaycheq.m_employee = null;
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
    }
  }
예제 #19
0
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Save selected data.");
      file_chooser.setMultiSelectionEnabled(false);

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File file = file_chooser.getSelectedFile();
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          AstrometricaWriter writer = new AstrometricaWriter(file);
          writer.open();

          int check_column = getCheckColumn();
          for (int i = 0; i < model.getRowCount(); i++) {
            if (((Boolean) getValueAt(i, check_column)).booleanValue()) {
              Variability record = (Variability) record_list.elementAt(index.get(i));
              writer.write(record.getStar());
            }
          }

          writer.close();

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed to save file.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        } catch (UnsupportedStarClassException exception) {
          String message = "Failed to save file.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }
예제 #20
0
    public void actionPerformed(ActionEvent clickEvent) {

      RecorderDialog recorderInfo = new RecorderDialog(parent);

      recorderInfo.show();

      JOptionPane.showMessageDialog(null, "Clock Reset\nrecordingRTP session...");

      stopRTPrecording.setEnabled(true);

      startRTPrecording.setEnabled(false);
    }
예제 #21
0
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Save package file.");
      file_chooser.setMultiSelectionEnabled(false);
      file_chooser.addChoosableFileFilter(new XmlFilter());
      file_chooser.setSelectedFile(new File("package.xml"));

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File file = file_chooser.getSelectedFile();
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          // Outputs the variability XML file.

          XmlVariabilityHolder holder = new XmlVariabilityHolder();

          Variability[] records = getSelectedRecords();
          for (int i = 0; i < records.length; i++) {
            XmlVariability variability = new XmlVariability(records[i]);
            holder.addVariability(variability);
          }

          holder.write(file);

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }
예제 #22
0
 public void toClipBoard() {
   try {
     Toolkit.getDefaultToolkit()
         .getSystemClipboard()
         .setContents(new StringSelection(PArray.cat(M)), null);
   } catch (IllegalStateException e) {
     JOptionPane.showConfirmDialog(
         null,
         "Copy to clipboard failed : " + e.getMessage(),
         "Error",
         JOptionPane.DEFAULT_OPTION,
         JOptionPane.ERROR_MESSAGE);
   }
 }
예제 #23
0
 private void btnEliminarRenglonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnEliminarRenglonActionPerformed
   // TODO add your handling code here:
   int IDRenglon = this.tablaPrincipal.getSelectedRow();
   if (IDRenglon != -1) {
     if (JOptionPane.showConfirmDialog(
             null,
             "¿Realmente desea eliminar el renglón seleccionado?",
             "¿Eliminar?",
             JOptionPane.OK_CANCEL_OPTION)
         == JOptionPane.OK_OPTION) {
       ((DefaultTableModel) tablaPrincipal.getModel()).removeRow(IDRenglon);
     }
   }
 } // GEN-LAST:event_btnEliminarRenglonActionPerformed
예제 #24
0
  void okButton_actionPerformed(ActionEvent e) {
    int num_rows = filtersTable.getRowCount();
    EditableDefinablePlugin edp = m_data.getPlugin();
    for (int row = 0; row < num_rows; row++) {
      String mimeType = (String) filtersTable.getValueAt(row, 0);
      String mimeTypeValue = (String) filtersTable.getValueAt(row, 1);

      try {
        mimeTypeEditorBuilder.checkValue(edp, mimeType, mimeTypeValue);
      } catch (DynamicallyLoadedComponentException dlce) {
        String logMessage =
            "Failed to set the "
                + mimeTypeEditorBuilder.getValueName()
                + " for MIME type "
                + mimeType
                + " to "
                + mimeTypeValue;
        logger.error(logMessage, dlce);
        if (!EDPInspectorTableModel.handleDynamicallyLoadedComponentException(this, dlce)) {
          return;
        } else {
          logger.debug("User override; allow " + mimeTypeValue);
        }
      }
    }
    mimeTypeEditorBuilder.clear(edp);
    for (int row = 0; row < num_rows; row++) {
      String mimeType = (String) filtersTable.getValueAt(row, 0);
      String mimeTypeValue = (String) filtersTable.getValueAt(row, 1);

      try {
        mimeTypeEditorBuilder.put(edp, mimeType, mimeTypeValue);
      } catch (DynamicallyLoadedComponentException dlce) {
        String logMessage =
            "Internal error; MIME type " + mimeType + " not set to " + mimeTypeValue;
        logger.error(logMessage, dlce);
      } catch (PluginException.InvalidDefinition ex) {
        JOptionPane.showMessageDialog(
            this,
            ex.getMessage(),
            WordUtils.capitalize(mimeTypeEditorBuilder.getValueName()) + " Warning",
            JOptionPane.WARNING_MESSAGE);
      }
    }
    setVisible(false);
  }
예제 #25
0
 public MimeTypeEditor(
     MimeTypeEditorBuilder mimeTypeEditorBuilder, Frame frame, String title, boolean modal) {
   super(frame, title, modal);
   this.mimeTypeEditorBuilder = mimeTypeEditorBuilder;
   this.m_model = new MimeTypeTableModel();
   try {
     jbInit();
     pack();
   } catch (Exception exc) {
     String logMessage =
         "Could not set up the " + mimeTypeEditorBuilder.getValueName() + " editor";
     logger.critical(logMessage, exc);
     JOptionPane.showMessageDialog(
         frame,
         logMessage,
         WordUtils.capitalize(mimeTypeEditorBuilder.getValueName()) + " Editor",
         JOptionPane.ERROR_MESSAGE);
   }
 }
 /**
  * * Each non abstract class that implements the ActionListener must have this method.
  *
  * @param e the action event.
  */
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == submitButton) {
     int result = submit();
     if (result == 0) {
       JOptionPane.showMessageDialog(
           this,
           "Fehler: Produktgruppe "
               + produktgruppeFormular.nameField.getText()
               + " konnte nicht eingefügt werden.",
           "Fehler",
           JOptionPane.ERROR_MESSAGE);
     } else {
       produktgruppenListe.updateAll();
       closeButton.doClick();
     }
     return;
   }
   super.actionPerformed(e);
 }
예제 #27
0
  public TableDeneme() {
    super("Dictionary Window");
    qtm = new QueryTableModel();
    table = new JTable(qtm);
    scrollpane = new JScrollPane(table);
    p1 = new JPanel();
    jb = new JButton("get em all");
    p1.add(jb);

    getContentPane().add(p1, BorderLayout.NORTH);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
    addWindowListener(new BasicWindowMonitor());
    setSize(500, 500);
    setVisible(true);

    JOptionPane.showMessageDialog(
        new Frame(),
        "Press the button,\n"
            + "It will fill the table with all records.\n"
            + "Then you can edit the cells.\n"
            + "When you select another cell, the previous one will updated.\n\n"
            + "*****@*****.**");

    /**
     * ****show selection***** table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); rowSM =
     * table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener(){ public
     * void valueChanged(ListSelectionEvent e){ if (e.getValueIsAdjusting()) return;
     * ListSelectionModel lsm = (ListSelectionModel)e.getSource(); if (lsm.isSelectionEmpty()){
     * System.out.println("No rows are selected."); } else{
     * System.out.println(table.getValueAt(table.getSelectionModel().getMinSelectionIndex(),0));
     * System.out.println(table.getValueAt(table.getSelectionModel().getMinSelectionIndex(),1)); } }
     * }); ********************
     */
    jb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            qtm.setHostURL(
                "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=281;DBQ=db1.mdb");
            qtm.setQuery("select * from soz");
          }
        });
  }
예제 #28
0
  /** Finds the previous occurance of the given string in the 3rd column of the table. */
  private void findPrev() {
    String infix = findTextField.getText();
    if (infix.equals("")) {
      return;
    }

    if (!matchCase) {
      infix = infix.toLowerCase();
    }

    String desc[] = ((ConstantPoolTableModel) table.getModel()).getDescriptions();
    if (null == desc) {
      return;
    }

    if (table.getSelectedRowCount() != 0) {
      actIndex = table.getSelectedRow();
    }

    int rows = ((ConstantPoolTableModel) table.getModel()).getRowCount();
    boolean found = false, end = false;
    int start = actIndex;

    while (!end && !found) {
      if (0 < actIndex) {
        actIndex--;
      } else {
        actIndex = (rows - 1);
      }

      found = desc[actIndex].toLowerCase().contains(infix);
      end = (start == actIndex) && !found;
    }

    if (found) {
      table.changeSelection(actIndex, 0, false, false);
    } else if (end) {
      Toolkit.getDefaultToolkit().beep();
      JOptionPane.showMessageDialog(
          this, "String " + infix + " was not found.", "Alert:", JOptionPane.ERROR_MESSAGE);
    }
  } // findPrev
예제 #29
0
  @SuppressWarnings("unused")
  @Override
  public void mouseClicked(MouseEvent e) {
    int iDongDaChon = jRoom.getSelectedRow();
    if (iDongDaChon == -1) {
      JOptionPane.showMessageDialog(this, "you select 1 row");
    } else {
      buttonDelete.setVisible(true);
      buttonUpdate.setEnabled(true);
      Vector vDongDaChon = (Vector) tableRecords.get(iDongDaChon);
      IDROOM = Integer.parseInt(vDongDaChon.get(0).toString());
      String roomNumber = vDongDaChon.get(1).toString();
      String roomType = vDongDaChon.get(2).toString();
      String numBeds = vDongDaChon.get(3).toString();
      String roomTypeRate = vDongDaChon.get(4).toString();
      String roomStatus = vDongDaChon.get(5).toString();
      String des = vDongDaChon.get(6).toString();

      txtRoomNumber.setText(roomNumber);
      boxRoomTypeID.setSelectedItem(roomType.toString());
      boxRoomStatusID.setSelectedItem(roomStatus.toString());
      txtDescription.setText(des);
      try {
        List<CheckIn> temp = CheckInController.checkInController.all();
        for (int i = 0; i < temp.size(); i++) {
          if (IDROOM == temp.get(i).getRoomID()) {
            this.error = 0;
            buttonUpdate.setEnabled(false);
            buttonDelete.setEnabled(false);
            break;
          } else {
            this.error = 0;
            buttonUpdate.setEnabled(true);
            buttonDelete.setEnabled(true);
          }
        }
      } catch (Exception e2) {
        e2.printStackTrace();
      }
    }
  }
예제 #30
0
파일: CorpusEditor.java 프로젝트: kzn/gate
 public void actionPerformed(ActionEvent e) {
   Component root = SwingUtilities.getRoot(CorpusEditor.this);
   if (!(root instanceof MainFrame)) {
     return;
   }
   final MainFrame mainFrame = (MainFrame) root;
   final int[] selectedRows = docTable.getSelectedRows();
   if (selectedRows.length > 10) {
     Object[] possibleValues = {"Open the " + selectedRows.length + " documents", "Don't open"};
     int selectedValue =
         JOptionPane.showOptionDialog(
             docTable,
             "Do you want to open "
                 + selectedRows.length
                 + " documents in the central tabbed pane ?",
             "Warning",
             JOptionPane.DEFAULT_OPTION,
             JOptionPane.QUESTION_MESSAGE,
             null,
             possibleValues,
             possibleValues[1]);
     if (selectedValue == 1 || selectedValue == JOptionPane.CLOSED_OPTION) {
       return;
     }
   }
   for (int row : selectedRows) {
     // load the document if inside a datastore
     corpus.get(docTable.rowViewToModel(row));
   }
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           for (int row : selectedRows) {
             Document doc = (Document) corpus.get(docTable.rowViewToModel(row));
             // show the document in the central view
             mainFrame.select(doc);
           }
         }
       });
 }