From 08de213b260397ee02aa02d4e7cf7b2747c495c8 Mon Sep 17 00:00:00 2001 From: James Blackburn Date: Fri, 14 Jan 2011 10:27:31 +0000 Subject: [PATCH] Bug 334118 - Build Preferences need some tidying Re-factor the build preferences out of CPluginPreferencePage to their own page BuildPreferencePage. Build category defined by cdt.ui: org.eclipse.cdt.ui.preferences.BuildSettings --- .../org.eclipse.cdt.make.ui/plugin.properties | 4 +- build/org.eclipse.cdt.make.ui/plugin.xml | 8 +- .../plugin.xml | 4 +- core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF | 1 + core/org.eclipse.cdt.ui/plugin.properties | 4 +- core/org.eclipse.cdt.ui/plugin.xml | 14 +- .../ui/build/BuildPreferencePage.java | 174 ++++++++++++++++++ .../ui/preferences/CPluginPreferencePage.java | 56 +----- .../ui/preferences/PreferencesMessages.java | 5 +- .../PreferencesMessages.properties | 5 +- 10 files changed, 209 insertions(+), 66 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties index c9969ad19de..21b341f00ec 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.properties +++ b/build/org.eclipse.cdt.make.ui/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2010 QNX Software Systems and others. +# Copyright (c) 2003, 2011 QNX Software Systems and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -40,7 +40,7 @@ LastTargetBuild.name=Rebuild Last Target LastTargetBuild.description=Rebuild the last make target for the selected container or project. # Build Preference page -PreferenceBuildSettings.name=Build +PreferenceBuildSettings.name=Settings ErrorParsersTab.name=Error Parsers ErrorParsersTab.tooltip=Error Parsers scan build output and report errors in Problems view diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml index c6418d6df98..3fd917f70ba 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.xml +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -158,19 +158,19 @@ point="org.eclipse.ui.preferencePages"> + id="org.eclipse.cdt.ui.preferences.BuildSettingProperties"> diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml index d46cd823111..d586182b82e 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml @@ -50,12 +50,12 @@ class="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_NewCDTWizard" id="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_NewCDTWizard"/> diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 4476127600d..0d2c61da2be 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -14,6 +14,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.internal.ui;x-friends:="org.eclipse.cdt.debug.edc.tests", org.eclipse.cdt.internal.ui.actions;x-internal:=true, org.eclipse.cdt.internal.ui.browser.opentype;x-internal:=true, + org.eclipse.cdt.internal.ui.build;x-internal:=true, org.eclipse.cdt.internal.ui.buildconsole;x-internal:=true, org.eclipse.cdt.internal.ui.callhierarchy;x-internal:=true, org.eclipse.cdt.internal.ui.compare;x-internal:=true, diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index c76042a22be..71a9341e652 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2010 IBM Corporation, QNX Software Systems, and others. +# Copyright (c) 2003, 2011 IBM Corporation, QNX Software Systems, and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -13,6 +13,7 @@ # QNX Software Systems - [272416] Rework the working set configurations # Axel Mueller - [289339] Surround with # Tomasz Wesolowski +# James Blackburn (Broadcom Corp.) ############################################################################### pluginName=C/C++ Development Tools UI providerName=Eclipse CDT @@ -177,6 +178,7 @@ CEditor.name=C/C++ Editor CPluginPreferencePage.name=C/C++ CPluginEditorPreferencePage.name=Editor CPluginTemplatePreferencePage.name=Templates +CPluginBuildPreferencePage.name=Build CPluginBuildConsolePreferencePage.name=Console CPluginGlobalBuildLogPreferencePage.name=Logging CPluginFileTypesPreferencePage.name=File Types diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 32ec7a3eaf8..a61db20ebee 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -676,17 +676,25 @@ + + + + + id="org.eclipse.cdt.ui.preferences.CBuildConsolePreferernces"> diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java new file mode 100644 index 00000000000..5c1f8984e9c --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java @@ -0,0 +1,174 @@ +/******************************************************************************* + * Copyright (c) 2000, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * QNX Software System + * Anton Leherbauer (Wind River Systems) + * Sergey Prigogin (Google) + * James Blackburn (Broadcom Corp.) + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.build; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.PlatformUI; + +import org.eclipse.cdt.core.resources.ACBuilder; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages; + +/** + * The page for top-level build preferences + */ +public class BuildPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + private static final int GROUP_VINDENT = 5; + private static final int GROUP_HINDENT = 20; + private Button buildActive, buildAll, buildOnlyOnRefChange; + + public BuildPreferencePage() { + super(); + setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); + setDescription(PreferencesMessages.CBuildPreferencePage_description); + } + + @Override + public void createControl(Composite parent) { + super.createControl(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_PREF_PAGE); + } + + @Override + protected Control createContents(Composite parent) { + initializeDialogUnits(parent); + + Composite container= new Composite(parent, SWT.NONE); + GridLayout layout= new GridLayout(); + layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth= 0; + layout.verticalSpacing= convertVerticalDLUsToPixels(10); + layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); + container.setLayout(layout); + + // Build either default configuration or all. + Group gr = addGroup(container, PreferencesMessages.CPluginPreferencePage_build_scope); + Label l1 = new Label(gr, SWT.NONE); + l1.setText(PreferencesMessages.CPluginPreferencePage_1); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.verticalIndent = GROUP_VINDENT; + l1.setLayoutData(gd); + + boolean needAllConfigBuild = ACBuilder.needAllConfigBuild(); + + buildActive = new Button(gr, SWT.RADIO); + buildActive.setText(PreferencesMessages.CPluginPreferencePage_2); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.verticalIndent = GROUP_VINDENT; + gd.horizontalIndent = GROUP_HINDENT; + buildActive.setLayoutData(gd); + buildActive.setSelection(!needAllConfigBuild); + + buildAll = new Button(gr, SWT.RADIO); + buildAll.setText(PreferencesMessages.CPluginPreferencePage_3); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalIndent = GROUP_HINDENT; + buildAll.setLayoutData(gd); + buildAll.setSelection(needAllConfigBuild); + + addNote(gr, PreferencesMessages.CPluginPreferencePage_4); + + // Building project dependencies. + Group gr2 = addGroup(container, PreferencesMessages.CPluginPreferencePage_building_configurations); + buildOnlyOnRefChange = new Button(gr2, SWT.CHECK); + buildOnlyOnRefChange.setText(PreferencesMessages.CPluginPreferencePage_7); + GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); + gd2.verticalIndent = GROUP_VINDENT; + buildOnlyOnRefChange.setLayoutData(gd2); + buildOnlyOnRefChange.setSelection(ACBuilder.buildConfigResourceChanges()); + + Dialog.applyDialogFont(container); + return container; + } + + private void addNote(Group parent, String noteMessage) { + Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), parent, + PreferencesMessages.CPluginPreferencePage_note, noteMessage); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.verticalIndent = GROUP_VINDENT; + noteControl.setLayoutData(gd); + } + + @Override + protected Composite createNoteComposite(Font font, Composite composite, String title, String message) { + Composite messageComposite = super.createNoteComposite(font, composite, title, message); + Control[] children = messageComposite.getChildren(); + if (children.length == 2 && (children[1] instanceof Label)) { + // this is temporary fix for problem that 3 line note does not displayed properly within the group + Label messageLabel = (Label) children[1]; + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint=500; + messageLabel.setLayoutData(gd); + } + return messageComposite; + } + + private Group addGroup(Composite parent, String label) { + return addGroup(parent, label, 1); + } + + private Group addGroup(Composite parent, String label, int numColumns) { + Group group = new Group(parent, SWT.NONE); + group.setText(label); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + group.setLayout(new GridLayout(numColumns, false)); + return group; + } + + /** + * @see IWorkbenchPreferencePage#init + */ + public void init(IWorkbench workbench) { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.IPreferencePage#performOk() + */ + @Override + public boolean performOk() { + if (!super.performOk()) + return false; + // tell the Core Plugin about this preference + ACBuilder.setAllConfigBuild(buildAll.getSelection()); + ACBuilder.setBuildConfigResourceChanges(buildOnlyOnRefChange.getSelection()); + return true; + } + + @Override + protected void performDefaults() { + ACBuilder.setAllConfigBuild(false); + ACBuilder.setBuildConfigResourceChanges(false); + buildActive.setSelection(true); + buildAll.setSelection(false); + buildOnlyOnRefChange.setSelection(false); + super.performDefaults(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java index 68fe8d92364..530d8db33f8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ * QNX Software System * Anton Leherbauer (Wind River Systems) * Sergey Prigogin (Google) + * James Blackburn (Broadcom Corp.) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; @@ -37,7 +38,6 @@ import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; @@ -52,10 +52,8 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP public static final String C_BASE_PREF_PAGE_ID= "org.eclipse.cdt.ui.preferences.CPluginPreferencePage"; //$NON-NLS-1$ private static final int GROUP_VINDENT = 5; - private static final int GROUP_HINDENT = 20; private ArrayList