Example #1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
  /** Initializes contained components. */
  private void initComponents() {
    final SimpleDateFormat format = new SimpleDateFormat("mm:ss");
    final Calendar c = Calendar.getInstance();
    final JLabel counter = new JLabel();

    counter.setForeground(Color.red);
    counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5)));

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    GridBagConstraints constraints = new GridBagConstraints();

    JLabel messageLabel =
        new JLabel(
            GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT"));

    messageLabel.setForeground(Color.WHITE);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    add(messageLabel, constraints);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 1;
    add(counter, constraints);

    ZrtpControl zrtpControl = null;
    if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl;

    long initialSeconds = 0;

    if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue();

    c.setTimeInMillis(initialSeconds);

    counter.setText(format.format(c.getTime()));

    if (initialSeconds > 0)
      timer.schedule(
          new TimerTask() {
            @Override
            public void run() {
              if (c.getTimeInMillis() - 1000 > 0) {
                c.add(Calendar.SECOND, -1);
                counter.setText(format.format(c.getTime()));
              }
            }
          },
          1000,
          1000);
  }
Example #3
0
  /**
   * Creates an instance of <tt>CallManager</tt>.
   *
   * @param mainFrame The main application window.
   */
  public CallManager(MainFrame mainFrame) {
    super(new BorderLayout());

    this.mainFrame = mainFrame;

    this.phoneNumberCombo = new CallComboBox(this);

    this.accountSelectorBox = new AccountSelectorBox(this);

    this.buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));

    this.comboPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5));

    this.init();
  }
  StatsPanel(String title) {
    TitledBorder tBorder = BorderFactory.createTitledBorder(title);
    setBorder(tBorder);
    setLayout(new GridLayout(0, 2));

    minLabel = new JLabel("Min");
    min = new JLabel("" + 0);
    meanLabel = new JLabel("Mean");
    mean = new JLabel("" + 0);
    maxLabel = new JLabel("Max");
    max = new JLabel("" + 0);
    stdDevLabel = new JLabel("StdDev");
    stdDev = new JLabel("" + 0);

    add(minLabel);
    add(min);
    add(meanLabel);
    add(mean);
    add(maxLabel);
    add(max);
    add(stdDevLabel);
    add(stdDev);

    setSize(width, height);
    setMinimumSize(new Dimension(width, height));
  }
Example #5
0
  private void addControls() {
    setLayout(new GridLayout(4, 2));

    add(makeLabel("Total Data:"));
    add(dataTotal = makeLabel("0"));
    dataTotal.setHorizontalAlignment(JLabel.CENTER);
    add(makeLabel("Data Rate: "));
    add(dataRate = makeLabel("0"));
    dataRate.setHorizontalAlignment(JLabel.CENTER);
    add(makeLabel("Total Flows:"));
    add(eventTotal = makeLabel("0"));
    eventTotal.setHorizontalAlignment(JLabel.CENTER);
    add(makeLabel("Flow Rate: "));
    add(eventRate = makeLabel("0e/s"));
    eventRate.setHorizontalAlignment(JLabel.CENTER);

    setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
  }
  /**
   * Creates a new <code>AddPersonDialog</code> with a given owner <code>JFrame</code> and <code>
   * FamilyTree</code>.
   */
  public AddPersonDialog(JFrame owner, FamilyTree tree) {
    super(owner, "Add New Person", true /* modal */);

    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayout(0, 2));
    Border infoBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    infoPanel.setBorder(infoBorder);

    infoPanel.add(new JLabel("id:"));
    final JTextField idField = new JTextField();
    infoPanel.add(idField);

    final ButtonGroup group = new ButtonGroup();

    final JRadioButton male = new JRadioButton("male", true);
    group.add(male);
    infoPanel.add(male);

    final JRadioButton female = new JRadioButton("female");
    group.add(female);
    infoPanel.add(female);

    infoPanel.add(new JLabel("First name:"));
    final JTextField firstNameField = new JTextField();
    infoPanel.add(firstNameField);

    infoPanel.add(new JLabel("Middle name:"));
    final JTextField middleNameField = new JTextField();
    infoPanel.add(middleNameField);

    infoPanel.add(new JLabel("Last name:"));
    final JTextField lastNameField = new JTextField();
    infoPanel.add(lastNameField);

    infoPanel.add(new JLabel("Date of Birth:"));
    final JTextField dobField = new JTextField();
    infoPanel.add(dobField);

    infoPanel.add(new JLabel("Date of Death:"));
    final JTextField dodField = new JTextField();
    infoPanel.add(dodField);

    infoPanel.add(new JLabel("Father:"));
    JPanel fatherPanel = new JPanel();
    fatherPanel.setLayout(new FlowLayout());
    final JTextField fatherText = new JTextField("Click to choose");
    fatherText.setEditable(false);
    fatherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked father");
          }
        });
    fatherPanel.add(fatherText);
    infoPanel.add(fatherPanel);

    infoPanel.add(new JLabel("Mother:"));
    JPanel motherPanel = new JPanel();
    motherPanel.setLayout(new FlowLayout());
    final JTextField motherText = new JTextField("Click to choose");
    motherText.setEditable(false);
    motherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked mother");
          }
        });
    motherPanel.add(motherText);
    infoPanel.add(motherPanel);

    pane.add(infoPanel, BorderLayout.NORTH);

    // "Add" and "Cancel" buttons
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());

    JButton addButton = new JButton("Add");
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Create a new person based on the information entered in
            // this dialog
            int id = 0;
            try {
              id = Integer.parseInt(idField.getText());

            } catch (NumberFormatException ex) {
              error("Invalid id: " + idField.getText());
              return;
            }

            String text = null;

            text = dobField.getText();
            Date dob = null;
            if (text != null && !text.equals("")) {
              dob = parseDate(dobField.getText());
              if (dob == null) {
                // Parse error
                return;
              }
            }

            text = dodField.getText();
            Date dod = null;
            if (text != null && !text.equals("")) {
              dod = parseDate(dodField.getText());
              if (dod == null) {
                // Parse error
                return;
              }
            }

            Person.Gender gender;
            if (group.getSelection().equals(male)) {
              gender = Person.MALE;

            } else {
              gender = Person.FEMALE;
            }

            // Okay, everything parsed alright
            newPerson = new Person(id, gender);
            newPerson.setFirstName(firstNameField.getText());
            newPerson.setMiddleName(middleNameField.getText());
            newPerson.setLastName(lastNameField.getText());
            newPerson.setDateOfBirth(dob);
            newPerson.setDateOfDeath(dod);

            if (mother != null) {
              newPerson.setMother(mother);
            }

            if (father != null) {
              newPerson.setFather(father);
            }

            // We're all happy
            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(addButton);

    buttonPanel.add(Box.createHorizontalGlue());

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Read my lips, no new Person!

            AddPersonDialog.this.newPerson = null;

            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(cancelButton);

    buttonPanel.add(Box.createHorizontalGlue());

    pane.add(buttonPanel, BorderLayout.SOUTH);
  }
Example #7
0
  static void buildGUI() {
    // Need this size to balance axes.
    frame.setSize(520, 690);
    frame.setTitle("DrawTool");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    Container cPane = frame.getContentPane();

    // Status label on top. Unused for now.
    statusLabel.setOpaque(true);
    statusLabel.setBackground(Color.white);
    cPane.add(statusLabel, BorderLayout.NORTH);

    // Build the input/output elements at the bottom.
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.black));
    panel.setBackground(inputPanelColor);
    panel.setLayout(new GridLayout(2, 1));
    panel.add(outputLabel);
    JPanel bottomPanel = new JPanel();
    bottomPanel.setBackground(inputPanelColor);
    bottomPanel.add(inputField);
    bottomPanel.add(new JLabel("   "));
    JButton enterButton = new JButton("Enter");
    enterButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            hasEntered = true;
          }
        });
    bottomPanel.add(enterButton);
    panel.add(bottomPanel);
    if (!sequencingOn) {
      cPane.add(panel, BorderLayout.SOUTH);
    }

    // Drawing in the center.
    drawArea = new DrawTool();
    if (sequencingOn) {
      frame.addKeyListener(
          new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
              handleKeyTyped(e);
            }
          });
    }
    cPane.add(drawArea, BorderLayout.CENTER);

    drawArea.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            handleMouseClick(e);
          }

          public void mouseReleased(MouseEvent e) {
            handleMouseReleased(e);
          }
        });

    drawArea.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            handleMouseDragged(e);
          }
        });
  }
Example #8
0
  ShutdownFrame(CryoBay cb) {
    super("CryoBay Monitor");
    cryoB = cb;

    cmdClose =
        new JButton("Close") {
          public JToolTip createToolTip() {
            return new JToolTip();
          }
        };

    cmdClose.setToolTipText("Close program");

    cmdClose.addActionListener(this);
    addWindowListener(this);

    GridBagConstraints gbc = new GridBagConstraints();
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();

    lblBStatus = new JLabel("Status: ");
    lblBHeater = new JLabel("Heater: ");
    lblBTemp = new JLabel("  Temp: ");
    lblBCli = new JLabel("   CLI: ");

    lblStatus = new JTextField(17);
    lblStatus.setEditable(false);
    lblStatus.setOpaque(true);
    lblStatus.setBorder(loweredbevel);

    lblHeater = new JTextField(17);
    lblHeater.setEditable(false);
    lblHeater.setOpaque(true);
    lblHeater.setBorder(loweredbevel);

    lblTemp = new JTextField(17);
    lblTemp.setEditable(false);
    lblTemp.setOpaque(true);
    lblTemp.setBorder(loweredbevel);

    lblCli = new JTextField(17);
    lblCli.setEditable(false);
    lblCli.setOpaque(true);
    lblCli.setBorder(loweredbevel);

    JPanel lblPanel = new JPanel();
    lblPanel.setLayout(new GridBagLayout());
    gbc.insets = new Insets(2, 5, 2, 5);
    setGbc(gbc, 0, 0, 1, 1);
    lblPanel.add(lblBStatus, gbc);
    setGbc(gbc, 0, 1, 1, 1);
    lblPanel.add(lblBHeater, gbc);
    setGbc(gbc, 0, 2, 1, 1);
    lblPanel.add(lblBTemp, gbc);
    setGbc(gbc, 0, 3, 1, 1);
    lblPanel.add(lblBCli, gbc);

    JPanel valPanel = new JPanel();
    valPanel.setLayout(new GridBagLayout());
    gbc.insets = new Insets(2, 5, 2, 5);
    setGbc(gbc, 0, 0, 1, 1);
    valPanel.add(lblStatus, gbc);
    setGbc(gbc, 0, 1, 1, 1);
    valPanel.add(lblHeater, gbc);
    setGbc(gbc, 0, 2, 1, 1);
    valPanel.add(lblTemp, gbc);
    setGbc(gbc, 0, 3, 1, 1);
    valPanel.add(lblCli, gbc);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    gbc.anchor = GridBagConstraints.CENTER;
    setGbc(gbc, 0, 5, 1, 1);
    buttonPanel.add(cmdClose, gbc);

    // finally, add the panels to the content pane
    getContentPane().setLayout(new GridBagLayout());
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.anchor = GridBagConstraints.CENTER;
    setGbc(gbc, 0, 0, 1, 4);
    getContentPane().add(lblPanel, gbc);
    setGbc(gbc, 1, 0, 1, 4);
    getContentPane().add(valPanel, gbc);
    setGbc(gbc, 0, 5, 0, 0);
    getContentPane().add(buttonPanel, gbc);

    setSize(300, 220);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(screenSize.width / 2 - 300, screenSize.height / 2 - 220);
    setResizable(true);
  }
Example #9
0
  ///////////////////////////////////
  // member functions
  //////////////////////////////////
  protected final void initForm() {
    thisPanel = new JPanel();
    thisPanel.setName("Import Range Data");
    thisPanel.setLayout(new java.awt.BorderLayout());

    _thePanel.add(thisPanel);

    _theWarning = new JTextArea();
    _theWarning.setEditable(false);
    String theMessage = "Warning, data imported through this panel has";
    theMessage += " speed and course calculated as over the ground.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "Debrief recognises PC Argos (RAO) and PMRF (PRN) files.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "See Debrief Help File for file format and details.";

    _theWarning.setText(theMessage);
    _theWarning.setLineWrap(true);
    _theWarning.setBorder(BorderFactory.createLoweredBevelBorder());
    _theWarning.setWrapStyleWord(true);
    thisPanel.add("North", _theWarning);
    ////////////////////////////////////////////
    // auto generated stuff
    ////////////////////////////////////////////

    ButtonPanel = new javax.swing.JPanel();
    importBtn = new javax.swing.JButton();
    closeBtn = new javax.swing.JButton();
    PropertiesList = new javax.swing.JPanel();
    FilenamePanel = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    FilenameLabel = new javax.swing.JLabel();
    selectFileBtn = new javax.swing.JButton();
    FrequencyPanel = new javax.swing.JPanel();
    FrequencyLabel = new javax.swing.JLabel();
    FrequencyCombo = new TimeFrequencyCombo();
    OriginPanel = new javax.swing.JPanel();
    jLabel7 = new javax.swing.JLabel();
    OriginLabel = new javax.swing.JLabel();
    selectOriginBtn = new javax.swing.JButton();
    DTGPanel = new javax.swing.JPanel();
    jLabel9 = new javax.swing.JLabel();
    _theDate = new javax.swing.JTextField("2001/01/30");

    /////////////////////////////////////////////////
    // button panel first
    //////////////////////////////////////////////////

    importBtn.setText("Import");
    ButtonPanel.add(importBtn);
    closeBtn.setText("Close");
    ButtonPanel.add(closeBtn);
    thisPanel.add(ButtonPanel, java.awt.BorderLayout.SOUTH);
    closeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doClose();
          }
        });
    importBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doImport();
          }
        });

    ///////////////////////////////////////////////////
    // now the properties panel
    ///////////////////////////////////////////////////

    PropertiesList.setLayout(new java.awt.GridLayout(0, 1));

    jLabel3.setText("Filename:");
    FilenamePanel.add(jLabel3);
    FilenameLabel.setText("    blank    ");
    FilenamePanel.add(FilenameLabel);
    selectFileBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectFileBtn.setToolTipText("Select file");
    selectFileBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectFileBtn.setText("...");
    selectFileBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doEditFilename();
          }
        });
    FilenamePanel.add(selectFileBtn);
    PropertiesList.add(FilenamePanel);

    FrequencyLabel.setText("Frequency:");
    FrequencyPanel.add(FrequencyLabel);
    FrequencyCombo.setPreferredSize(new java.awt.Dimension(100, 25));
    FrequencyPanel.add(FrequencyCombo);
    PropertiesList.add(FrequencyPanel);

    jLabel7.setText("Origin:");
    OriginPanel.add(jLabel7);
    OriginLabel.setText("    blank    ");
    OriginPanel.add(OriginLabel);
    selectOriginBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectOriginBtn.setToolTipText("Select file");
    selectOriginBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectOriginBtn.setText("...");
    selectOriginBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            editOrigin();
          }
        });
    OriginPanel.add(selectOriginBtn);
    PropertiesList.add(OriginPanel);

    //////////////////////////////////////////////////////
    // DTG
    /////////////////////////////////////////////////////

    jLabel9.setText("DTG (yyyy/mm/dd):");
    _theDate.setText("2001/01/30");
    _theDate.addFocusListener(
        new FocusAdapter() {
          public void focusLost(final FocusEvent e) {
            checkDTG();
          }
        });
    DTGPanel.add(jLabel9);
    DTGPanel.add(_theDate);
    PropertiesList.add(DTGPanel);

    final JPanel jp = new JPanel();
    jp.setLayout(new FlowLayout());
    jp.add(PropertiesList);

    thisPanel.add(jp, java.awt.BorderLayout.CENTER);
  }