From 39acf97212bfd03c2a4730677b0b676ca6512807 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Fri, 5 Nov 2004 23:22:40 +0000 Subject: [PATCH] Code formatter Preference Page. --- .../CodeFormatterPreferencePage.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java new file mode 100644 index 00000000000..fe5a29045d8 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.preferences; + + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.dialogs.CodeFormatterBlock; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.help.WorkbenchHelp; + +/** + * + */ +public class CodeFormatterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + CodeFormatterBlock fCodeFormatterBlock; + + public CodeFormatterPreferencePage() { + setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); + // only used when page is shown programatically + setTitle(PreferencesMessages.getString("CodeFormatterPreferencePage.title")); //$NON-NLS-1$ + //setDescription(PreferencesMessages.getString("CodeFormatterPreferencePage.description")); //$NON-NLS-1$ + fCodeFormatterBlock= new CodeFormatterBlock(CUIPlugin.getDefault().getPluginPreferences()); + } + + + /* + * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + + /* + * @see PreferencePage#createContents(Composite) + */ + protected Control createContents(Composite parent) { + Composite topPane = new Composite(parent, SWT.NONE); + + topPane.setLayout(new GridLayout()); + topPane.setLayoutData(new GridData(GridData.FILL_BOTH)); + + + applyDialogFont(parent); + WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE); + return fCodeFormatterBlock.createControl(topPane); + } + + /* + * @see IPreferencePage#performOk() + */ + public boolean performOk() { + fCodeFormatterBlock.performOk(); + return super.performOk(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + protected void performDefaults() { + fCodeFormatterBlock.performDefaults(); + super.performDefaults(); + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus) + */ + public void statusChanged(IStatus status) { + setValid(!status.matches(IStatus.ERROR)); + StatusUtil.applyToStatusLine(this, status); + } + +}