@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()); } }
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); }
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; }
@Override public void apply() throws ConfigurationException { settings.loadState(uiModel); }
public boolean isModified() { return !uiModel.equals(settings); }
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()); }
@Override public void reset() { uiModel.loadState(settings); updateUI(); }