Esempio n. 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();
 }
Esempio n. 2
0
  /** Créer les composants */
  private void initComponents() {

    text = new JTextArea();
    button_licence = new JButton();
    button_close = new JButton();
    logo = new LogoComponent();

    // Ajout des actions listeners
    button_licence.addActionListener(new ButtonLicenceActionListener());
    button_close.addActionListener(new ButtonCloseActionListener(this));

    logo.setPreferredSize(new Dimension(128, 128));

    text.setText(
        "Version : 1.0b \n"
            + "\n"
            + "Copyright © 2008-2012 Sipieter Clément \n"
            + "Copyright © 2011-2012 Sellem Lev-Arcady");
    text.setBackground(this.getBackground());

    button_licence.setText("Licence");
    button_close.setText("Fermer");

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    this.add(logo, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 3;
    gbc.insets = new Insets(20, 20, 20, 20);
    this.add(text, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 5, 20, 5);

    this.add(button_licence, gbc);

    gbc.gridx = 2;
    gbc.gridy = 2;
    this.add(button_close, gbc);
    this.pack();
  }
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      JLabel label = null;

      // i18n
      // label = new JLabel( "File names can be constructed from a template. The LABEL field is " );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_"));
      label.setForeground(Color.black);
      // m_gbc.weightx = 0.5;
      showInstruction(m_gbl, m_gbc, 0, 0, 7, label);

      // i18n
      // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up."));
      showInstruction(m_gbl, m_gbc, 0, 1, 7, label);
      showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel(""));

      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 0; // reset to default
      m_gbc.gridwidth = 5;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE")));

      m_nRow = 3;
      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Esempio n. 4
0
 private void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h) {
   gbc.gridx = x;
   gbc.gridy = y;
   gbc.gridwidth = w;
   gbc.gridheight = h;
   getContentPane().add(c, gbc);
 }
Esempio n. 5
0
  protected void addComp(JPanel panel, Component comp, GridBagConstraints gbc, int x, int y) {
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    panel.add(comp, gbc);
  }
  /** Get the panel for a given form. * */
  public JPanel getPanelFor(ArrayList elements) {
    JPanel p = new JPanel(new GridBagLayout());
    int maxCols = 1;
    int elementSize = elements.size();
    for (int i = 0; i < elementSize; i++) { // count max number of cols
      // ((XmlUIElement)elements.get(i)).setEditable(true);//by jai
      int cols = ((XmlUIElement) elements.get(i)).getNumberOfColumns();
      if (cols > maxCols) {
        maxCols = cols;
      }
    }
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    if (elementSize < 5) c.insets = new Insets(8, 8, 8, 14);
    else if (elementSize < 20) c.insets = new Insets(4, 4, 4, 10);
    else if ((elementSize > 40 && maxCols == 2) || (elementSize > 80 && maxCols == 4))
      c.insets = new Insets(1, 1, 1, 8);
    else c.insets = new Insets(2, 2, 2, 8);

    int rowsAdded = 0;
    for (int i = 0; i < elementSize; i++) {
      elementsAndPanels.put(elements.get(i), p);
      rowsAdded += ((XmlUIElement) elements.get(i)).addComponents(p, c, 0, rowsAdded, maxCols);
    }
    return p;
  }
    public DisplayResults() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      text.setForeground(Color.black);
      add(text, gbc);
      gbc.gridy = 0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(emptyLabel, gbc);
      add(Box.createVerticalStrut(0), gbc);
      add(emptyLabel, gbc);

      /*	 gbc.gridy = 1;
      VTextMsg result = new VTextMsg(sshare, vnmrif, null);
      result.setPreferredSize(new Dimension(300, 30));
      result.setForeground(Color.black);
      add( result, gbc );
      */
      setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder("  Results  "),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
 private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) {
   JLabel spaces = new JLabel("     ");
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(spaces, gbc);
   m_pnlDisplay.add(spaces);
 }
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      // gbc.weightx = 0.5;

      showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1);
      showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2);
      showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3);
      /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 );
      showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/
      showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel(""));

      // i18n
      // label = new JLabel( "LABEL" );
      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 5;
      // gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 5;
      m_gbc.ipadx = 0;
      m_gbc.gridwidth = 5;
      m_gbc.weightx = 0;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      // i18n
      // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" ));
      showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY")));

      m_nRow = 5;

      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder( "  Parent Directories  "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
  private void addField(OptionField field) {
    // Add label
    JLabel l = new JLabel(field.getDisplayName() + ":");
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow;
    c.insets = new Insets(5, 2, 2, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    content.add(l, c);

    // Add enable checkbox
    if (field.getEnableToggle() != null) {
      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = currentRow;
      c.fill = GridBagConstraints.BOTH;
      c.insets = new Insets(2, 2, 2, 2);
      c.anchor = GridBagConstraints.NORTHWEST;
      content.add(field.getEnableToggle(), c);
    }

    // Add field
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = currentRow;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(2, 2, 2, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    content.add(field.getComponent(), c);

    // Add change listener
    field.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            fireChangeEvent();
          }
        });

    // Update state
    currentRow++;
    pack();
  }
    GitCheckinOptions(@NotNull final Project project, @NotNull CheckinProjectPanel panel) {
      super(project, panel);
      myVcs = GitVcs.getInstance(project);
      final Insets insets = new Insets(2, 2, 2, 2);
      // add authors drop down
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.anchor = GridBagConstraints.WEST;
      c.insets = insets;
      final JLabel authorLabel = new JLabel(GitBundle.message("commit.author"));
      myPanel.add(authorLabel, c);

      c = new GridBagConstraints();
      c.anchor = GridBagConstraints.CENTER;
      c.insets = insets;
      c.gridx = 1;
      c.gridy = 0;
      c.weightx = 1;
      c.fill = GridBagConstraints.HORIZONTAL;
      final List<String> usersList = getUsersList(project);
      final Set<String> authors =
          usersList == null ? new HashSet<String>() : new HashSet<String>(usersList);
      ContainerUtil.addAll(authors, mySettings.getCommitAuthors());
      List<String> list = new ArrayList<String>(authors);
      Collections.sort(list);
      list =
          ObjectsConvertor.convert(
              list,
              new Convertor<String, String>() {
                @Override
                public String convert(String o) {
                  return StringUtil.shortenTextWithEllipsis(o, 30, 0);
                }
              });
      myAuthor = new ComboBox(ArrayUtil.toObjectArray(list));
      myAuthor.insertItemAt("", 0);
      myAuthor.setSelectedItem("");
      myAuthor.setEditable(true);
      authorLabel.setLabelFor(myAuthor);
      myAuthor.setToolTipText(GitBundle.getString("commit.author.tooltip"));
      myPanel.add(myAuthor, c);
    }
 // For setting the gridbagconstraints for this application
 public static void setConstraints(GridBagConstraints c, int fill, int col, int row) {
   c.fill = fill;
   c.weightx = 1.0;
   c.weighty = 1.0;
   c.gridx = col;
   c.gridy = row;
   c.gridwidth = 1;
   c.gridheight = 1;
   Insets insets = new Insets(5, 5, 5, 5);
   c.insets = insets;
 }
Esempio n. 13
0
 private void showComp(
     GridBagLayout gbl,
     GridBagConstraints gbc,
     int gridx,
     int gridy,
     int gridwidth,
     JComponent comp) {
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(comp, gbc);
   m_pnlDisplay.add(comp);
 }
  private void addSeparator(String label) {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c;

    if (label != null) {
      // left border
      c = new GridBagConstraints();
      c.gridy = 0;
      c.ipadx = 15; // half the desired width
      p.add(new JSeparator(), c);

      // label
      c = new GridBagConstraints();
      c.gridy = 0;
      c.insets = new Insets(0, 4, 0, 4);
      p.add(new JLabel(label), c);
    }

    // right border
    c = new GridBagConstraints();
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    p.add(new JSeparator(), c);

    // add to window
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow++;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    if (label == null) {
      // simple separator between predicate name and options; don't use
      // pronounced section break
      c.insets = new Insets(3, 0, 3, 0);
    } else {
      c.insets = new Insets(10, 0, 0, 0);
    }
    content.add(p, c);
  }
Esempio n. 15
0
  private void drawComponents() {
    GridBagConstraints con = new GridBagConstraints();
    con.gridx = 0;
    con.gridy = 0;
    con.gridwidth = 1;
    con.gridheight = 1;
    con.anchor = GridBagConstraints.NORTH;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.insets = new Insets(5, 5, 5, 5);
    con.weightx = 0;
    con.weighty = 0;

    Box btns = Box.createHorizontalBox();
    btns.add(btnDetails);
    btns.add(Box.createHorizontalGlue());
    btns.add(btnClose);

    // Set up content
    Container content = getContentPane();
    content.setLayout(new GridBagLayout());

    // Add message label
    con.weightx = 1;
    con.weighty = 1;
    content.add(lblMessage, con);

    // Add button box
    con.gridy = 1;
    con.weighty = 0;
    content.add(btns, con);

    // Add trace pane
    con.gridy = 2;

    content.add(srlTrace, con);

    // Set default button
    getRootPane().setDefaultButton(btnClose);
  }
Esempio n. 16
0
 private void addGrid(
     JPanel p, Component co, int x, int y, int w, int fill, double wx, int anchor) {
   GridBagConstraints c = new GridBagConstraints();
   c.gridx = x;
   c.gridy = y;
   c.gridwidth = w;
   c.anchor = anchor;
   c.weightx = wx;
   c.fill = fill;
   if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty = 1.0;
   c.insets = new Insets(y == 0 ? 10 : 0, GAP, GAP, GAP);
   p.add(co, c);
 }
Esempio n. 17
0
 /**
  * This method adds the panels to the window and organises them using a GridBagLayout and a
  * JLayeredPane.
  */
 private void populateFrame(Container frame) {
   frame.setLayout(new GridBagLayout());
   GridBagConstraints layoutConstraints = new GridBagConstraints();
   JLayeredPane dungeonArea = new JLayeredPane();
   dungeonArea.setPreferredSize(new Dimension(448, 448));
   dungeonArea.add(dungeonPanel, JLayeredPane.DEFAULT_LAYER);
   // the DungeonPanel is added underneath
   dungeonArea.add(dungeonPanelOverlay, JLayeredPane.PALETTE_LAYER);
   // the mostly transparent DungeonPanelOverlay is added on top in the same position
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 0;
   layoutConstraints.gridwidth = 7;
   layoutConstraints.gridheight = 7;
   frame.add(dungeonArea, layoutConstraints);
   layoutConstraints.gridx = 7;
   layoutConstraints.gridwidth = 1;
   frame.add(serverSettings, layoutConstraints);
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 7;
   layoutConstraints.gridwidth = 8;
   layoutConstraints.gridheight = 1;
   frame.add(chatPanel, layoutConstraints);
 }
Esempio n. 18
0
 private void showInstruction(
     GridBagLayout gbl,
     GridBagConstraints gbc,
     int gridx,
     int gridy,
     int gridwidth,
     JLabel instruction) {
   gbc.gridwidth = gridwidth;
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(instruction, gbc);
   instruction.setForeground(Color.black);
   m_pnlDisplay.add(instruction);
 }
Esempio n. 19
0
 private JComponent createButtons() {
   JPanel pane = new JPanel(new GridBagLayout());
   JButton btnOK = new JButton(_I("ok"));
   btnOK.addActionListener(new ActionOK(this));
   JButton btnApply = new JButton(_I("apply"));
   btnApply.addActionListener(new ActionApply(this));
   JButton btnCancel = new JButton(_I("cancel"));
   btnCancel.addActionListener(new ActionCancel(this));
   GridBagConstraints c = new GridBagConstraints();
   c.gridy = 3;
   c.gridx = 0;
   c.insets = new Insets(5, 0, 10, 0);
   c.anchor = GridBagConstraints.LAST_LINE_END;
   pane.add(btnOK, c);
   c.gridx = 1;
   pane.add(btnApply, c);
   c.gridx = 2;
   pane.add(btnCancel, c);
   return pane;
 }
 // For setting the gridbagconstraints for this application
 public static void setConstraints(
     GridBagConstraints c,
     int fill,
     double wx,
     double wy,
     int gx,
     int gy,
     int gw,
     int gh,
     int ins) {
   c.fill = fill;
   c.weightx = (float) wx;
   c.weighty = (float) wy;
   c.gridx = gx;
   c.gridy = gy;
   c.gridwidth = gw;
   c.gridheight = gh;
   Insets insets = new Insets(ins, ins, ins, ins);
   c.insets = insets;
 }
  private void išdėstymas() {
    setLocation(500, 20);
    // sudedame duomenis į paneles
    panAutoSąr.add(scrNeregZona);
    panAutoSąr.add(scrRegZona);
    panDuomenys.add(panRegNumeris);
    panDuomenys.add(panRez);
    panDuomenys.add(panMygt);

    GridBagLayout dėstymoBūdas = new GridBagLayout();
    GridBagConstraints dėsnis = new GridBagConstraints();
    panRegNumeris.setLayout(dėstymoBūdas);
    panRez.setLayout(dėstymoBūdas);

    dėsnis.fill = GridBagConstraints.NONE;
    dėsnis.insets = new Insets(5, 8, 0, 6);

    dėsnis.anchor = GridBagConstraints.LINE_END;
    dėsnis.gridy = GridBagConstraints.RELATIVE;
    dėsnis.gridx = 0;
    panRegNumeris.add(new JLabel("Auto Numeris"), dėsnis);
    panRez.add(new JLabel("Neregistruotų kiekis"), dėsnis);
    panRez.add(new JLabel("Registruotų kiekis"), dėsnis);

    dėsnis.anchor = GridBagConstraints.LINE_START;
    dėsnis.gridx = 1;

    panRegNumeris.add(tfAutoNr, dėsnis);

    panRez.add(tfNeregKiekis, dėsnis);
    panRez.add(tfRegKiekis, dėsnis);

    panMygt.setLayout(new BoxLayout(panMygt, BoxLayout.Y_AXIS));
    panMygt.add(jbReg);
    panMygt.add(jbRasti);
    panMygt.add(jbSkaityti);
    panMygt.add(jbSaveObj);
    panMygt.add(jbLoadObj);
  }
Esempio n. 22
0
  /**
   * Standard constructor: it needs the parent frame.
   *
   * @param parent the dialog's parent
   */
  public DialogPrint(JFrame parent) {
    super(400, 350, parent, Globals.messages.getString("Print_dlg"), true);
    addComponentListener(this);
    export = false;

    // Ensure that under MacOSX >= 10.5 Leopard, this dialog will appear
    // as a document modal sheet

    getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE);

    GridBagLayout bgl = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    Container contentPane = getContentPane();
    contentPane.setLayout(bgl);

    constraints.insets.right = 30;

    JLabel empty = new JLabel("  ");
    constraints.weightx = 100;
    constraints.weighty = 100;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    contentPane.add(empty, constraints); // Add "   " label

    JLabel empty1 = new JLabel("  ");
    constraints.weightx = 100;
    constraints.weighty = 100;
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    contentPane.add(empty1, constraints); // Add "   " label

    mirror_CB = new JCheckBox(Globals.messages.getString("Mirror"));
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(mirror_CB, constraints); // Add Print Mirror cb

    fit_CB = new JCheckBox(Globals.messages.getString("FitPage"));
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(fit_CB, constraints); // Add Fit to page cb

    bw_CB = new JCheckBox(Globals.messages.getString("B_W"));
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(bw_CB, constraints); // Add BlackWhite cb

    landscape_CB = new JCheckBox(Globals.messages.getString("Landscape"));
    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(landscape_CB, constraints); // Add landscape cb

    // Put the OK and Cancel buttons and make them active.
    JButton ok = new JButton(Globals.messages.getString("Ok_btn"));
    JButton cancel = new JButton(Globals.messages.getString("Cancel_btn"));

    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 4;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.EAST;

    // Put the OK and Cancel buttons and make them active.
    Box b = Box.createHorizontalBox();
    b.add(Box.createHorizontalGlue());
    ok.setPreferredSize(cancel.getPreferredSize());

    if (Globals.okCancelWinOrder) {
      b.add(ok);
      b.add(Box.createHorizontalStrut(12));
      b.add(cancel);

    } else {
      b.add(cancel);
      b.add(Box.createHorizontalStrut(12));
      b.add(ok);
    }

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            export = true;
            setVisible(false);
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
    // Here is an action in which the dialog is closed

    AbstractAction cancelAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        };
    contentPane.add(b, constraints); // Add OK/cancel dialog

    DialogUtil.addCancelEscape(this, cancelAction);
    pack();
    DialogUtil.center(this);
    getRootPane().setDefaultButton(ok);
  }
Esempio n. 23
0
  /** Creating the configuration form */
  private void init() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    enableCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE"));
    enableCheckBox.addActionListener(this);

    sipProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME"));
    sipProtocolCheckBox.addActionListener(this);

    jabberProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME"));
    jabberProtocolCheckBox.addActionListener(this);

    String rtpDescription =
        resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION");
    rtpProtocolCheckBox =
        new SIPCommCheckBox(
            resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP")
                + " "
                + rtpDescription);
    rtpProtocolCheckBox.addActionListener(this);
    rtpProtocolCheckBox.setToolTipText(rtpDescription);

    ice4jProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J"));
    ice4jProtocolCheckBox.addActionListener(this);

    JPanel mainPanel = new TransparentPanel();

    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    mainPanel.add(enableCheckBox, c);

    String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION");
    JLabel descriptionLabel = new JLabel(label);
    descriptionLabel.setToolTipText(label);
    enableCheckBox.setToolTipText(label);
    descriptionLabel.setForeground(Color.GRAY);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8));
    c.gridy = 1;
    c.insets = new Insets(0, 25, 10, 0);
    mainPanel.add(descriptionLabel, c);

    final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1));

    loggersButtonPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL")));

    loggersButtonPanel.add(sipProtocolCheckBox);
    loggersButtonPanel.add(jabberProtocolCheckBox);
    loggersButtonPanel.add(rtpProtocolCheckBox);
    loggersButtonPanel.add(ice4jProtocolCheckBox);

    c.insets = new Insets(0, 20, 10, 0);
    c.gridy = 2;
    mainPanel.add(loggersButtonPanel, c);

    final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2));

    advancedPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED")));

    fileCountField.getDocument().addDocumentListener(this);
    fileSizeField.getDocument().addDocumentListener(this);

    fileCountLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT"));
    advancedPanel.add(fileCountLabel);
    advancedPanel.add(fileCountField);
    fileSizeLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE"));
    advancedPanel.add(fileSizeLabel);
    advancedPanel.add(fileSizeField);

    c.gridy = 3;
    mainPanel.add(advancedPanel, c);

    archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"));
    archiveButton.addActionListener(this);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    mainPanel.add(archiveButton, c);

    if (!StringUtils.isNullOrEmpty(getUploadLocation())) {
      uploadLogsButton =
          new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));
      uploadLogsButton.addActionListener(this);

      c.insets = new Insets(10, 0, 0, 0);
      c.gridy = 5;
      mainPanel.add(uploadLogsButton, c);
    }
  }
Esempio n. 24
0
 /**
  * The only constructor of the review dialog, which initialises the dates, sets the outer layout,
  * runs the analyser, creates rows for the results, and displays the window.
  *
  * @param main A link to the parent component.
  * @param config A link to the configuration object.
  */
 ReviewDialog(Main main, Config config) {
   super(main, "Review & Save");
   this.main = main;
   this.config = config;
   // layout date components
   GridBagLayout gbl = new GridBagLayout();
   setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.BOTH;
   gbc.insets = new Insets(0, 0, 5, 0);
   gbc.ipadx = 10;
   gbc.gridx = 0;
   gbc.gridy = 0;
   gbl.setConstraints(yearLabel, gbc);
   gbc.gridx = 1;
   gbl.setConstraints(yearCB, gbc);
   gbc.gridx = 0;
   gbc.gridy = 1;
   gbl.setConstraints(weekLabel, gbc);
   gbc.gridx = 1;
   gbl.setConstraints(weekCB, gbc);
   gbc.gridx = 0;
   gbc.gridy = 2;
   gbl.setConstraints(fromLabel, gbc);
   gbc.weightx = 1;
   gbc.gridx = 1;
   gbl.setConstraints(fromDate, gbc);
   gbc.insets = new Insets(0, 0, 0, 0);
   gbc.weightx = 0;
   gbc.gridx = 0;
   gbc.gridy = 3;
   gbl.setConstraints(toLabel, gbc);
   gbc.weightx = 1;
   gbc.gridx = 1;
   gbl.setConstraints(toDate, gbc);
   gbc.gridx = 0;
   gbc.gridy = 4;
   gbc.gridwidth = 2;
   gbc.insets = new Insets(10, 5, 10, 5);
   gbc.weighty = 1;
   JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel);
   gbl.setConstraints(scrollReviewPanel, gbc);
   gbc.insets = new Insets(0, 0, 0, 0);
   gbc.gridy = 5;
   gbc.weighty = 0;
   gbl.setConstraints(saveToFileButton, gbc);
   gbc.gridy = 6;
   gbl.setConstraints(copyToClipboardButton, gbc);
   add(yearLabel);
   add(yearCB);
   add(weekLabel);
   add(weekCB);
   add(fromLabel);
   add(fromDate);
   add(toLabel);
   add(toDate);
   add(scrollReviewPanel);
   add(saveToFileButton);
   add(copyToClipboardButton);
   // layout results
   updateYearWeekDates();
   setVisible(true);
   setLocation(main.getLocation());
 }
Esempio n. 25
0
  public SaveDialog(Frame parent) {
    super(parent, true);
    this.setLayout(new BorderLayout());
    // gather unsaved tab
    Set<Tab> unsaved = new LinkedHashSet<>();
    for (Tab tab : MainPanel.getAllTab()) {
      if (!tab.isSaved()) {
        unsaved.add(tab);
      }
    }
    if (unsaved.isEmpty()) {
      // close directly
      this.setTitle("Confirm close");
      // upper labels
      JPanel labels = new JPanel(new FlowLayout(FlowLayout.LEFT, 11, 7));
      labels.add(iconLabel);
      labels.add(new MyLabel(" Do you really want to close RefluxEdit?"));
      // buttons
      JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7));
      buttons.add(
          new MyButton("YES") {
            {
              SaveDialog.this.getRootPane().setDefaultButton(this);
              this.setFocusPainted(true);
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              close = true;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.add(
          new MyButton("NO") {
            {
              this.setFocusPainted(true);
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              close = false;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.setBorder(new EmptyBorder(0, 0, 5, 0));
      //
      this.add(labels, BorderLayout.CENTER);
      this.add(buttons, BorderLayout.PAGE_END);
    } else {
      // ask save changes
      this.setTitle("Unsaved changes");
      // upper components: icon and list
      JPanel upper = new JPanel(new GridBagLayout());
      JPanel listPane = new JPanel(new BorderLayout());
      final DefaultListModel<Tab> listModel = new DefaultListModel<>();
      final JList<Tab> tabList = new JList<>(listModel);
      tabList.setFont(f13);
      tabList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
      tabList.setCellRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              JLabel label =
                  (JLabel)
                      (super.getListCellRendererComponent(
                          list, value, index, isSelected, cellHasFocus));
              if (value instanceof Tab) {
                String text = ((Tab) value).getTabLabel().getText();
                label.setText(text.substring(1)); // remove "*"
              }
              return label;
            }
          });
      for (Tab tab : unsaved) {
        listModel.addElement(tab);
      }
      tabList.getSelectionModel().setSelectionInterval(0, listModel.size() - 1);
      JScrollPane scrollPane = new JScrollPane(tabList);
      scrollPane.setPreferredSize(new Dimension(350, 170));
      listPane.add(new MyLabel("The following tabs are unsaved:"), BorderLayout.PAGE_START);
      listPane.add(scrollPane, BorderLayout.CENTER);
      // setup upper
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 0;
      c.weighty = 1;
      c.insets = new Insets(5, 5, 5, 5);
      c.anchor = GridBagConstraints.FIRST_LINE_START;
      upper.add(iconLabel, c);
      //
      c.gridx = 1;
      c.weightx = 1;
      c.fill = GridBagConstraints.BOTH;
      upper.add(listPane, c);
      // lower components: buttons
      JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7));
      buttons.add(
          new MyButton("Save") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Save selected tab(s)");
              SaveDialog.this.getRootPane().setDefaultButton(this);
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              for (Tab tab : tabList.getSelectedValuesList()) {
                if (tab.getFile() != null) {
                  try {
                    tab.save();
                    MainPanel.close(tab);
                    listModel.removeElement(tab);
                  } catch (Exception ex) {
                    exception(ex);
                    break;
                  }
                } else {
                  File file =
                      FileChooser.showPreferredFileDialog(
                          RefluxEdit.getInstance(), FileChooser.SAVE, new String[0]);
                  if (file != null) {
                    try {
                      tab.save(file, false);
                      MainPanel.close(tab);
                      listModel.removeElement(tab);
                    } catch (Exception ex) {
                      exception(ex);
                      break;
                    }
                  }
                }
              }
              if (listModel.size() == 0) {
                RefluxEdit.getInstance().close();
              }
            }
          });
      buttons.add(
          new MyButton("Discard") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Discard selected tab(s)");
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              for (Tab tab : tabList.getSelectedValuesList()) {
                MainPanel.close(tab);
                listModel.removeElement(tab);
              }
              if (listModel.size() == 0) {
                RefluxEdit.getInstance().close();
              }
            }
          });
      buttons.add(
          new MyButton("Close") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Close RefluxEdit");
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              SaveDialog.this.close = true;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.add(
          new MyButton("Cancel") {
            {
              this.setFocusPainted(true);
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              SaveDialog.this.close = false;
              SaveDialog.this.setVisible(false);
            }
          });
      this.add(upper, BorderLayout.CENTER);
      this.add(buttons, BorderLayout.PAGE_END);
    }
  }
Esempio n. 26
0
  /**
   * Creates the video advanced settings.
   *
   * @return video advanced settings panel.
   */
  private static Component createVideoAdvancedSettings() {
    ResourceManagementService resources = NeomediaActivator.getResources();

    final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration();

    TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout());
    centerPanel.setMaximumSize(new Dimension(WIDTH, 150));

    JButton resetDefaultsButton =
        new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET"));
    JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
    resetButtonPanel.add(resetDefaultsButton);

    final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout());
    centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH);
    centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH);

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.insets = new Insets(5, 5, 0, 0);
    constraints.gridx = 0;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.gridy = 0;

    centerPanel.add(
        new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints);
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 0, 0, 0);
    final JCheckBox frameRateCheck =
        new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE"));
    centerPanel.add(frameRateCheck, constraints);
    constraints.gridy = 2;
    constraints.insets = new Insets(5, 5, 0, 0);
    centerPanel.add(
        new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")),
        constraints);

    constraints.weightx = 1;
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.insets = new Insets(5, 0, 0, 5);
    Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1];
    System.arraycopy(
        DeviceConfiguration.SUPPORTED_RESOLUTIONS,
        0,
        resolutionValues,
        1,
        DeviceConfiguration.SUPPORTED_RESOLUTIONS.length);
    final JComboBox sizeCombo = new JComboBox(resolutionValues);
    sizeCombo.setRenderer(new ResolutionCellRenderer());
    sizeCombo.setEditable(false);
    centerPanel.add(sizeCombo, constraints);

    // default value is 20
    final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1));
    frameRate.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            deviceConfig.setFrameRate(
                ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue());
          }
        });
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 0, 0, 5);
    centerPanel.add(frameRate, constraints);

    frameRateCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (frameRateCheck.isSelected()) {
              deviceConfig.setFrameRate(
                  ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue());
            } else // unlimited framerate
            deviceConfig.setFrameRate(-1);

            frameRate.setEnabled(frameRateCheck.isSelected());
          }
        });

    final JSpinner videoMaxBandwidth =
        new JSpinner(
            new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1));
    videoMaxBandwidth.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            deviceConfig.setVideoMaxBandwidth(
                ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue());
          }
        });
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.insets = new Insets(0, 0, 5, 5);
    centerPanel.add(videoMaxBandwidth, constraints);

    resetDefaultsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // reset to defaults
            sizeCombo.setSelectedIndex(0);
            frameRateCheck.setSelected(false);
            frameRate.setEnabled(false);
            frameRate.setValue(20);
            // unlimited framerate
            deviceConfig.setFrameRate(-1);
            videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH);
          }
        });

    // load selected value or auto
    Dimension videoSize = deviceConfig.getVideoSize();

    if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT)
        && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH))
      sizeCombo.setSelectedItem(deviceConfig.getVideoSize());
    else sizeCombo.setSelectedIndex(0);
    sizeCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem();

            if (selectedVideoSize == null) {
              // the auto value, default one
              selectedVideoSize =
                  new Dimension(
                      DeviceConfiguration.DEFAULT_VIDEO_WIDTH,
                      DeviceConfiguration.DEFAULT_VIDEO_HEIGHT);
            }
            deviceConfig.setVideoSize(selectedVideoSize);
          }
        });

    frameRateCheck.setSelected(
        deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE);
    frameRate.setEnabled(frameRateCheck.isSelected());

    if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate());

    return centerAdvancedPanel;
  }
Esempio n. 27
0
  /**
   * Creates the UI controls which are to control the details of a specific <tt>AudioSystem</tt>.
   *
   * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to control its details
   *     are to be created
   * @param container the <tt>JComponent</tt> into which the UI controls which are to control the
   *     details of the specified <tt>audioSystem</tt> are to be added
   */
  public static void createAudioSystemControls(AudioSystem audioSystem, JComponent container) {
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weighty = 0;

    int audioSystemFeatures = audioSystem.getFeatures();
    boolean featureNotifyAndPlaybackDevices =
        ((audioSystemFeatures & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES) != 0);

    constraints.gridx = 0;
    constraints.insets = new Insets(3, 0, 3, 3);
    constraints.weightx = 0;

    constraints.gridy = 0;
    container.add(
        new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), constraints);
    if (featureNotifyAndPlaybackDevices) {
      constraints.gridy = 2;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), constraints);
      constraints.gridy = 3;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), constraints);
    }

    constraints.gridx = 1;
    constraints.insets = new Insets(3, 3, 3, 0);
    constraints.weightx = 1;

    JComboBox captureCombo = null;

    if (featureNotifyAndPlaybackDevices) {
      captureCombo = new JComboBox();
      captureCombo.setEditable(false);
      captureCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_CAPTURE));
      constraints.gridy = 0;
      container.add(captureCombo, constraints);
    }

    int anchor = constraints.anchor;
    SoundLevelIndicator capturePreview =
        new SoundLevelIndicator(
            SimpleAudioLevelListener.MIN_LEVEL, SimpleAudioLevelListener.MAX_LEVEL);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridy = (captureCombo == null) ? 0 : 1;
    container.add(capturePreview, constraints);
    constraints.anchor = anchor;

    constraints.gridy = GridBagConstraints.RELATIVE;

    if (featureNotifyAndPlaybackDevices) {
      JComboBox playbackCombo = new JComboBox();

      playbackCombo.setEditable(false);
      playbackCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK));
      container.add(playbackCombo, constraints);

      JComboBox notifyCombo = new JComboBox();

      notifyCombo.setEditable(false);
      notifyCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_NOTIFY));
      container.add(notifyCombo, constraints);
    }

    if ((AudioSystem.FEATURE_ECHO_CANCELLATION & audioSystemFeatures) != 0) {
      final SIPCommCheckBox echoCancelCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.ECHOCANCEL"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      echoCancelCheckBox.setSelected(mediaService.getDeviceConfiguration().isEchoCancel());
      echoCancelCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setEchoCancel(echoCancelCheckBox.isSelected());
            }
          });
      container.add(echoCancelCheckBox, constraints);
    }

    if ((AudioSystem.FEATURE_DENOISE & audioSystemFeatures) != 0) {
      final SIPCommCheckBox denoiseCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.DENOISE"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      denoiseCheckBox.setSelected(mediaService.getDeviceConfiguration().isDenoise());
      denoiseCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setDenoise(denoiseCheckBox.isSelected());
            }
          });
      container.add(denoiseCheckBox, constraints);
    }

    createAudioPreview(audioSystem, captureCombo, capturePreview);
  }
Esempio n. 28
0
  /** Shows a dialog with input for logs description. */
  private void uploadLogs() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    final SIPCommDialog dialog =
        new SIPCommDialog(false) {
          /** Serial version UID. */
          private static final long serialVersionUID = 0L;

          /**
           * Dialog is closed. Do nothing.
           *
           * @param escaped <tt>true</tt> if this dialog has been closed by pressing
           */
          @Override
          protected void close(boolean escaped) {}
        };

    dialog.setModal(true);
    dialog.setTitle(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));

    Container container = dialog.getContentPane();
    container.setLayout(new GridBagLayout());

    JLabel descriptionLabel = new JLabel("Add a comment:");
    final JTextArea commentTextArea = new JTextArea();
    commentTextArea.setRows(4);
    final JButton uploadButton =
        new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_BUTTON"));
    final SIPCommTextField emailField =
        new SIPCommTextField(resources.getI18NString("plugin.loggingutils.ARCHIVE_UPREPORT_EMAIL"));
    final JCheckBox emailCheckBox =
        new SIPCommCheckBox("Email me when more information is available");
    emailCheckBox.setSelected(true);
    emailCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!emailCheckBox.isSelected()) {
              uploadButton.setEnabled(true);
              emailField.setEnabled(false);
            } else {
              emailField.setEnabled(true);

              if (emailField.getText() != null && emailField.getText().trim().length() > 0)
                uploadButton.setEnabled(true);
              else uploadButton.setEnabled(false);
            }
          }
        });

    emailField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void insertUpdate(DocumentEvent e) {
                updateButtonsState();
              }

              public void removeUpdate(DocumentEvent e) {
                updateButtonsState();
              }

              public void changedUpdate(DocumentEvent e) {}

              /** Check whether we should enable upload button. */
              private void updateButtonsState() {
                if (emailCheckBox.isSelected()
                    && emailField.getText() != null
                    && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true);
                else uploadButton.setEnabled(false);
              }
            });

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(10, 10, 3, 10);
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;

    container.add(descriptionLabel, c);

    c.insets = new Insets(0, 10, 10, 10);
    c.gridy = 1;
    container.add(new JScrollPane(commentTextArea), c);

    c.insets = new Insets(0, 10, 0, 10);
    c.gridy = 2;
    container.add(emailCheckBox, c);

    c.insets = new Insets(0, 10, 10, 10);
    c.gridy = 3;
    container.add(emailField, c);

    JButton cancelButton = new JButton(resources.getI18NString("service.gui.CANCEL"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dialog.dispose();
          }
        });

    uploadButton.setEnabled(false);
    uploadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              final ArrayList<String> paramNames = new ArrayList<String>();
              final ArrayList<String> paramValues = new ArrayList<String>();

              if (emailCheckBox.isSelected()) {
                paramNames.add("Email");
                paramValues.add(emailField.getText());
              }

              paramNames.add("Description");
              paramValues.add(commentTextArea.getText());

              // don't block the UI thread we may need to show
              // some ui for password input if protected area on the way
              new Thread(
                      new Runnable() {
                        public void run() {
                          uploadLogs(
                              getUploadLocation(),
                              LogsCollector.getDefaultFileName(),
                              paramNames.toArray(new String[] {}),
                              paramValues.toArray(new String[] {}));
                        }
                      })
                  .start();
            } finally {
              dialog.dispose();
            }
          }
        });
    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonsPanel.add(uploadButton);
    buttonsPanel.add(cancelButton);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0;
    c.gridy = 4;
    container.add(buttonsPanel, c);

    dialog.setVisible(true);
  }
  /** Draw the contents of the dialog. */
  private void drawDialog() {

    JPanel oCenterPanel = new JPanel();

    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints gc = new GridBagConstraints();
    gc.anchor = GridBagConstraints.WEST;
    oCenterPanel.setLayout(gb);
    gc.insets = new Insets(5, 5, 5, 5);

    int y = 0;

    cbIncludeKeywords =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importKeywordData")); //$NON-NLS-1$
    cbIncludeKeywords.setSelected(true);
    cbIncludeKeywords.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeKeywords, gc);
    oCenterPanel.add(cbIncludeKeywords);

    cbIncludePlayList =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importPlayListData")); //$NON-NLS-1$
    cbIncludePlayList.setSelected(true);
    cbIncludePlayList.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludePlayList, gc);
    oCenterPanel.add(cbIncludePlayList);

    cbIncludeURLs =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importURLData")); //$NON-NLS-1$
    cbIncludeURLs.setSelected(true);
    cbIncludeURLs.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeURLs, gc);
    oCenterPanel.add(cbIncludeURLs);

    cbIncludeAttendees =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importAttendeeData")); //$NON-NLS-1$
    cbIncludeAttendees.setSelected(true);
    cbIncludeAttendees.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeAttendees, gc);
    oCenterPanel.add(cbIncludeAttendees);

    cbIncludeChats =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.imortChatData")); //$NON-NLS-1$
    cbIncludeChats.setSelected(true);
    cbIncludeChats.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeChats, gc);
    oCenterPanel.add(cbIncludeChats);

    cbIncludeWhiteboard =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importWhiteBoardData")); //$NON-NLS-1$
    cbIncludeWhiteboard.setSelected(true);
    cbIncludeWhiteboard.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeWhiteboard, gc);
    oCenterPanel.add(cbIncludeWhiteboard);

    cbIncludeAnnotations =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importAnnotationData")); //$NON-NLS-1$
    cbIncludeAnnotations.setSelected(true);
    cbIncludeAnnotations.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeAnnotations, gc);
    oCenterPanel.add(cbIncludeAnnotations);

    cbIncludeFileData =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importFileData")); //$NON-NLS-1$
    cbIncludeFileData.setSelected(true);
    cbIncludeFileData.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeFileData, gc);
    oCenterPanel.add(cbIncludeFileData);

    cbIncludeVotes =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importVotingData")); //$NON-NLS-1$
    cbIncludeVotes.setSelected(true);
    cbIncludeVotes.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeVotes, gc);
    oCenterPanel.add(cbIncludeVotes);

    // Add spacer label
    JLabel spacer = new JLabel(" "); // $NON-NLS-1$
    gc.gridy = y;
    y++;
    gb.setConstraints(spacer, gc);
    oCenterPanel.add(spacer);

    // flag to mark seen/unseen on import
    cbMarkSeen =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.markSeen")); //$NON-NLS-1$
    cbMarkSeen.setSelected(true);
    cbMarkSeen.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbMarkSeen, gc);
    oCenterPanel.add(cbMarkSeen);

    // Add spacer label
    spacer = new JLabel(" "); // $NON-NLS-1$
    gc.gridy = y;
    y++;
    gb.setConstraints(spacer, gc);
    oCenterPanel.add(spacer);

    gc.gridwidth = 1;

    UIButtonPanel oButtonPanel = new UIButtonPanel();

    pbImport =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importMainButton")); //$NON-NLS-1$
    pbImport.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importMainButtonMnemonic")
            .charAt(0));
    pbImport.addActionListener(this);
    getRootPane().setDefaultButton(pbImport);
    oButtonPanel.addButton(pbImport);

    pbClose =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.cancelButton")); //$NON-NLS-1$
    pbClose.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.cancelButtonMnemonic")
            .charAt(0));
    pbClose.addActionListener(this);
    oButtonPanel.addButton(pbClose);

    pbHelp =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.helpButton")); //$NON-NLS-1$
    pbHelp.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.helpButtonMnemonic")
            .charAt(0));
    ProjectCompendium.APP.mainHB.enableHelpOnButton(
        pbHelp, "io.import_flashmeeting_xml", ProjectCompendium.APP.mainHS); // $NON-NLS-1$
    oButtonPanel.addHelpButton(pbHelp);

    // other initializations
    oContentPane.setLayout(new BorderLayout());
    oContentPane.add(oCenterPanel, BorderLayout.CENTER);
    oContentPane.add(oButtonPanel, BorderLayout.SOUTH);

    pack();
    setResizable(false);
    return;
  }
Esempio n. 30
0
  /**
   * Inizialize frame components
   *
   * @throws CMSException
   * @throws FileNotFoundException
   * @throws IOException
   * @throws GeneralSecurityException
   */
  private void initComponents()
      throws CMSException, FileNotFoundException, IOException, GeneralSecurityException {

    // *********************************

    panel4 = new JPanel();
    label2 = new JLabel();
    textPane1 = new JTextPane();
    panel5 = new JPanel();
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    progressBar = new JProgressBar();

    textPane2 = new JTextPane();
    textField1 = new JTextField();
    button1 = new JButton();
    panel6 = new JPanel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    GridBagConstraints gbc;
    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

    // ======== panel4 ========
    {
      panel4.setBackground(Color.white);
      panel4.setLayout(new GridBagLayout());
      ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0};
      ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
      ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4};
      ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4};

      // ---- label2 ----
      label2.setIcon(
          new ImageIcon(
              "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png"));
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      panel4.add(label2, gbc);

      // ---- textPane1 ----
      textPane1.setFont(new Font("Verdana", Font.BOLD, 12));
      textPane1.setText("Lettura\ncertificati\nda token");
      textPane1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      panel4.add(textPane1, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    contentPane.add(panel4, gbc);

    // ======== panel5 ========
    {
      panel5.setBackground(Color.white);
      panel5.setLayout(new GridBagLayout());
      ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0};
      ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0};
      ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4};

      // ---- textArea1 ----
      textArea1.setFont(new Font("Verdana", Font.BOLD, 14));
      textArea1.setText("Lettura certificati da token");
      textArea1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.VERTICAL;
      gbc.insets.bottom = 5;
      panel5.add(textArea1, gbc);

      // ---- textArea2 ----
      textArea2.setFont(new Font("Verdana", Font.PLAIN, 12));
      textArea2.setText("Ricerca certificati...\n");
      textArea2.setEditable(false);
      textArea2.setColumns(30);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.BOTH;
      panel5.add(textArea2, gbc);
      progressBar.setValue(0);
      progressBar.setMaximum(1);
      progressBar.setStringPainted(true);
      progressBar.setBounds(0, 0, 300, 150);

      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      gbc.insets.right = 5;
      gbc.gridwidth = 3;
      panel5.add(progressBar, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    contentPane.add(panel5, gbc);

    // ======== panel6 ========
    {
      panel6.setBackground(Color.white);
      panel6.setLayout(new GridBagLayout());
      ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
      ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0};
      ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

      // ---- button2 ----
      button2.setText("Indietro");
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.insets.right = 5;
      button2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {

              frame.hide();

              FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
            }
          });

      // panel6.add(button2, gbc);

      // ---- button4 ----
      button4.setText("Annulla");
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 0;
      // panel6.add(button4, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    contentPane.add(panel6, gbc);
    contentPane.setBackground(Color.white);
    frame = new JFrame();
    frame.setContentPane(contentPane);
    frame.setTitle("Freesigner");
    frame.setSize(300, 150);
    frame.setResizable(false);
    frame.pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    timer =
        new Timer(
            10,
            new ActionListener() {

              public void actionPerformed(ActionEvent evt) {
                frame.show();
                if (task.getMessage() != null) {
                  String s = new String();
                  s = task.getMessage();
                  s = s.substring(0, Math.min(60, s.length()));

                  textArea2.setText(s + " ");
                  progressBar.setValue(task.getStatus());
                }
                if (task.isDone()) {
                  timer.stop();

                  // Finalizzo la cryptoki, onde evitare
                  // successivi errori PKCS11 "cryptoki alreadi initialized"

                  if ((task != null)) task.libFinalize();

                  ArrayList slotInfos = task.getSlotInfos();
                  if ((slotInfos == null) || slotInfos.isEmpty()) {

                    frame.show();

                    JOptionPane.showMessageDialog(
                        frame,
                        "Controllare la presenza sul sistema\n"
                            + "della libreria PKCS11 impostata.",
                        "Nessun lettore rilevato",
                        JOptionPane.WARNING_MESSAGE);

                    frame.hide();

                  } else {
                    String st = task.getCRLerror();

                    if (st.length() > 0) {
                      timer.stop();

                      JOptionPane.showMessageDialog(
                          frame,
                          "C'è stato un errore nella verifica CRL.\n" + st,
                          "Errore verifica CRL",
                          JOptionPane.ERROR_MESSAGE);
                      frame.hide();
                      FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
                    }
                    if (task.getDifferentCerts() == 0) {
                      if (task.getCIr() != null) {
                        JOptionPane.showMessageDialog(
                            frame,
                            "La carta "
                                + task.getCardDescription()
                                + " nel lettore "
                                + conf.getReader()
                                + " non contiene certificati",
                            "Attenzione",
                            JOptionPane.WARNING_MESSAGE);

                      } else
                        JOptionPane.showMessageDialog(
                            frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE);
                    }

                    frame.hide();

                    // confFrame.createTreeAndTokenNodes(task.getSlotInfos());

                  }
                }
              }
            });
  }