Esempio n. 1
0
 public void update(JTextArea area) {
   DBItem item = dataList.getSelectedValue();
   if (item != null && !isSet) {
     isSet = true;
     try {
       if (area == hexKey) {
         if (area.getText().isEmpty()) {
           return;
         }
         item.key =
             new BigInteger(area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n"), 16)
                 .toByteArray();
         stringKey.setText(cutToLine(new String(item.key), 64));
         dataList.updateUI();
       } else if (area == stringKey) {
         if (area.getText().isEmpty()) {
           return;
         }
         item.key = area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n").getBytes();
         hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64));
         dataList.updateUI();
       } else if (area == hexValue) {
         item.value =
             new BigInteger(area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n"), 16)
                 .toByteArray();
         stringValue.setText(cutToLine(new String(item.value), 64));
       } else if (area == stringValue) {
         item.value = area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n").getBytes();
         hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64));
       }
       notice.setVisible(false);
       notice.setText("");
       saveButton.setEnabled(true);
     } catch (Exception e) {
       notice.setVisible(true);
       notice.setText("Invalid number!");
     } finally {
       lengthLabel.setText(String.valueOf(item.value.length + item.key.length));
       keyLength.setText(String.valueOf(item.key.length));
       valueLength.setText(String.valueOf(item.value.length));
       isSet = false;
     }
   }
 }