public void hideTime() {
   mMaxXTLabel.setEnabled(false);
   mMinXTLabel.setEnabled(false);
   mMaxXLabel.setEnabled(true);
   mMinXLabel.setEnabled(true);
   mIncLabel.setEnabled(true);
   xMin.setEnabled(true);
   xMax.setEnabled(true);
   xInc.setEnabled(true);
   mStartSpinner.setEnabled(false);
   mEndSpinner.setEnabled(false);
   xTics.setEnabled(true);
   mPlotXGrid.setEnabled(true);
   mXIncLabel.setEnabled(true);
 }
  /** {@inheritDoc} */
  public void setEnabled(boolean b) {
    if (b != isEnabled()) {
      super.setEnabled(b);

      if ((selectedComponents & DISPLAY_DATE) > 0) {
        yearDecrButton.setEnabled(b);
        monthDecrButton.setEnabled(b);
        monthYearLabel.setEnabled(b);
        monthIncrButton.setEnabled(b);
        yearIncrButton.setEnabled(b);

        for (int day = 0; day < 7; day++) {
          dayOfWeekLabels[day].setEnabled(b);
        }

        for (int row = 0; row < 6; row++) {
          for (int day = 0; day < 7; day++) {
            if (dayButtons[row][day].getText().length() > 0) {
              dayButtons[row][day].setEnabled(b);
            }
          }
        }
      }

      if ((selectedComponents & DISPLAY_TIME) > 0) {
        spinner.setEnabled(b);
      }
    }
  }
  /** Update the calendar panel to display the currently selected date. */
  private void updateCalendarComponents() {
    if ((selectedComponents & DISPLAY_DATE) > 0) {

      // Unselect all visible dates

      offScreenButton.setSelected(true);

      // Get the display date. We only need the month and year

      displayMonth = displayCalendar.get(Calendar.MONTH);
      displayYear = displayCalendar.get(Calendar.YEAR);

      // Get the localized display month name and year

      String month = formatMonth.format(displayCalendar.getTime());
      String year = Integer.toString(displayYear);

      {
        Object[] args = {month, year};
        monthYearLabel.setText(MessageFormat.format(bundle.getString("MonthYearTitle"), args));
      }

      // If the month or year have changed, we need to re-lay out
      // the days. Otherwise, we don't

      if (!month.equals(lastMonth) || !year.equals(lastYear)) {

        // Create a temporary calendar that we will use to
        // determine where day 1 goes and how many days there are
        // in this month

        Calendar temp = (Calendar) displayCalendar.clone();
        temp.set(Calendar.DATE, 1);

        int dayOfWeek = temp.get(Calendar.DAY_OF_WEEK);
        int firstDay = temp.getFirstDayOfWeek();

        // Determine how many blank slots occur before day 1 of this
        // month

        int dayPtr;
        for (dayPtr = 0; dayPtr < 7; dayPtr++) {
          int curDay = ((firstDay - 1) + dayPtr) % 7 + 1;
          if (curDay != dayOfWeek) {
            dayButtons[0][dayPtr].setText("");
            dayButtons[0][dayPtr].setEnabled(false);
          } else {
            break;
          }
        }

        // Determine the number of days in this month

        int maxDays = temp.getActualMaximum(Calendar.DATE);

        // Fill in the days

        int row = 0;
        for (int day = 1; day <= maxDays; day++) {
          dayButtons[row][dayPtr].setText(Integer.toString(day));
          dayButtons[row][dayPtr].setEnabled(true);

          // If this is the selected date, select the button;
          // otherwise, deselect it

          if (day == selectedDay && displayMonth == selectedMonth && displayYear == selectedYear) {
            dayButtons[row][dayPtr].setSelected(true);
          } else {
            dayButtons[row][dayPtr].getModel().setSelected(false);
          }

          // Wrap as needed

          dayPtr = (dayPtr + 1) % 7;
          if (dayPtr == 0) row++;
        }

        // Set the blanks slots after the last day

        while (row < 6) {
          dayButtons[row][dayPtr].setText("");
          dayButtons[row][dayPtr].setEnabled(false);
          dayButtons[row][dayPtr].getModel().setSelected(false);
          dayPtr = (dayPtr + 1) % 7;
          if (dayPtr == 0) row++;
        }
      }
    }

    // Update the time component, if displayed

    if ((selectedComponents & DISPLAY_TIME) > 0) {

      // If no date is selected, we set the date used by the time
      // field to today @ noon. We also make the field insensitive
      // -- the user must pick a non-null date before being able to
      // change the time (unless all we have is a time field)

      if (isNullDate) {
        Calendar temp = (Calendar) selectedCalendar.clone();
        temp.setTime(new Date());
        temp.set(Calendar.HOUR, 12);
        temp.set(Calendar.MINUTE, 0);
        temp.set(Calendar.SECOND, 0);
        spinnerDateModel.setValue(temp.getTime());
        spinner.setEnabled((selectedComponents & DISPLAY_DATE) == 0);
      }

      // If a date is selected, use it

      else {
        spinner.setEnabled(JCalendar.this.isEnabled());
        spinnerDateModel.setValue(selectedCalendar.getTime());
        spinnerDateModel.setStart(null);
        spinnerDateModel.setEnd(null);
        spinner.revalidate();
      }
    }
  }
示例#4
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;
  }
 public void setType(String type) {
   if ("Control Change".equals(type)) {
     channel.setEnabled(true);
     cc.setEnabled(true);
     min.setEnabled(true);
     max.setEnabled(true);
     min.setValue(0);
     max.setValue(127);
     modeList.setEnabled(false);
   } else if ("NRPN".equals(type)) {
     channel.setEnabled(true);
     cc.setEnabled(true);
     min.setEnabled(true);
     max.setEnabled(true);
     min.setValue(0);
     max.setValue(127);
     modeList.setEnabled(false);
   } else if ("Pitch Bend".equals(type)) {
     channel.setEnabled(true);
     cc.setEnabled(false);
     min.setEnabled(true);
     max.setEnabled(true);
     min.setValue(-8192);
     max.setValue(8191);
     modeList.setEnabled(false);
   } else if ("Basenote".equals(type)) {
     channel.setEnabled(false);
     cc.setEnabled(false);
     min.setEnabled(true);
     max.setEnabled(true);
     min.setValue(0);
     max.setValue(127);
     modeList.setEnabled(false);
   } else if ("Scale".equals(type)) {
     channel.setEnabled(false);
     cc.setEnabled(false);
     min.setEnabled(false);
     max.setEnabled(false);
     modeList.setEnabled(false);
   } else if ("Mode Change".equals(type)) {
     channel.setEnabled(false);
     cc.setEnabled(false);
     min.setEnabled(false);
     max.setEnabled(false);
     modeList.setEnabled(true);
   } else if ("Unassigned".equals(type)) {
     channel.setEnabled(false);
     cc.setEnabled(false);
     min.setEnabled(false);
     max.setEnabled(false);
     modeList.setEnabled(false);
   }
 }