public AppearancePreferencePage() {
    setPreferenceStore(JavaScriptPlugin.getDefault().getPreferenceStore());
    setDescription(PreferencesMessages.AppearancePreferencePage_description);

    IDialogFieldListener listener =
        new IDialogFieldListener() {
          public void dialogFieldChanged(DialogField field) {
            doDialogFieldChanged(field);
          }
        };

    fShowMethodReturnType = new SelectionButtonDialogField(SWT.CHECK);
    fShowMethodReturnType.setDialogFieldListener(listener);
    //
    //	fShowMethodReturnType.setLabelText(PreferencesMessages.AppearancePreferencePage_methodreturntype_label);
    fShowMethodReturnType.setLabelText(
        PreferencesMessages.AppearancePreferencePage_inferredmethodreturntype_label);

    //		fShowMethodTypeParameters= new SelectionButtonDialogField(SWT.CHECK);
    //		fShowMethodTypeParameters.setDialogFieldListener(listener);
    //
    //	fShowMethodTypeParameters.setLabelText(PreferencesMessages.AppearancePreferencePage_methodtypeparams_label);

    fShowCategory = new SelectionButtonDialogField(SWT.CHECK);
    fShowCategory.setDialogFieldListener(listener);
    fShowCategory.setLabelText(PreferencesMessages.AppearancePreferencePage_showCategory_label);

    fShowMembersInPackageView = new SelectionButtonDialogField(SWT.CHECK);
    fShowMembersInPackageView.setDialogFieldListener(listener);
    fShowMembersInPackageView.setLabelText(
        PreferencesMessages.AppearancePreferencePage_showMembersInPackagesView);

    //		fStackBrowsingViewsVertically= new SelectionButtonDialogField(SWT.CHECK);
    //		fStackBrowsingViewsVertically.setDialogFieldListener(listener);
    //
    //	fStackBrowsingViewsVertically.setLabelText(PreferencesMessages.AppearancePreferencePage_stackViewsVerticallyInTheJavaBrowsingPerspective);

    fFoldPackagesInPackageExplorer = new SelectionButtonDialogField(SWT.CHECK);
    fFoldPackagesInPackageExplorer.setDialogFieldListener(listener);
    //
    //	fFoldPackagesInPackageExplorer.setLabelText(PreferencesMessages.AppearancePreferencePage_foldEmptyPackages);
    fFoldPackagesInPackageExplorer.setLabelText(
        PreferencesMessages.AppearancePreferencePage_foldEmptySourceFolders);

    //		fCompressPackageNames= new SelectionButtonDialogField(SWT.CHECK);
    //		fCompressPackageNames.setDialogFieldListener(listener);
    //
    //	fCompressPackageNames.setLabelText(PreferencesMessages.AppearancePreferencePage_pkgNamePatternEnable_label);

    //		fPackageNamePattern= new StringDialogField();
    //		fPackageNamePattern.setDialogFieldListener(listener);
    //
    //	fPackageNamePattern.setLabelText(PreferencesMessages.AppearancePreferencePage_pkgNamePattern_label);

    fShowColoredLabels = new SelectionButtonDialogField(SWT.CHECK);
    fShowColoredLabels.setDialogFieldListener(listener);
    fShowColoredLabels.setLabelText(
        PreferencesMessages.AppearancePreferencePage_coloredlabels_label);
  }
 /*
  * @see IPreferencePage#performOk()
  */
 public boolean performOk() {
   IPreferenceStore prefs = getPreferenceStore();
   prefs.setValue(PREF_METHOD_RETURNTYPE, fShowMethodReturnType.isSelected());
   //		prefs.setValue(PREF_METHOD_TYPEPARAMETERS, fShowMethodTypeParameters.isSelected());
   prefs.setValue(PREF_CATEGORY, fShowCategory.isSelected());
   prefs.setValue(SHOW_CU_CHILDREN, fShowMembersInPackageView.isSelected());
   //		prefs.setValue(STACK_BROWSING_VIEWS_VERTICALLY, fStackBrowsingViewsVertically.isSelected());
   //		prefs.setValue(PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW, fPackageNamePattern.getText());
   //		prefs.setValue(PREF_COMPRESS_PACKAGE_NAMES, fCompressPackageNames.isSelected());
   prefs.setValue(
       PREF_FOLD_PACKAGES_IN_PACKAGE_EXPLORER, fFoldPackagesInPackageExplorer.isSelected());
   prefs.setValue(PREF_COLORED_LABELS, fShowColoredLabels.isSelected());
   JavaScriptPlugin.getDefault().savePluginPreferences();
   return super.performOk();
 }
 /*
  * @see PreferencePage#performDefaults()
  */
 protected void performDefaults() {
   IPreferenceStore prefs = getPreferenceStore();
   fShowMethodReturnType.setSelection(prefs.getDefaultBoolean(PREF_METHOD_RETURNTYPE));
   //		fShowMethodTypeParameters.setSelection(prefs.getDefaultBoolean(PREF_METHOD_TYPEPARAMETERS));
   fShowCategory.setSelection(prefs.getDefaultBoolean(PREF_CATEGORY));
   fShowMembersInPackageView.setSelection(prefs.getDefaultBoolean(SHOW_CU_CHILDREN));
   //
   //	fStackBrowsingViewsVertically.setSelection(prefs.getDefaultBoolean(STACK_BROWSING_VIEWS_VERTICALLY));
   //		fPackageNamePattern.setText(prefs.getDefaultString(PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW));
   //		fCompressPackageNames.setSelection(prefs.getDefaultBoolean(PREF_COMPRESS_PACKAGE_NAMES));
   fFoldPackagesInPackageExplorer.setSelection(
       prefs.getDefaultBoolean(PREF_FOLD_PACKAGES_IN_PACKAGE_EXPLORER));
   fShowColoredLabels.setSelection(false);
   super.performDefaults();
 }
  /*
   * @see PreferencePage#createContents(Composite)
   */
  protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);
    int nColumns = 1;

    Composite result = new Composite(parent, SWT.NONE);
    result.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = 0;
    layout.numColumns = nColumns;
    result.setLayout(layout);

    fShowMethodReturnType.doFillIntoGrid(result, nColumns);
    //		fShowMethodTypeParameters.doFillIntoGrid(result, nColumns);
    fShowCategory.doFillIntoGrid(result, nColumns);
    fShowMembersInPackageView.doFillIntoGrid(result, nColumns);
    fShowColoredLabels.doFillIntoGrid(result, nColumns);
    fFoldPackagesInPackageExplorer.doFillIntoGrid(result, nColumns);

    //		new Separator().doFillIntoGrid(result, nColumns);

    //		fCompressPackageNames.doFillIntoGrid(result, nColumns);
    //		fPackageNamePattern.doFillIntoGrid(result, 2);
    //		LayoutUtil.setHorizontalGrabbing(fPackageNamePattern.getTextControl(null));
    //		LayoutUtil.setWidthHint(fPackageNamePattern.getLabelControl(null),
    // convertWidthInCharsToPixels(65));

    //		new Separator().doFillIntoGrid(result, nColumns);
    //		fStackBrowsingViewsVertically.doFillIntoGrid(result, nColumns);

    //		String noteTitle= PreferencesMessages.AppearancePreferencePage_note;
    //		String noteMessage=
    // PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives;
    //		Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result,
    // noteTitle, noteMessage);
    //		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    //		gd.horizontalSpan= 2;
    //		noteControl.setLayoutData(gd);

    initFields();

    Dialog.applyDialogFont(result);
    return result;
  }
  protected Control createContents(Composite parent) {
    setShell(parent.getShell());

    fPixelConverter = new PixelConverter(parent);

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;

    composite.setLayout(layout);

    fOrderListField.doFillIntoGrid(composite, 3);
    LayoutUtil.setHorizontalSpan(fOrderListField.getLabelControl(null), 2);
    LayoutUtil.setWidthHint(
        fOrderListField.getLabelControl(null), fPixelConverter.convertWidthInCharsToPixels(60));
    LayoutUtil.setHorizontalGrabbing(fOrderListField.getListControl(null));

    Composite importExportComp = new Composite(composite, SWT.NONE);
    importExportComp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;

    importExportComp.setLayout(layout);

    fImportButton.doFillIntoGrid(importExportComp, 1);
    fExportButton.doFillIntoGrid(importExportComp, 1);

    fThresholdField.doFillIntoGrid(composite, 2);
    ((GridData) fThresholdField.getTextControl(null).getLayoutData()).grabExcessHorizontalSpace =
        false;
    fStaticThresholdField.doFillIntoGrid(composite, 2);
    fIgnoreLowerCaseTypesField.doFillIntoGrid(composite, 2);

    Dialog.applyDialogFont(composite);

    return composite;
  }
  /* (non-Javadoc)
   * @see org.eclipse.wst.jsdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
   */
  protected void updateControls() {
    ImportOrderEntry[] importOrder = getImportOrderPreference();
    int threshold = getImportNumberThreshold(PREF_ONDEMANDTHRESHOLD);
    int staticThreshold = getImportNumberThreshold(PREF_STATICONDEMANDTHRESHOLD);
    boolean ignoreLowerCase = Boolean.valueOf(getValue(PREF_IGNORELOWERCASE)).booleanValue();

    fOrderListField.removeAllElements();
    for (int i = 0; i < importOrder.length; i++) {
      fOrderListField.addElement(importOrder[i]);
    }
    fThresholdField.setText(String.valueOf(threshold));
    fStaticThresholdField.setText(String.valueOf(staticThreshold));
    fIgnoreLowerCaseTypesField.setSelection(ignoreLowerCase);
  }
  public ImportOrganizeConfigurationBlock(
      IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
    super(context, project, getAllKeys(), container);

    String[] buttonLabels =
        new String[] {
          PreferencesMessages.ImportOrganizeConfigurationBlock_order_add_button,
          PreferencesMessages.ImportOrganizeConfigurationBlock_order_add_static_button,
          PreferencesMessages.ImportOrganizeConfigurationBlock_order_edit_button,
          PreferencesMessages.ImportOrganizeConfigurationBlock_order_remove_button,
          /* 4 */ null,
          PreferencesMessages.ImportOrganizeConfigurationBlock_order_up_button,
          PreferencesMessages.ImportOrganizeConfigurationBlock_order_down_button,
        };

    ImportOrganizeAdapter adapter = new ImportOrganizeAdapter();

    fOrderListField = new ListDialogField(adapter, buttonLabels, new ImportOrganizeLabelProvider());
    fOrderListField.setDialogFieldListener(adapter);
    fOrderListField.setLabelText(PreferencesMessages.ImportOrganizeConfigurationBlock_order_label);
    fOrderListField.setUpButtonIndex(IDX_UP);
    fOrderListField.setDownButtonIndex(IDX_DOWN);
    fOrderListField.setRemoveButtonIndex(IDX_REMOVE);

    fOrderListField.enableButton(IDX_EDIT, false);

    fImportButton = new SelectionButtonDialogField(SWT.PUSH);
    fImportButton.setDialogFieldListener(adapter);
    fImportButton.setLabelText(
        PreferencesMessages.ImportOrganizeConfigurationBlock_order_load_button);

    fExportButton = new SelectionButtonDialogField(SWT.PUSH);
    fExportButton.setDialogFieldListener(adapter);
    fExportButton.setLabelText(
        PreferencesMessages.ImportOrganizeConfigurationBlock_order_save_button);

    fThresholdField = new StringDialogField();
    fThresholdField.setDialogFieldListener(adapter);
    fThresholdField.setLabelText(
        PreferencesMessages.ImportOrganizeConfigurationBlock_threshold_label);

    fStaticThresholdField = new StringDialogField();
    fStaticThresholdField.setDialogFieldListener(adapter);
    fStaticThresholdField.setLabelText(
        PreferencesMessages.ImportOrganizeConfigurationBlock_staticthreshold_label);

    fIgnoreLowerCaseTypesField = new SelectionButtonDialogField(SWT.CHECK);
    fIgnoreLowerCaseTypesField.setDialogFieldListener(adapter);
    fIgnoreLowerCaseTypesField.setLabelText(
        PreferencesMessages.ImportOrganizeConfigurationBlock_ignoreLowerCase_label);

    updateControls();
  }
 protected final void doDialogFieldChanged(DialogField field) {
   // set values in working copy
   if (field == fOrderListField) {
     setValue(PREF_IMPORTORDER, packOrderList(fOrderListField.getElements()));
   } else if (field == fThresholdField) {
     if (doThresholdChanged(fThresholdField.getText())) {
       setValue(PREF_ONDEMANDTHRESHOLD, fThresholdField.getText());
     }
   } else if (field == fStaticThresholdField) {
     if (doThresholdChanged(fStaticThresholdField.getText())) {
       setValue(PREF_STATICONDEMANDTHRESHOLD, fStaticThresholdField.getText());
     }
   } else if (field == fIgnoreLowerCaseTypesField) {
     setValue(PREF_IGNORELOWERCASE, fIgnoreLowerCaseTypesField.isSelected());
   } else if (field == fImportButton) {
     List order = loadImportOrder();
     if (order != null) {
       fOrderListField.setElements(order);
     }
   } else if (field == fExportButton) {
     saveImportOrder(fOrderListField.getElements());
   }
 }