@Override
    protected void doLoad() {
      int maxBRVal = getPreferenceStore().getInt(PreferenceConstants.ENCODING_MAX_BITRATE);
      int maxBRValCombo = getPreferenceStore().getInt(getPreferenceName());

      if (maxBRVal != maxBRValCombo) getPreferenceStore().setValue(getPreferenceName(), "");

      super.doLoad();
    }
    @Override
    protected void doStore() {
      super.doStore();

      int[] res = getStoredResolution();
      if (res == null) return;

      getPreferenceStore().setValue(PreferenceConstants.ENCODING_VIDEO_WIDTH, res[0]);
      getPreferenceStore().setValue(PreferenceConstants.ENCODING_VIDEO_HEIGHT, res[1]);
    }
    @Override
    protected void doLoad() {
      super.doLoad();

      if (Codec.XUGGLER
              .name()
              .equals(getPreferenceStore().getString(PreferenceConstants.ENCODING_CODEC))
          && !XugglerEncoder.isInstalled())
        getPage().setErrorMessage(XUGGLER_NOT_INSTALLED_MESSAGE);
    }
 @Override
 protected void doLoad() {
   int[] res = getStoredResolution();
   if (res != null) {
     int width = getPreferenceStore().getInt(PreferenceConstants.ENCODING_VIDEO_WIDTH);
     int height = getPreferenceStore().getInt(PreferenceConstants.ENCODING_VIDEO_HEIGHT);
     if (res[0] != width || res[1] != height)
       getPreferenceStore().setValue(getPreferenceName(), "");
   }
   super.doLoad();
 }
  @Override
  protected void performDefaults() {
    fDateTimeFields.loadDefault();
    fSSecFields.loadDefault();
    fDateFieldDelim.loadDefault();
    fTimeFieldDelim.loadDefault();
    fSSecFieldDelim.loadDefault();
    fCombo.loadDefault();

    fPreferenceMap = TmfTimePreferences.getDefaultPreferenceMap();
    displayExample();
  }
  @Override
  protected void performApply() {
    fDateTimeFields.store();
    fSSecFields.store();
    fDateFieldDelim.store();
    fTimeFieldDelim.store();
    fSSecFieldDelim.store();
    fCombo.store();

    TmfTimestampFormat.updateDefaultFormats();
    TmfSignalManager.dispatchSignal(new TmfTimestampFormatUpdateSignal(null));
    displayExample();
  }
    @Override
    protected void doStore() {
      super.doStore();

      String rawZoom =
          getPreferenceStore().getString(PreferenceConstants.SCREEN_MOUSE_AREA_QUALITY);
      if (rawZoom == null || rawZoom.equals("")) return;

      int zoom = Integer.parseInt(rawZoom);
      int[] newRes = calculateResolutionForZoom(zoom);

      getPreferenceStore().setValue(PreferenceConstants.SCREEN_MOUSE_AREA_WIDTH, newRes[0]);
      getPreferenceStore().setValue(PreferenceConstants.SCREEN_MOUSE_AREA_HEIGHT, newRes[1]);
    }
    @Override
    protected void doLoad() {
      super.doLoad();

      String rawZoom =
          getPreferenceStore().getString(PreferenceConstants.SCREEN_MOUSE_AREA_QUALITY);

      if (rawZoom == null || rawZoom.equals("")) return;

      int zoom = Integer.parseInt(rawZoom);

      if (!Arrays.equals(getCustomResolution(), calculateResolutionForZoom(zoom)))
        getPreferenceStore().setValue(getPreferenceName(), "");
    }
    @Override
    protected void doStore() {
      super.doStore();

      String maxBRValComboString = getPreferenceStore().getString(getPreferenceName());

      int maxBRValCombo;

      try {
        maxBRValCombo = Integer.parseInt(maxBRValComboString);
      } catch (NumberFormatException e) {
        maxBRValCombo = 0;
        return;
      }

      getPreferenceStore().setValue(PreferenceConstants.ENCODING_MAX_BITRATE, maxBRValCombo);
    }
 @Override
 protected void initialize() {
   super.initialize();
   // When the chooser's selection changes, update the dateFormat &
   // enablement
   formatChooser.setPropertyChangeListener(
       new IPropertyChangeListener() {
         @Override
         public void propertyChange(PropertyChangeEvent event) {
           if (FieldEditor.VALUE.equals(event.getProperty())) {
             GitDateFormatter.Format format = fromString((String) event.getOldValue());
             if (format == null) {
               lastCustomValue = dateFormat.getStringValue();
             }
             updateFields((String) event.getNewValue());
           }
         }
       });
 }
  @Override
  protected void createFieldEditors() {
    Composite main = getFieldEditorParent();
    GridLayoutFactory.swtDefaults().margins(0, 0).applyTo(main);

    Group cloningGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    cloningGroup.setText(UIText.GitPreferenceRoot_CloningRepoGroupHeader);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(cloningGroup);
    DirectoryFieldEditor editor =
        new DirectoryFieldEditor(
            UIPreferences.DEFAULT_REPO_DIR,
            UIText.GitPreferenceRoot_DefaultRepoFolderLabel,
            cloningGroup) {

          /** The own control is the variableButton */
          private static final int NUMBER_OF_OWN_CONTROLS = 1;

          @Override
          protected boolean doCheckState() {
            String fileName = getTextControl().getText();
            fileName = fileName.trim();
            if (fileName.length() == 0 && isEmptyStringAllowed()) return true;

            IStringVariableManager manager =
                VariablesPlugin.getDefault().getStringVariableManager();
            String substitutedFileName;
            try {
              substitutedFileName = manager.performStringSubstitution(fileName);
            } catch (CoreException e) {
              // It's apparently invalid
              return false;
            }

            File file = new File(substitutedFileName);
            // other than the super implementation, we don't
            // require the file to exist
            return !file.exists() || file.isDirectory();
          }

          @Override
          public int getNumberOfControls() {
            return super.getNumberOfControls() + NUMBER_OF_OWN_CONTROLS;
          }

          @Override
          protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns - NUMBER_OF_OWN_CONTROLS);
          }

          @Override
          protected void adjustForNumColumns(int numColumns) {
            super.adjustForNumColumns(numColumns - NUMBER_OF_OWN_CONTROLS);
          }

          @Override
          protected void createControl(Composite parent) {
            // setting validate strategy using the setter method is too late
            super.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);

            super.createControl(parent);

            if (HAS_DEBUG_UI) addVariablesButton(parent);
          }

          private void addVariablesButton(Composite parent) {
            Button variableButton = new Button(parent, SWT.PUSH);
            variableButton.setText(UIText.GitPreferenceRoot_DefaultRepoFolderVariableButton);

            variableButton.addSelectionListener(
                new SelectionAdapter() {
                  public void widgetSelected(SelectionEvent e) {
                    org.eclipse.debug.ui.StringVariableSelectionDialog dialog =
                        new org.eclipse.debug.ui.StringVariableSelectionDialog(getShell());
                    int returnCode = dialog.open();
                    if (returnCode == Window.OK) setStringValue(dialog.getVariableExpression());
                  }
                });
          }
        };
    updateMargins(cloningGroup);
    editor.setEmptyStringAllowed(false);
    editor
        .getLabelControl(cloningGroup)
        .setToolTipText(UIText.GitPreferenceRoot_DefaultRepoFolderTooltip);
    addField(editor);

    Group remoteConnectionsGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .span(GROUP_SPAN, 1)
        .applyTo(remoteConnectionsGroup);
    remoteConnectionsGroup.setText(UIText.GitPreferenceRoot_RemoteConnectionsGroupHeader);

    IntegerFieldEditor timeoutEditor =
        new IntegerFieldEditor(
            UIPreferences.REMOTE_CONNECTION_TIMEOUT,
            UIText.RemoteConnectionPreferencePage_TimeoutLabel,
            remoteConnectionsGroup);
    timeoutEditor
        .getLabelControl(remoteConnectionsGroup)
        .setToolTipText(UIText.RemoteConnectionPreferencePage_ZeroValueTooltip);
    addField(timeoutEditor);
    updateMargins(remoteConnectionsGroup);

    Group repoChangeScannerGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .span(GROUP_SPAN, 1)
        .applyTo(repoChangeScannerGroup);
    repoChangeScannerGroup.setText(UIText.GitPreferenceRoot_RepoChangeScannerGroupHeader);
    addField(
        new BooleanFieldEditor(
            UIPreferences.REFESH_ON_INDEX_CHANGE,
            UIText.RefreshPreferencesPage_RefreshWhenIndexChange,
            repoChangeScannerGroup));
    addField(
        new BooleanFieldEditor(
            UIPreferences.REFESH_ONLY_WHEN_ACTIVE,
            UIText.RefreshPreferencesPage_RefreshOnlyWhenActive,
            repoChangeScannerGroup));
    updateMargins(repoChangeScannerGroup);

    Group mergeGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(mergeGroup);
    mergeGroup.setText(UIText.GitPreferenceRoot_MergeGroupHeader);
    ComboFieldEditor mergeMode =
        new ComboFieldEditor(
            UIPreferences.MERGE_MODE,
            UIText.GitPreferenceRoot_MergeModeLabel,
            MERGE_MODE_NAMES_AND_VALUES,
            mergeGroup);
    mergeMode.getLabelControl(mergeGroup).setToolTipText(UIText.GitPreferenceRoot_MergeModeTooltip);
    addField(mergeMode);
    updateMargins(mergeGroup);

    Group blameGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(blameGroup);
    blameGroup.setText(UIText.GitPreferenceRoot_BlameGroupHeader);
    addField(
        new BooleanFieldEditor(
            UIPreferences.BLAME_IGNORE_WHITESPACE,
            UIText.GitPreferenceRoot_BlameIgnoreWhitespaceLabel,
            blameGroup));
    updateMargins(blameGroup);

    Group secureGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(secureGroup);
    secureGroup.setText(UIText.GitPreferenceRoot_SecureStoreGroupLabel);
    addField(
        new BooleanFieldEditor(
            UIPreferences.CLONE_WIZARD_STORE_SECURESTORE,
            UIText.GitPreferenceRoot_SecureStoreUseByDefault,
            secureGroup));
    updateMargins(secureGroup);
  }
 @Override
 protected void fireValueChanged(String property, Object oldValue, Object newValue) {
   super.fireValueChanged(property, oldValue, newValue);
 }
 private void updateFieldEnablement(boolean disabled) {
   useThreads.setEnabled(!disabled, getFieldEditorParent());
   resolutionScopeMainDescription.setEnabled(!disabled);
   resolutionScope.setEnabled(!disabled, resolutionScopeComboComposite);
   resolutionScopeDescriptionComposite.setEnabled(!disabled);
 }
  @Override
  protected Control createContents(Composite parent) {

    // Overall preference page layout
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    parent.setLayout(gl);
    fPage = new Composite(parent, SWT.NONE);
    fPage.setLayout(new GridLayout());
    fPage.setLayoutData(
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.GRAB_VERTICAL
                | GridData.VERTICAL_ALIGN_FILL));

    // Example section
    fExampleSection = new Composite(fPage, SWT.NONE);
    fExampleSection.setLayout(new GridLayout(2, false));
    fExampleSection.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label patternLabel = new Label(fExampleSection, SWT.HORIZONTAL);
    patternLabel.setText("Current Format: "); // $NON-NLS-1$
    fPatternDisplay = new Text(fExampleSection, SWT.BORDER | SWT.READ_ONLY);
    fPatternDisplay.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label exampleLabel = new Label(fExampleSection, SWT.NONE);
    exampleLabel.setText("Sample Display: "); // $NON-NLS-1$
    fExampleDisplay = new Text(fExampleSection, SWT.BORDER | SWT.READ_ONLY);
    fExampleDisplay.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label separator = new Label(fPage, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_NONE);
    separator.setLayoutData(
        new GridData(
            GridData.HORIZONTAL_ALIGN_FILL
                | GridData.GRAB_HORIZONTAL
                | GridData.VERTICAL_ALIGN_FILL));

    // Time Zones
    String[][] timeZoneIntervals = new String[timeZones.length][2];
    timeZoneIntervals[0][0] = timeZones[0];
    timeZoneIntervals[0][1] =
        fPreferenceStore.getDefaultString(ITmfTimePreferencesConstants.TIME_ZONE);
    for (int i = 1; i < timeZones.length; i++) {
      TimeZone tz = null;
      try {
        tz = TimeZone.getTimeZone(timeZones[i]);
        timeZoneIntervals[i][0] = tz.getDisplayName();
        timeZoneIntervals[i][1] = tz.getID();
      } catch (NullPointerException e) {
        Activator.getDefault()
            .logError(
                "TimeZone " + timeZones[i] + " does not exist.", e); // $NON-NLS-1$ //$NON-NLS-2$
      }
    }

    fCombo =
        new ComboFieldEditor(
            ITmfTimePreferencesConstants.TIME_ZONE,
            "Time Zone",
            timeZoneIntervals,
            fPage); //$NON-NLS-1$
    fCombo.setPreferenceStore(fPreferenceStore);
    fCombo.load();
    fCombo.setPropertyChangeListener(this);

    // Date and Time section
    fDateTimeFields =
        new RadioGroupFieldEditor(
            ITmfTimePreferencesConstants.DATIME,
            "Date and Time format",
            3,
            fDateTimeFormats,
            fPage,
            true); //$NON-NLS-1$
    fDateTimeFields.setPreferenceStore(fPreferenceStore);
    fDateTimeFields.load();
    fDateTimeFields.setPropertyChangeListener(this);

    // Sub-second section
    fSSecFields =
        new RadioGroupFieldEditor(
            ITmfTimePreferencesConstants.SUBSEC,
            "Sub-second format",
            3,
            fSubSecondFormats,
            fPage,
            true); //$NON-NLS-1$
    fSSecFields.setPreferenceStore(fPreferenceStore);
    fSSecFields.load();
    fSSecFields.setPropertyChangeListener(this);

    // Separators section
    fDateFieldDelim =
        new RadioGroupFieldEditor(
            ITmfTimePreferencesConstants.DATE_DELIMITER,
            "Date delimiter",
            5,
            fDateTimeDelimiters,
            fPage,
            true); //$NON-NLS-1$
    fDateFieldDelim.setPreferenceStore(fPreferenceStore);
    fDateFieldDelim.load();
    fDateFieldDelim.setPropertyChangeListener(this);

    fTimeFieldDelim =
        new RadioGroupFieldEditor(
            ITmfTimePreferencesConstants.TIME_DELIMITER,
            "Time delimiter",
            5,
            fDateTimeDelimiters,
            fPage,
            true); //$NON-NLS-1$
    fTimeFieldDelim.setPreferenceStore(fPreferenceStore);
    fTimeFieldDelim.load();
    fTimeFieldDelim.setPropertyChangeListener(this);

    fSSecFieldDelim =
        new RadioGroupFieldEditor(
            ITmfTimePreferencesConstants.SSEC_DELIMITER,
            "Sub-Second Delimiter",
            5,
            fSubSecondDelimiters,
            fPage,
            true); //$NON-NLS-1$
    fSSecFieldDelim.setPreferenceStore(fPreferenceStore);
    fSSecFieldDelim.load();
    fSSecFieldDelim.setPropertyChangeListener(this);

    refresh();
    return fPage;
  }
  public void createControl(Composite parent) {
    setTitle(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "title", "label", this.m_language));
    setDescription(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "description", "label", this.m_language));

    final Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(new GridLayout(1, false));
    c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    BooleanFieldEditor bfe =
        new BooleanFieldEditor(
            "activemonitor",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip",
                "activemonitor2",
                "label",
                this.m_language),
            c);
    bfe.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof Boolean)
              m_active = ((Boolean) e.getNewValue()).booleanValue();
            setPageComplete(isComplete());
          }
        });

    new Label(c, SWT.LEFT);

    StringFieldEditor sfe =
        new StringFieldEditor(
            "boxip",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip", "boxip", "label", this.m_language),
            c);
    sfe.setStringValue("fritz.box");
    this.m_boxip = "fritz.box";

    sfe.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
              m_boxip = (String) e.getNewValue();
            setPageComplete(isComplete());
          }
        });

    ComboFieldEditor mode =
        new ComboFieldEditor(
            "boxloginmode",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip",
                "boxloginmode",
                "label",
                this.m_language),
            new String[][] {
              {
                this.m_i18n.getString(
                    "ui.jface.configuration.pages.FritzBoxVoip",
                    "userpassword",
                    "label",
                    this.m_language),
                "0"
              },
              {
                this.m_i18n.getString(
                    "ui.jface.configuration.pages.FritzBoxVoip",
                    "password_only",
                    "label",
                    this.m_language),
                "1"
              }
            },
            c);

    final StringFieldEditor sfe1 =
        new StringFieldEditor(
            "boxuser",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip", "boxuser", "label", this.m_language),
            c);

    sfe1.setStringValue("");
    this.m_boxuser = "";

    mode.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String) {
              String state = (String) e.getNewValue();
              if (state.equalsIgnoreCase("1")) {
                sfe1.setEnabled(false, c);
                sfe1.setStringValue("");
                sfe1.getTextControl(c)
                    .setBackground(new Color(DisplayManager.getDefaultDisplay(), 190, 190, 190));
                m_boxuser = "";
              } else {
                sfe1.setEnabled(true, c);
                sfe1.getTextControl(c)
                    .setBackground(new Color(DisplayManager.getDefaultDisplay(), 255, 255, 255));
              }
            }
          }
        });

    sfe1.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
              m_boxuser = (String) e.getNewValue();
            setPageComplete(isComplete());
          }
        });

    sfe =
        new StringFieldEditor(
            "boxpassword",
            this.m_i18n.getString(
                "ui.jface.configuration.pages.FritzBoxVoip",
                "boxpassword",
                "label",
                this.m_language),
            c);

    sfe.getTextControl(c).setEchoChar('*');
    sfe.setStringValue("");
    this.m_boxpassword = "";

    sfe.setPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent e) {
            if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
              m_boxpassword = (String) e.getNewValue();
            setPageComplete(isComplete());
          }
        });

    new Label(c, SWT.LEFT);
    Text l = new Text(c, SWT.LEFT | SWT.WRAP);
    l.setText(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "openfb", "label", this.m_language));
    l.setEditable(false);
    l.setBackground(parent.getBackground());

    new Label(c, SWT.LEFT);
    HyperLink hl = new HyperLink(c, SWT.LEFT | SWT.WRAP);
    hl.setText(
        this.m_i18n.getString(
            "ui.jface.configuration.pages.FritzBoxVoip", "openfb2", "label", this.m_language));
    hl.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 1) Program.launch("http://www.janrufmonitor.de/fritzbox-freischalten");
          }
        });

    setPageComplete(isComplete());
    setControl(c);
  }