1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

2005-01-29 Alain Magloire

Fix for 81403: Move the Code Assist preference page
	out of the CEditor preference page.  It clean the CEditorPreferencePage
	and takes less time to instantiate.
	New checkbox in Code Assist to complete common prefix.
	+ src/org/eclipse/cdt/internal/ui/preferences/AbstracPreferencePage.java
	* src/org/eclipse/cdt/internal/ui/prefernces/CEditorPreferencePage.java
	+ src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencge.java
	* src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessage.java
	* src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
	* src/org/eclipse/cdt/ui/CUIPrefernceInitializer.java
	* plugin.xml
	* plugin.properties
This commit is contained in:
Alain Magloire 2005-01-30 04:27:36 +00:00
parent d35174e94d
commit a865ae80b6
9 changed files with 560 additions and 163 deletions

View file

@ -1,3 +1,17 @@
2005-01-29 Alain Magloire
Fix for 81403: Move the Code Assist preference page
out of the CEditor preference page. It clean the CEditorPreferencePage
and takes less time to instantiate.
New checkbox in Code Assist to complete common prefix.
+ src/org/eclipse/cdt/internal/ui/preferences/AbstracPreferencePage.java
* src/org/eclipse/cdt/internal/ui/prefernces/CEditorPreferencePage.java
+ src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencge.java
* src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessage.java
* src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
* src/org/eclipse/cdt/ui/CUIPrefernceInitializer.java
* plugin.xml
* plugin.properties
2005-01-28 Alain Magloire
Add Indexer search in the Source Hover implementation.
* src/org/eclipse/cdt/intenal/ui/text/CSourceHover.java

View file

@ -110,6 +110,7 @@ CPluginTemplatePreferencePage.name=Code Templates
CPluginBuildConsolePreferencePage.name=Build Console
CPluginFileTypesPreferencePage.name=File Types
CodeFormatterPreferencePage.name=Code Formatter
CodeAssistPreferencePage.name=Code Assist
todoPageName=C/C++ Task Tags
todoTaskPrefName=Task Tags

View file

@ -553,6 +553,12 @@
class="org.eclipse.cdt.internal.ui.preferences.CEditorPreferencePage"
id="org.eclipse.cdt.ui.preferences.CEditorPreferencePage">
</page>
<page
name="%CodeAssistPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage"
id="org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage">
</page>
<page
name="%CPluginTemplatePreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"

View file

@ -0,0 +1,300 @@
/**********************************************************************
* Copyright (c) 2002,2003,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 java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.RGB;
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.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
* AbstractPreferencePage
*/
public abstract class AbstractPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
protected OverlayPreferenceStore fOverlayStore;
protected Map fTextFields = new HashMap();
private ModifyListener fTextFieldListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text text = (Text) e.widget;
fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
}
};
protected Map fCheckBoxes = new HashMap();
private SelectionListener fCheckBoxListener = new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.widget;
fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
}
};
protected ArrayList fNumberFields = new ArrayList();
private ModifyListener fNumberFieldListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
numberFieldChanged((Text) e.widget);
}
};
protected Map fColorButtons = new HashMap();
private SelectionListener fColorButtonListener = new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
ColorEditor editor = (ColorEditor) e.widget.getData();
PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
}
};
protected Button addRadioButton(Composite parent, String label, String key, int indentation) {
Button radioButton = new Button(parent, SWT.RADIO);
radioButton.setText(label);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = indentation;
gd.horizontalSpan = 2;
radioButton.setLayoutData(gd);
radioButton.addSelectionListener(fCheckBoxListener);
fCheckBoxes.put(radioButton, key);
return radioButton;
}
protected Button addCheckBox(Composite parent, String label, String key, int indentation) {
Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = indentation;
gd.horizontalSpan = 2;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(fCheckBoxListener);
fCheckBoxes.put(checkBox, key);
return checkBox;
}
protected Group addGroupBox(Composite parent, String label, int nColumns ){
Group group = new Group(parent, SWT.NONE);
group.setText(label);
GridLayout layout = new GridLayout();
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
layout.numColumns = nColumns;
group.setLayout(layout);
group.setLayoutData(gd);
return group;
}
protected Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
textControl.setLayoutData(gd);
textControl.setTextLimit(textLimit);
fTextFields.put(textControl, key);
if (isNumber) {
fNumberFields.add(textControl);
textControl.addModifyListener(fNumberFieldListener);
} else {
textControl.addModifyListener(fTextFieldListener);
}
return textControl;
}
protected void numberFieldChanged(Text textControl) {
String number = textControl.getText();
IStatus status = validatePositiveNumber(number);
if (!status.matches(IStatus.ERROR))
fOverlayStore.setValue((String) fTextFields.get(textControl), number);
updateStatus(status);
}
private IStatus validatePositiveNumber(String number) {
StatusInfo status = new StatusInfo();
if (number.length() == 0) {
status.setError(PreferencesMessages.getString("CEditorPreferencePage.empty_input")); //$NON-NLS-1$
} else {
try {
int value = Integer.parseInt(number);
if (value < 0)
status.setError(PreferencesMessages.getString("CEditorPreferencePage.invalid_input")); //$NON-NLS-1$
} catch (NumberFormatException e) {
status.setError(PreferencesMessages.getString("CEditorPreferencePage.invalid_input")); //$NON-NLS-1$
}
}
return status;
}
protected void updateStatus(IStatus status) {
if (!status.matches(IStatus.ERROR)) {
for (int i = 0; i < fNumberFields.size(); i++) {
Text text = (Text) fNumberFields.get(i);
IStatus s = validatePositiveNumber(text.getText());
status = StatusUtil.getMoreSevere(s, status);
}
}
//status= StatusUtil.getMoreSevere(fCEditorHoverConfigurationBlock.getStatus(), status);
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
}
protected Control addColorButton(Composite parent, String label, String key, int indentation) {
Composite composite = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
composite.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
ColorEditor editor = new ColorEditor(composite);
Button button = editor.getButton();
button.setData(editor);
gd = new GridData();
gd.horizontalAlignment = GridData.END;
button.setLayoutData(gd);
button.addSelectionListener(fColorButtonListener);
fColorButtons.put(editor, key);
return composite;
}
/**
*
*/
public AbstractPreferencePage() {
super();
setPreferenceStore(PreferenceConstants.getPreferenceStore());
fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), createOverlayStoreKeys());
}
protected abstract OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys();
public void createControl(Composite parent){
fOverlayStore.load();
fOverlayStore.start();
super.createControl(parent);
initializeFields();
}
protected void initializeFields() {
Iterator e = fColorButtons.keySet().iterator();
while (e.hasNext()) {
ColorEditor c = (ColorEditor) e.next();
String key = (String) fColorButtons.get(c);
RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
c.setColorValue(rgb);
}
e = fCheckBoxes.keySet().iterator();
while (e.hasNext()) {
Button b = (Button) e.next();
String key = (String) fCheckBoxes.get(b);
b.setSelection(fOverlayStore.getBoolean(key));
}
e = fTextFields.keySet().iterator();
while (e.hasNext()) {
Text t = (Text) e.next();
String key = (String) fTextFields.get(t);
t.setText(fOverlayStore.getString(key));
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
}
/*
* @see PreferencePage#performOk()
*/
public boolean performOk() {
fOverlayStore.propagate();
return true;
}
/*
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
fOverlayStore.loadDefaults();
initializeFields();
super.performDefaults();
}
/*
* @see DialogPage#dispose()
*/
public void dispose() {
if (fOverlayStore != null) {
fOverlayStore.stop();
fOverlayStore = null;
}
super.dispose();
}
}

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
@ -195,21 +194,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.TIMEOUT_DELAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SEARCH_SCOPE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR));
@ -276,24 +260,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
store.setDefault(ContentAssistPreference.TIMEOUT_DELAY, 3000);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
store.setDefault(ContentAssistPreference.AUTOINSERT, true);
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
store.setDefault(ContentAssistPreference.ADD_INCLUDE, true);
store.setDefault(CEditor.HYPERLINK_ENABLED,true);
// override default extended text editor prefs
@ -762,71 +728,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
fMasterSlaveListeners.add(listener);
}
private Control createContentAssistPage(Composite parent) {
Composite contentAssistComposite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
contentAssistComposite.setLayout(layout);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// The following three radio buttons are grouped together
String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle"); //$NON-NLS-1$
Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption"); //$NON-NLS-1$
addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption"); //$NON-NLS-1$
addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically"); //$NON-NLS-1$
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder"); //$NON-NLS-1$
addCheckBox(contentAssistComposite, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.timeoutDelay"); //$NON-NLS-1$
addTextField(contentAssistComposite, label, ContentAssistPreference.TIMEOUT_DELAY, 6, 0, true);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// The following items are grouped for Auto Activation
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle"); //$NON-NLS-1$
Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot"); //$NON-NLS-1$
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow"); //$NON-NLS-1$
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDoubleColon"); //$NON-NLS-1$
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationDelay"); //$NON-NLS-1$
addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor"); //$NON-NLS-1$
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_BACKGROUND, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor"); //$NON-NLS-1$
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FOREGROUND, 0);
// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor");
// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_BACKGROUND, 0);
//
// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterForegroundColor");
// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_FOREGROUND, 0);
WorkbenchHelp.setHelp(contentAssistComposite, ICHelpContextIds.C_EDITOR_CONTENT_ASSIST_PREF_PAGE);
return contentAssistComposite;
}
/*
* @see PreferencePage#createContents(Composite)
*/
@ -851,10 +752,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
item.setText(PreferencesMessages.getString("CEditorPreferencePage.colorsTabTitle")); //$NON-NLS-1$
item.setControl(createSyntaxPage(folder));
item = new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CEditorPreferencePage.contentAssistTabTitle")); //$NON-NLS-1$
item.setControl(createContentAssistPage(folder));
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$
item.setControl(fCEditorHoverConfigurationBlock.createControl(folder));
@ -1008,51 +905,51 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
super.dispose();
}
private Control addColorButton(Composite parent, String label, String key, int indentation) {
// private Control addColorButton(Composite parent, String label, String key, int indentation) {
//
// Composite composite = new Composite(parent, SWT.NONE);
// GridData gd = new GridData(GridData.FILL_HORIZONTAL);
// gd.horizontalSpan = 2;
// composite.setLayoutData(gd);
//
// GridLayout layout = new GridLayout();
// layout.numColumns = 2;
// layout.marginWidth = 0;
// layout.marginHeight = 0;
// composite.setLayout(layout);
//
// Label labelControl = new Label(composite, SWT.NONE);
// labelControl.setText(label);
//
// gd = new GridData(GridData.FILL_HORIZONTAL);
// gd.horizontalIndent = indentation;
// labelControl.setLayoutData(gd);
//
// ColorEditor editor = new ColorEditor(composite);
// Button button = editor.getButton();
// button.setData(editor);
//
// gd = new GridData();
// gd.horizontalAlignment = GridData.END;
// button.setLayoutData(gd);
// button.addSelectionListener(fColorButtonListener);
//
// fColorButtons.put(editor, key);
//
// return composite;
// }
Composite composite = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
composite.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
ColorEditor editor = new ColorEditor(composite);
Button button = editor.getButton();
button.setData(editor);
gd = new GridData();
gd.horizontalAlignment = GridData.END;
button.setLayoutData(gd);
button.addSelectionListener(fColorButtonListener);
fColorButtons.put(editor, key);
return composite;
}
private Group addGroupBox(Composite parent, String label, int nColumns ){
Group group = new Group(parent, SWT.NONE);
group.setText(label);
GridLayout layout = new GridLayout();
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
layout.numColumns = nColumns;
group.setLayout(layout);
group.setLayoutData(gd);
return group;
}
// private Group addGroupBox(Composite parent, String label, int nColumns ){
// Group group = new Group(parent, SWT.NONE);
// group.setText(label);
// GridLayout layout = new GridLayout();
// GridData gd = new GridData(GridData.FILL_HORIZONTAL);
// gd.horizontalSpan = 2;
// layout.numColumns = nColumns;
// group.setLayout(layout);
// group.setLayoutData(gd);
// return group;
// }
private Button addCheckBox(Composite parent, String label, String key, int indentation) {
Button checkBox = new Button(parent, SWT.CHECK);
@ -1069,20 +966,20 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
return checkBox;
}
private Button addRadioButton(Composite parent, String label, String key, int indentation) {
Button radioButton = new Button(parent, SWT.RADIO);
radioButton.setText(label);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = indentation;
gd.horizontalSpan = 2;
radioButton.setLayoutData(gd);
radioButton.addSelectionListener(fCheckBoxListener);
fCheckBoxes.put(radioButton, key);
return radioButton;
}
// private Button addRadioButton(Composite parent, String label, String key, int indentation) {
// Button radioButton = new Button(parent, SWT.RADIO);
// radioButton.setText(label);
//
// GridData gd = new GridData(GridData.FILL_HORIZONTAL);
// gd.horizontalIndent = indentation;
// gd.horizontalSpan = 2;
// radioButton.setLayoutData(gd);
// radioButton.addSelectionListener(fCheckBoxListener);
//
// fCheckBoxes.put(radioButton, key);
//
// return radioButton;
// }
private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {

View file

@ -0,0 +1,168 @@
/**********************************************************************
* Copyright (c) 2002,2003,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 java.util.ArrayList;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.help.WorkbenchHelp;
/**
* CodeAssistPreferencePage
*/
public class CodeAssistPreferencePage extends AbstractPreferencePage {
/**
*
*/
public CodeAssistPreferencePage() {
super();
//setDescription(PreferencesMessages.getString("CodeAssistPreferencePage.description")); //$NON-NLS-1$
}
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList overlayKeys = new ArrayList();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CODEASSIST_PREFIX_COMPLETION));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.TIMEOUT_DELAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SEARCH_SCOPE));
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
protected Control createContents(Composite parent) {
Composite contentAssistComposite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
contentAssistComposite.setLayout(layout);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// The following three radio buttons are grouped together
String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle"); //$NON-NLS-1$
Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption"); //$NON-NLS-1$
addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption"); //$NON-NLS-1$
addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertionGroupTitle"); //$NON-NLS-1$
Group insertionGroup = addGroupBox(contentAssistComposite, label, 2);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically"); //$NON-NLS-1$
addCheckBox(insertionGroup, label, ContentAssistPreference.AUTOINSERT, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertCommonProposalAutomatically"); //$NON-NLS-1$
addCheckBox(insertionGroup, label, ContentAssistPreference.CODEASSIST_PREFIX_COMPLETION, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder"); //$NON-NLS-1$
addCheckBox(insertionGroup, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.timeoutDelay"); //$NON-NLS-1$
addTextField(insertionGroup, label, ContentAssistPreference.TIMEOUT_DELAY, 6, 0, true);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// The following items are grouped for Auto Activation
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle"); //$NON-NLS-1$
Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot"); //$NON-NLS-1$
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow"); //$NON-NLS-1$
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDoubleColon"); //$NON-NLS-1$
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationDelay"); //$NON-NLS-1$
addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor"); //$NON-NLS-1$
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_BACKGROUND, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor"); //$NON-NLS-1$
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FOREGROUND, 0);
// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor");
// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_BACKGROUND, 0);
//
// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterForegroundColor");
// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_FOREGROUND, 0);
WorkbenchHelp.setHelp(contentAssistComposite, ICHelpContextIds.C_EDITOR_CONTENT_ASSIST_PREF_PAGE);
return contentAssistComposite;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
public static void initDefaults(IPreferenceStore store) {
store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
store.setDefault(ContentAssistPreference.TIMEOUT_DELAY, 3000);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
store.setDefault(ContentAssistPreference.AUTOINSERT, true);
store.setDefault(ContentAssistPreference.CODEASSIST_PREFIX_COMPLETION, true);
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
store.setDefault(ContentAssistPreference.ADD_INCLUDE, true);
}
}

View file

@ -69,10 +69,14 @@ CEditorPreferencePage.contentAssistTabTitle=Content A&ssist
CEditorPreferencePage.invalid_input=Invalid input.
CEditorPreferencePage.empty_input=Empty input
CodeAssistPreferencePage.name=Code Assist
CodeAssistPreferencePage.description=Code Assist
CEditorPreferencePage.ContentAssistPage.searchGroupTitle=Search scope for completion proposals:
CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption=S&earch current file and included files
CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption=Search current &project
CEditorPreferencePage.ContentAssistPage.insertionGroupTitle=Insertion
CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=&Insert single proposals automatically
CEditorPreferencePage.ContentAssistPage.insertCommonProposalAutomatically=Insert common prefixes automatically
CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt
CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
CEditorPreferencePage.ContentAssistPage.timeoutDelay=Content Assist parsing &timeout (ms)

View file

@ -38,6 +38,8 @@ public class ContentAssistPreference {
public final static String PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
/** Preference key for content assist auto insert */
public final static String AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$
/** Preference key for content assist to insert the common prefix */
public final static String CODEASSIST_PREFIX_COMPLETION= "content_assist_prefix_completion"; //$NON-NLS-1$
/** Preference key for C/CPP content assist auto activation triggers */
public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$
@ -140,6 +142,9 @@ public class ContentAssistPreference {
enabled= store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
enabled = store.getBoolean(CODEASSIST_PREFIX_COMPLETION);
assistant.enablePrefixCompletion(enabled);
configureCProcessor(assistant, store);
}

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
import org.eclipse.cdt.internal.ui.preferences.CEditorPreferencePage;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
import org.eclipse.cdt.internal.ui.preferences.CSearchPreferencePage;
import org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage;
import org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
@ -43,6 +44,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
CSearchPreferencePage.initDefaults(store);
CView.initDefaults(store);
CEditorPreferencePage.initDefaults(store);
CodeAssistPreferencePage.initDefaults(store);
}
}