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();
 }
  /** 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;
  }
Esempio n. 3
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();
  }
Esempio n. 4
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
    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);
    }
  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();
  }
 // 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;
 }
  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. 9
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);
 }
    private Connector() {
      setLayout(new GridBagLayout());
      //      setBorder (new EmptyBorder (8, 8, 8, 8));
      GridBagConstraints c = new GridBagConstraints();

      c.insets = new Insets(0, 0, 3, 3);
      c.anchor = GridBagConstraints.WEST;
      add(new JLabel(bundle.getString("CTL_HostName")), c);

      tfHost = new JTextField(host, 25);
      c = new GridBagConstraints();
      c.gridwidth = 0;
      c.insets = new Insets(0, 3, 3, 0);
      c.fill = java.awt.GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      add(tfHost, c);

      c = new GridBagConstraints();
      c.insets = new Insets(3, 0, 0, 3);
      c.anchor = GridBagConstraints.WEST;
      add(new JLabel(bundle.getString("CTL_Password")), c);

      tfPassword = new JTextField(25);
      c = new GridBagConstraints();
      c.gridwidth = 0;
      c.fill = java.awt.GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      c.insets = new Insets(3, 3, 0, 0);
      add(tfPassword, c);

      c = new GridBagConstraints();
      c.fill = java.awt.GridBagConstraints.BOTH;
      c.weighty = 1.0;
      JPanel p = new JPanel();
      p.setPreferredSize(new Dimension(1, 1));
      add(p, c);
    }
  /**
   * The constructor.
   *
   * @param parent The parent.
   * @param idata The installation data.
   */
  public FinishPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    vs = new VariableSubstitutor(idata.getVariableValueMap());

    // The 'super' layout
    GridBagLayout superLayout = new GridBagLayout();
    setLayout(superLayout);
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.insets = new Insets(0, 0, 0, 0);
    gbConstraints.fill = GridBagConstraints.NONE;
    gbConstraints.anchor = GridBagConstraints.CENTER;

    // We initialize our 'real' layout
    centerPanel = new JPanel();
    layout = new BoxLayout(centerPanel, BoxLayout.Y_AXIS);
    centerPanel.setLayout(layout);
    superLayout.addLayoutComponent(centerPanel, gbConstraints);
    add(centerPanel);
  }
Esempio n. 12
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;
 }
Esempio n. 14
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);
  }
  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. 16
0
  protected void buildGUI() {
    // einmalig PropertyArray initialisieren
    if (static_pr == null) {
      static_pr = new PropertyArray();
      static_pr.text = prText;
      static_pr.textName = prTextName;
      static_pr.intg = prIntg;
      static_pr.intgName = prIntgName;
      static_pr.bool = prBool;
      static_pr.boolName = prBoolName;
      static_pr.para = prPara;
      static_pr.para[PR_WARP] = new Param(-10.0, Param.FACTOR);
      static_pr.para[PR_WARPMODDEPTH] = new Param(20.0, Param.OFFSET_AMP);
      static_pr.para[PR_INFREQ] = new Param(1000.0, Param.ABS_HZ);
      static_pr.para[PR_OUTFREQ] = new Param(1000.0, Param.ABS_HZ);
      static_pr.paraName = prParaName;
      static_pr.envl = prEnvl;
      static_pr.envl[PR_WARPENV] = Envelope.createBasicEnvelope(Envelope.BASIC_TIME);
      static_pr.envlName = prEnvlName;
      //			static_pr.superPr	= DocumentFrame.static_pr;

      fillDefaultAudioDescr(static_pr.intg, PR_OUTPUTTYPE, PR_OUTPUTRES);
      fillDefaultGain(static_pr.para, PR_GAIN);
      static_presets = new Presets(getClass(), static_pr.toProperties(true));
    }
    presets = static_presets;
    pr = (PropertyArray) static_pr.clone();

    // -------- GUI bauen --------

    GridBagConstraints con;

    PathField ggInputFile, ggOutputFile;
    PathField[] ggParent1;
    ParamField ggWarp, ggWarpModDepth, ggInFreq, ggOutFreq;
    JCheckBox ggWarpMod;
    EnvIcon ggWarpEnv;
    Component[] ggGain;
    JComboBox ggFrameSize, ggOverlap;

    gui = new GUISupport();
    con = gui.getGridBagConstraints();
    con.insets = new Insets(1, 2, 1, 2);

    ParamListener paramL =
        new ParamListener() {
          public void paramChanged(ParamEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_WARP:
              case GG_INFREQ:
                pr.para[ID - GG_OFF_PARAMFIELD] = ((ParamField) e.getSource()).getParam();
                recalcOutFreq();
                break;

              case GG_OUTFREQ:
                pr.para[ID - GG_OFF_PARAMFIELD] = ((ParamField) e.getSource()).getParam();
                recalcWarpAmount();
                break;
            }
          }
        };

    ItemListener il =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_WARPMOD:
                pr.bool[ID - GG_OFF_CHECKBOX] = ((JCheckBox) e.getSource()).isSelected();
                reflectPropertyChanges();
                break;
            }
          }
        };

    PathListener pathL =
        new PathListener() {
          public void pathChanged(PathEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_INPUTFILE:
                setInput(((PathField) e.getSource()).getPath().getPath());
                break;
            }
          }
        };

    // -------- I/O-Gadgets --------
    con.fill = GridBagConstraints.BOTH;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addLabel(
        new GroupLabel("Waveform I/O", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggInputFile =
        new PathField(PathField.TYPE_INPUTFILE + PathField.TYPE_FORMATFIELD, "Select input file");
    ggInputFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Input file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggInputFile, GG_INPUTFILE, pathL);

    ggOutputFile =
        new PathField(
            PathField.TYPE_OUTPUTFILE + PathField.TYPE_FORMATFIELD + PathField.TYPE_RESFIELD,
            "Select output file");
    ggOutputFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Output file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggOutputFile, GG_OUTPUTFILE, pathL);
    gui.registerGadget(ggOutputFile.getTypeGadget(), GG_OUTPUTTYPE);
    gui.registerGadget(ggOutputFile.getResGadget(), GG_OUTPUTRES);

    ggParent1 = new PathField[1];
    ggParent1[0] = ggInputFile;
    ggOutputFile.deriveFrom(ggParent1, "$D0$F0Wrp$E");

    ggGain = createGadgets(GGTYPE_GAIN);
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Gain", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField((ParamField) ggGain[0], GG_GAIN, paramL);
    con.weightx = 0.5;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice((JComboBox) ggGain[1], GG_GAINTYPE, il);

    // -------- Settings-Gadgets --------
    gui.addLabel(
        new GroupLabel("Warp settings", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggWarp = new ParamField(Constants.spaces[Constants.modSpace]); // XXX
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Warp amount", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField(ggWarp, GG_WARP, paramL);

    ggWarpModDepth = new ParamField(Constants.spaces[Constants.offsetAmpSpace]); // XXX
    ggWarpModDepth.setReference(ggWarp);
    ggWarpMod = new JCheckBox();
    con.weightx = 0.1;
    gui.addCheckbox(ggWarpMod, GG_WARPMOD, il);
    con.weightx = 0.4;
    gui.addParamField(ggWarpModDepth, GG_WARPMODDEPTH, paramL);

    ggWarpEnv = new EnvIcon(getComponent());
    con.weightx = 0.1;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addGadget(ggWarpEnv, GG_WARPENV);

    ggInFreq = new ParamField(Constants.spaces[Constants.absHzSpace]);
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Input freq.", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField(ggInFreq, GG_INFREQ, paramL);
    ggOutFreq = new ParamField(Constants.spaces[Constants.absHzSpace]);
    con.weightx = 0.1;
    gui.addLabel(new JLabel("\u2192 Output freq.", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addParamField(ggOutFreq, GG_OUTFREQ, paramL);

    ggFrameSize = new JComboBox();
    for (int i = 32; i <= 32768; i <<= 1) {
      ggFrameSize.addItem(String.valueOf(i));
    }
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Frame size [smp]", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addChoice(ggFrameSize, GG_FRAMESIZE, il);

    ggOverlap = new JComboBox();
    for (int i = 1; i <= 16; i++) {
      ggOverlap.addItem(i + "x");
    }
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Overlap", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice(ggOverlap, GG_OVERLAP, il);

    initGUI(this, FLAGS_PRESETS | FLAGS_PROGBAR, gui);
  }
Esempio n. 17
0
  RecordingFrame(VncViewer v) {
    super("Teambox Screen Sharing Session Recording");

    viewer = v;

    // Determine initial filename for next saved session.
    // FIXME: Check SecurityManager.

    String fname =
        nextNewFilename(
            System.getProperty("user.dir")
                + System.getProperty("file.separator")
                + "vncsession.fbs");

    // Construct new panel with file name field and "Browse" button.

    Panel fnamePanel = new Panel();
    GridBagLayout fnameGridbag = new GridBagLayout();
    fnamePanel.setLayout(fnameGridbag);

    GridBagConstraints fnameConstraints = new GridBagConstraints();
    fnameConstraints.gridwidth = GridBagConstraints.RELATIVE;
    fnameConstraints.fill = GridBagConstraints.BOTH;
    fnameConstraints.weightx = 4.0;

    fnameField = new TextField(fname, 64);
    fnameGridbag.setConstraints(fnameField, fnameConstraints);
    fnamePanel.add(fnameField);
    fnameField.addActionListener(this);

    fnameConstraints.gridwidth = GridBagConstraints.REMAINDER;
    fnameConstraints.weightx = 1.0;

    browseButton = new Button("Browse");
    fnameGridbag.setConstraints(browseButton, fnameConstraints);
    fnamePanel.add(browseButton);
    browseButton.addActionListener(this);

    // Construct the frame.

    GridBagLayout gridbag = new GridBagLayout();
    setLayout(gridbag);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(10, 0, 0, 0);

    Label helpLabel = new Label("File name to save next recorded session in:", Label.CENTER);
    gridbag.setConstraints(helpLabel, gbc);
    add(helpLabel);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weighty = 0.0;
    gbc.insets = new Insets(0, 0, 0, 0);

    gridbag.setConstraints(fnamePanel, gbc);
    add(fnamePanel);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(10, 0, 10, 0);

    statusLabel = new Label("", Label.CENTER);
    gridbag.setConstraints(statusLabel, gbc);
    add(statusLabel);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 0, 0, 0);

    recordButton = new Button("Record");
    gridbag.setConstraints(recordButton, gbc);
    add(recordButton);
    recordButton.addActionListener(this);

    nextButton = new Button("Next file");
    gridbag.setConstraints(nextButton, gbc);
    add(nextButton);
    nextButton.addActionListener(this);

    closeButton = new Button("Close");
    gridbag.setConstraints(closeButton, gbc);
    add(closeButton);
    closeButton.addActionListener(this);

    // Set correct text, font and color for the statusLabel.
    stopRecording();

    pack();

    addWindowListener(this);
  }
  public BundleOptionsFrame(String displayName, String instanceName, List<OptionGroup> options) {
    setResizable(false);
    this.displayName = displayName;
    content = (JComponent) getContentPane();
    content.setLayout(new GridBagLayout());

    final BundleOptionsFrame frame = this;

    // Close button
    Action closeAction =
        new AbstractAction("Close") {
          @Override
          public void actionPerformed(ActionEvent e) {
            frame.setVisible(false);
          }
        };
    JButton close_button = new JButton(closeAction);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow++;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(2, 2, 2, 2);
    content.add(close_button, c);

    // Escape key binding
    JComponent root = frame.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke("ctrl W"), "close");
    root.getActionMap().put("close", closeAction);

    if (instanceName != null) {
      // Predicate name
      StringOption opt = new StringOption();
      opt.setDisplayName("Predicate name");
      opt.setDefault(instanceName);
      instanceNameField = new StringField(opt);
      instanceNameField.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              updateTitle();
            }
          });
      addField(instanceNameField);
      JTextField tf = (JTextField) instanceNameField.getComponent();
      tf.selectAll();
      tf.requestFocusInWindow();
    } else {
      // We're a codec; no instance name
      instanceNameField = null;
    }
    updateTitle();

    // Options
    ExampleField example = null;
    for (OptionGroup group : options) {
      addSeparator(group.getDisplayName());
      for (Option option : group.getOptions()) {
        OptionField field;
        if (option instanceof BooleanOption) {
          field = new BooleanField((BooleanOption) option);
        } else if (option instanceof StringOption) {
          field = new StringField((StringOption) option);
        } else if (option instanceof NumberOption) {
          field = new NumberField((NumberOption) option);
        } else if (option instanceof ChoiceOption) {
          field = new ChoiceField((ChoiceOption) option);
        } else if (option instanceof ExampleOption) {
          if (example != null) {
            throw new IllegalArgumentException("Cannot display more than one ExampleOption");
          }
          example = new ExampleField((ExampleOption) option);
          field = example;
        } else {
          throw new IllegalArgumentException("Unknown option type");
        }
        addField(field);
        optionFields.add(field);
      }
    }
    this.exampleField = example;

    pack();
  }
Esempio n. 19
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. 20
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. 21
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. 22
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. 23
0
  private void init(EditorPatternButton imgBtn, JLabel msgApplied) {
    _imgBtn = imgBtn;
    JLabel lblPath = new JLabel(_I("lblPath"));
    JLabel lblFilename = new JLabel(_I("lblFilename"));

    String filename = _imgBtn.getFilename();
    File f = new File(filename);
    String fullpath = f.getParent();
    filename = getFilenameWithoutExt(f);
    _oldFilename = filename;

    BufferedImage thumb = _imgBtn.createThumbnailImage(THUMB_MAX_HEIGHT);
    Border border = LineBorder.createGrayLineBorder();
    JLabel lblThumb = new JLabel(new ImageIcon(thumb));
    lblThumb.setBorder(border);

    _txtPath = new JTextField(fullpath, TXT_FILENAME_LENGTH);
    _txtPath.setEditable(false);
    _txtPath.setEnabled(false);

    String[] candidates = new String[] {filename};
    // <editor-fold defaultstate="collapsed" desc="OCR --- not used">
    /*
    String ocrText = getFilenameFromImage(thumb);
    if(ocrText.length()>0 && !ocrText.equals(filename))
    candidates = new String[] {filename, ocrText};
    */
    // </editor-fold>
    _txtFilename = new AutoCompleteCombo(candidates);

    _txtFileExt = new JTextField(getFileExt(f), TXT_FILE_EXT_LENGTH);
    _txtFileExt.setEditable(false);
    _txtFileExt.setEnabled(false);

    GridBagConstraints c = new GridBagConstraints();

    c.gridy = 0;
    c.insets = new Insets(100, 0, 0, 0);
    this.add(new JLabel(""), c);

    c = new GridBagConstraints();
    c.fill = 0;
    c.gridwidth = 3;
    c.gridy = 1;
    c.insets = new Insets(0, 10, 20, 10);
    this.add(lblThumb, c);

    c = new GridBagConstraints();
    c.fill = 1;
    c.gridy = 2;
    this.add(lblPath, c);
    c.gridx = 1;
    c.gridwidth = 2;
    this.add(_txtPath, c);

    c = new GridBagConstraints();
    c.gridy = 3;
    c.fill = 0;
    this.add(lblFilename, c);
    this.add(_txtFilename, c);
    this.add(_txtFileExt, c);

    c = new GridBagConstraints();
    c.gridy = 4;
    c.gridx = 1;
    c.insets = new Insets(200, 0, 0, 0);
    this.add(msgApplied, c);
  }
Esempio n. 24
0
    public RecorderDialog(EditorServer parent) {

      super(parent, true);

      setTitle("Recorder Info");

      // fieldsPanel

      JPanel fieldsPanel = new JPanel();
      GridBagLayout gbLayout = new GridBagLayout();
      GridBagConstraints constraints;

      //		  	Address/Port/TTL :

      constraints = new GridBagConstraints();
      constraints.anchor = GridBagConstraints.EAST;
      constraints.insets = new Insets(5, 5, 0, 0);

      fieldsPanel.setLayout(gbLayout);

      JLabel AddPTTLabel = new JLabel("Address/Port/TTL :");
      gbLayout.setConstraints(AddPTTLabel, constraints);
      fieldsPanel.add(AddPTTLabel, constraints);

      constraints = new GridBagConstraints();
      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.insets = new Insets(5, 5, 0, 5);
      constraints.weightx = 1.0D;

      addressPortTTL = new JTextField(25);
      addressPortTTL.setText("224.20.20.20/20002");

      gbLayout.setConstraints(addressPortTTL, constraints);

      fieldsPanel.add(addressPortTTL, constraints);

      // Outputfile...

      constraints = new GridBagConstraints();
      constraints.anchor = GridBagConstraints.EAST;
      constraints.insets = new Insets(5, 5, 0, 0);

      JLabel OFileLabel = new JLabel("Save file as... :");
      gbLayout.setConstraints(OFileLabel, constraints);
      fieldsPanel.add(OFileLabel, constraints);

      constraints = new GridBagConstraints();
      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.insets = new Insets(5, 5, 0, 5);
      constraints.weightx = 1.0D;

      outFile = new JTextField(25);
      outFile.setText("Placebo.rtp");

      gbLayout.setConstraints(outFile, constraints);

      fieldsPanel.add(outFile, constraints);

      // Recording time...

      constraints = new GridBagConstraints();
      constraints.anchor = GridBagConstraints.EAST;
      constraints.insets = new Insets(5, 5, 0, 0);

      JLabel timeLabel = new JLabel("Recording time (in seconds) : ");
      gbLayout.setConstraints(timeLabel, constraints);
      fieldsPanel.add(timeLabel, constraints);

      constraints = new GridBagConstraints();
      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.insets = new Insets(5, 5, 0, 5);
      constraints.weightx = 1.0D;

      durationField = new JTextField(25);
      durationField.setText("2700");

      gbLayout.setConstraints(durationField, constraints);

      fieldsPanel.add(durationField, constraints);

      // The buttons...

      JPanel buttonPanel = new JPanel();

      JButton startRecordingButton = new JButton("Start Recording");

      startRecordingButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent buttonPressed) {

              // startThread here !!!

              String apt = addressPortTTL.getText().trim();
              String ofile = outFile.getText().trim();
              String duration = durationField.getText().trim();

              System.out.println(
                  "\napt : *" + apt + "* ofile : *" + ofile + "* duration: *" + duration + "*");

              long dur = new Integer(duration).intValue() * 1000; // turned into ms

              recorder = new Recorder(apt, ofile, dur);

              recorder.start();

              document.resetStartTime(System.currentTimeMillis());

              // close dialog Box

              dispose();
            } //
          }); // endActionListener

      buttonPanel.add(startRecordingButton);

      Container dialogContainer = getContentPane();

      dialogContainer.setLayout(new BorderLayout());
      dialogContainer.add(fieldsPanel, BorderLayout.CENTER);
      dialogContainer.add(buttonPanel, BorderLayout.SOUTH);

      pack();

      setLocationRelativeTo(parent);
    }
Esempio n. 25
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);
  }
Esempio n. 26
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);
    }
  }
  /** 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;
  }
    public NumberField(NumberOption option) {
      super(option);

      panel = new JPanel(new GridBagLayout());
      this.step = option.getStep();
      Double min = option.getMin();
      Double max = option.getMax();
      Double defl = new Double(option.getDefault());

      // Normalize parameters
      if (min != null && defl.compareTo(min) < 0) {
        defl = min;
      } else if (max != null && defl.compareTo(max) > 0) {
        defl = max;
      }
      if (min != null) {
        sliderMin = (int) (min.doubleValue() / step);
      } else {
        sliderMin = SLIDER_DEFAULT_MIN;
      }
      if (max != null) {
        sliderMax = (int) (max.doubleValue() / step);
      } else {
        sliderMax = SLIDER_DEFAULT_MAX;
      }

      // Create spinner
      SpinnerNumberModel spinnerModel = new SpinnerNumberModel(defl, min, max, new Double(step));
      spinner = new JSpinner(spinnerModel);
      ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().setColumns(FIELD_WIDTH);

      // Create slider
      slider = new JSlider(sliderMin, sliderMax, sliderIndex(defl));
      slider.setPaintLabels(false);
      slider.setPaintTicks(false);
      slider.setSnapToTicks(false);

      // Add listeners.  The spinner is the master and the slider is
      // the slave.
      spinner.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              int newIndex = sliderIndex((Double) spinner.getValue());
              if (slider.getValue() != newIndex) {
                slider.setValue(newIndex);
              }
              fireChangeEvent();
            }
          });
      slider.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              int newIndex = slider.getValue();
              if (newIndex != sliderIndex((Double) spinner.getValue())) {
                spinner.setValue(new Double(newIndex * step));
              }
            }
          });

      // Create enable checkbox
      configureEnableToggle(
          option.isInitiallyEnabled(),
          string(option.getDisabledValue()),
          Arrays.asList((JComponent) spinner, slider));

      // Add to the panel
      panel.add(spinner);
      GridBagConstraints c = new GridBagConstraints();
      c.insets = new Insets(0, 8, 0, 0);
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1;
      panel.add(slider, c);
    }
Esempio n. 29
0
  protected void buildGUI() {
    // einmalig PropertyArray initialisieren
    if (static_pr == null) {
      static_pr = new PropertyArray();
      static_pr.text = prText;
      static_pr.textName = prTextName;
      static_pr.intg = prIntg;
      static_pr.intgName = prIntgName;
      static_pr.bool = prBool;
      static_pr.boolName = prBoolName;
      static_pr.para = prPara;
      static_pr.para[PR_MAXCHANGE] = new Param(96.0, Param.DECIBEL_AMP);
      static_pr.para[PR_AVERAGE] = new Param(1000.0, Param.ABS_MS);
      static_pr.paraName = prParaName;
      static_pr.envl = prEnvl;
      static_pr.envl[PR_ENV] = Envelope.createBasicEnvelope(Envelope.BASIC_UNSIGNED_TIME);
      static_pr.envl[PR_RIGHTCHANENV] = Envelope.createBasicEnvelope(Envelope.BASIC_UNSIGNED_TIME);
      static_pr.envlName = prEnvlName;
      //			static_pr.superPr	= DocumentFrame.static_pr;

      fillDefaultAudioDescr(static_pr.intg, PR_OUTPUTTYPE, PR_OUTPUTRES);
      fillDefaultAudioDescr(static_pr.intg, PR_ENVOUTTYPE, PR_ENVOUTRES);
      fillDefaultGain(static_pr.para, PR_GAIN);
      fillDefaultGain(static_pr.para, PR_ENVGAIN);
      static_presets = new Presets(getClass(), static_pr.toProperties(true));
    }
    presets = static_presets;
    pr = (PropertyArray) static_pr.clone();

    // -------- GUI bauen --------

    GridBagConstraints con;
    //		GridBagLayout		lay;

    PathField ggInputFile, ggOutputFile, ggEnvInFile, ggEnvOutFile;
    PathField[] ggInputs;
    JComboBox ggEnvSource, ggMode;
    ParamField ggMaxChange, ggAverage;
    JCheckBox ggEnvOutput, ggInvert, ggRightChan;
    EnvIcon ggEnv, ggRightChanEnv;
    Component[] ggGain, ggEnvGain;
    ParamSpace[] spcAverage;
    ParamSpace spcMaxChange;

    gui = new GUISupport();
    con = gui.getGridBagConstraints();
    //		lay				= gui.getGridBagLayout();
    con.insets = new Insets(1, 2, 1, 2);

    ItemListener il =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_ENVSOURCE:
                pr.intg[ID - GG_OFF_CHOICE] = ((JComboBox) e.getSource()).getSelectedIndex();
                reflectPropertyChanges();
                break;
              case GG_ENVOUTPUT:
              case GG_RIGHTCHAN:
                pr.bool[ID - GG_OFF_CHECKBOX] = ((JCheckBox) e.getSource()).isSelected();
                reflectPropertyChanges();
                break;
            }
          }
        };

    // -------- Input-Gadgets --------
    con.fill = GridBagConstraints.BOTH;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addLabel(
        new GroupLabel("Waveform I/O", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggInputFile =
        new PathField(PathField.TYPE_INPUTFILE + PathField.TYPE_FORMATFIELD, "Select input file");
    ggInputFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Input file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggInputFile, GG_INPUTFILE, null);

    ggEnvInFile =
        new PathField(
            PathField.TYPE_INPUTFILE + PathField.TYPE_FORMATFIELD, "Select input envelope file");
    ggEnvInFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Env input", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggEnvInFile, GG_ENVINFILE, null);

    ggOutputFile =
        new PathField(
            PathField.TYPE_OUTPUTFILE + PathField.TYPE_FORMATFIELD + PathField.TYPE_RESFIELD,
            "Select output file");
    ggOutputFile.handleTypes(GenericFile.TYPES_SOUND);
    ggInputs = new PathField[1];
    ggInputs[0] = ggInputFile;
    ggOutputFile.deriveFrom(ggInputs, "$D0$F0Amp$E");
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Output file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggOutputFile, GG_OUTPUTFILE, null);
    gui.registerGadget(ggOutputFile.getTypeGadget(), GG_OUTPUTTYPE);
    gui.registerGadget(ggOutputFile.getResGadget(), GG_OUTPUTRES);

    ggGain = createGadgets(GGTYPE_GAIN);
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Gain", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField((ParamField) ggGain[0], GG_GAIN, null);
    con.weightx = 0.5;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice((JComboBox) ggGain[1], GG_GAINTYPE, il);

    // -------- Env-Output-Gadgets --------
    gui.addLabel(
        new GroupLabel(
            "Separate envelope output", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggEnvOutFile =
        new PathField(
            PathField.TYPE_OUTPUTFILE + PathField.TYPE_FORMATFIELD + PathField.TYPE_RESFIELD,
            "Select output envelope file");
    ggEnvOutFile.handleTypes(GenericFile.TYPES_SOUND);
    ggEnvOutFile.deriveFrom(ggInputs, "$D0$F0Env$E");
    con.gridwidth = 1;
    con.weightx = 0.1;
    ggEnvOutput = new JCheckBox("Env output");
    gui.addCheckbox(ggEnvOutput, GG_ENVOUTPUT, il);
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggEnvOutFile, GG_ENVOUTFILE, null);
    gui.registerGadget(ggEnvOutFile.getTypeGadget(), GG_ENVOUTTYPE);
    gui.registerGadget(ggEnvOutFile.getResGadget(), GG_ENVOUTRES);

    // cannot call createGadgets twice (BUG!) XXX
    ggEnvGain = new Component[2]; // createGadgets( GGTYPE_GAIN );
    ggEnvGain[0] = new ParamField(Constants.spaces[Constants.decibelAmpSpace]);
    JComboBox ch = new JComboBox();
    ch.addItem("normalized");
    ch.addItem("immediate");
    ggEnvGain[1] = ch;

    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Gain", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField((ParamField) ggEnvGain[0], GG_ENVGAIN, null);
    con.weightx = 0.5;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice((JComboBox) ggEnvGain[1], GG_ENVGAINTYPE, il);

    // -------- Settings --------
    gui.addLabel(
        new GroupLabel("Shaper Settings", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggEnvSource = new JComboBox();
    ggEnvSource.addItem("Input file");
    ggEnvSource.addItem("Sound file");
    ggEnvSource.addItem("Envelope file");
    ggEnvSource.addItem("Envelope");
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Source", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addChoice(ggEnvSource, GG_ENVSOURCE, il);

    ggInvert = new JCheckBox();
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Inversion", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.4;
    gui.addCheckbox(ggInvert, GG_INVERT, il);

    ggMode = new JComboBox();
    ggMode.addItem("Superposition");
    ggMode.addItem("Replacement");
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Apply mode", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice(ggMode, GG_MODE, il);

    ggEnv = new EnvIcon(getComponent());
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Envelope", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addGadget(ggEnv, GG_ENV);

    spcMaxChange = new ParamSpace(Constants.spaces[Constants.decibelAmpSpace]);
    //		spcMaxChange.min= spcMaxChange.inc;
    spcMaxChange =
        new ParamSpace(spcMaxChange.inc, spcMaxChange.max, spcMaxChange.inc, spcMaxChange.unit);
    ggMaxChange = new ParamField(spcMaxChange);
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Max boost", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addParamField(ggMaxChange, GG_MAXCHANGE, null);

    ggRightChan = new JCheckBox("Right chan.");
    ggRightChanEnv = new EnvIcon(getComponent());
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addCheckbox(ggRightChan, GG_RIGHTCHAN, il);
    con.weightx = 0.4;
    gui.addGadget(ggRightChanEnv, GG_RIGHTCHANENV);

    spcAverage = new ParamSpace[3];
    spcAverage[0] = Constants.spaces[Constants.absMsSpace];
    spcAverage[1] = Constants.spaces[Constants.absBeatsSpace];
    spcAverage[2] = Constants.spaces[Constants.ratioTimeSpace];
    ggAverage = new ParamField(spcAverage);
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Smoothing", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addParamField(ggAverage, GG_AVERAGE, null);

    initGUI(this, FLAGS_PRESETS | FLAGS_PROGBAR, gui);
  }
Esempio n. 30
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);
  }