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

Fix annotations in overview bar, added index IProblem markers, added new preference page for controlling external search markers

This commit is contained in:
Bogdan Gheorghe 2004-03-31 07:57:18 +00:00
parent 5cfae571a1
commit 5c3d8fdb41
16 changed files with 480 additions and 72 deletions

View file

@ -1,3 +1,7 @@
2004-03-31 Bogdan Gheorghe
Modified SourceIndexer and SourceIndexerRequestor to place IProblem markers
on resources.
2004-03-15 Andrew Niefer
updated SourceIndexerRequestor with acceptTemplateParameterReference

View file

@ -73,7 +73,8 @@ public class SourceIndexer extends AbstractIndexer {
// Add the name of the file to the index
output.addDocument(document);
// Create a new Parser
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, document);
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, resourceFile);
requestor.removeMarkers(resourceFile);
//Get the scanner info
IProject currentProject = resourceFile.getProject();

View file

@ -18,6 +18,8 @@ package org.eclipse.cdt.internal.core.search.indexing;
import java.io.Reader;
import java.util.LinkedList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.parser.DefaultProblemHandler;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
@ -58,7 +60,12 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* @author bgheorgh
@ -69,7 +76,7 @@ import org.eclipse.cdt.internal.core.index.IDocument;
public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexConstants {
SourceIndexer indexer;
IDocument document;
IFile resourceFile;
char[] packageName;
char[][] enclosingTypeNames = new char[5][];
@ -79,15 +86,39 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
private IASTInclusion currentInclude = null;
private LinkedList includeStack = new LinkedList();
public SourceIndexerRequestor(SourceIndexer indexer, IDocument document) {
public SourceIndexerRequestor(SourceIndexer indexer, IFile resourceFile) {
super();
this.indexer = indexer;
this.document= document;
this.resourceFile = resourceFile;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
*/
public boolean acceptProblem(IProblem problem) {
IASTInclusion include = peekInclude();
IFile tempFile = resourceFile;
int lineNumber = problem.getSourceLineNumber();
//If we are in an include file, get the include file
if (include != null){
IPath newPath = new Path(include.getFullFileName());
IPath problemPath = new Path(new String(problem.getOriginatingFileName()));
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
//Needed for external files
if (tempFile == null)
tempFile = resourceFile;
if (!newPath.equals(problemPath)){
lineNumber = include.getStartingLine();
}
}
addMarkers(tempFile,problem, lineNumber);
return DefaultProblemHandler.ruleOnProblem( problem, ParserMode.COMPLETE_PARSE );
}
@ -188,6 +219,15 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
*/
public void enterInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub
IPath newPath = new Path(inclusion.getFullFileName());
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
if (tempFile !=null){
removeMarkers(tempFile);
}
else{
//File is out of workspace
}
IASTInclusion parent = peekInclude();
indexer.addInclude(inclusion, parent);
@ -491,6 +531,59 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
public Reader createReader(String finalPath) {
return ParserUtil.createReader(finalPath);
}
/**
*
*/
public void removeMarkers(IFile resource) {
int depth = IResource.DEPTH_INFINITE;
try {
resource.deleteMarkers(ICModelMarker.INDEXER_MARKER, true, depth);
} catch (CoreException e) {
// something went wrong
}
}
private void addMarkers(IFile tempFile, IProblem problem, int lineNumber){
try {
IMarker[] markers = tempFile.findMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_INFINITE);
boolean newProblem = true;
if (markers.length > 0){
IMarker tempMarker = null;
Integer tempInt = null;
String tempMsgString = null;
for (int i=0; i<markers.length; i++){
tempMarker = markers[i];
tempInt = (Integer) tempMarker.getAttribute(IMarker.LINE_NUMBER);
tempMsgString = (String) tempMarker.getAttribute(IMarker.MESSAGE);
if (tempInt.intValue()==problem.getSourceLineNumber() &&
tempMsgString.equals(problem.getMessage())){
newProblem = false;
break;
}
}
}
if (newProblem){
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
marker.setAttribute(IMarker.LOCATION, problem.getSourceLineNumber());
marker.setAttribute(IMarker.MESSAGE, /*"Resource File: " + resourceFile.getName() + " - " +*/ problem.getMessage());
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
marker.setAttribute(IMarker.CHAR_START,-1);
marker.setAttribute(IMarker.CHAR_END, -1);
}
} catch (CoreException e) {
// You need to handle the cases where attribute value is rejected
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
@ -498,4 +591,5 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
// TODO Auto-generated method stub
return false;
}
}

View file

@ -39,6 +39,8 @@ public interface ICModelMarker {
* option <code>"org.eclipse.cdt.core.translation.taskTag"</code>.
*/
public static final String TASK_MARKER = CCorePlugin.PLUGIN_ID + ".task"; //$NON-NLS-1$
public static final String INDEXER_MARKER = CCorePlugin.PLUGIN_ID + ".indexermarker"; //$NON-NLS-1$
}

View file

@ -13,6 +13,8 @@ ErrorParser.name=Error Parser
CTaskName=C/C++ Task
IndexerMarker=Indexer Marker
ElfParser.name=Elf Parser
GNUElfParser.name=GNU Elf Parser
PEWindowsParser.name=PE Windows Parser

View file

@ -268,5 +268,19 @@
value="true">
</persistent>
</extension>
<extension
id="indexermarker"
name="%IndexerMarker"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<persistent
value="true">
</persistent>
<super
type="org.eclipse.core.resources.textmarker">
</super>
</extension>
</plugin>

View file

@ -1,3 +1,17 @@
2004-03-31 Bogdan Gheorghe
Fixed the overview annotations in the Overview bar in the CEditor
Modified the CEditorPreferencePage to add the Index Marker annotation
Created a new Preference Page to contain the options for placing markers
on external files
Modified CSearchResultCollector to use external marker search prefs
* src/org/eclipse/cdt/internal/ui/editor/CEditor.java
* src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
* src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java
* src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
* src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
* plugin.xml
2004-03-30 Bogdan Gheorghe
Modified the AnnotationModel to solve all annotation refresh problems.

View file

@ -146,3 +146,5 @@ HideCFiles.description= Hides all C files
HideHeaderFiles.label= Header files
HideHeaderFiles.description= Hides all Header files
WorkInProgress.name=Work In Progress

View file

@ -96,14 +96,6 @@
class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter"
id="org.eclipse.cdt.internal.ui.CView.NonCElementFilter">
</filter>
<!--filter
targetId="org.eclipse.cdt.ui.CView"
name="%HideHeaderFilter.label"
enabled="false"
description="%HideHeaderFilter.description"
class="org.eclipse.cdt.internal.ui.filters.HeaderFilter"
id="org.eclipse.cdt.internal.ui.CView.HeaderFilter">
</filter-->
</extension>
<extension
point="org.eclipse.ui.perspectives">
@ -196,35 +188,35 @@
id="org.eclipse.cdt.ui.ceditor"
point="org.eclipse.ui.editors">
<editor
name="%CEditor.name"
default="true"
icon="icons/full/obj16/c_file_obj.gif"
name="%CEditor.name"
extensions="c, cc, cpp, cxx"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
icon="icons/full/obj16/c_file_obj.gif"
class="org.eclipse.cdt.internal.ui.editor.CEditor"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
id="org.eclipse.cdt.ui.editor.CEditor">
</editor>
<editor
name="%CEditor.name"
default="true"
icon="icons/full/obj16/h_file_obj.gif"
name="%CEditor.name"
extensions="h, hh, hpp"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
icon="icons/full/obj16/h_file_obj.gif"
class="org.eclipse.cdt.internal.ui.editor.CEditor"
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
id="org.eclipse.cdt.ui.editor.CEditor">
</editor>
<editor
name="%Editors.DefaultTextEditor"
icon="icons/full/obj16/file_obj.gif"
extensions="mk"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
icon="icons/full/obj16/file_obj.gif"
class="org.eclipse.ui.editors.text.TextEditor"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
id="org.eclipse.ui.DefaultTextEditor">
</editor>
<editor
name="%AsmEditor.name"
icon="icons/full/obj16/c_file_obj.gif"
extensions="s"
icon="icons/full/obj16/c_file_obj.gif"
class="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
id="org.eclipse.cdt.ui.editor.asm.AsmEditor">
</editor>
@ -293,16 +285,16 @@
<action
label="%AddTask.label"
helpContextId="org.eclipse.ui.AddTask_action_context"
tooltip="%AddTask.tooltip"
class="org.eclipse.ui.texteditor.TaskRulerAction"
tooltip="%AddTask.tooltip"
menubarPath="add"
id="org.eclipse.ui.texteditor.TaskRulerAction">
</action>
<action
label="%AddBookmark.label"
helpContextId="org.eclipse.ui.bookmark_action_context"
tooltip="%AddBookmark.tooltip"
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
tooltip="%AddBookmark.tooltip"
menubarPath="add"
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
</action>
@ -313,16 +305,16 @@
<action
label="%AddTask.label"
helpContextId="org.eclipse.ui.AddTask_action_context"
tooltip="%AddTask.tooltip"
class="org.eclipse.ui.texteditor.TaskRulerAction"
tooltip="%AddTask.tooltip"
menubarPath="add"
id="org.eclipse.ui.texteditor.TaskRulerAction">
</action>
<action
label="%AddBookmark.label"
helpContextId="org.eclipse.ui.bookmark_action_context"
tooltip="%AddBookmark.tooltip"
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
tooltip="%AddBookmark.tooltip"
menubarPath="add"
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
</action>
@ -352,24 +344,24 @@
<action
label="%OpenNewFileWizardAction.label"
icon="icons/full/ctool16/newfile_wiz.gif"
tooltip="%OpenNewFileWizardAction.tooltip"
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFileWizardAction"
tooltip="%OpenNewFileWizardAction.tooltip"
toolbarPath="Normal/FolderWizards"
id="org.eclipse.cdt.ui.actions.OpenNewFileWizardAction">
</action>
<action
label="%OpenNewFolderWizardAction.label"
icon="icons/full/ctool16/newfolder_wiz.gif"
tooltip="%OpenNewFolderWizardAction.tooltip"
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFolderWizardAction"
tooltip="%OpenNewFolderWizardAction.tooltip"
toolbarPath="Normal/FolderWizards"
id="org.eclipse.cdt.ui.actions.OpenNewFolderWizardAction">
</action>
<action
label="%OpenClassWizardAction.label"
icon="icons/full/ctool16/newclass_wiz.gif"
tooltip="%OpenClassWizardAction.tooltip"
class="org.eclipse.cdt.ui.actions.OpenClassWizardAction"
tooltip="%OpenClassWizardAction.tooltip"
toolbarPath="Normal/FolderWizards"
id="org.eclipse.cdt.ui.actions.OpenClassWizardAction">
<enablement>
@ -410,8 +402,8 @@
</category>
<command
name="%ActionDefinition.comment.name"
description="%ActionDefinition.comment.description"
category="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.comment.description"
id="org.eclipse.cdt.ui.edit.text.c.comment">
</command>
<keyBinding
@ -422,8 +414,8 @@
</keyBinding>
<command
name="%ActionDefinition.uncomment.name"
description="%ActionDefinition.uncomment.description"
category="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.uncomment.description"
id="org.eclipse.cdt.ui.edit.text.c.uncomment">
</command>
<keyBinding
@ -434,8 +426,8 @@
</keyBinding>
<command
name="%ActionDefinition.opendecl.name"
description="%ActionDefinition.opendecl.description"
category="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.opendecl.description"
id="org.eclipse.cdt.ui.edit.opendecl">
</command>
<keyBinding
@ -446,8 +438,8 @@
</keyBinding>
<command
name="%ActionDefinition.openType.name"
description="%ActionDefinition.openType.description"
category="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.openType.description"
id="org.eclipse.cdt.ui.navigate.opentype">
</command>
<keyBinding
@ -458,8 +450,8 @@
</keyBinding>
<command
name="%ActionDefinition.opencview.name"
category="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.opencview.description"
category="org.eclipse.cdt.ui.category.source"
id="org.eclipse.cdt.ui.edit.opencview">
</command>
</extension>
@ -470,8 +462,8 @@
<page
showScopeSection="true"
label="%CSearchPage.label"
icon="icons/full/obj16/csearch_obj.gif"
extensions="c:90,cpp:90, cxx:90, cc:90,C:90, h:90, hh:90, hpp:90, H:90"
icon="icons/full/obj16/csearch_obj.gif"
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
sizeHint="460, 160"
id="org.eclipse.cdt.ui.CSearchPage">
@ -483,24 +475,24 @@
pageId="org.eclipse.cdt.ui.CSearchPage"
label="%ElementNameSorter.label"
icon="icons/full/clcl16/search_sortmatch.gif"
tooltip="%ElementNameSorter.tooltip"
class="org.eclipse.cdt.internal.ui.search.ElementNameSorter"
tooltip="%ElementNameSorter.tooltip"
id="org.eclipse.cdt.search.internal.ui.ElementNameSorter">
</sorter>
<sorter
pageId="org.eclipse.cdt.ui.CSearchPage"
label="%ParentNameSorter.label"
icon="icons/full/clcl16/search_sortmatch.gif"
tooltip="%ParentNameSorter.tooltip"
class="org.eclipse.cdt.internal.ui.search.ParentNameSorter"
tooltip="%ParentNameSorter.tooltip"
id="org.eclipse.cdt.search.internal.ui.ParentNameSorter">
</sorter>
<sorter
pageId="org.eclipse.cdt.ui.CSearchPage"
label="%PathNameSorter.label"
icon="icons/full/clcl16/search_sortmatch.gif"
tooltip="%PathNameSorter.tooltip"
class="org.eclipse.cdt.internal.ui.search.PathNameSorter"
tooltip="%PathNameSorter.tooltip"
id="org.eclipse.cdt.search.internal.ui.PathNameSorter">
</sorter>
</extension>
@ -553,16 +545,16 @@
<extension
point="org.eclipse.cdt.ui.BinaryParserPage">
<parserPage
parserID="org.eclipse.cdt.core.GNU_ELF"
class="org.eclipse.cdt.ui.dialogs.GNUElfBinaryParserPage"
parserID="org.eclipse.cdt.core.GNU_ELF"
id="ElfBinaryParserPage">
</parserPage>
</extension>
<extension
point="org.eclipse.cdt.ui.BinaryParserPage">
<parserPage
parserID="org.eclipse.cdt.core.Cygwin_PE"
class="org.eclipse.cdt.ui.dialogs.CygwinPEBinaryParserPage"
parserID="org.eclipse.cdt.core.Cygwin_PE"
id="PEBinaryParserPage">
</parserPage>
</extension>
@ -586,6 +578,43 @@
</description>
</fontDefinition>
</extension>
<extension
point="org.eclipse.ui.editors.markerAnnotationSpecification">
<specification
colorPreferenceValue="192,192,192"
annotationType="org.eclipse.cdt.ui.indexmarker"
verticalRulerPreferenceValue="false"
colorPreferenceKey="indexResultIndicationColor"
contributesToHeader="false"
overviewRulerPreferenceValue="false"
presentationLayer="3"
textStylePreferenceValue="NONE"
symbolicIcon="warning"
icon="icons/full/obj16/unknown_obj.gif"
label="Index Markers"
textPreferenceValue="false"
textPreferenceKey="indexResultIndication"
verticalRulerPreferenceKey="indexResultIndicationInVerticalRuler"
overviewRulerPreferenceKey="indexResultIndicationInOverviewRuler">
</specification>
</extension>
<extension
point="org.eclipse.ui.editors.annotationTypes">
<type
markerType="org.eclipse.cdt.core.indexermarker"
name="org.eclipse.cdt.ui.indexmarker">
</type>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage"
id="org.eclipse.cdt.ui.preferneces.WorkInProgressPreferencePage">
</page>
</extension>
<!--
<extension
point="org.eclipse.ui.propertyPages">

View file

@ -150,7 +150,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/** Preference key for hyperlink enablement */
public final static String HYPERLINK_ENABLED = "hyperlinkEnable"; //$NON-NLS-1$
private class PropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener, org.eclipse.jface.util.IPropertyChangeListener {
/*
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
@ -902,7 +902,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fSourceViewerDecorationSupport =
new SourceViewerDecorationSupport(sourceViewer, fOverviewRuler, fAnnotationAccess, sharedColors);
getSourceViewerDecorationSupport(sourceViewer);
configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
return sourceViewer;
}

View file

@ -138,6 +138,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
private ColorEditor fAnnotationForegroundColorEditor;
private List fAnnotationList;
private Button fShowInOverviewRulerCheckBox;
private Button fShowInVerticalRulerCheckBox;
private Button fShowInTextCheckBox;
public CEditorPreferencePage() {
@ -157,6 +158,12 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
overlayKeys.add(
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
String verticalKey = info.getVerticalRulerPreferenceKey();
if (verticalKey != null){
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, verticalKey));
}
}
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,CEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT));
@ -208,7 +215,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.HYPERLINK_ENABLED));
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return new OverlayPreferenceStore(getPreferenceStore(), keys);
@ -225,6 +232,14 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
AnnotationPreference info = (AnnotationPreference) e.next();
store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
String verticalRulerKey = info.getVerticalRulerPreferenceKey();
boolean verticalRulerPreference = info.getVerticalRulerPreferenceValue();
if (verticalRulerKey != null){
store.setDefault(verticalRulerKey,verticalRulerPreference);
}
PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
}
store.setDefault(CEditor.MATCHING_BRACKETS, true);
@ -369,6 +384,13 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
gd.horizontalAlignment = GridData.BEGINNING;
gd.horizontalSpan = 2;
fShowInOverviewRulerCheckBox.setLayoutData(gd);
fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
fShowInVerticalRulerCheckBox.setText(PreferencesMessages.getString("CEditorPreferencePage.annotationsPage.showInVertical")); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
gd.horizontalSpan = 2;
fShowInVerticalRulerCheckBox.setLayoutData(gd);
label = new Label(optionsComposite, SWT.LEFT);
label.setText(PreferencesMessages.getString("CEditorPreferencePage.annotationsPage.color")); //$NON-NLS-1$
@ -415,6 +437,18 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
}
});
fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
public void widgetSelected(SelectionEvent e) {
int i = fAnnotationList.getSelectionIndex();
String key = fAnnotationColorListModel[i][4];
fOverlayStore.setValue(key, fShowInVerticalRulerCheckBox.getSelection());
}
});
foregroundColorButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
@ -444,6 +478,11 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
key = fAnnotationColorListModel[i][3];
fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
key = fAnnotationColorListModel[i][4];
if (key != null){
fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
}
}
private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
@ -456,7 +495,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
info.getPreferenceLabel(),
info.getColorPreferenceKey(),
info.getTextPreferenceKey(),
info.getOverviewRulerPreferenceKey()});
info.getOverviewRulerPreferenceKey(),
info.getVerticalRulerPreferenceKey()});
}
String[][] items = new String[listModelItems.size()][];
listModelItems.toArray(items);
@ -761,6 +801,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.printMargin"); //$NON-NLS-1$
addCheckBox(behaviorComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
Label l = new Label(behaviorComposite, SWT.LEFT);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;

View file

@ -95,6 +95,7 @@ CEditorPreferencePage.cCommentTaskTags.others=Others
CEditorPreferencePage.annotationsPage.presentationOptions=Annotation Presentation Options
CEditorPreferencePage.annotationsPage.showInText=Show In Text
CEditorPreferencePage.annotationsPage.showInOverview=Show In Overview Ruler
CEditorPreferencePage.annotationsPage.showInVertical=Show In Vertical Ruler
CEditorPreferencePage.annotationsPage.color=Annotations Color
CEditorPreferencePage.colorPage.backgroundColor=Bac&kground Color:
CEditorPreferencePage.colorPage.systemDefault=S&ystem Default

View file

@ -0,0 +1,181 @@
/*
* Created on Mar 30, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.eclipse.cdt.internal.ui.preferences;
import java.util.ArrayList;
import org.eclipse.cdt.internal.ui.search.CSearchPage;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
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.IWorkbenchPreferencePage;
/**
* @author bgheorgh
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class WorkInProgressPreferencePage extends PreferencePage
implements
IWorkbenchPreferencePage {
private Combo fExternLinks;
private Button fExternEnabled;
protected OverlayPreferenceStore fOverlayStore;
public WorkInProgressPreferencePage(){
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
fOverlayStore = createOverlayStore();
}
private OverlayPreferenceStore createOverlayStore() {
ArrayList overlayKeys = new ArrayList();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CSearchPage.EXTERNALMATCH_ENABLED));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, CSearchPage.EXTERNALMATCH_VISIBLE));
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return new OverlayPreferenceStore(getPreferenceStore(), keys);
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
protected Control createContents(Composite parent) {
fOverlayStore.load();
fOverlayStore.start();
initializeDialogUnits(parent);
Composite result= 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);
result.setLayout(layout);
Group group= new Group(result, SWT.NONE);
group.setLayout(new GridLayout());
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setText("External Search Links"); //$NON-NLS-1$
fExternEnabled = createCheckButton(group, "Enable external search markers"); //$NON-NLS-1$
fExternEnabled.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.widget;
boolean externLinkEnabled = false;
fExternLinks.setEnabled(false);
if (button.getSelection()){
fExternLinks.setEnabled(true);
externLinkEnabled = true;
}
fOverlayStore.setValue(CSearchPage.EXTERNALMATCH_ENABLED, externLinkEnabled);
}
});
fExternLinks = createComboBox(group,"External Marker Link Type",new String[]{"Visible","Invisible"},"Visible"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
fExternLinks.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
Combo combo = (Combo) e.widget;
fOverlayStore.setValue(CSearchPage.EXTERNALMATCH_VISIBLE, combo.getSelectionIndex());
}
});
initialize();
return result;
}
private void initialize(){
boolean extEnabled = fOverlayStore.getBoolean(CSearchPage.EXTERNALMATCH_ENABLED);
fExternEnabled.setSelection(extEnabled);
fExternLinks.select(fOverlayStore.getInt(CSearchPage.EXTERNALMATCH_VISIBLE));
fExternLinks.setEnabled(extEnabled);
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
/**
* Creates a button with the given label and sets the default
* configuration data.
*/
private Combo createComboBox( Composite parent, String label, String[] items, String selection )
{
ControlFactory.createLabel( parent, label );
Combo combo = ControlFactory.createSelectCombo( parent, items, selection );
combo.setLayoutData( new GridData() );
return combo;
}
/**
* Creates a button with the given label and sets the default
* configuration data.
*/
private Button createCheckButton( Composite parent, String label )
{
Button button = new Button( parent, SWT.CHECK | SWT.LEFT );
button.setText( label );
// FieldEditor GridData
GridData data = new GridData();
button.setLayoutData( data );
return button;
}
/*
* @see IPreferencePage#performOk()
*/
public boolean performOk() {
fOverlayStore.propagate();
return true;
}
/**
* @param store
*/
public static void initDefaults(IPreferenceStore store) {
store.setDefault(CSearchPage.EXTERNALMATCH_ENABLED, false);
store.setDefault(CSearchPage.EXTERNALMATCH_VISIBLE, 0);
}
/*
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
fOverlayStore.loadDefaults();
initialize();
super.performDefaults();
}
}

View file

@ -638,6 +638,11 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
private final static String PAGE_NAME= "CSearchPage"; //$NON-NLS-1$
private final static String STORE_CASE_SENSITIVE= PAGE_NAME + "CASE_SENSITIVE"; //$NON-NLS-1$
/** Preference key for external marker enablement */
public final static String EXTERNALMATCH_ENABLED = "externMatchEnable"; //$NON-NLS-1$
/** Preference key for external marker visibilty */
public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
private static List fgPreviousSearchPatterns = new ArrayList(20);
private Button[] fSearchFor;

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.search.BasicSearchMatch;
import org.eclipse.cdt.core.search.BasicSearchResultCollector;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.ui.CSearchResultLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@ -28,6 +29,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.search.ui.IGroupByKeyComputer;
import org.eclipse.search.ui.ISearchResultView;
import org.eclipse.search.ui.SearchUI;
@ -128,34 +130,46 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
}
}
else {
//Create Link in referring file's project
IPath refLocation = searchMatch.getReferenceLocation();
IFile refFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(refLocation);
IProject refProject = refFile.getProject();
IPath externalMatchLocation = searchMatch.getLocation();
IFile linksFile = refProject.getFile(externalMatchLocation.lastSegment());
//Check to see if the file already exists - create if doesn't, mark team private
if (!linksFile.exists()){
linksFile.createLink(externalMatchLocation,IResource.NONE,null);
//linksFile.setTeamPrivateMember(true);
linksFile.setDerived(true);
}
IMarker marker = linksFile.createMarker( SearchUI.SEARCH_MARKER );
HashMap markerAttributes = new HashMap( 2 );
markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) );
markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) );
markerAttributes.put( IMATCH, searchMatch );
marker.setAttributes( markerAttributes );
if( _view != null ){
_view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), linksFile, marker );
}
//Check to see if external markers are enabled
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
if (store.getBoolean(CSearchPage.EXTERNALMATCH_ENABLED)){
//Create Link in referring file's project
IPath refLocation = searchMatch.getReferenceLocation();
IFile refFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(refLocation);
IProject refProject = refFile.getProject();
IPath externalMatchLocation = searchMatch.getLocation();
IFile linksFile = refProject.getFile(externalMatchLocation.lastSegment());
//Delete links file to keep up to date with latest prefs
if (linksFile.exists())
linksFile.delete(true,null);
//Check to see if the file already exists - create if doesn't, mark team private
if (!linksFile.exists()){
linksFile.createLink(externalMatchLocation,IResource.NONE,null);
int number = store.getInt(CSearchPage.EXTERNALMATCH_VISIBLE);
if (number==0){
linksFile.setDerived(true);
}
else{
linksFile.setTeamPrivateMember(true);
}
}
IMarker marker = linksFile.createMarker( SearchUI.SEARCH_MARKER );
HashMap markerAttributes = new HashMap( 2 );
markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) );
markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) );
markerAttributes.put( IMATCH, searchMatch );
marker.setAttributes( markerAttributes );
if( _view != null ){
_view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), linksFile, marker );
}
}
}
_matchCount++;

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
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.WorkInProgressPreferencePage;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.internal.ui.util.ProblemMarkerManager;
@ -68,6 +69,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
public class CUIPlugin extends AbstractUIPlugin {
@ -345,6 +347,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
protected void initializeDefaultPreferences(final IPreferenceStore store) {
super.initializeDefaultPreferences(store);
MarkerAnnotationPreferences.initializeDefaultValues(store);
PreferenceConstants.initializeDefaultValues(store);
runUI(new Runnable() {
@ -353,6 +356,7 @@ public class CUIPlugin extends AbstractUIPlugin {
CEditorPreferencePage.initDefaults(store);
CView.initDefaults(store);
BuildConsolePreferencePage.initDefaults(store);
WorkInProgressPreferencePage.initDefaults(store);
}
});
}