예제 #1
0
 /** Update button enable/disable state according enableCheckBox. */
 private void updateButtonsState() {
   sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   fileCountField.setEnabled(enableCheckBox.isSelected());
   fileSizeField.setEnabled(enableCheckBox.isSelected());
   fileSizeLabel.setEnabled(enableCheckBox.isSelected());
   fileCountLabel.setEnabled(enableCheckBox.isSelected());
 }
예제 #2
0
  private void setComponentsEnabled(boolean enabled) {
    list.setEnabled(enabled);
    process.setEnabled(enabled);
    remove.setEnabled(enabled);
    xres.setEnabled(enabled);
    yres.setEnabled(enabled);
    aspect.setEnabled(enabled);

    boolean b = aspect.isSelected() && enabled;
    colorLabel.setEnabled(b);
    colorBox.setEnabled(b);
    redLabel.setEnabled(b);
    red.setEnabled(b);
    redValue.setEnabled(b);
    greenLabel.setEnabled(b);
    green.setEnabled(b);
    greenValue.setEnabled(b);
    blueLabel.setEnabled(b);
    blue.setEnabled(b);
    blueValue.setEnabled(b);

    format.setEnabled(enabled);
    algorithm.setEnabled(enabled);
    prepend.setEnabled(enabled);
    append.setEnabled(enabled);
    output.setEnabled(enabled);
  }
예제 #3
0
  public Viewer() {
    leveldbStore.setMultiSelectionEnabled(false);
    leveldbStore.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    putButton.setEnabled(false);
    key.setEnabled(false);
    value.setEnabled(false);
    findField.setEnabled(false);
    deleteButton.setEnabled(false);
    saveButton.setEnabled(false);
    putType.setEnabled(false);
    putType.setEditable(false);
    signedBox.setEnabled(false);

    openButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (openButton.isEnabled()) {
              openButton.setEnabled(false);
              new Thread() {
                public void run() {
                  if (leveldbStore.showOpenDialog(pane) == JFileChooser.APPROVE_OPTION) {
                    File select = leveldbStore.getSelectedFile();
                    if (select.isDirectory()) {
                      new OpenLevelDBDialog(Viewer.this, select);
                      openDatabase(select);
                      dbPathField.setText(select.getAbsolutePath());
                    } else {
                      JOptionPane.showMessageDialog(
                          pane,
                          "The selecting item must be a directory",
                          "Unable to load database",
                          JOptionPane.WARNING_MESSAGE);
                    }
                  } else {
                    openButton.setEnabled(true);
                  }
                }
              }.start();
            }
          }
        });

    deleteButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (dataList.getSelectedValue() != null) {
              delete(dataList.getSelectedValue().key);
            }
            openDatabase(leveldbStore.getSelectedFile());
          }
        });

    putButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            put(
                ((PutType) putType.getSelectedItem()).getBytes(key.getText()),
                ((PutType) putType.getSelectedItem()).getBytes(value.getText()));
            openDatabase(leveldbStore.getSelectedFile());
          }
        });

    findField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            openDatabase(leveldbStore.getSelectedFile());
          }
        });
    findField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                openDatabase(leveldbStore.getSelectedFile());
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                openDatabase(leveldbStore.getSelectedFile());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                openDatabase(leveldbStore.getSelectedFile());
              }
            });
    findField
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {
              @Override
              public void undoableEditHappened(UndoableEditEvent e) {
                openDatabase(leveldbStore.getSelectedFile());
              }
            });

    hexKey
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                update(hexKey);
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update(hexKey);
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update(hexKey);
              }
            });
    hexKey
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {
              @Override
              public void undoableEditHappened(UndoableEditEvent e) {
                update(hexKey);
              }
            });

    stringKey
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                update(stringKey);
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update(stringKey);
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update(stringKey);
              }
            });
    stringKey
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {
              @Override
              public void undoableEditHappened(UndoableEditEvent e) {
                update(stringKey);
              }
            });

    hexValue
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                update(hexValue);
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update(hexValue);
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update(hexValue);
              }
            });
    hexValue
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {
              @Override
              public void undoableEditHappened(UndoableEditEvent e) {
                update(hexValue);
              }
            });

    stringValue
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                update(stringValue);
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update(stringValue);
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update(stringValue);
              }
            });
    stringValue
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {
              @Override
              public void undoableEditHappened(UndoableEditEvent e) {
                update(stringValue);
              }
            });

    saveButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            save();
            openDatabase(leveldbStore.getSelectedFile());
          }
        });

    dataList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            DBItem item = dataList.getSelectedValue();
            if (item != null) {
              hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64));
              stringValue.setText(cutToLine(new String(item.value), 64));
              hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64));
              stringKey.setText(cutToLine(new String(item.key), 64));

              lengthLabel.setText(String.valueOf(item.value.length + item.key.length));
              keyLength.setText(String.valueOf(item.key.length));
              valueLength.setText(String.valueOf(item.value.length));
            }
          }
        });

    signedBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            LevelDBViewer.DEFAULT_SINGED = signedBox.isSelected();
            int i = dataList.getSelectedIndex();
            dataList.clearSelection();
            dataList.updateUI();
            dataList.setSelectedIndex(i);
            update(hexKey);
            update(hexValue);
          }
        });

    for (PutType t : PutType.values()) {
      putType.addItem(t);
    }
    putType.setSelectedItem(PutType.STRING);
    putType.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            openDatabase(leveldbStore.getSelectedFile());
          }
        });
    putType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            openDatabase(leveldbStore.getSelectedFile());
          }
        });

    dialog.setLocationByPlatform(true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setContentPane(pane);
    dialog.setTitle("LevelDB Viewer By Marcus (https://github.com/SuperMarcus)");
    dialog.getRootPane().setDefaultButton(openButton);
    dialog.pack();
    dialog.setVisible(true);
  }
예제 #4
0
  public void openDatabase(File select) {
    if (getOptions() != null) {
      DB database = null;
      try {
        database = factory.open(select, getOptions());
        DBIterator iterator = database.iterator();

        ArrayList<DBItem> data = new ArrayList<>();

        String reg = findField.getText().trim();

        for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) {
          if (reg.isEmpty()
              || new BigInteger(iterator.peekNext().getKey()).toString(16).contains(reg)
              || LevelDBViewer.toHexString(iterator.peekNext().getKey()).contains(reg)
              || new BigInteger(iterator.peekNext().getValue()).toString(16).contains(reg)
              || LevelDBViewer.toHexString(iterator.peekNext().getValue()).contains(reg)
              || new String(iterator.peekNext().getKey()).contains(reg)
              || new String(iterator.peekNext().getValue()).contains(reg)) {
            data.add(new DBItem(iterator.peekNext().getKey(), iterator.peekNext().getValue()));
          }
        }

        iterator.close();

        dialog.getRootPane().setDefaultButton(putButton);

        dataList.getSelectionModel().clearSelection();
        dataList.setListData(data.toArray(new DBItem[data.size()]));

        putButton.setEnabled(true);
        key.setEnabled(true);
        value.setEnabled(true);
        findField.setEnabled(true);
        deleteButton.setEnabled(true);
        putType.setEnabled(true);
        signedBox.setEnabled(true);
        // saveButton.setEnabled(true);

        hexValue.setText("");
        stringValue.setText("");
        hexKey.setText("");
        stringKey.setText("");

        lengthLabel.setText("");
        keyLength.setText("");
        valueLength.setText("");
      } catch (Exception e) {
        JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e);
        e.printStackTrace();
      } finally {
        if (database != null) {
          try {
            database.close();
          } catch (IOException e) {
            JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e);
            e.printStackTrace();
          }
        }
      }
    }
  }
  protected boolean exportApplicationPrompt() throws IOException, SketchException {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalStrut(6));

    // Box panel = Box.createVerticalBox();

    // Box labelBox = Box.createHorizontalBox();
    //    String msg = "<html>Click Export to Application to create a standalone, " +
    //      "double-clickable application for the selected plaforms.";

    //    String msg = "Export to Application creates a standalone, \n" +
    //      "double-clickable application for the selected plaforms.";
    String line1 = "Export to Application creates double-clickable,";
    String line2 = "standalone applications for the selected plaforms.";
    JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
    JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    //    label1.setAlignmentX();
    //    label2.setAlignmentX(0);
    panel.add(label1);
    panel.add(label2);
    int wide = label2.getPreferredSize().width;
    panel.add(Box.createVerticalStrut(12));

    final JCheckBox windowsButton = new JCheckBox("Windows");
    // windowsButton.setMnemonic(KeyEvent.VK_W);
    windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
    windowsButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean(
                "export.application.platform.windows", windowsButton.isSelected());
          }
        });

    final JCheckBox macosxButton = new JCheckBox("Mac OS X");
    // macosxButton.setMnemonic(KeyEvent.VK_M);
    macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
    macosxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
          }
        });

    final JCheckBox linuxButton = new JCheckBox("Linux");
    // linuxButton.setMnemonic(KeyEvent.VK_L);
    linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux"));
    linuxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected());
          }
        });

    JPanel platformPanel = new JPanel();
    // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
    platformPanel.add(windowsButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(macosxButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(linuxButton);
    platformPanel.setBorder(new TitledBorder("Platforms"));
    // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
    // platformPanel.setMaximumSize(goodIdea);
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(platformPanel);

    //  Box indentPanel = Box.createHorizontalBox();
    //  indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
    final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
    // showStopButton.setMnemonic(KeyEvent.VK_S);
    showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
    showStopButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
          }
        });
    showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
    showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
    //  indentPanel.add(showStopButton);
    //  indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
    // fullscreenButton.setMnemonic(KeyEvent.VK_F);
    fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
    fullScreenButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean sal = fullScreenButton.isSelected();
            Preferences.setBoolean("export.application.fullscreen", sal);
            showStopButton.setEnabled(sal);
          }
        });
    fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(fullScreenButton);
    optionPanel.add(showStopButton);
    //    optionPanel.add(indentPanel);
    optionPanel.setBorder(new TitledBorder("Options"));
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // optionPanel.setMaximumSize(goodIdea);
    panel.add(optionPanel);

    Dimension good;
    // label1, label2, platformPanel, optionPanel
    good = new Dimension(wide, label1.getPreferredSize().height);
    label1.setMaximumSize(good);
    good = new Dimension(wide, label2.getPreferredSize().height);
    label2.setMaximumSize(good);
    good = new Dimension(wide, platformPanel.getPreferredSize().height);
    platformPanel.setMaximumSize(good);
    good = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setMaximumSize(good);

    //    JPanel actionPanel = new JPanel();
    //    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
    //    optionPanel.add(Box.createHorizontalGlue());

    //    final JDialog frame = new JDialog(editor, "Export to Application");

    //    JButton cancelButton = new JButton("Cancel");
    //    cancelButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //        frame.dispose();
    //        return false;
    //      }
    //    });

    // Add the buttons in platform-specific order
    //    if (PApplet.platform == PConstants.MACOSX) {
    //      optionPanel.add(cancelButton);
    //      optionPanel.add(exportButton);
    //    } else {
    //      optionPanel.add(exportButton);
    //      optionPanel.add(cancelButton);
    //    }
    String[] options = {"Export", "Cancel"};
    final JOptionPane optionPane =
        new JOptionPane(
            panel,
            JOptionPane.PLAIN_MESSAGE,
            // JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    final JDialog dialog = new JDialog(this, "Export Options", true);
    dialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
              // If you were going to check something
              // before closing the window, you'd do
              // it here.
              dialog.setVisible(false);
            }
          }
        });
    dialog.pack();
    dialog.setResizable(false);

    Rectangle bounds = getBounds();
    dialog.setLocation(
        bounds.x + (bounds.width - dialog.getSize().width) / 2,
        bounds.y + (bounds.height - dialog.getSize().height) / 2);
    dialog.setVisible(true);

    Object value = optionPane.getValue();
    if (value.equals(options[0])) {
      return jmode.handleExportApplication(sketch);
    } else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
      // closed window by hitting Cancel or ESC
      statusNotice("Export to Application canceled.");
    }
    return false;
  }