1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 228653: [scalability mode] additional options

This commit is contained in:
Anton Leherbauer 2008-04-30 17:50:37 +00:00
parent f3ee65691f
commit 457ccce1be
8 changed files with 121 additions and 69 deletions

View file

@ -763,9 +763,9 @@
id="org.eclipse.cdt.ui.preferences.MarkOccurrencesPreferencePage"/>
<page
name="%ScalabilityPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.ScalabilityPreferencePage"
id="org.eclipse.cdt.ui.preferneces.CScalabilityPreferernces"/>
id="org.eclipse.cdt.ui.preferences.CScalabilityPreferences"/>
<!--page
name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"

View file

@ -95,7 +95,6 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.ISourceViewerExtension2;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
import org.eclipse.jface.text.source.projection.ProjectionSupport;
@ -1346,22 +1345,22 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
//Alert users that scalability mode should be turned on
if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) {
MessageDialogWithToggle dialog = new MessageDialogWithToggle(
Display.getCurrent().getActiveShell(),
Display.getCurrent().getActiveShell(),
CEditorMessages.getString("Scalability.info"), //$NON-NLS-1$
null,
null,
CEditorMessages.getString("Scalability.message"), //$NON-NLS-1$
MessageDialog.INFORMATION,
new String[] {IDialogConstants.OK_LABEL}, 0,
MessageDialog.INFORMATION,
new String[] {IDialogConstants.OK_LABEL}, 0,
CEditorMessages.getString("Scalability.reappear"), //$NON-NLS-1$
false) {
@Override
protected void buttonPressed(int buttonId) {
protected void buttonPressed(int buttonId) {
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState());
super.buttonPressed(buttonId);
}
};
};
dialog.setBlockOnOpen(false);
dialog.open();
dialog.open();
}
}
}
@ -1584,7 +1583,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
return;
}
if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) {
if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)
|| (isEnableScalablilityMode() && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(property))) {
if (isSemanticHighlightingEnabled()) {
installSemanticHighlighting();
fSemanticManager.refresh();
@ -1593,22 +1593,20 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
}
return;
}
//For Scalability
if (isEnableScalablilityMode()) {
if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property) ||
PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) {
asv.unconfigure();
asv.configure(getSourceViewerConfiguration());
}
}
IContentAssistant c = asv.getContentAssistant();
if (c instanceof ContentAssistant) {
ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
}
//For Scalability
if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property)) {
((SourceViewer)getSourceViewer()).unconfigure();
getSourceViewer().configure(getSourceViewerConfiguration());
}
if (PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) {
((SourceViewer)getSourceViewer()).unconfigure();
getSourceViewer().configure(getSourceViewerConfiguration());
}
}
} finally {
super.handlePreferenceStoreChanged(event);
@ -2819,7 +2817,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
protected String[] collectContextMenuPreferencePages() {
// Add C/C++ Editor relevant pages
String[] parentPrefPageIds = super.collectContextMenuPreferencePages();
String[] prefPageIds = new String[parentPrefPageIds.length + 10];
String[] prefPageIds = new String[parentPrefPageIds.length + 11];
int nIds = 0;
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$
@ -2831,6 +2829,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage"; //$NON-NLS-1$
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CScalabilityPreferences"; //$NON-NLS-1$
System.arraycopy(parentPrefPageIds, 0, prefPageIds, nIds, parentPrefPageIds.length);
return prefPageIds;
}
@ -2898,7 +2897,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
* @since 4.0
*/
private boolean isSemanticHighlightingEnabled() {
return SemanticHighlightings.isEnabled(getPreferenceStore());
return SemanticHighlightings.isEnabled(getPreferenceStore()) && !(isEnableScalablilityMode() && getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT));
}
/**
@ -3312,6 +3311,15 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
}
/**
* @return <code>true</code> if Content Assist auto activation is disabled.
*
* @since 5.0
*/
public boolean isContentAssistAutoActivartionDisabled() {
return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
}
/**
* @return <code>true</code> if the number of lines in the file exceed
* the line number for scalability mode in the preference.

View file

@ -20,7 +20,7 @@ AddIncludeOnSelection.label=Add Include
AddIncludeOnSelection.tooltip=Add Include Statement on Selection
AddIncludesOperation.description=Adding include statement
Scalability.message=You are opening a large file. Turning on scalability mode might help improve editor's performance. Please see the Scalability preference page under Preferences -> C/C++.
Scalability.message=You are opening a large file. Turning on scalability mode might help improve editor's performance. Please see the Scalability preference page under Preferences > C/C++ > Editor.
Scalability.info=Editor Scalability
Scalability.reappear=Do not show this message again.
ShowInCView.description=Show the current resource in the C/C++ Projects view

View file

@ -377,11 +377,12 @@ public final class PreferencesMessages extends NLS {
public static String ScalabilityPreferencePage_scalabilityMode_label;
public static String ScalabilityPreferencePage_reconciler_label;
public static String ScalabilityPreferencePage_syntaxColor_label;
public static String ScalabilityPreferencePage_semanticHighlighting_label;
public static String ScalabilityPreferencePage_contentAssist_label;
public static String ScalabilityPreferencePage_note;
public static String ScalabilityPreferencePage_preferenceOnlyForNewViews;
public static String ScalabilityPreferencePage_preferenceOnlyForNewEditors;
public static String ScalabilityPreferencePage_contentAssist_autoActivation;
static {
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
}

View file

@ -433,10 +433,12 @@ ScalabilityPreferencePage_trigger_lines_label= Enable scalability mode options w
ScalabilityPreferencePage_error=Value must be an integer between {0} and {1}.
ScalabilityPreferencePage_scalabilityMode_group_label= Scalability mode settings
ScalabilityPreferencePage_scalabilityMode_label= Enable all scalability mode options
ScalabilityPreferencePage_reconciler_label= Disable editor reconciling (Outline view, semantic highlighting and editor folding will also be disabled)
ScalabilityPreferencePage_reconciler_label= Disable editor live parsing (Outline view, semantic highlighting and editor folding will also be disabled)
ScalabilityPreferencePage_syntaxColor_label= Disable syntax coloring in editor
ScalabilityPreferencePage_semanticHighlighting_label= Disable semantic highlighting in editor
ScalabilityPreferencePage_contentAssist_label= Disable parsing-based content assist proposals
ScalabilityPreferencePage_contentAssist_autoActivation= Disable content assist auto-activation
ScalabilityPreferencePage_note=Note:
ScalabilityPreferencePage_preferenceOnlyForNewViews=Some options do not affect opened views
ScalabilityPreferencePage_preferenceOnlyForNewEditors=Some options do not affect open editors
ScalabilityPreferencePage_error=Value must be an integer between {0} and {1}.

View file

@ -59,8 +59,12 @@ public class ScalabilityPreferencePage extends PreferencePage implements
private Button fSyntaxColor;
private Button fSemanticHighlighting;
private Button fContentAssist;
private Button fContentAssistAutoActivation;
private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
/**
@ -72,7 +76,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
public ScalabilityPreferencePage() {
setPreferenceStore(PreferenceConstants.getPreferenceStore());
setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
}
/**
@ -104,7 +108,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
SelectionListener listener= (SelectionListener)iter.next();
listener.widgetSelected(null);
}
fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
}
/*
@ -114,7 +118,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
public void createControl(Composite parent) {
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SCALABILITY_PREFERENCE_PAGE);
}
}
/*
* @see PreferencePage#createContents(Composite)
@ -138,14 +142,14 @@ public class ScalabilityPreferencePage extends PreferencePage implements
createDetectionSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
new Separator().doFillIntoGrid(composite, nColumns);
createScalabilityModeSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
new Separator().doFillIntoGrid(composite, nColumns);
String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewViews;
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewEditors;
Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 2;
@ -178,15 +182,8 @@ public class ScalabilityPreferencePage extends PreferencePage implements
private void createDetectionSettings( Composite parent ) {
Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_detection_group_label );
createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_detection_label,PreferenceConstants.SCALABILITY_ALERT);
}
/**
* Create the view setting preferences composite widget
*/
private void createScalabilityModeSettings( Composite parent ) {
Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_group_label );
Composite comp = ControlFactory.createComposite( group, 2 );
Composite comp= new Composite(group, SWT.NONE);
fLinesToTrigger = new IntegerFieldEditor( PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, PreferencesMessages.ScalabilityPreferencePage_trigger_lines_label, comp);
GridData data = (GridData)fLinesToTrigger.getTextControl( comp ).getLayoutData();
data.horizontalAlignment = GridData.BEGINNING;
@ -206,27 +203,42 @@ public class ScalabilityPreferencePage extends PreferencePage implements
}
} );
new Separator().doFillIntoGrid(group, 1);
}
/**
* Create the view setting preferences composite widget
*/
private void createScalabilityModeSettings( Composite parent ) {
Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_group_label );
fEnableAll = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_label, PreferenceConstants.SCALABILITY_ENABLE_ALL);
fReconciler = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_reconciler_label, PreferenceConstants.SCALABILITY_RECONCILER);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fReconciler);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fReconciler, true);
fContentAssist = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_label, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssist);
fSemanticHighlighting = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_semanticHighlighting_label, PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSemanticHighlighting, true);
fSyntaxColor = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_syntaxColor_label, PreferenceConstants.SCALABILITY_SYNTAX_COLOR);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSyntaxColor);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSyntaxColor, true);
fContentAssist = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_label, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssist, true);
fContentAssistAutoActivation = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_autoActivation, PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
createDependency(fContentAssist, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST, fContentAssistAutoActivation, true);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssistAutoActivation, false);
}
private static void indent(Control control) {
private static void indent(Control control, GridData masterLayoutData) {
GridData gridData= new GridData();
gridData.horizontalIndent= 20;
control.setLayoutData(gridData);
gridData.horizontalIndent= masterLayoutData.horizontalIndent + 20;
control.setLayoutData(gridData);
}
private void createDependency(final Button master, String masterKey, final Control slave) {
indent(slave);
private void createDependency(final Button master, String masterKey, final Control slave, boolean indent) {
if (indent) {
indent(slave, (GridData)master.getLayoutData());
}
boolean masterState= getPreferenceStore().getBoolean(masterKey);
slave.setEnabled(!masterState);
@ -269,7 +281,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
prefs.setValue(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, fLinesToTrigger.getIntValue());
CUIPlugin.getDefault().savePluginPreferences();
return super.performOk();
}
}
/*
* @see PreferencePage#performDefaults()
@ -291,6 +303,6 @@ public class ScalabilityPreferencePage extends PreferencePage implements
SelectionListener listener= (SelectionListener)iter.next();
listener.widgetSelected(null);
}
fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
}
}

View file

@ -116,8 +116,14 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
//for scalability
if (fEditor != null && fEditor instanceof CEditor) {
CEditor editor = (CEditor)fEditor;
if (editor.isEnableScalablilityMode() && editor.isParserBasedContentAssistDisabled())
return null;
if (editor.isEnableScalablilityMode()) {
if (editor.isParserBasedContentAssistDisabled()) {
return null;
}
if (isAutoActivated() && editor.isContentAssistAutoActivartionDisabled()) {
return null;
}
}
}
if (fCNComputed) return fCN;

View file

@ -754,7 +754,7 @@ public class PreferenceConstants {
public static final String OUTLINE_LINK_TO_EDITOR = "org.eclipse.cdt.ui.outline.linktoeditor"; //$NON-NLS-1$
/**
* A named preference that controls whether include directives should be grouped in the
* A named preference that controls whether include directives should be grouped in the
* C/C++ Projects view and the Project Explorer view.
* <p>
* Value is of type <code>Boolean</code>.
@ -763,7 +763,7 @@ public class PreferenceConstants {
public static final String CVIEW_GROUP_INCLUDES= "org.eclipse.cdt.ui.cview.groupincludes"; //$NON-NLS-1$
/**
* A named preference that controls whether header and source files should be separated in the
* A named preference that controls whether header and source files should be separated in the
* C/C++ Projects view and the Project Explorer view.
* <p>
* Value is of type <code>Boolean</code>.
@ -1308,7 +1308,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
public static final String SCALABILITY_ENABLE_ALL = "enableScalabilityOptions"; //$NON-NLS-1$
public static final String SCALABILITY_ENABLE_ALL = "scalability.enableAll"; //$NON-NLS-1$
/**
* A named preference that controls whether the editor's reconciler is disabled.
@ -1318,7 +1318,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
public static final String SCALABILITY_RECONCILER = "reconciler"; //$NON-NLS-1$
public static final String SCALABILITY_RECONCILER = "scalability.reconciler"; //$NON-NLS-1$
/**
* A named preference that controls whether syntax coloring is disabled.
@ -1328,7 +1328,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
public static final String SCALABILITY_SYNTAX_COLOR = "syntaxColor"; //$NON-NLS-1$
public static final String SCALABILITY_SYNTAX_COLOR = "scalability.syntaxColor"; //$NON-NLS-1$
/**
* A named preference that controls whether parser-based content assist proposals are disabled.
@ -1338,7 +1338,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
public static final String SCALABILITY_PARSER_BASED_CONTENT_ASSIST = "cdtContentAssist"; //$NON-NLS-1$
public static final String SCALABILITY_PARSER_BASED_CONTENT_ASSIST = "scalability.parserBasedContentAssist"; //$NON-NLS-1$
/**
* A named preference that controls whether users should be notified if scalability mode should be turned on.
@ -1348,7 +1348,7 @@ public class PreferenceConstants {
*
* @since 5.0
*/
public static final String SCALABILITY_ALERT = "detectScalability"; //$NON-NLS-1$
public static final String SCALABILITY_ALERT = "scalability.detect"; //$NON-NLS-1$
/**
* The size of the file that will trigger scalability mode
@ -1358,8 +1358,29 @@ public class PreferenceConstants {
*
* @since 5.0
*/
public static final String SCALABILITY_NUMBER_OF_LINES = "numberOfLines"; //$NON-NLS-1$
public static final String SCALABILITY_NUMBER_OF_LINES = "scalability.numberOfLines"; //$NON-NLS-1$
/**
* A named preference that controls whether syntax coloring is disabled.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_SEMANTIC_HIGHLIGHT = "scalability.semanticHighlight"; //$NON-NLS-1$
/**
* A named preference that controls whether the content assist auto activation is disabled in scalability mode.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION = "scalability.contentAssistAutoActivation"; //$NON-NLS-1$
/**
* Returns the CDT-UI preference store.
*
@ -1548,7 +1569,9 @@ public class PreferenceConstants {
store.setDefault(PreferenceConstants.SCALABILITY_ENABLE_ALL, false);
store.setDefault(PreferenceConstants.SCALABILITY_RECONCILER, false);
store.setDefault(PreferenceConstants.SCALABILITY_SYNTAX_COLOR, false);
store.setDefault(PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT, false);
store.setDefault(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST, false);
store.setDefault(PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION, false);
}