@Override
    public void configureRegistry(IConfigRegistry configRegistry) {
      super.configureRegistry(configRegistry);

      Style errorStyle = new Style();
      errorStyle.setAttributeValue(CellStyleAttributes.IMAGE, ERROR_IMAGE);
      configRegistry.registerConfigAttribute(
          CellConfigAttributes.CELL_STYLE, errorStyle, DisplayMode.NORMAL, Level.SEVERE.toString());

      Style warningStyle = new Style();
      warningStyle.setAttributeValue(CellStyleAttributes.IMAGE, WARNING_IMAGE);
      configRegistry.registerConfigAttribute(
          CellConfigAttributes.CELL_STYLE,
          warningStyle,
          DisplayMode.NORMAL,
          Level.WARNING.toString());

      Style informationStyle = new Style();
      informationStyle.setAttributeValue(CellStyleAttributes.IMAGE, INFORMATION_IMAGE);
      configRegistry.registerConfigAttribute(
          CellConfigAttributes.CELL_STYLE,
          informationStyle,
          DisplayMode.NORMAL,
          Level.INFO.toString());
    }
Ejemplo n.º 2
0
public class ReportPreferencePage extends FieldEditorPreferencePage
    implements IWorkbenchPreferencePage {

  private String[][] logLvlValues =
      new String[][] {
        new String[] {Messages.getString("ReportLogLevel.0"), Level.INFO.toString()},
        new String[] {Messages.getString("ReportLogLevel.1"), Level.WARNING.toString()},
        new String[] {Messages.getString("ReportLogLevel.2"), Level.FINEST.toString()},
        new String[] {Messages.getString("ReportLogLevel.3"), Level.SEVERE.toString()},
        new String[] {Messages.getString("ReportLogLevel.4"), Level.ALL.toString()}
      };
  private DirectoryFieldEditor localTemplateEditor;

  public ReportPreferencePage() {
    super(GRID);
    setDescription(Messages.getString("ReportPreferencePage.0")); // $NON-NLS-1$
  }

  /* (non-Javadoc)
   * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
   */
  @Override
  public void init(IWorkbench arg0) {
    setPreferenceStore(Activator.getDefault().getPreferenceStore());
  }

  /* (non-Javadoc)
   * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
   */
  @Override
  protected void createFieldEditors() {

    BooleanFieldEditor reportLoggingEditor =
        new BooleanFieldEditor(
            PreferenceConstants.REPORT_LOGGING_ENABLED,
            Messages.getString("ReportPreferencePage.1"),
            getFieldEditorParent());
    addField(reportLoggingEditor);

    ComboFieldEditor logLvlFieldEditor =
        new ComboFieldEditor(
            PreferenceConstants.REPORT_LOGGING_LVL,
            Messages.getString("ReportPreferencePage.2"),
            logLvlValues,
            getFieldEditorParent());
    addField(logLvlFieldEditor);

    DirectoryFieldEditor logFileNameEditor =
        new DirectoryFieldEditor(
            PreferenceConstants.REPORT_LOG_FILE,
            Messages.getString("ReportPreferencePage.3"),
            getFieldEditorParent());
    addField(logFileNameEditor);

    localTemplateEditor =
        new DirectoryFieldEditor(
            PreferenceConstants.REPORT_LOCAL_TEMPLATE_DIRECTORY,
            Messages.getString("ReportPreferencePage.8"),
            getFieldEditorParent());
    addField(localTemplateEditor);

    BooleanFieldEditor useCacheEditor =
        new BooleanFieldEditor(
            PreferenceConstants.REPORT_USE_CACHE,
            Messages.getString("ReportPreferencePage.7"),
            getFieldEditorParent());
    addField(useCacheEditor);
  }

  @Override
  public void propertyChange(PropertyChangeEvent event) {
    super.propertyChange(event);
    if (event.getProperty().equals(FieldEditor.VALUE)) {
      checkState();
    }

    if (event.getSource() == localTemplateEditor) {
      Activator.getDefault()
          .getIReportTemplateDirectoryService()
          .setDirectory((String) event.getNewValue());
    }
  }

  @Override
  protected void checkState() {
    super.checkState();
    if (!isValid()) {
      return;
    }
  }
}