예제 #1
0
 @Nls
 private String ringVolumeTooltip(Settings uiModel) {
   if (uiModel.getRingVolume() == 0) {
     return UIBundle.message("settings.ringSlider.noSoundTooltip");
   } else {
     return UIBundle.message("settings.ringSlider.volumeTooltip", uiModel.getRingVolume());
   }
 }
예제 #2
0
 private void setupUIBindings() {
   lastUIRingVolume = uiModel.getRingVolume();
   final ActionListener actionListener =
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent event) {
           updateUIModel();
           updateUI();
         }
       };
   ChangeListener changeListener =
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           actionListener.actionPerformed(null);
         }
       };
   settingsForm.pomodoroLengthComboBox.addActionListener(actionListener);
   settingsForm.breakLengthComboBox.addActionListener(actionListener);
   settingsForm.popupCheckBox.addChangeListener(changeListener);
   settingsForm.blockDuringBreak.addChangeListener(changeListener);
   settingsForm.ringVolumeSlider.addChangeListener(changeListener);
   settingsForm.showToolWindowCheckbox.addChangeListener(changeListener);
   settingsForm.showTimeInToolbarWidgetCheckbox.addChangeListener(changeListener);
 }
예제 #3
0
  private void updateUI() {
    if (uiResourcesDisposed()) return;
    if (updatingUI) return;
    updatingUI = true;

    settingsForm
        .pomodoroLengthComboBox
        .getModel()
        .setSelectedItem(String.valueOf(uiModel.getPomodoroLengthInMinutes()));
    settingsForm
        .breakLengthComboBox
        .getModel()
        .setSelectedItem(String.valueOf(uiModel.getBreakLengthInMinutes()));

    settingsForm.ringVolumeSlider.setValue(uiModel.getRingVolume());
    settingsForm.ringVolumeSlider.setToolTipText(ringVolumeTooltip(uiModel));

    settingsForm.popupCheckBox.setSelected(uiModel.isPopupEnabled());
    settingsForm.blockDuringBreak.setSelected(uiModel.isBlockDuringBreak());
    settingsForm.showToolWindowCheckbox.setSelected(uiModel.isShowToolWindow());
    settingsForm.showTimeInToolbarWidgetCheckbox.setSelected(uiModel.isShowTimeInToolbarWidget());

    updatingUI = false;
  }
예제 #4
0
 @Override
 public void apply() throws ConfigurationException {
   settings.loadState(uiModel);
 }
예제 #5
0
 public boolean isModified() {
   return !uiModel.equals(settings);
 }
예제 #6
0
  private void updateUIModel() {
    if (uiResourcesDisposed()) return;
    if (updatingUI) return;

    try {
      uiModel.setPomodoroLengthInMinutes(
          selectedItemAsInteger(settingsForm.pomodoroLengthComboBox));
    } catch (NumberFormatException e) {
      uiModel.setPomodoroLengthInMinutes(Settings.DEFAULT_POMODORO_LENGTH);
    }

    try {
      uiModel.setBreakLengthInMinutes(selectedItemAsInteger(settingsForm.breakLengthComboBox));
    } catch (NumberFormatException e) {
      uiModel.setBreakLengthInMinutes(Settings.DEFAULT_BREAK_LENGTH);
    }

    uiModel.setRingVolume(settingsForm.ringVolumeSlider.getValue());
    if (lastUIRingVolume != uiModel.getRingVolume()) {
      lastUIRingVolume = uiModel.getRingVolume();
      ringSound.play(uiModel.getRingVolume());
    }

    uiModel.setPopupEnabled(settingsForm.popupCheckBox.isSelected());
    uiModel.setBlockDuringBreak(settingsForm.blockDuringBreak.isSelected());
    uiModel.setShowToolWindow(settingsForm.showToolWindowCheckbox.isSelected());
    uiModel.setShowTimeInToolbarWidget(settingsForm.showTimeInToolbarWidgetCheckbox.isSelected());
  }
예제 #7
0
 @Override
 public void reset() {
   uiModel.loadState(settings);
   updateUI();
 }