Package hidb2.gui.preferences

Source Code of hidb2.gui.preferences.FileBrowserPrefPage

/**
* This file is part of HIDB2.
*
* HIDB2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HIDB2 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 Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with HIDB2.  If not, see <http://www.gnu.org/licenses/>.
*/
package hidb2.gui.preferences;

import hidb2.Activator;
import hidb2.gui.Application;

import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

/**
* This class represents the preference page of the file browser.
*/
public class FileBrowserPrefPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
  {

  public FileBrowserPrefPage()
    {
    super(GRID);
    setPreferenceStore(Activator.getDefault().getPreferenceStore());
    setDescription("FileBrowser Preference page");
    }

  /**
   * 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()
    {
    addField(new FileFieldEditor(PrefConst.P_IMG_EDITOR_CMD, "&External Image Editor:", getFieldEditorParent()));

    addField(new FontFieldEditor(PrefConst.P_FNT_FILEBROWSE_STD, "Default Browser Font", getFieldEditorParent()));   

    addField(new IntegerFieldEditor(PrefConst.P_BRW_MAXFILESIZE, "Max File Size (Bytes)", getFieldEditorParent()));

    addField(new IntegerFieldEditor(PrefConst.P_BRW_ICONSIZE, "Icon Size (pixel)", getFieldEditorParent()));

    addField(new IntegerFieldEditor(PrefConst.P_BRW_MARGINLEFT, "Margin Left", getFieldEditorParent()));

    addField(new IntegerFieldEditor(PrefConst.P_BRW_MARGINRIGHT, "Margin Right", getFieldEditorParent()));

    addField(new IntegerFieldEditor(PrefConst.P_BRW_MARGINTOP, "Margin Top", getFieldEditorParent()));

    addField(new IntegerFieldEditor(PrefConst.P_BRW_MARGINBOTTOM, "Margin Bottom", getFieldEditorParent()));
    }

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

  /* (non-Javadoc)
   * @see org.eclipse.jface.preference.PreferencePage#performOk()
   */
  @Override
  public boolean performOk()
    {
    boolean res = super.performOk();

    // Restart the filebrowser
    Application.restartViews();
   
    return res;
    }

//  static class ExtensionListEditor extends ListEditor
//    {
//    private Composite _parent;
//
//    protected ExtensionListEditor(Composite parent)
//      {
//      super(PrefConst.P_BRW_EXTS, "Image Extension List", parent);
//      _parent = parent;
//      }
//
//    @Override
//    protected String createList(String[] items)
//      {
//      StringBuffer sb = new StringBuffer(1024);
//
//      for (int i = 0; i < items.length; i++)
//        {
//        sb.append(items[i]);
//        if (i < items.length - 1)
//          sb.append(File.pathSeparatorChar);
//        }
//
//      return sb.toString();
//      }
//
//    @Override
//    protected String getNewInputObject()
//      {
//      DirectoryDialog dialog = new DirectoryDialog(_parent.getShell());
//
//      dialog.setText("Data Directory");
//
//      String dn = dialog.open();
//
//      return dn;
//      }
//
//    @Override
//    protected String[] parseString(String stringList)
//      {
//      return stringList.split(File.pathSeparator);
//      }
//
//    }

  }
TOP

Related Classes of hidb2.gui.preferences.FileBrowserPrefPage

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.