1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

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
This commit is contained in:
James Blackburn 2011-01-14 10:27:31 +00:00
parent 3bf6639e4b
commit 08de213b26
10 changed files with 209 additions and 66 deletions

View file

@ -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

View file

@ -158,19 +158,19 @@
point="org.eclipse.ui.preferencePages">
<page
name="%PreferenceBuildSettings.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.make.internal.ui.preferences.BuildSettingsPreferencePage"
id="org.eclipse.cdt.make.ui.preferences.BuildSettings">
id="org.eclipse.cdt.ui.preferences.BuildSettingProperties">
</page>
<page
name="%PreferenceMake.name"
category="org.eclipse.cdt.make.ui.preferences.BuildSettings"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage"
id="org.eclipse.cdt.make.ui.preferences.MakePreferencePage">
</page>
<page
name="%PreferenceMakefileEditor.name"
category="org.eclipse.cdt.make.ui.preferences.BuildSettings"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.make.internal.ui.preferences.MakefileEditorPreferencePage"
id="org.eclipse.cdt.make.ui.preferences.MakeFileEditorPreferencePage">
</page>

View file

@ -50,12 +50,12 @@
class="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_NewCDTWizard"
id="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_NewCDTWizard"/>
<page
category="org.eclipse.cdt.make.ui.preferences.BuildSettings"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_Env"
id="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_Env"
name="%envPrefName"/>
<page
category="org.eclipse.cdt.make.ui.preferences.BuildSettings"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_Vars"
id="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_Vars"
name="%varsPrefName"/>

View file

@ -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,

View file

@ -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

View file

@ -676,17 +676,25 @@
<keywordReference id="org.eclipse.cdt.ui.codestyle"/>
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
<!-- Build Preference page category provided by CDT UI -->
<page
name="%CPluginBuildPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.build.BuildPreferencePage"
id="org.eclipse.cdt.ui.preferences.BuildSettings">
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
<!-- Note that build console should be eventually moved to build plugin -->
<page
name="%CPluginBuildConsolePreferencePage.name"
category="org.eclipse.cdt.make.ui.preferences.BuildSettings"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage"
id="org.eclipse.cdt.ui.preferneces.CBuildConsolePreferernces">
id="org.eclipse.cdt.ui.preferences.CBuildConsolePreferernces">
<keywordReference id="org.eclipse.cdt.ui.common"/>
</page>
<page
name="%CPluginGlobalBuildLogPreferencePage.name"
category="org.eclipse.cdt.make.ui.preferences.BuildSettings"
category="org.eclipse.cdt.ui.preferences.BuildSettings"
class="org.eclipse.cdt.internal.ui.preferences.GlobalBuildLogPreferencePage"
id="org.eclipse.cdt.ui.preferences.CGlobalBuildLogPreferences">
<keywordReference id="org.eclipse.cdt.ui.common"/>

View file

@ -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();
}
}

View file

@ -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<Button> fCheckBoxes;
private Button b1, b2, b3;
public CPluginPreferencePage() {
super();
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
@ -87,43 +85,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
addNote(outlineViewGroup, PreferencesMessages.CPluginPreferencePage_performanceHint);
// 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();
b1 = new Button(gr, SWT.RADIO);
b1.setText(PreferencesMessages.CPluginPreferencePage_2);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = GROUP_VINDENT;
gd.horizontalIndent = GROUP_HINDENT;
b1.setLayoutData(gd);
b1.setSelection(!needAllConfigBuild);
b2 = new Button(gr, SWT.RADIO);
b2.setText(PreferencesMessages.CPluginPreferencePage_3);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = GROUP_HINDENT;
b2.setLayoutData(gd);
b2.setSelection(needAllConfigBuild);
addNote(gr, PreferencesMessages.CPluginPreferencePage_4);
// Building project dependencies.
Group gr2 = addGroup(container, PreferencesMessages.CPluginPreferencePage_building_configurations);
b3 = new Button(gr2, SWT.CHECK);
b3.setText(PreferencesMessages.CPluginPreferencePage_7);
GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
gd2.verticalIndent = GROUP_VINDENT;
b3.setLayoutData(gd2);
b3.setSelection(ACBuilder.buildConfigResourceChanges());
// Refactoring.
Group refactoringGroup = addGroup(container, PreferencesMessages.CPluginPreferencePage_refactoring_title);
addCheckBox(refactoringGroup,
@ -222,10 +184,7 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
public static boolean useStructuralParseMode() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
}
public static void setBuildAllMode3(boolean enable) {
}
/**
* @see IWorkbenchPreferencePage#init
*/
@ -255,8 +214,6 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
}
// tell the Core Plugin about this preference
CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode());
ACBuilder.setAllConfigBuild(b2.getSelection());
ACBuilder.setBuildConfigResourceChanges(b3.getSelection());
return true;
}
@ -269,10 +226,5 @@ public class CPluginPreferencePage extends PreferencePage implements IWorkbenchP
String key= (String) button.getData();
button.setSelection(store.getDefaultBoolean(key));
}
ACBuilder.setAllConfigBuild(false);
ACBuilder.setBuildConfigResourceChanges(false);
b1.setSelection(true);
b2.setSelection(false);
b3.setSelection(false);
}
}

View file

@ -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
@ -12,6 +12,7 @@
* Sergey Prigogin (Google)
* Andrew Ferguson (Symbian)
* Kirk Beitz (Nokia)
* James Blackburn (Broadcom Corp.)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
@ -306,6 +307,8 @@ public final class PreferencesMessages extends NLS {
public static String FileLanguagesPropertyPage_missingLanguage;
public static String FileLanguagesPropertyPage_mappingTableTitle;
public static String CBuildPreferencePage_description;
public static String CPluginPreferencePage_outline_view;
public static String CPluginPreferencePage_build_scope;
public static String CPluginPreferencePage_1;

View file

@ -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
@ -12,6 +12,7 @@
# Sergey Prigogin (Google)
# Andrew Ferguson (Symbian)
# Kirk Beitz (Nokia)
# James Blackburn (Broadcom Corp.)
###############################################################################
CEditorPreferencePage_link=C/C++ Editor Preferences. General preferences may be set via <a href="org.eclipse.ui.preferencePages.GeneralTextEditor">Text Editors</a>.
@ -349,6 +350,8 @@ FileLanguagesPropertyPage_mappingTableTitle = Language mappings for this file
ProposalFilterPreferencesUtil_defaultFilterName=<Default Filter>
# C/C++ Preferences
CBuildPreferencePage_description=General build settings for C/C++ Development:
CPluginPreferencePage_outline_view=Outline view
CPluginPreferencePage_build_scope=Build scope
CPluginPreferencePage_1=Commands 'Build project', 'Build All', 'Build Working Set':