/** Creates the panel with the optional components. */
  private void _setupOptionsPanel(JComponent[] components) {
    JPanel mainButtons = new JPanel();
    JPanel emptyPanel = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    mainButtons.setLayout(gbLayout);

    for (JComponent b : components) {
      mainButtons.add(b);
    }
    mainButtons.add(emptyPanel);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;

    for (JComponent b : components) {
      gbLayout.setConstraints(b, c);
    }

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.SOUTH;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.weighty = 1.0;

    gbLayout.setConstraints(emptyPanel, c);

    _optionsPanel.add(mainButtons, BorderLayout.CENTER);
  }
Ejemplo n.º 2
0
  public void initComponents() {
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();

    JLabel label;
    JPanel panel;
    Dimension size;

    setBorder(new javax.swing.border.EtchedBorder());
    setLayout(gridBag);

    label = new JLabel(name);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(label, constraints);
    add(label);

    panel = filterOptions();
    gridBag.setConstraints(panel, constraints);
    add(panel);

    sliderCutoff = new JSlider(JSlider.VERTICAL);
    sliderCutoff.setPaintTicks(true);
    sliderCutoff.setToolTipText("Cutoff Frequency");
    sliderCutoff.setMinimum(0);
    sliderCutoff.setMaximum(500);
    sliderCutoff.setMinorTickSpacing(25);
    sliderCutoff.setMajorTickSpacing(100);
    sliderCutoff.setValue(100);
    sliderCutoff.addChangeListener(new CutoffListener(filter));
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridwidth = 1;
    gridBag.setConstraints(sliderCutoff, constraints);
    add(sliderCutoff);

    sliderResonance = new JSlider(JSlider.VERTICAL);
    sliderResonance.setPaintTicks(true);
    sliderResonance.setToolTipText("Resonance (Pass-band Ripple)");
    sliderResonance.setMinimum(1);
    sliderResonance.setMaximum(58);
    sliderResonance.setMinorTickSpacing(3);
    sliderResonance.setMajorTickSpacing(57);
    sliderResonance.setValue(1);
    sliderResonance.addChangeListener(new ResonanceListener(filter));
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(sliderResonance, constraints);
    add(sliderResonance);

    label = new JLabel("Cutoff");
    constraints.gridwidth = 1;
    constraints.ipadx = 10;
    gridBag.setConstraints(label, constraints);
    add(label);

    label = new JLabel("Resonance");
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(label, constraints);
    add(label);
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
0
  private JPanel getUpdatePanel() {
    if (updatePanel == null) {
      updatePanel = new JPanel(new GridBagLayout());
      updatePanel.setBorder(new EmptyBorder(0, 30, 0, 5));
      final GridBagConstraints constraints = new GridBagConstraints();
      constraints.insets = new Insets(0, 5, 5, 5);
      constraints.weighty = 0;
      constraints.weightx = 0;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      constraints.gridy = 0;

      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.weightx = 0.5;
      updatePanel.add(minimumIntervalLabel, constraints);
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.weightx = 1;
      updatePanel.add(minimumIntervalTextField, constraints);

      constraints.insets =
          new Insets(0, 5, 0, 5); // we have a bottom inset in the containing layout!
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.gridy++;
      constraints.weightx = 0.5;
      updatePanel.add(concurrentUpdatesLabel, constraints);
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.weightx = 1;
      updatePanel.add(concurrentUpdatesTextField, constraints);
    }
    return updatePanel;
  }
    public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) {
      GridBagLayout gridbag = (GridBagLayout) getLayout();
      labelPair = lp;
      label = new JLabel(labelPair.getSingular(), JLabel.LEFT);
      pane.getDocument().addDocumentListener(this);

      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 20, 0, 00);
      gridbag.setConstraints(pane, c);
      add(pane);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 0, 0, 20);
      gridbag.setConstraints(label, c);
      add(label);

      JPanel filler = new JPanel();
      filler.setBackground(white);
      c = new GridBagConstraints();
      c.gridx = 2;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.8;
      c.weighty = 0.8;
      c.fill = GridBagConstraints.BOTH;
      c.anchor = GridBagConstraints.LINE_END;
      gridbag.setConstraints(filler, c);
      add(filler);

      filler = null;
      c = null;
    }
Ejemplo n.º 6
0
  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();
  }
 protected GridBagConstraints createConstraints(int x, int y) {
   GridBagConstraints c = new GridBagConstraints();
   c.gridx = x;
   c.gridy = y;
   c.gridwidth = 2;
   c.gridheight = 1;
   c.ipadx = 1;
   c.weightx = 0.5;
   c.weighty = 0.5;
   c.fill = GridBagConstraints.BOTH;
   c.anchor = GridBagConstraints.CENTER;
   return c;
 }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
  private JPanel filterOptions() {
    Dimension size;
    JPanel panel = new JPanel();

    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();

    ButtonGroup buttons = new ButtonGroup();
    JRadioButton radio;
    JLabel label;
    JLabel filler;

    panel.setLayout(gridBag);

    label = new JLabel("Type:");
    constraints.anchor = GridBagConstraints.WEST;
    gridBag.setConstraints(label, constraints);
    panel.add(label);

    radio = new JRadioButton("Low-pass");
    radio.addActionListener(this);
    radio.setSelected(true);
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(radio, constraints);
    buttons.add(radio);
    panel.add(radio);

    filler = new JLabel();
    constraints.gridwidth = 1;
    gridBag.setConstraints(label, constraints);
    panel.add(filler);

    radio = new JRadioButton("High-pass");
    radio.addActionListener(this);
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(radio, constraints);
    buttons.add(radio);
    panel.add(radio);

    return panel;
  }
Ejemplo n.º 10
0
  /**
   * Messaged from installComponents to create a Container containing the body of the message. The
   * icon is the created by calling <code>addIcon</code>.
   */
  protected Container createMessageArea() {
    JPanel top = new JPanel();
    Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder");
    if (topBorder != null) {
      top.setBorder(topBorder);
    }
    top.setLayout(new BorderLayout());

    /* Fill the body. */
    Container body = new JPanel(new GridBagLayout());
    Container realBody = new JPanel(new BorderLayout());

    body.setName("OptionPane.body");
    realBody.setName("OptionPane.realBody");

    if (getIcon() != null) {
      JPanel sep = new JPanel();
      sep.setName("OptionPane.separator");
      sep.setPreferredSize(new Dimension(15, 1));
      realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS);
    }
    realBody.add(body, BorderLayout.CENTER);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor =
        DefaultLookup.getInt(
            optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER);
    cons.insets = new Insets(0, 0, 3, 0);

    addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false);
    top.add(realBody, BorderLayout.CENTER);

    addIcon(top);
    return top;
  }
Ejemplo n.º 11
0
  /*
  public void addMiniChart(Plugin p){
  	components.add(p);

  	rebuild();
  }

  public void removeMiniChart(Plugin p){
  	components.remove(p);
  	rebuild();

  }
  */
  public void rebuild() {
    // remove everything from main panel
    mainpanel.removeAll();

    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    mainpanel.setLayout(gbl);

    gbc.anchor = gbc.NORTHWEST;
    gbc.fill = gbc.BOTH;
    gbc.weightx = 1;
    gbc.gridx = 0;

    int i = 0;
    // add chart

    gbc.weighty = 1;
    gbc.gridy = i;
    gbl.setConstraints(chartPanel, gbc);
    mainpanel.add(chartPanel);

    // add all other plugins/components
    validate();
  }
  /**
   * The consturctor Constructor instantiates all the panels, convertible value instance, and the
   * frame. And adds the panels to the frame. And sets a proper size for the frame.
   */
  public HappyHackingConverter() {
    CFrame frame = new CFrame();
    frame.setBackground(white);

    ConvertibleValue temperatures = new ConvertibleValue();
    ConvertibleValue distances = new ConvertibleValue();
    ConvertibleValue weights = new ConvertibleValue();

    GridBagLayout leftSideLayout = new GridBagLayout();
    JPanel leftSide = new JPanel(leftSideLayout);
    leftSide.setBackground(white);

    GridBagLayout rightSideLayout = new GridBagLayout();
    JPanel rightSide = new JPanel(rightSideLayout);
    rightSide.setBackground(white);

    GridBagConstraints metricTemperatureConstraints = new GridBagConstraints();
    metricTemperatureConstraints.gridx = 0;
    metricTemperatureConstraints.gridy = 0;
    metricTemperatureConstraints.weighty = 0.1;
    metricTemperatureConstraints.weightx = 1;
    metricTemperatureConstraints.fill = GridBagConstraints.BOTH;
    metricTemperatureConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel metricTemperaturePanel =
        new TemperaturePanel(frame, temperatures, TemperatureScales.CENTIGRADE);
    leftSideLayout.setConstraints(metricTemperaturePanel, metricTemperatureConstraints);
    leftSide.add(metricTemperaturePanel);

    GridBagConstraints metricDistancesPanelConstraints = new GridBagConstraints();
    metricDistancesPanelConstraints.gridx = 0;
    metricDistancesPanelConstraints.gridy = 1;
    metricDistancesPanelConstraints.weighty = 0.3;
    metricDistancesPanelConstraints.weightx = 1;
    metricDistancesPanelConstraints.fill = GridBagConstraints.BOTH;
    metricDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel metricDistancesPanel = new MetricDistancesPanel(frame, distances);
    leftSideLayout.setConstraints(metricDistancesPanel, metricDistancesPanelConstraints);
    leftSide.add(metricDistancesPanel);

    GridBagConstraints fahrenheitConstraints = new GridBagConstraints();
    fahrenheitConstraints.gridx = 0;
    fahrenheitConstraints.gridy = 0;
    fahrenheitConstraints.weighty = 0.1;
    fahrenheitConstraints.weightx = 1;
    fahrenheitConstraints.fill = GridBagConstraints.BOTH;
    fahrenheitConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel fahrenheitTemperaturePanel =
        new TemperaturePanel(frame, temperatures, TemperatureScales.FAHRENHEIT);
    rightSideLayout.setConstraints(fahrenheitTemperaturePanel, fahrenheitConstraints);
    rightSide.add(fahrenheitTemperaturePanel);

    GridBagConstraints imperialDistancesPanelConstraints = new GridBagConstraints();
    imperialDistancesPanelConstraints.gridx = 0;
    imperialDistancesPanelConstraints.gridy = 1;
    imperialDistancesPanelConstraints.weighty = 0.3;
    imperialDistancesPanelConstraints.weightx = 1;
    imperialDistancesPanelConstraints.fill = GridBagConstraints.BOTH;
    imperialDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel imperialDistancesPanel = new ImperialDistancesPanel(frame, distances);
    rightSideLayout.setConstraints(imperialDistancesPanel, imperialDistancesPanelConstraints);
    rightSide.add(imperialDistancesPanel);

    GridBagConstraints metricWeightsConstraints = new GridBagConstraints();
    metricWeightsConstraints.gridx = 0;
    metricWeightsConstraints.gridy = 2;
    metricWeightsConstraints.weighty = 0.6;
    metricWeightsConstraints.weightx = 1;
    metricWeightsConstraints.fill = GridBagConstraints.BOTH;
    metricWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    MetricWeightsPanel metricWeightsPanel = new MetricWeightsPanel(frame, weights);
    leftSideLayout.setConstraints(metricWeightsPanel, metricWeightsConstraints);
    leftSide.add(metricWeightsPanel);

    GridBagConstraints imperialWeightsConstraints = new GridBagConstraints();
    imperialWeightsConstraints.gridx = 0;
    imperialWeightsConstraints.gridy = 2;
    imperialWeightsConstraints.weighty = 0.6;
    imperialWeightsConstraints.weightx = 1;
    imperialWeightsConstraints.fill = GridBagConstraints.BOTH;
    imperialWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    ImperialWeightsPanel imperialWeightsPanel = new ImperialWeightsPanel(frame, weights);
    rightSideLayout.setConstraints(imperialWeightsPanel, imperialWeightsConstraints);
    rightSide.add(imperialWeightsPanel);

    CSplit split = new CSplit(JSplitPane.HORIZONTAL_SPLIT, true, leftSide, rightSide);
    Container contentPane = frame.getContentPane();
    contentPane.add(split);
    frame.validate();
    frame.pack();
    frame.setSize(600, 997);
    split.setResizeWeight(0.5);
    split.setDividerLocation(0.5);
  } // end of HappyHackingConverter constructor
Ejemplo n.º 13
0
  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();
  }
Ejemplo n.º 14
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);
    }
Ejemplo n.º 15
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;
  }
Ejemplo n.º 16
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);
    }
  }
Ejemplo n.º 17
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);
  }
Ejemplo n.º 18
0
    public ExampleField(ExampleOption option) {
      super(option);

      model = new DefaultListModel();
      model.addListDataListener(
          new ListDataListener() {
            @Override
            public void intervalAdded(ListDataEvent e) {
              fireChangeEvent();
            }

            @Override
            public void intervalRemoved(ListDataEvent e) {
              fireChangeEvent();
            }

            @Override
            public void contentsChanged(ListDataEvent e) {
              fireChangeEvent();
            }
          });

      final JList list =
          new JList(model) {
            @Override
            public Dimension getPreferredScrollableViewportSize() {
              return new Dimension(3 * CELL_SIZE, 2 * CELL_SIZE);
            }
          };
      list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
      list.setVisibleRowCount(0);
      list.setFixedCellHeight(CELL_SIZE);
      list.setFixedCellWidth(CELL_SIZE);
      list.setTransferHandler(
          new URIImportTransferHandler() {
            @Override
            public boolean canImport(TransferSupport support) {
              support.setShowDropLocation(false);
              return super.canImport(support);
            }

            @Override
            public boolean importData(TransferSupport support) {
              try {
                List<BufferedImage> images = new ArrayList<BufferedImage>();
                for (URI u : getURIs(support)) {
                  try {
                    images.add(ImageIO.read(u.toURL()));
                  } catch (IOException e) {
                  }
                }
                addExamples(images);
                return true;
              } catch (IOException e) {
                return false;
              } catch (UnsupportedFlavorException e) {
                return false;
              } catch (URISyntaxException e) {
                return false;
              }
            }
          });
      list.setCellRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

              Example example = (Example) value;

              setHorizontalAlignment(SwingConstants.CENTER);
              setText(null);
              setIcon(example.getIcon());
              setBorder(BorderFactory.createEmptyBorder());

              return this;
            }
          });
      JScrollPane jsp = new JScrollPane(list);
      jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

      final JButton remove = new JButton("Remove");
      remove.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              int[] indices = list.getSelectedIndices();
              for (int i = indices.length - 1; i >= 0; i--) {
                model.remove(indices[i]);
              }
            }
          });
      list.addListSelectionListener(
          new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
              remove.setEnabled(list.getSelectedIndex() != -1);
            }
          });
      remove.setEnabled(false);

      panel = new JPanel(new GridBagLayout());
      // Add list
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 1;
      c.fill = GridBagConstraints.BOTH;
      panel.add(jsp, c);
      // Add remove button
      c = new GridBagConstraints();
      c.gridx = 0;
      c.anchor = GridBagConstraints.WEST;
      panel.add(remove, c);
    }
Ejemplo n.º 19
0
  public ChartWindow(String title) {

    this.symbol = title;
    thisp = this;
    // initialize the main layout
    setTitle(title);
    mainpanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    mainpanel.setLayout(gbl);

    // build a toolbar
    //		add a plain status bar
    this.statusLine = new JLabel("Done");
    this.getContentPane().add(statusLine, BorderLayout.SOUTH);

    statusLine.setBackground(new Color(0, 0, 0));
    statusLine.setForeground(new Color(255, 255, 255));
    statusLine.setOpaque(true);

    //
    x1 = new TimeSeries("symbol", FixedMillisecond.class);
    dataset1.addSeries(x1);

    System.out.println("Populated.");

    //
    chart = createChart(dataset1);
    System.out.println("constr.");

    // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);

    chart.setAntiAlias(false);

    chartPanel = new ChartPanel(chart);

    //

    int i = 0;
    gbc.anchor = gbc.NORTHWEST;
    gbc.fill = gbc.BOTH;
    gbc.weightx = 1;
    gbc.gridx = 0;

    gbc.weighty = 1;
    gbc.gridy = i;
    gbl.setConstraints(chartPanel, gbc);

    mainpanel.add(chartPanel);
    // System.out.println("add");
    setVisible(true);
    setSize(new Dimension(400, 300));

    // chartPanel.setPopupMenu(buildPopupMenu());
    chartPanel.setMouseZoomable(true);
    chartPanel.setHorizontalAxisTrace(true);
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setHorizontalZoom(true);

    chartPanel.setOpaque(true);
    chartPanel.setBackground(new Color(0, 0, 0));

    this.getContentPane().add(mainpanel, BorderLayout.CENTER);

    this.setSize(600, 400);
    this.toFront();
    this.show();
  }
Ejemplo n.º 20
0
  Client(String[] args) {
    //
    // Initialize an Ice communicator.
    //
    try {
      com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData();
      initData.properties = com.zeroc.Ice.Util.createProperties();
      initData.properties.load("config.client");
      initData.dispatcher =
          (runnable, connection) -> {
            SwingUtilities.invokeLater(runnable);
          };
      _communicator = com.zeroc.Ice.Util.initialize(args, initData).communicator;
    } catch (Throwable ex) {
      handleException(ex);
    }

    Container cp = this;

    JLabel l1 = new JLabel("Hostname");
    _hostname = new JTextField();
    JLabel l2 = new JLabel("Mode");
    _mode = new JComboBox<String>();
    JLabel l3 = new JLabel("Timeout");
    _timeoutSlider = new JSlider(0, MAX_TIME);
    _timeoutLabel = new JLabel("0.0");
    JLabel l4 = new JLabel("Delay");
    _delaySlider = new JSlider(0, MAX_TIME);
    _delayLabel = new JLabel("0.0");
    JPanel buttonPanel = new JPanel();
    _hello = new JButton("Hello World!");
    _shutdown = new JButton("Shutdown");
    _flush = new JButton("Flush");
    _flush.setEnabled(false);
    JSeparator statusPanelSeparator = new JSeparator();
    _status = new JLabel();
    _status.setText("Ready");

    //
    // Default to localhost.
    //
    _hostname.setText("127.0.0.1");
    _hostname
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void changedUpdate(DocumentEvent e) {
                updateProxy();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                if (e.getDocument().getLength() > 0) {
                  _hello.setEnabled(true);
                  _shutdown.setEnabled(true);
                }
                updateProxy();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                if (e.getDocument().getLength() == 0) {
                  _hello.setEnabled(false);
                  _shutdown.setEnabled(false);
                  _flush.setEnabled(false);
                }
                updateProxy();
              }
            });

    _mode.setModel(new DefaultComboBoxModel<String>(DELIVERY_MODE_DESC));

    _hello.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            sayHello();
          }
        });
    _shutdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            shutdown();
          }
        });
    _flush.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            flush();
          }
        });
    _mode.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            changeDeliveryMode(_mode.getSelectedIndex());
          }
        });
    changeDeliveryMode(_mode.getSelectedIndex());

    _timeoutSlider.addChangeListener(new SliderListener(_timeoutSlider, _timeoutLabel));
    _timeoutSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent ce) {
            updateProxy();
          }
        });
    _timeoutSlider.setValue(0);
    _delaySlider.addChangeListener(new SliderListener(_delaySlider, _delayLabel));
    _delaySlider.setValue(0);

    GridBagConstraints gridBagConstraints;

    cp.setMaximumSize(null);
    cp.setPreferredSize(null);
    cp.setLayout(new GridBagLayout());

    l1.setText("Hostname");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    cp.add(l1, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(5, 0, 5, 5);
    cp.add(_hostname, gridBagConstraints);

    l2.setText("Mode");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l2, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 0, 5, 5);
    cp.add(_mode, gridBagConstraints);

    l3.setText("Timeout");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l3, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    cp.add(_timeoutSlider, gridBagConstraints);

    _timeoutLabel.setMinimumSize(new Dimension(20, 17));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_timeoutLabel, gridBagConstraints);

    l4.setText("Delay");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l4, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    cp.add(_delaySlider, gridBagConstraints);

    _delayLabel.setMinimumSize(new Dimension(20, 17));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_delayLabel, gridBagConstraints);

    _hello.setText("Hello World!");
    buttonPanel.add(_hello);

    _shutdown.setText("Shutdown");
    buttonPanel.add(_shutdown);

    _flush.setText("Flush");
    buttonPanel.add(_flush);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.ipady = 5;
    cp.add(buttonPanel, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(statusPanelSeparator, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_status, gridBagConstraints);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    _shutdownHook =
        new Thread("Shutdown hook") {
          @Override
          public void run() {
            destroyCommunicator();
          }
        };

    try {
      Runtime.getRuntime().addShutdownHook(_shutdownHook);
    } catch (IllegalStateException e) {
      //
      // Shutdown in progress, ignored
      //
    }

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            destroyCommunicator();
            Runtime.getRuntime().removeShutdownHook(_shutdownHook);
            dispose();
            Runtime.getRuntime().exit(0);
          }
        });

    setTitle("Ice - Hello World!");
    pack();
    locateOnScreen(this);
    setVisible(true);
  }
Ejemplo n.º 21
0
  private void initialize() {
    setName("NewsPanel");
    setLayout(new GridBagLayout());
    refreshLanguage();

    // We create the components
    new TextComponentClipboardMenu(uploadPrioTextField, language);
    new TextComponentClipboardMenu(downloadPrioTextField, language);
    new TextComponentClipboardMenu(displayDaysTextField, language);
    new TextComponentClipboardMenu(downloadDaysTextField, language);
    new TextComponentClipboardMenu(messageBaseTextField, language);
    new TextComponentClipboardMenu(minimumIntervalTextField, language);
    new TextComponentClipboardMenu(concurrentUpdatesTextField, language);
    new TextComponentClipboardMenu(altEditTextField, language);

    // Adds all of the components
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.weighty = 0.0;
    constraints.weightx = 0;

    constraints.insets = new Insets(0, 5, 5, 5);
    constraints.gridy = 0;

    constraints.gridx = 0;
    add(displayDaysLabel, constraints);
    constraints.gridx = 1;
    add(displayDaysTextField, constraints);

    constraints.gridx = 0;
    constraints.gridy++;
    add(downloadDaysLabel, constraints);
    constraints.gridx = 1;
    add(downloadDaysTextField, constraints);

    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridwidth = 2;
    add(alwaysDownloadBackloadCheckBox, constraints);
    constraints.gridwidth = 1;

    constraints.gridx = 0;
    constraints.gridy++;
    add(messageBaseLabel, constraints);
    constraints.gridx = 1;
    add(messageBaseTextField, constraints);

    constraints.gridy++;
    constraints.gridx = 0;
    add(uploadPrioLabel, constraints);
    constraints.gridx = 1;
    add(uploadPrioTextField, constraints);

    constraints.gridy++;
    constraints.gridx = 0;
    add(downloadPrioLabel, constraints);
    constraints.gridx = 1;
    add(downloadPrioTextField, constraints);
    constraints.gridx = 0;

    constraints.gridwidth = 2;

    constraints.gridy++;
    add(automaticBoardUpdateCheckBox, constraints);

    constraints.gridy++;
    add(getUpdatePanel(), constraints);

    constraints.gridy++;
    add(useOneConnectionForMessagesCheckBox, constraints);

    constraints.gridy++;
    add(storeSentMessagesCheckBox, constraints);

    constraints.gridy++;
    add(silentlyRetryCheckBox, constraints);

    constraints.gridwidth = 1;

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

    constraints.gridy++;
    constraints.gridx = 0;
    add(altEditCheckBox, constraints);
    constraints.gridx = 1;
    constraints.weightx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    add(altEditTextField, constraints);
    constraints.weightx = 0;
    constraints.fill = GridBagConstraints.NONE;

    // glue
    constraints.gridy++;
    constraints.gridx = 0;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;
    constraints.weighty = 1;
    add(new JLabel(""), constraints);

    // Add listeners
    automaticBoardUpdateCheckBox.addActionListener(listener);
    altEditCheckBox.addChangeListener(listener);
  }
Ejemplo n.º 22
0
  private <T extends Enum<T>> void createControls(JPanel panel, ZrtpConfigureTableModel<T> model) {
    ResourceManagementService resources = NeomediaActivator.getResources();

    final JButton upButton = new JButton(resources.getI18NString("impl.media.configform.UP"));
    upButton.setOpaque(false);

    final JButton downButton = new JButton(resources.getI18NString("impl.media.configform.DOWN"));
    downButton.setOpaque(false);

    Container buttonBar = new TransparentPanel(new GridLayout(0, 1));
    buttonBar.add(upButton);
    buttonBar.add(downButton);

    panel.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));
    panel.setLayout(new GridBagLayout());

    final JTable table = new JTable(model.getRowCount(), 2);
    table.setShowGrid(false);
    table.setTableHeader(null);
    table.setModel(model);
    // table.setFillsViewportHeight(true); // Since 1.6 only - nicer view

    /*
     * The first column contains the check boxes which enable/disable their
     * associated encodings and it doesn't make sense to make it wider than
     * the check boxes.
     */
    TableColumnModel tableColumnModel = table.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth() + 5);
    table.doLayout();

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    panel.add(new JScrollPane(table), constraints);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridwidth = 1;
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    panel.add(buttonBar, constraints);

    ListSelectionListener tableSelectionListener =
        new ListSelectionListener() {
          @SuppressWarnings("unchecked")
          public void valueChanged(ListSelectionEvent event) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getSelectionModel().addListSelectionListener(tableSelectionListener);

    TableModelListener tableListener =
        new TableModelListener() {
          @SuppressWarnings("unchecked")
          public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getModel().addTableModelListener(tableListener);

    tableSelectionListener.valueChanged(null);

    ActionListener buttonListener =
        new ActionListener() {
          @SuppressWarnings("unchecked")
          public void actionPerformed(ActionEvent event) {
            Object source = event.getSource();
            boolean up;
            if (source == upButton) up = true;
            else if (source == downButton) up = false;
            else return;

            int index =
                ((ZrtpConfigureTableModel<T>) table.getModel())
                    .move(table.getSelectedRow(), up, up);
            table.getSelectionModel().setSelectionInterval(index, index);
          }
        };
    upButton.addActionListener(buttonListener);
    downButton.addActionListener(buttonListener);
  }
  public WizStepManyTextFields(Wizard w, String instr, Vector strings) {
    // store wizard?
    _instructions.setText(instr);
    _instructions.setWrapStyleWord(true);
    _instructions.setEditable(false);
    _instructions.setBorder(null);
    _instructions.setBackground(_mainPanel.getBackground());

    _mainPanel.setBorder(new EtchedBorder());

    GridBagLayout gb = new GridBagLayout();
    _mainPanel.setLayout(gb);

    GridBagConstraints c = new GridBagConstraints();
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.EAST;

    JLabel image = new JLabel("");
    // image.setMargin(new Insets(0, 0, 0, 0));
    image.setIcon(WIZ_ICON);
    image.setBorder(null);
    c.gridx = 0;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridy = 0;
    c.anchor = GridBagConstraints.NORTH;
    gb.setConstraints(image, c);
    _mainPanel.add(image);

    c.weightx = 0.0;
    c.gridx = 2;
    c.gridheight = 1;
    c.gridwidth = 3;
    c.gridy = 0;
    c.fill = GridBagConstraints.NONE;
    gb.setConstraints(_instructions, c);
    _mainPanel.add(_instructions);

    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer = new SpacerPanel();
    gb.setConstraints(spacer, c);
    _mainPanel.add(spacer);

    c.gridx = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    int size = strings.size();
    for (int i = 0; i < size; i++) {
      c.gridy = 2 + i;
      String s = (String) strings.elementAt(i);
      JTextField tf = new JTextField(s, 50);
      tf.setMinimumSize(new Dimension(200, 20));
      tf.getDocument().addDocumentListener(this);
      _fields.addElement(tf);
      gb.setConstraints(tf, c);
      _mainPanel.add(tf);
    }

    c.gridx = 1;
    c.gridy = 3 + strings.size();
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer2 = new SpacerPanel();
    gb.setConstraints(spacer2, c);
    _mainPanel.add(spacer2);
  }
  /**
   * Initialize the frame.
   *
   * @param info true if additional information is desired
   */
  private void init(boolean info) {
    _buttonPressed = null;
    addComponentListener(
        new java.awt.event.ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            validate();
            _matchList.ensureIndexIsVisible(_matchList.getSelectedIndex());
          }
        });

    // buttons
    int i = 0;
    for (final CloseAction<T> a : _actions) {
      _buttons[i] = new JButton(a.getName());
      final String tooltip = a.getToolTipText();
      if (tooltip != null) {
        _buttons[i].setToolTipText(tooltip);
      }
      _buttons[i].addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              buttonPressed(a);
            }
          });
      ++i;
    }

    getRootPane().setDefaultButton(_buttons[0]);

    _strategyBox.setEditable(false);
    _strategyBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // System.out.println("set strategy!");
            selectStrategy();
          }
        });
    _strategyBox.addFocusListener(
        new FocusAdapter() {

          public void focusLost(FocusEvent e) {
            boolean bf = false;
            for (JButton b : _buttons) {
              if (e.getOppositeComponent() == b) {
                bf = true;
                break;
              }
            }
            if ((e.getOppositeComponent() != _textField) && (!bf)) {
              for (JComponent c : _optionalComponents) {
                if (e.getOppositeComponent() == c) {
                  return;
                }
              }
              _textField.requestFocus();
            }
          }
        });

    // text field
    _textField.setDragEnabled(false);
    _textField.setFocusTraversalKeysEnabled(false);

    addListener();

    Keymap ourMap =
        JTextComponent.addKeymap("PredictiveInputFrame._textField", _textField.getKeymap());
    for (final CloseAction<T> a : _actions) {
      KeyStroke ks = a.getKeyStroke();
      if (ks != null) {
        ourMap.addActionForKeyStroke(
            ks,
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                buttonPressed(a);
              }
            });
      }
    }
    ourMap.addActionForKeyStroke(
        KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            //        System.out.println("tab!");
            removeListener();
            _pim.extendSharedMask();
            updateTextField();
            updateExtensionLabel();
            updateList();
            addListener();
          }
        });
    ourMap.addActionForKeyStroke(
        KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            //        System.out.println("up!");
            if (_matchList.getModel().getSize() > 0) {
              removeListener();
              int i = _matchList.getSelectedIndex();
              if (i > 0) {
                _matchList.setSelectedIndex(i - 1);
                _matchList.ensureIndexIsVisible(i - 1);
                _pim.setCurrentItem(_pim.getMatchingItems().get(i - 1));
                updateInfo();
              }
              addListener();
            }
          }
        });
    ourMap.addActionForKeyStroke(
        KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            //        System.out.println("down!");
            if (_matchList.getModel().getSize() > 0) {
              removeListener();
              int i = _matchList.getSelectedIndex();
              if (i < _matchList.getModel().getSize() - 1) {
                _matchList.setSelectedIndex(i + 1);
                _matchList.ensureIndexIsVisible(i + 1);
                _pim.setCurrentItem(_pim.getMatchingItems().get(i + 1));
                updateInfo();
              }
              addListener();
            }
          }
        });
    ourMap.addActionForKeyStroke(
        KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            //        System.out.println("page up!");
            if (_matchList.getModel().getSize() > 0) {
              removeListener();
              int page = _matchList.getLastVisibleIndex() - _matchList.getFirstVisibleIndex() + 1;
              int i = _matchList.getSelectedIndex() - page;
              if (i < 0) i = 0;
              _matchList.setSelectedIndex(i);
              _matchList.ensureIndexIsVisible(i);
              _pim.setCurrentItem(_pim.getMatchingItems().get(i));
              updateInfo();
              addListener();
            }
          }
        });
    ourMap.addActionForKeyStroke(
        KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            //        System.out.println("page down!");
            if (_matchList.getModel().getSize() > 0) {
              removeListener();
              int page = _matchList.getLastVisibleIndex() - _matchList.getFirstVisibleIndex() + 1;
              int i = _matchList.getSelectedIndex() + page;
              if (i >= _matchList.getModel().getSize()) {
                i = _matchList.getModel().getSize() - 1;
              }
              _matchList.setSelectedIndex(i);
              _matchList.ensureIndexIsVisible(i);
              _pim.setCurrentItem(_pim.getMatchingItems().get(i));
              updateInfo();
              addListener();
            }
          }
        });
    _textField.setKeymap(ourMap);

    _textField.addFocusListener(
        new FocusAdapter() {
          public void focusLost(FocusEvent e) {
            boolean bf = false;
            for (JButton b : _buttons) {
              if (e.getOppositeComponent() == b) {
                bf = true;
                break;
              }
            }
            if ((e.getOppositeComponent() != _strategyBox) && (!bf)) {
              for (JComponent c : _optionalComponents) {
                if (e.getOppositeComponent() == c) {
                  return;
                }
              }
              _textField.requestFocus();
            }
          }
        });

    _matchList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _matchList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            //        System.out.println("click!");
            removeListener();
            int i = _matchList.getSelectedIndex();
            if (i >= 0) {
              _pim.setCurrentItem(_pim.getMatchingItems().get(i));
              _matchList.ensureIndexIsVisible(i);
              updateInfo();
            }
            addListener();
          }
        });

    // put everything together
    Container contentPane = getContentPane();

    GridBagLayout layout = new GridBagLayout();
    contentPane.setLayout(layout);

    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST;
    c.weightx = 1.0;
    c.weighty = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER; // end row
    c.insets.top = 2;
    c.insets.left = 2;
    c.insets.bottom = 2;
    c.insets.right = 2;

    if (info) {
      c.fill = GridBagConstraints.NONE;
      contentPane.add(_infoLabel, c);
    }

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    contentPane.add(
        new JScrollPane(
            _matchList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED),
        c);

    c.anchor = GridBagConstraints.SOUTHWEST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    contentPane.add(_tabCompletesLabel, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    contentPane.add(_sharedExtLabel, c);

    contentPane.add(_textField, c);

    _optionalComponents = makeOptions();
    if (_optionalComponents.length > 0) {
      _optionsPanel = new JPanel(new BorderLayout());
      _setupOptionsPanel(_optionalComponents);
      contentPane.add(_optionsPanel, c);
    }

    c.anchor = GridBagConstraints.SOUTHWEST;
    c.weightx = 1.0;
    c.weighty = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER; // end row
    c.insets.top = 2;
    c.insets.left = 2;
    c.insets.bottom = 2;
    c.insets.right = 2;

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints bc = new GridBagConstraints();
    bc.insets.left = 2;
    bc.insets.right = 2;
    buttonPanel.add(new JLabel("Matching strategy:"), bc);
    buttonPanel.add(_strategyBox, bc);
    for (JButton b : _buttons) {
      buttonPanel.add(b, bc);
    }

    contentPane.add(buttonPanel, c);

    pack();
    //    Dimension parentDim = (_owner != null) ? _owner.getSize() : getToolkit().getScreenSize();
    //// int xs = (int) parentDim.getWidth()/3;
    //    int ys = (int) parentDim.getHeight()/4;
    //// in line below, parentDim was _owner.getSize(); changed because former could generate
    // NullPointerException
    //    setSize(new Dimension((int) getSize().getWidth(), (int)Math.min(parentDim.getHeight(),
    // Math.max(ys, 300))));
    if (_owner != null) {
      setLocationRelativeTo(_owner);
    }

    removeListener();
    updateTextField();
    addListener();
    updateList();
  }
Ejemplo n.º 25
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);
  }
Ejemplo n.º 26
0
  private void initComponents() {
    setLayout(new BorderLayout());
    final JPanel mainPanel = new TransparentPanel();
    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;

    // general encryption option
    enableDefaultEncryption =
        new SIPCommCheckBox(
            UtilActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"),
            regform.isDefaultEncryption());
    enableDefaultEncryption.addActionListener(this);
    mainPanel.add(enableDefaultEncryption, c);

    // warning message and button to show advanced options
    JLabel lblWarning = new JLabel();
    lblWarning.setBorder(new EmptyBorder(10, 5, 10, 0));
    lblWarning.setText(
        UtilActivator.getResources()
            .getI18NString(
                "plugin.sipaccregwizz.SECURITY_WARNING",
                new String[] {
                  UtilActivator.getResources().getSettingsString("service.gui.APPLICATION_NAME")
                }));
    c.gridy++;
    mainPanel.add(lblWarning, c);

    cmdExpandAdvancedSettings = new JLabel();
    cmdExpandAdvancedSettings.setBorder(new EmptyBorder(0, 5, 0, 0));
    cmdExpandAdvancedSettings.setIcon(
        UtilActivator.getResources().getImage("service.gui.icons.RIGHT_ARROW_ICON"));
    cmdExpandAdvancedSettings.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SHOW_ADVANCED"));
    cmdExpandAdvancedSettings.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            cmdExpandAdvancedSettings.setIcon(
                UtilActivator.getResources()
                    .getImage(
                        pnlAdvancedSettings.isVisible()
                            ? "service.gui.icons.RIGHT_ARROW_ICON"
                            : "service.gui.icons.DOWN_ARROW_ICON"));

            pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible());

            pnlAdvancedSettings.revalidate();
          }
        });
    c.gridy++;
    mainPanel.add(cmdExpandAdvancedSettings, c);

    pnlAdvancedSettings = new TransparentPanel();
    pnlAdvancedSettings.setLayout(new GridBagLayout());
    pnlAdvancedSettings.setVisible(false);
    c.gridy++;
    mainPanel.add(pnlAdvancedSettings, c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    pnlAdvancedSettings.add(new JSeparator(), c);

    // Encryption protcol preferences.
    JLabel lblEncryptionProtocolPreferences = new JLabel();
    lblEncryptionProtocolPreferences.setText(
        UtilActivator.getResources()
            .getI18NString("plugin.sipaccregwizz.ENCRYPTION_PROTOCOL_PREFERENCES"));
    c.gridy++;
    pnlAdvancedSettings.add(lblEncryptionProtocolPreferences, c);

    int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length;
    String[] encryptions = new String[nbEncryptionProtocols];
    boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols];

    this.encryptionConfigurationTableModel =
        new EncryptionConfigurationTableModel(encryptions, selectedEncryptions);
    loadEncryptionProtocols(new HashMap<String, Integer>(), new HashMap<String, Boolean>());
    this.encryptionProtocolPreferences =
        new PriorityTable(this.encryptionConfigurationTableModel, 60);
    this.encryptionConfigurationTableModel.addTableModelListener(this);
    c.gridy++;
    pnlAdvancedSettings.add(this.encryptionProtocolPreferences, c);

    // ZRTP
    JLabel lblZrtpOption = new JLabel();
    lblZrtpOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblZrtpOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.ZRTP_OPTION"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    pnlAdvancedSettings.add(lblZrtpOption, c);
    c.gridx = 1;
    pnlAdvancedSettings.add(new JSeparator(), c);

    enableSipZrtpAttribute =
        new SIPCommCheckBox(
            UtilActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"),
            regform.isSipZrtpAttribute());
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    pnlAdvancedSettings.add(enableSipZrtpAttribute, c);

    // SDES
    JLabel lblSDesOption = new JLabel();
    lblSDesOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblSDesOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SDES_OPTION"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    pnlAdvancedSettings.add(lblSDesOption, c);
    c.gridx = 1;
    pnlAdvancedSettings.add(new JSeparator(), c);

    JLabel lblCipherInfo = new JLabel();
    lblCipherInfo.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.CIPHER_SUITES"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    pnlAdvancedSettings.add(lblCipherInfo, c);

    cipherModel = new CipherTableModel(regform.getSDesCipherSuites());
    tabCiphers = new JTable(cipherModel);
    tabCiphers.setShowGrid(false);
    tabCiphers.setTableHeader(null);
    TableColumnModel tableColumnModel = tabCiphers.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth());
    JScrollPane scrollPane = new JScrollPane(tabCiphers);
    scrollPane.setPreferredSize(new Dimension(tabCiphers.getWidth(), 100));
    c.gridy++;
    pnlAdvancedSettings.add(scrollPane, c);

    // SAVP selection
    c.gridx = 0;
    c.gridwidth = 1;
    JLabel lblSavpOption = new JLabel();
    lblSavpOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblSavpOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SAVP_OPTION"));
    if (this.displaySavpOtions) {
      c.gridy++;
      pnlAdvancedSettings.add(lblSavpOption, c);
    }
    c.gridx = 1;
    if (this.displaySavpOtions) {
      pnlAdvancedSettings.add(new JSeparator(), c);
    }

    cboSavpOption =
        new JComboBox(new SavpOption[] {new SavpOption(0), new SavpOption(1), new SavpOption(2)});
    c.gridx = 0;
    c.gridwidth = 2;
    c.insets = new Insets(0, 20, 0, 0);
    if (this.displaySavpOtions) {
      c.gridy++;
      pnlAdvancedSettings.add(cboSavpOption, c);
    }
  }