Exemplo n.º 1
0
  public AmltpvViewClient(SingleFrameApplication app) {
    super(app);

    initComponents();

    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    messageTimer =
        new Timer(
            messageTimeout,
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
              }
            });
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
      busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer =
        new Timer(
            busyAnimationRate,
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
              }
            });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(
        new java.beans.PropertyChangeListener() {
          public void propertyChange(java.beans.PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName)) {
              if (!busyIconTimer.isRunning()) {
                statusAnimationLabel.setIcon(busyIcons[0]);
                busyIconIndex = 0;
                busyIconTimer.start();
              }
              progressBar.setVisible(true);
              progressBar.setIndeterminate(true);
            } else if ("done".equals(propertyName)) {
              busyIconTimer.stop();
              statusAnimationLabel.setIcon(idleIcon);
              progressBar.setVisible(false);
              progressBar.setValue(0);
            } else if ("message".equals(propertyName)) {
              String text = (String) (evt.getNewValue());
              statusMessageLabel.setText((text == null) ? "" : text);
              messageTimer.restart();
            } else if ("progress".equals(propertyName)) {
              int value = (Integer) (evt.getNewValue());
              progressBar.setVisible(true);
              progressBar.setIndeterminate(false);
              progressBar.setValue(value);
            }
          }
        });

    // SEVERRAL INITIALIZATIONS
    util = new amltpv.Utils(statusMessageLabel);
    util.setMainFrame(AmltpvClientApp.getApplication().getMainFrame());
    db = new DataBase();
    super.getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    // Thread t = new Thread(new ThreadTest());
    // t.start();
    cobradasDialog = new CobradasDialog(super.getFrame(), true);
    cobradasDialog.setLocationRelativeTo(super.getComponent());
    self = this;
  }
Exemplo n.º 2
0
 private void cobradasMenuItemActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cobradasMenuItemActionPerformed
   cobradasDialog.setVisible(true);
 } // GEN-LAST:event_cobradasMenuItemActionPerformed