/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the ok button
   if (e.getSource() == ok_button) {
     filter_include_list = include_panel.getServiceList();
     filter_exclude_list = exclude_panel.getServiceList();
     if (status_box.isSelected()) {
       filter_active = status_active.isSelected();
       filter_complete = status_complete.isSelected();
     } else {
       filter_active = false;
       filter_complete = false;
     }
     ok_pressed = true;
     dialog.dispose();
   }
   // Check if the user pressed the cancel button
   if (e.getSource() == cancel_button) {
     dialog.dispose();
   }
   // Check if the user changed the status filter option
   if (e.getSource() == status_box) {
     status_active.setEnabled(status_box.isSelected());
     status_complete.setEnabled(status_box.isSelected());
   }
 }
  /*
   * The following method creates the color chooser dialog box
   */
  public void createColorDialog() {
    colorDialog = new JDialog(this, new String("Choose a color"), true);
    colorDialog.getContentPane().add(createColorPicker(), BorderLayout.CENTER);

    JButton okButton = new JButton("OK");

    // This class is used to create a special ActionListener for
    //    the ok button
    class ButtonListener implements ActionListener {
      /*
       * This method is called whenever the ok button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        currentChoice.changeColor(color_panel.getColor());
        currentChoice.repaint();
        fontColor = color_panel.getColor();
        colorDialog.hide();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    okButton.addActionListener(listener);

    // Add the four font control panels to one big panel using
    //  a grid layout
    JPanel buttonPanel = new JPanel();

    buttonPanel.add(okButton);

    // Add the button panel to the content pane of the ColorDialogue
    colorDialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    colorDialog.pack();
  }
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
예제 #4
0
  /** Close me */
  public void close() {
    if (dialog != null) {
      dialog.setVisible(false);
      if (dialog.isModal()) {
        dialog.setModal(false);
      }
    }

    if (frame != null) {
      frame.setVisible(false);
    }
  }
예제 #5
0
  /**
   * Open me
   *
   * @param modal _more_
   */
  public void show(boolean modal) {
    if (!windowOk()) {
      return;
    }
    if (dialog != null) {
      dialog.setModal(modal);
      dialog.setVisible(true);
    }
    if (frame != null) {
      frame.setVisible(true);
    }

    if (window != null) {
      GuiUtils.showWidget(window);
    }
  }
예제 #6
0
파일: Board.java 프로젝트: ankeshs/hex
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("New Game")) {
      newGame();
    }

    if (e.getActionCommand().equals("Exit Game")) {
      exit();
    }
    if (e.getActionCommand().equals("About")) {
      JDialog f = new JDialog();
      f.add(new JLabel(new ImageIcon("splash_applet.jpg")));
      f.setSize(660, 520);
      f.setLocationRelativeTo(this);
      f.setVisible(true);
    }
  }
예제 #7
0
  protected void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      status = CLOSED_OPTION;
      dispose();
    }

    super.processWindowEvent(e);
  }
예제 #8
0
  /** _more_ */
  public void removeAll() {
    if (dialog != null) {
      dialog.getContentPane().removeAll();
    }

    if (frame != null) {
      frame.getContentPane().removeAll();
    }
  }
예제 #9
0
 /**
  * Set the title of the window to the given title
  *
  * @param title The window title
  */
 public void setWindowTitle(String title) {
   if (!windowOk()) {
     return;
   }
   if (dialog != null) {
     dialog.setTitle(title);
   }
   if (frame != null) {
     frame.setTitle(title);
   }
 }
예제 #10
0
 /**
  * _more_
  *
  * @return _more_
  */
 private boolean windowOk() {
   getContents();
   if (contents == null) {
     return false;
   }
   if (shouldMakeDialog()) {
     if (dialog == null) {
       dialog = new JDialog((Frame) null, getWindowTitle(), false);
       LogUtil.registerWindow(dialog);
       GuiUtils.packDialog(dialog, contents);
       dialog.setLocation(100, 100);
       window = dialog;
     }
   } else {
     if (frame == null) {
       frame = new JFrame(getWindowTitle());
       if (menuBar != null) {
         GuiUtils.decorateFrame(frame, menuBar);
       }
       LogUtil.registerWindow(frame);
       frame.getContentPane().add(contents);
       frame.pack();
       Msg.translateTree(frame);
       frame.setLocation(100, 100);
       window = frame;
     }
   }
   if (window != null) {
     window.addWindowListener(
         new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             windowIsClosing();
           }
         });
   }
   return window != null;
 }
예제 #11
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);
  }
예제 #12
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();
          }
        }
      }
    }
  }
예제 #13
0
 /** Destroy this object */
 public void destroy() {
   if (viewDialog != null) {
     viewDialog.dispose();
     viewDialog = null;
   }
 }
예제 #14
0
 /** Popup the Manager Dialog */
 public void show() {
   if (viewDialog != null) {
     viewDialog.setVisible(true);
   }
 }
예제 #15
0
 /** Close this widget */
 public void close() {
   if (viewDialog != null) {
     viewDialog.setVisible(false);
   }
 }
예제 #16
0
  /**
   * Create a new ProjectionManager.
   *
   * @param parent JFrame (application) or JApplet (applet)
   * @param projections list of initial projections
   * @param makeDialog true to make this a dialog
   * @param helpId help id if dialog
   * @param maps List of MapData
   */
  public ProjectionManager(
      RootPaneContainer parent, List projections, boolean makeDialog, String helpId, List maps) {

    this.helpId = helpId;
    this.maps = maps;
    this.parent = parent;

    // manage NewProjectionListeners
    lm =
        new ListenerManager(
            "java.beans.PropertyChangeListener",
            "java.beans.PropertyChangeEvent",
            "propertyChange");

    // here's where the map will be drawn: but cant be changed/edited
    npViewControl = new NPController();
    if (maps == null) {
      maps = getDefaultMaps(); // we use the system default
    }
    for (int mapIdx = 0; mapIdx < maps.size(); mapIdx++) {
      MapData mapData = (MapData) maps.get(mapIdx);
      if (mapData.getVisible()) {
        npViewControl.addMap(mapData.getSource(), mapData.getColor());
      }
    }
    mapViewPanel = npViewControl.getNavigatedPanel();
    mapViewPanel.setPreferredSize(new Dimension(250, 250));
    mapViewPanel.setToolTipText("Shows the default zoom of the current projection");
    mapViewPanel.setChangeable(false);

    if ((projections == null) || (projections.size() == 0)) {
      projections = makeDefaultProjections();
    }

    // the actual list is a JTable subclass
    projTable = new JTableProjection(this, projections);

    JComponent listContents = new JScrollPane(projTable);

    JComponent buttons =
        GuiUtils.hbox(
            GuiUtils.makeButton("Edit", this, "doEdit"),
            GuiUtils.makeButton("New", this, "doNew"),
            GuiUtils.makeButton("Export", this, "doExport"),
            GuiUtils.makeButton("Delete", this, "doDelete"));

    mapLabel = new JLabel(" ");
    JComponent leftPanel = GuiUtils.inset(GuiUtils.topCenter(mapLabel, mapViewPanel), 5);

    JComponent rightPanel = GuiUtils.topCenter(buttons, listContents);
    rightPanel = GuiUtils.inset(rightPanel, 5);
    contents = GuiUtils.inset(GuiUtils.hbox(leftPanel, rightPanel), 5);

    // default current and working projection
    if (null != (current = projTable.getSelected())) {
      setWorkingProjection(current);
      projTable.setCurrentProjection(current);
      mapLabel.setText(current.getName());
    }

    /* listen for new working Projections from projTable */
    projTable.addNewProjectionListener(
        new NewProjectionListener() {
          public void actionPerformed(NewProjectionEvent e) {
            if (e.getProjection() != null) {
              setWorkingProjection(e.getProjection());
            }
          }
        });

    eventsOK = true;

    // put it together in the viewDialog
    if (makeDialog) {
      Container buttPanel = GuiUtils.makeApplyOkHelpCancelButtons(this);
      contents = GuiUtils.centerBottom(contents, buttPanel);
      viewDialog =
          GuiUtils.createDialog(GuiUtils.getApplicationTitle() + "Projection Manager", false);
      viewDialog.getContentPane().add(contents);
      viewDialog.pack();
      ucar.unidata.util.Msg.translateTree(viewDialog);
      viewDialog.setLocation(100, 100);
    }
  }
예제 #17
0
  public static boolean showLicensing() {
    if (Config.getLicenseResource() == null) return true;
    ClassLoader cl = Main.class.getClassLoader();
    URL url = cl.getResource(Config.getLicenseResource());
    if (url == null) return true;

    String license = null;
    try {
      URLConnection con = url.openConnection();
      int size = con.getContentLength();
      byte[] content = new byte[size];
      InputStream in = new BufferedInputStream(con.getInputStream());
      in.read(content);
      license = new String(content);
    } catch (IOException ioe) {
      Config.trace("Got exception when reading " + Config.getLicenseResource() + ": " + ioe);
      return false;
    }

    // Build dialog
    JTextArea ta = new JTextArea(license);
    ta.setEditable(false);
    final JDialog jd = new JDialog(_installerFrame, true);
    Container comp = jd.getContentPane();
    jd.setTitle(Config.getLicenseDialogTitle());
    comp.setLayout(new BorderLayout(10, 10));
    comp.add(new JScrollPane(ta), "Center");
    Box box = new Box(BoxLayout.X_AXIS);
    box.add(box.createHorizontalStrut(10));
    box.add(new JLabel(Config.getLicenseDialogQuestionString()));
    box.add(box.createHorizontalGlue());
    JButton acceptButton = new JButton(Config.getLicenseDialogAcceptString());
    JButton exitButton = new JButton(Config.getLicenseDialogExitString());
    box.add(acceptButton);
    box.add(box.createHorizontalStrut(10));
    box.add(exitButton);
    box.add(box.createHorizontalStrut(10));
    jd.getRootPane().setDefaultButton(acceptButton);
    Box box2 = new Box(BoxLayout.Y_AXIS);
    box2.add(box);
    box2.add(box2.createVerticalStrut(5));
    comp.add(box2, "South");
    jd.pack();

    final boolean accept[] = new boolean[1];
    acceptButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            accept[0] = true;
            jd.hide();
            jd.dispose();
          }
        });

    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            accept[0] = false;
            jd.hide();
            jd.dispose();
          }
        });

    // Apply any defaults the user may have, constraining to the size
    // of the screen, and default (packed) size.
    Rectangle size = new Rectangle(0, 0, 500, 300);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    size.width = Math.min(screenSize.width, size.width);
    size.height = Math.min(screenSize.height, size.height);
    // Center the window
    jd.setBounds(
        (screenSize.width - size.width) / 2,
        (screenSize.height - size.height) / 2,
        size.width,
        size.height);

    // Show dialog
    jd.show();

    return accept[0];
  }