Package org.jampa.preferences.pages

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

package org.jampa.preferences.pages;

import org.eclipse.jface.preference.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.jampa.Activator;
import org.jampa.gui.translations.Messages;
import org.jampa.preferences.PreferenceConstants;
import org.jampa.preferences.pages.editors.LibraryPathEditor;


/**
* This class represents a preference page that
* is contributed to the Preferences dialog. By
* subclassing <samp>FieldEditorPreferencePage</samp>, we
* can use the field support built into JFace that allows
* us to create a page that is small and knows how to
* save, restore and apply itself.
* <p>
* This page is used to modify preferences only. They
* are stored in the preference store that belongs to
* the main plug-in class. That way, preferences can
* be accessed directly via the preference store.
*/

public class GeneralPage
  extends FieldEditorPreferencePage
  implements IWorkbenchPreferencePage {

  public GeneralPage() {
    super(GRID);
    setPreferenceStore(Activator.getDefault().getPreferenceStore());
    setDescription(Messages.getString("GeneralPage.Title")); //$NON-NLS-1$
  }
 
  /**
   * Creates the field editors. Field editors are abstractions of
   * the common GUI blocks needed to manipulate various types
   * of preferences. Each field editor knows how to save and
   * restore itself.
   */
  public void createFieldEditors() {
   
    Label horizontalLine;
   
    horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
    horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));       
   
    addField(new BooleanFieldEditor(PreferenceConstants.USE_STATISTICS,
          Messages.getString("GeneralPage.UseStatistics"), //$NON-NLS-1$
          getFieldEditorParent()));
   
    addField(new BooleanFieldEditor(PreferenceConstants.VERSION_CHECK_AT_STARTUP,
        Messages.getString("GeneralPage.VersionCheckAtStartup"), //$NON-NLS-1$
        getFieldEditorParent()));
   
    horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
    horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));         
   
    addField(new LibraryPathEditor(PreferenceConstants.P_LIBRARY_PATH,
        Messages.getString("GeneralPage.LibraryPath"), //$NON-NLS-1$
        Messages.getString("GeneralPage.ChooseLibraryPath"), //$NON-NLS-1$
        getFieldEditorParent()));
   
    addField(new BooleanFieldEditor(PreferenceConstants.AUTOMATIC_LIBRARY_UPDATE,
        Messages.getString("GeneralPage.AutomaticLibraryUpdate"), //$NON-NLS-1$
        getFieldEditorParent()));
   
    horizontalLine = new Label(getFieldEditorParent(), SWT.NONE);
    horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
   
    Composite formatComposite = new Composite(getFieldEditorParent(), SWT.NONE);
    formatComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
   
    addField(new StringFieldEditor(PreferenceConstants.DISPLAY_DATE_FORMAT,
        Messages.getString("GeneralPage.DisplayDateFormat"), //$NON-NLS-1$
        formatComposite));
   
    addField(new StringFieldEditor(PreferenceConstants.DISPLAY_TIME_FORMAT,
        Messages.getString("GeneralPage.DisplayTimeFormat"), //$NON-NLS-1$
        formatComposite));
   
  }

  /* (non-Javadoc)
formatCompositelipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
   */
  public void init(IWorkbench workbench) {
  }
 
}
TOP

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

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.