예제 #1
0
 /** Prida nebo edituje vzorec */
 public void addEdit(boolean edit) {
   try {
     // prevod dat na stream bytu
     ByteArrayOutputStream buffer = new ByteArrayOutputStream();
     DataOutputStream dos = new DataOutputStream(buffer);
     dos.writeUTF(gui.get_tfPatternName().getString());
     dos.writeUTF(gui.get_tfEditPatternLattitude().getString().toUpperCase());
     dos.writeUTF(gui.get_tfEditPatternLongitude().getString().toUpperCase());
     byte[] bytes = buffer.toByteArray();
     // nejdriv zjistit zda uz dane pismeno v databazi je
     if (edit) {
       RecordEnumeration rc = recordStore.enumerateRecords(this, this, true);
       rc.rebuild();
       int id = 0;
       for (int i = 0; i < gui.get_lstPatterns().getSelectedIndex() + 1; i++) {
         id = rc.nextRecordId();
       }
       recordStore.setRecord(id, bytes, 0, bytes.length);
     } else {
       recordStore.addRecord(bytes, 0, bytes.length);
     }
     viewAll();
   } catch (Exception ex) {
     gui.showError("addEditPattern", ex.toString(), "");
   }
 }
예제 #2
0
 /** Smaze jeden vzorecek */
 public void delete() {
   try {
     RecordEnumeration rc = recordStore.enumerateRecords(this, this, true);
     rc.rebuild();
     int id = 0;
     for (int i = 0; i < gui.get_lstPatterns().getSelectedIndex() + 1; i++) {
       id = rc.nextRecordId();
     }
     recordStore.deleteRecord(id);
   } catch (Exception e) {
     gui.showError("deletePattern", e.toString(), "");
   }
 }
예제 #3
0
 /** Zobrazi vsechny vzorce */
 public void viewAll() {
   try {
     gui.get_lstPatterns().deleteAll();
     RecordEnumeration rc = recordStore.enumerateRecords(this, this, true);
     rc.rebuild();
     for (int i = 0; i < rc.numRecords(); i++) {
       DataInputStream dis =
           new DataInputStream(new ByteArrayInputStream(recordStore.getRecord(rc.nextRecordId())));
       gui.get_lstPatterns().append(dis.readUTF(), null);
     }
   } catch (Exception ex) {
     gui.showError("viewPatterns", ex.toString(), "");
   }
 }
예제 #4
0
 /** Zobrazi vzorec */
 public void view() {
   try {
     RecordEnumeration rc = recordStore.enumerateRecords(this, this, true);
     rc.rebuild();
     int id = 0;
     for (int i = 0; i < gui.get_lstPatterns().getSelectedIndex() + 1; i++) {
       id = rc.nextRecordId();
     }
     DataInputStream dis =
         new DataInputStream(new ByteArrayInputStream(recordStore.getRecord(id)));
     gui.get_tfPatternName().setString(dis.readUTF());
     gui.get_tfEditPatternLattitude().setString(dis.readUTF());
     gui.get_tfEditPatternLongitude().setString(dis.readUTF());
   } catch (Exception e) {
     gui.showError("viewPattern", e.toString(), "");
   }
 }