Package org.jampa.preferences.pages

Source Code of org.jampa.preferences.pages.PodcastsPage

/*
* 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.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.gui.translations.Messages;
import org.jampa.preferences.PreferenceConstants;

public class PodcastsPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {

  private BooleanFieldEditor automaticUpdateBFE;
  private IntegerFieldEditor automaticUpdateIntervalIFE;
 
  private BooleanFieldEditor downloadBeforePlayBFE;
  private BooleanFieldEditor playAfterDownloadBFE;
  private BooleanFieldEditor cleanCacheOnUpdateBFE;
 
  public PodcastsPage() {
    super(GRID);
    setPreferenceStore(Activator.getDefault().getPreferenceStore());
    setDescription(Messages.getString("PodcastsPage.Title")); //$NON-NLS-1$
  }
 
  private void setAutomaticUpdateGroupEnable(boolean value) {
    automaticUpdateIntervalIFE.setEnabled(value, getFieldEditorParent());
  }
 
  private void setDownloadGroupEnable(boolean value) {
    playAfterDownloadBFE.setEnabled(value, getFieldEditorParent());   
  }
 
  protected void initialize() {
    super.initialize();
    setAutomaticUpdateGroupEnable(automaticUpdateBFE.getBooleanValue());
    setDownloadGroupEnable(downloadBeforePlayBFE.getBooleanValue());
  }
 
  public void propertyChange(PropertyChangeEvent event) {   
    if (event.getSource().equals(automaticUpdateBFE)) {
      setAutomaticUpdateGroupEnable(automaticUpdateBFE.getBooleanValue());
    } else if (event.getSource().equals(downloadBeforePlayBFE)) {
      setDownloadGroupEnable(downloadBeforePlayBFE.getBooleanValue());
    }
  }
 
  @Override
  protected void createFieldEditors() {
    Label horizontalLine;
   
    horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
    horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 3, 1));
   
    addField(new BooleanFieldEditor(PreferenceConstants.PODCAST_UPDATE_AT_STARTUP,
        Messages.getString("PodcastsPage.PodcastsUpdateAtStartUp"), //$NON-NLS-1$
        getFieldEditorParent()));
   
    cleanCacheOnUpdateBFE = new BooleanFieldEditor(PreferenceConstants.PODCAST_CLEAN_DOWNLOAD_CACHE_ON_UPDATE,
        Messages.getString("PodcastsPage.PodcastsCleanDownloadCacheOnUpdate"), //$NON-NLS-1$
        getFieldEditorParent());
    addField(cleanCacheOnUpdateBFE);
   
    automaticUpdateBFE = new BooleanFieldEditor(PreferenceConstants.PODCAST_AUTOMATIC_UPDATE,
        Messages.getString("PodcastsPage.PodcastsAutomaticUpdate"), //$NON-NLS-1$
        getFieldEditorParent());
    addField(automaticUpdateBFE);
   
    automaticUpdateIntervalIFE = new IntegerFieldEditor(PreferenceConstants.PODCAST_AUTOMATIC_UPDATE_INTERVAL,
        Messages.getString("PodcastsPage.PodcastsAutomaticUpdateInterval"), //$NON-NLS-1$
        getFieldEditorParent());
    addField(automaticUpdateIntervalIFE);   
   
    horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
    horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 3, 1));
   
    downloadBeforePlayBFE = new BooleanFieldEditor(PreferenceConstants.PODCAST_DOWNLOAD_BEFORE_PLAY,
        Messages.getString("PodcastsPage.PodcastsDownloadBeforePlay"), //$NON-NLS-1$
        getFieldEditorParent());
    addField(downloadBeforePlayBFE);
   
    playAfterDownloadBFE = new BooleanFieldEditor(PreferenceConstants.PODCAST_PLAY_AFTER_DOWNLOAD,
        Messages.getString("PodcastsPage.PodcastsPlayAfterDownload"), //$NON-NLS-1$
        getFieldEditorParent());
    addField(playAfterDownloadBFE);       
   
  }

  @Override
  public void init(IWorkbench workbench) {   
  }

 
}
TOP

Related Classes of org.jampa.preferences.pages.PodcastsPage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.