/*
* Jampa
* Copyright (C) 2008-2009 J. Devauchelle and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
package org.jampa.preferences.pages;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.jampa.Activator;
import org.jampa.controllers.ui.ToolbarController.ToolBarSize;
import org.jampa.gui.translations.Messages;
import org.jampa.preferences.PreferenceConstants;
public class PlayerViewPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
private RadioGroupFieldEditor _toolbarSizeRFE;
BooleanFieldEditor _showToolbarEditor;
public PlayerViewPage() {
super(GRID);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription(Messages.getString("PlayerViewPage.Title")); //$NON-NLS-1$
}
@Override
protected void createFieldEditors() {
Label horizontalLine;
horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
_showToolbarEditor = new BooleanFieldEditor(PreferenceConstants.PLAYERVIEW_SHOW_IN_TOOLBAR,
Messages.getString("PlayerViewPage.ShowInToolbar"), //$NON-NLS-1$
getFieldEditorParent());
addField(_showToolbarEditor);
_toolbarSizeRFE = new RadioGroupFieldEditor(
PreferenceConstants.PLAYERVIEW_TOOLBAR_SIZE,
Messages.getString("PlayerViewPage.ToolbarSize"), //$NON-NLS-1$
1,
new String[][] { { Messages.getString("PlayerViewPage.ToolbarSizeLarge"), ToolBarSize.LARGE.getValue() }, { //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("PlayerViewPage.ToolbarSizeMedium"), ToolBarSize.MEDIUM.getValue() }, { //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("PlayerViewPage.ToolbarSizeSmall"), ToolBarSize.SMALL.getValue() }
}, //$NON-NLS-1$ //$NON-NLS-2$
getFieldEditorParent());
addField(_toolbarSizeRFE);
horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
BooleanFieldEditor useNativeSliderEditor = new BooleanFieldEditor(PreferenceConstants.PLAYERVIEW_USE_NATIVE_SLIDER,
Messages.getString("PlayerViewPage.UseNativeSlider"), //$NON-NLS-1$
getFieldEditorParent());
useNativeSliderEditor.getDescriptionControl(getFieldEditorParent()).setToolTipText((Messages.getString("PlayerViewPage.UseNativeSliderExplanation"))); //$NON-NLS-1$
addField(useNativeSliderEditor);
addField(new IntegerFieldEditor(PreferenceConstants.PLAYERVIEW_SEEK_STEP,
Messages.getString("PlayerViewPage.SeekStep"), //$NON-NLS-1$
getFieldEditorParent()));
}
protected void initialize() {
super.initialize();
setToolbarSizeRFEEnabled(_showToolbarEditor.getBooleanValue());
}
public void propertyChange(PropertyChangeEvent event) {
if (event.getSource().equals(_showToolbarEditor)) {
setToolbarSizeRFEEnabled(_showToolbarEditor.getBooleanValue());
}
}
private void setToolbarSizeRFEEnabled(boolean value) {
_toolbarSizeRFE.setEnabled(value, getFieldEditorParent());
}
@Override
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
}