@Override
 public Dimension getPreferredSize() {
   Dimension dimension = super.getPreferredSize();
   if (getText() == null || getText().isEmpty()) {
     setText("Roots");
     dimension.height = super.getPreferredSize().height;
     setText("");
     return dimension;
   }
   return dimension;
 }
Exemplo n.º 2
0
    /**
     * Sets readable text describing the resolution if the selected value is null we return the
     * string "Auto".
     *
     * @param list
     * @param value
     * @param index
     * @param isSelected
     * @param cellHasFocus
     * @return Component
     */
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      // call super to set backgrounds and fonts
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      // now just change the text
      if (value == null) setText("Auto");
      else if (value instanceof Dimension) {
        Dimension d = (Dimension) value;

        setText(((int) d.getWidth()) + "x" + ((int) d.getHeight()));
      }
      return this;
    }
Exemplo n.º 3
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
Exemplo n.º 4
0
  public FileNameRenderer(JTable table) {
    Border b = UIManager.getBorder("Table.noFocusBorder");
    if (Objects.isNull(b)) { // Nimbus???
      Insets i = focusCellHighlightBorder.getBorderInsets(textLabel);
      b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right);
    }
    noFocusBorder = b;

    p.setOpaque(false);
    panel.setOpaque(false);

    // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons
    nicon = new ImageIcon(getClass().getResource("wi0063-16.png"));
    sicon =
        new ImageIcon(
            p.createImage(
                new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter())));

    iconLabel = new JLabel(nicon);
    iconLabel.setBorder(BorderFactory.createEmptyBorder());

    p.add(iconLabel, BorderLayout.WEST);
    p.add(textLabel);
    panel.add(p, BorderLayout.WEST);

    Dimension d = iconLabel.getPreferredSize();
    dim.setSize(d);
    table.setRowHeight(d.height);
  }
Exemplo n.º 5
0
 // Set the width/height of columns/rows by the largest rendering entry
 private void customiseMinimumDimensions(Dimension dim, int row, int column) {
   TableColumn tableColumn = getColumnModel().getColumn(column);
   // this required extra margin padding is a mystery to me...
   dim.setSize(dim.width + getColumnMargin(), dim.height + getRowMargin());
   // potential bug: refresh() is needed to reduce size of unusually large temporary entries
   if (tableColumn.getWidth() < dim.width) {
     tableColumn.setMinWidth(dim.width);
     if (column == 0) {
       tableColumn.setMaxWidth(dim.width);
     }
   }
   if (getRowHeight(row) < dim.height) {
     setRowHeight(row, dim.height);
   }
 }
Exemplo n.º 6
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;
  }
 /** Constructor (create and layout page) */
 public SOAPMonitorPage(String host_name) {
   host = host_name;
   // Set up default filter (show all messages)
   filter = new SOAPMonitorFilter();
   // Use borders to help improve appearance
   etched_border = new EtchedBorder();
   // Build top portion of split (list panel)
   model = new SOAPMonitorTableModel();
   table = new JTable(model);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table.setRowSelectionInterval(0, 0);
   table.setPreferredScrollableViewportSize(new Dimension(600, 96));
   table.getSelectionModel().addListSelectionListener(this);
   scroll = new JScrollPane(table);
   remove_button = new JButton("Remove");
   remove_button.addActionListener(this);
   remove_button.setEnabled(false);
   remove_all_button = new JButton("Remove All");
   remove_all_button.addActionListener(this);
   filter_button = new JButton("Filter ...");
   filter_button.addActionListener(this);
   list_buttons = new JPanel();
   list_buttons.setLayout(new FlowLayout());
   list_buttons.add(remove_button);
   list_buttons.add(remove_all_button);
   list_buttons.add(filter_button);
   list_panel = new JPanel();
   list_panel.setLayout(new BorderLayout());
   list_panel.add(scroll, BorderLayout.CENTER);
   list_panel.add(list_buttons, BorderLayout.SOUTH);
   list_panel.setBorder(empty_border);
   // Build bottom portion of split (message details)
   details_time = new JLabel("Time: ", SwingConstants.RIGHT);
   details_target = new JLabel("Target Service: ", SwingConstants.RIGHT);
   details_status = new JLabel("Status: ", SwingConstants.RIGHT);
   details_time_value = new JLabel();
   details_target_value = new JLabel();
   details_status_value = new JLabel();
   Dimension preferred_size = details_time.getPreferredSize();
   preferred_size.width = 1;
   details_time.setPreferredSize(preferred_size);
   details_target.setPreferredSize(preferred_size);
   details_status.setPreferredSize(preferred_size);
   details_time_value.setPreferredSize(preferred_size);
   details_target_value.setPreferredSize(preferred_size);
   details_status_value.setPreferredSize(preferred_size);
   details_header = new JPanel();
   details_header_layout = new GridBagLayout();
   details_header.setLayout(details_header_layout);
   details_header_constraints = new GridBagConstraints();
   details_header_constraints.fill = GridBagConstraints.BOTH;
   details_header_constraints.weightx = 0.5;
   details_header_layout.setConstraints(details_time, details_header_constraints);
   details_header.add(details_time);
   details_header_layout.setConstraints(details_time_value, details_header_constraints);
   details_header.add(details_time_value);
   details_header_layout.setConstraints(details_target, details_header_constraints);
   details_header.add(details_target);
   details_header_constraints.weightx = 1.0;
   details_header_layout.setConstraints(details_target_value, details_header_constraints);
   details_header.add(details_target_value);
   details_header_constraints.weightx = .5;
   details_header_layout.setConstraints(details_status, details_header_constraints);
   details_header.add(details_status);
   details_header_layout.setConstraints(details_status_value, details_header_constraints);
   details_header.add(details_status_value);
   details_header.setBorder(etched_border);
   request_label = new JLabel("SOAP Request", SwingConstants.CENTER);
   request_text = new SOAPMonitorTextArea();
   request_text.setEditable(false);
   request_scroll = new JScrollPane(request_text);
   request_panel = new JPanel();
   request_panel.setLayout(new BorderLayout());
   request_panel.add(request_label, BorderLayout.NORTH);
   request_panel.add(request_scroll, BorderLayout.CENTER);
   response_label = new JLabel("SOAP Response", SwingConstants.CENTER);
   response_text = new SOAPMonitorTextArea();
   response_text.setEditable(false);
   response_scroll = new JScrollPane(response_text);
   response_panel = new JPanel();
   response_panel.setLayout(new BorderLayout());
   response_panel.add(response_label, BorderLayout.NORTH);
   response_panel.add(response_scroll, BorderLayout.CENTER);
   details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
   details_soap.setTopComponent(request_panel);
   details_soap.setRightComponent(response_panel);
   details_soap.setResizeWeight(.5);
   details_panel = new JPanel();
   layout_button = new JButton("Switch Layout");
   layout_button.addActionListener(this);
   reflow_xml = new JCheckBox("Reflow XML text");
   reflow_xml.addActionListener(this);
   details_buttons = new JPanel();
   details_buttons.setLayout(new FlowLayout());
   details_buttons.add(reflow_xml);
   details_buttons.add(layout_button);
   details_panel.setLayout(new BorderLayout());
   details_panel.add(details_header, BorderLayout.NORTH);
   details_panel.add(details_soap, BorderLayout.CENTER);
   details_panel.add(details_buttons, BorderLayout.SOUTH);
   details_panel.setBorder(empty_border);
   // Add the two parts to the age split pane
   split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
   split.setTopComponent(list_panel);
   split.setRightComponent(details_panel);
   // Build status area
   start_button = new JButton("Start");
   start_button.addActionListener(this);
   stop_button = new JButton("Stop");
   stop_button.addActionListener(this);
   status_buttons = new JPanel();
   status_buttons.setLayout(new FlowLayout());
   status_buttons.add(start_button);
   status_buttons.add(stop_button);
   status_text = new JLabel();
   status_text.setBorder(new BevelBorder(BevelBorder.LOWERED));
   status_text_panel = new JPanel();
   status_text_panel.setLayout(new BorderLayout());
   status_text_panel.add(status_text, BorderLayout.CENTER);
   status_text_panel.setBorder(empty_border);
   status_area = new JPanel();
   status_area.setLayout(new BorderLayout());
   status_area.add(status_buttons, BorderLayout.WEST);
   status_area.add(status_text_panel, BorderLayout.CENTER);
   status_area.setBorder(etched_border);
   // Add the split and status area to page
   setLayout(new BorderLayout());
   add(split, BorderLayout.CENTER);
   add(status_area, BorderLayout.SOUTH);
 }