diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 6ef92cc56d3..edb789bc529 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-01 Alain Magloire
+ Patch from Mikhail Voronin to implement 71240.
+ Too many changes to enumerate refer to PR:
+ https://bugs.eclipse.org/bugs/show_bug.cgi?id=71240
+
2004-10-14 Alain Magloire
Provide the hashCode method.
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 185c0028809..a04404185fe 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -17,7 +17,7 @@ pathContainerPage=Path Container Page
textHoversName=Text Hovers
editorActionsName=Editor Actions
editorRulerActionsName=Editor Ruler Actions
-completionContributorName=Completion Contribution
+cHelpProviderName=C Help Provider
nature.name=C Nature
perspective.name=C/C++
viewsCategory.name=&C
@@ -199,6 +199,8 @@ CDTSearch.name=Search
CDTIndexerProperty.name=C/C++ Indexer
+CDTHelpProperty.name=C/C++ Documentation
+
CDTFileTypesProperty.name=C/C++ File Types
cDocumentFactory=C Document Factory
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 62b1e4db2e3..67bf72b8056 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -27,10 +27,11 @@
+
-
+
@@ -1082,6 +1083,17 @@
value="org.eclipse.cdt.core.cnature">
+
+
+
+
diff --git a/core/org.eclipse.cdt.ui/schema/CCompletionContributor.exsd b/core/org.eclipse.cdt.ui/schema/CHelpProvider.exsd
similarity index 86%
rename from core/org.eclipse.cdt.ui/schema/CCompletionContributor.exsd
rename to core/org.eclipse.cdt.ui/schema/CHelpProvider.exsd
index 0956590a8f2..61a9f5116c7 100644
--- a/core/org.eclipse.cdt.ui/schema/CCompletionContributor.exsd
+++ b/core/org.eclipse.cdt.ui/schema/CHelpProvider.exsd
@@ -1,115 +1,109 @@
-
-
-
-
-
-
-
-
- [Enter description of this extension point.]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Enter the first release in which this extension point appears.]
-
-
-
-
-
-
-
-
- [Enter extension point usage example here.]
-
-
-
-
-
-
-
-
- [Enter API information here.]
-
-
-
-
-
-
-
-
- [Enter information about supplied implementation of this extension point.]
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ [Enter description of this extension point.]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [Enter the first release in which this extension point appears.]
+
+
+
+
+
+
+
+
+ [Enter extension point usage example here.]
+
+
+
+
+
+
+
+
+ [Enter API information here.]
+
+
+
+
+
+
+
+
+ [Enter information about supplied implementation of this extension point.]
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java
deleted file mode 100644
index 9a05256611b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CCompletionContributorManager.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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;
-
-
-import java.util.ArrayList;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.text.CCompletionContributorDescriptor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.ICCompletionContributor;
-import org.eclipse.cdt.ui.IFunctionSummary;
-import org.eclipse.cdt.ui.text.ICCompletionInvocationContext;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * Manages external plugins that contribute completion and function
- * info through the CCompletionContributor extension point
- */
-
-public class CCompletionContributorManager {
-
- public static final String CONTRIBUTION_EXTENSION = "CCompletionContributor"; //$NON-NLS-1$
- private static CCompletionContributorDescriptor[] fCCompletionContributorDescriptors = null;
-
-
- static private CCompletionContributorManager fInstance;
-
- private CCompletionContributorManager() {
- // Initialize and scan the extension points
- }
-
- public static CCompletionContributorManager getDefault() {
- if (fInstance == null) {
- fInstance = new CCompletionContributorManager();
- }
- return fInstance;
- }
-
- public IFunctionSummary getFunctionInfo(ICCompletionInvocationContext context, String name) {
- CCompletionContributorDescriptor[] desc = getCCompletionContributorDescriptors();
- for (int i = 0; i < desc.length; i++) {
- try {
- ICCompletionContributor c = null;
- ITranslationUnit unit = context.getTranslationUnit();
- if (unit != null) {
- c = desc[i].getCCompletionContributor(unit);
- } else {
- IProject project = context.getProject();
- c = desc[i].getCCompletionContributor(project);
- }
- if (c != null) {
- IFunctionSummary f = c.getFunctionInfo(context, name);
- if (f != null) {
- return f;
- }
- }
- } catch (CoreException e) {
- //
- }
- }
-
- return null;
- }
-
- public IFunctionSummary[] getMatchingFunctions(ICCompletionInvocationContext context, String frag) {
-
- IFunctionSummary[] fs = null;
-
- CCompletionContributorDescriptor[] desc = getCCompletionContributorDescriptors();
- for (int i = 0; i < desc.length; i++) {
- try {
- ICCompletionContributor c = null;
- ITranslationUnit unit = context.getTranslationUnit();
- if (unit != null) {
- c = desc[i].getCCompletionContributor(unit);
- } else {
- IProject project = context.getProject();
- c = desc[i].getCCompletionContributor(project);
- }
- if (c != null) {
- IFunctionSummary[] f = c.getMatchingFunctions(context, frag);
- if (f != null) {
- if (fs == null) {
- fs = f;
- } else {
- IFunctionSummary[] dest = new IFunctionSummary[fs.length + f.length];
- System.arraycopy(fs, 0, dest, 0, fs.length);
- System.arraycopy(f, 0, dest, fs.length, f.length);
- fs = dest;
- }
- }
- }
- } catch (CoreException e) {
- //
- }
- }
-
- return fs;
- }
-
- private static CCompletionContributorDescriptor[] getCCompletionContributorDescriptors() {
- if (fCCompletionContributorDescriptors == null) {
- fCCompletionContributorDescriptors= getCCompletionContributorDescriptors(CONTRIBUTION_EXTENSION);
- }
- return fCCompletionContributorDescriptors;
- }
-
-
- private static CCompletionContributorDescriptor[] getCCompletionContributorDescriptors(String contributionId) {
- IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
- ArrayList res= new ArrayList(elements.length);
- for (int i= 0; i < elements.length; i++) {
- CCompletionContributorDescriptor desc= new CCompletionContributorDescriptor(elements[i]);
- IStatus status= desc.checkSyntax();
- if (status.isOK()) {
- res.add(desc);
- } else {
- CUIPlugin.getDefault().log(status);
- }
- }
- return (CCompletionContributorDescriptor[]) res.toArray(new CCompletionContributorDescriptor[res.size()]);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java
new file mode 100644
index 00000000000..fd649d02be1
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java
@@ -0,0 +1,230 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
+import org.eclipse.cdt.internal.ui.text.CHelpSettings;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * This class is used to manage external plugins that contribute
+ * C/C++ help information through the CHelpProvider extension point
+ */
+
+public class CHelpProviderManager {
+ final private static String C_HELP_SETTINGS_FILE_NAME = "cHelpSettings.xml"; //$NON-NLS-1$
+ final private static String ELEMENT_ROOT = "cHelpSettings"; //$NON-NLS-1$
+
+ private static Map fProjectHelpSettings = null;
+ private static CHelpSettings fDefaultHelpSettings = null;
+
+ private static File fSettingsFile = null;
+ static private CHelpProviderManager fInstance = null;
+
+ private static IProject fCurrentProject = null;
+ private static CHelpSettings fCurrentSettings = null;
+
+ private CHelpProviderManager() {
+ }
+
+ private static File getSettingsFile(){
+ if(fSettingsFile == null){
+ fSettingsFile = CUIPlugin.getDefault().getStateLocation().append(C_HELP_SETTINGS_FILE_NAME).toFile();
+ }
+ return fSettingsFile;
+ }
+
+ private static Map getSettingsMap(){
+ if(fProjectHelpSettings == null)
+ fProjectHelpSettings = new HashMap();
+ return fProjectHelpSettings;
+ }
+
+ private static CHelpSettings getDefaultHelpSettings(){
+ if(fDefaultHelpSettings == null){
+ fDefaultHelpSettings = new CHelpSettings(null);
+ }
+ return fDefaultHelpSettings;
+ }
+
+ private static CHelpSettings getPersistedHelpSettings(IProject project){
+/* uncomment to use Map
+ Map settingsMap = getSettingsMap();
+ CHelpSettings settings = (CHelpSettings)settingsMap.get(project.getName());
+ if(settings == null){
+ settings = createHelpSettings(project);
+ settingsMap.put(project.getName(),settings);
+ }
+ return settings;
+*/
+ return createHelpSettings(project);
+ }
+
+ private static CHelpSettings createHelpSettings(IProject project){
+ String projectName = project.getName();
+ File file = getSettingsFile();
+ CHelpSettings settings = null;
+ Element rootElement = null;
+
+ if(file.isFile()){
+ try{
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.parse(file);
+ NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
+
+ if (nodes.getLength() > 0)
+ rootElement = (Element)nodes.item(0);
+
+ }catch(ParserConfigurationException e){
+ }catch(SAXException e){
+ }catch(IOException e){
+ }
+ }
+
+ settings = new CHelpSettings(project,rootElement);
+ return settings;
+ }
+
+ private static CHelpSettings getHelpSettings(IProject project){
+ if(project == null)
+ return getDefaultHelpSettings();
+
+ CHelpSettings settings = null;
+ if(fCurrentProject != null && fCurrentSettings != null && project == fCurrentProject)
+ settings = fCurrentSettings;
+ else{
+ fCurrentProject = project;
+ fCurrentSettings = getPersistedHelpSettings(project);
+ settings = fCurrentSettings;
+ }
+ return settings;
+ }
+
+ private static CHelpSettings getHelpSettings(ICHelpInvocationContext context){
+ IProject project = getProjectFromContext(context);
+
+ return getHelpSettings(project);
+ }
+
+ private static IProject getProjectFromContext(ICHelpInvocationContext context){
+ IProject project = context.getProject();
+ if(project == null){
+ ITranslationUnit unit = context.getTranslationUnit();
+ if(unit != null)
+ project = unit.getCProject().getProject();
+ }
+ return project;
+ }
+
+ public static CHelpProviderManager getDefault() {
+ if (fInstance == null) {
+ fInstance = new CHelpProviderManager();
+ }
+ return fInstance;
+ }
+
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name) {
+ CHelpSettings settings = getHelpSettings(context);
+
+ return settings.getFunctionInfo(context,name);
+ }
+
+ public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag) {
+ CHelpSettings settings = getHelpSettings(context);
+
+ return settings.getMatchingFunctions(context,frag);
+ }
+
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
+ CHelpSettings settings = getHelpSettings(context);
+
+ return settings.getHelpResources(context,name);
+ }
+
+ public CHelpBookDescriptor[] getCHelpBookDescriptors(ICHelpInvocationContext context){
+ return getHelpSettings(context).getCHelpBookDescriptors();
+ }
+
+ public void serialize(ICHelpInvocationContext context){
+ CHelpSettings settings = getHelpSettings(context);
+
+ File file = getSettingsFile();
+
+ try{
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc;
+ Element rootElement = null;
+
+ if(file.exists()){
+ doc = builder.parse(file);
+ NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
+
+ if (nodes.getLength() > 0)
+ rootElement = (Element)nodes.item(0);
+ }
+ else{
+ doc = builder.newDocument();
+ }
+
+ if(rootElement == null){
+ rootElement = doc.createElement(ELEMENT_ROOT);
+ doc.appendChild(rootElement);
+ }
+
+ settings.serialize(doc,rootElement);
+
+ FileWriter writer = new FileWriter(file);
+
+ Transformer transformer=TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(writer);
+
+ transformer.transform(source, result);
+
+ writer.close();
+ }catch(ParserConfigurationException e){
+ }catch(SAXException e){
+ }catch(TransformerConfigurationException e){
+ }catch(TransformerException e){
+ }catch(IOException e){
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
index be9e0a1a2ad..b969fe0ff8e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
@@ -67,3 +67,6 @@ CElementLabels.anonymous=(anon)
CElementLabels.concat_string=\ -\
CElementLabels.comma_string=,\
CElementLabels.declseparator_string=\ :\
+CHelpConfigurationPropertyPage.buttonLabels.CheckAll=Check All
+CHelpConfigurationPropertyPage.buttonLabels.UncheckAll=Uncheck All
+CHelpConfigurationPropertyPage.HelpBooks=Help books
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
index 14f4535d216..7ced916d077 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
@@ -9,7 +9,7 @@ import java.io.InputStream;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-
/**
+/**
* Input stream which reads from a document
*/
public class DocumentInputStream extends InputStream {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
index 5c3ba68af55..0f50549c44f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
import org.eclipse.cdt.internal.ui.codemanipulation.AddIncludesOperation;
@@ -44,7 +44,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IRequiredInclude;
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
-import org.eclipse.cdt.ui.text.ICCompletionInvocationContext;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -217,7 +217,7 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
final IFunctionSummary[] fs = new IFunctionSummary[1];
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- ICCompletionInvocationContext context = new ICCompletionInvocationContext() {
+ ICHelpInvocationContext context = new ICHelpInvocationContext() {
public IProject getProject() {
ITranslationUnit u = getTranslationUnit();
@@ -232,7 +232,7 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
}
};
- fs[0] = CCompletionContributorManager.getDefault().getFunctionInfo(context, name);
+ fs[0] = CHelpProviderManager.getDefault().getFunctionInfo(context, name);
}
};
try {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index 01caa5fb5aa..f121966751c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -30,6 +30,7 @@ import org.eclipse.cdt.internal.ui.text.CPairMatcher;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+import org.eclipse.cdt.internal.ui.util.CUIHelp;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.PreferenceConstants;
@@ -1061,6 +1062,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fSourceViewerDecorationSupport.setCharacterPairMatcher(fBracketMatcher);
fSourceViewerDecorationSupport.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
+ CUIHelp.setHelp(this, sourceViewer.getTextWidget(), ICHelpContextIds.CEDITOR_VIEW);
+
return sourceViewer;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionContributorDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionContributorDescriptor.java
deleted file mode 100644
index cc2cff67981..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionContributorDescriptor.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.text;
-
-import java.util.Arrays;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.expressions.ExpressionTagNames;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.ICCompletionContributor;
-
-/**
- * CCompletionContributorDescriptor
- */
-public class CCompletionContributorDescriptor {
- private IConfigurationElement fConfigurationElement;
- private ICCompletionContributor fContributorInstance;
- private ITranslationUnit fLastUnit;
- private boolean fLastResult;
-
- private static final String ID= "id"; //$NON-NLS-1$
- private static final String CLASS= "class"; //$NON-NLS-1$
-
- public CCompletionContributorDescriptor(IConfigurationElement element) {
- fConfigurationElement= element;
- fContributorInstance= null;
- fLastUnit= null;
- }
-
- public IStatus checkSyntax() {
- IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
- if (children.length > 1) {
- String id= fConfigurationElement.getAttribute(ID);
- return new StatusInfo(IStatus.ERROR, "Only one element allowed. Disabling " + id); //$NON-NLS-1$
- }
- return new StatusInfo(IStatus.OK, "Syntactically correct completion contributor"); //$NON-NLS-1$
- }
-
- private boolean matches(ITranslationUnit unit) {
- IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
- if (children.length == 1) {
- if (unit.equals(fLastUnit)) {
- return fLastResult;
- }
- try {
- ExpressionConverter parser= ExpressionConverter.getDefault();
- Expression expression= parser.perform(children[0]);
- EvaluationContext evalContext= new EvaluationContext(null, unit);
- evalContext.addVariable("translationUnit", unit); //$NON-NLS-1$
- String[] natures= unit.getCProject().getProject().getDescription().getNatureIds();
- evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
-
- fLastResult= !(expression.evaluate(evalContext) != EvaluationResult.TRUE);
- fLastUnit= unit;
- return fLastResult;
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- }
- }
- // For backward compat. we have to return true in no enablement was specified.
- return true;
- }
-
- public ICCompletionContributor getCCompletionContributor(ITranslationUnit cunit) throws CoreException {
- if (matches(cunit)) {
- if (fContributorInstance == null) {
- try {
- fContributorInstance= (ICCompletionContributor)fConfigurationElement.createExecutableExtension(CLASS);
- final ICCompletionContributor c = fContributorInstance;
- // Run the initialiser the class
- ISafeRunnable runnable = new ISafeRunnable() {
- public void run() throws Exception {
- // Initialize
- c.initialize();
- }
- public void handleException(Throwable exception) {
- }
- };
- Platform.run(runnable);
- } catch (ClassCastException e) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "", e)); //$NON-NLS-1$
- }
- }
- return fContributorInstance;
- }
- return null;
- }
-
-
- private boolean matches(IProject project) {
- IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
- if (children.length == 1 && project != null) {
- try {
- ExpressionConverter parser= ExpressionConverter.getDefault();
- Expression expression= parser.perform(children[0]);
- EvaluationContext evalContext= new EvaluationContext(null, project);
- String[] natures= project.getDescription().getNatureIds();
- evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
-
- fLastResult= !(expression.evaluate(evalContext) != EvaluationResult.TRUE);
- return fLastResult;
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e);
- }
- }
- // For backward compat. we have to return true in no enablement was specified.
- return true;
- }
-
- public ICCompletionContributor getCCompletionContributor(IProject project) throws CoreException {
- if (matches(project)) {
- if (fContributorInstance == null) {
- try {
- fContributorInstance= (ICCompletionContributor)fConfigurationElement.createExecutableExtension(CLASS);
- final ICCompletionContributor c = fContributorInstance;
- // Run the initialiser the class
- ISafeRunnable runnable = new ISafeRunnable() {
- public void run() throws Exception {
- // Initialize
- c.initialize();
- }
- public void handleException(Throwable exception) {
- }
- };
- Platform.run(runnable);
- } catch (ClassCastException e) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "", e)); //$NON-NLS-1$
- }
- }
- return fContributorInstance;
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java
new file mode 100644
index 00000000000..c295d82fbaa
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java
@@ -0,0 +1,133 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the CHelpBook settings
+ *
+ * @since 2.1
+ */
+public class CHelpBookDescriptor {
+ final private static String ELEMENT_BOOK = "book"; //$NON-NLS-1$
+ final private static String ATTRIBUTE_TITLE = "title"; //$NON-NLS-1$
+ final private static String ATTRIBUTE_ENABLED = "enabled"; //$NON-NLS-1$
+ final private static String VALUE_TRUE = "true"; //$NON-NLS-1$
+ final private static String VALUE_FALSE = "false"; //$NON-NLS-1$
+
+ private boolean fEnabled = true;
+ private ICHelpBook fCHelpBook;
+
+ CHelpBookDescriptor(ICHelpBook book){
+ this(book,null);
+ }
+
+ CHelpBookDescriptor(ICHelpBook book, Element parentElement){
+ fCHelpBook = book;
+
+ if(parentElement == null)
+ return;
+
+ NodeList bookElements = parentElement.getElementsByTagName(ELEMENT_BOOK);
+ if(bookElements.getLength() == 0)
+ return;
+
+ String title = book.getTitle();
+ for(int i = 0; i < bookElements.getLength(); i++){
+ Element bookElement = (Element)bookElements.item(i);
+ if(title.equals(bookElement.getAttribute(ATTRIBUTE_TITLE))){
+ fEnabled = VALUE_TRUE.equalsIgnoreCase(bookElement.getAttribute(ATTRIBUTE_ENABLED));
+ break;
+ }
+ }
+ }
+
+ public boolean isEnabled(){
+ return fEnabled;
+ }
+
+ public boolean matches(ICHelpInvocationContext context){
+ ITranslationUnit unit = context.getTranslationUnit();
+ if(unit != null)
+ return matches(unit);
+ IProject project = context.getProject();
+ if(project != null)
+ return matches(project);
+ return true;
+ }
+
+ public boolean matches(IProject project){
+ ICHelpBook book = getCHelpBook();
+ boolean bMatches = false;
+ switch(book.getCHelpType()){
+ case ICHelpBook.HELP_TYPE_CPP:
+ try{
+ bMatches = project.hasNature(CCProjectNature.CC_NATURE_ID);
+ }catch(CoreException e){
+ }
+ break;
+ case ICHelpBook.HELP_TYPE_C:
+ case ICHelpBook.HELP_TYPE_ASM:
+ try{
+ bMatches = project.hasNature(CProjectNature.C_NATURE_ID);
+ }catch(CoreException e){
+ }
+ break;
+ default:
+ bMatches = true;
+ }
+ return bMatches;
+ }
+
+ public boolean matches(ITranslationUnit unit){
+ ICHelpBook book = getCHelpBook();
+ boolean bMatches = false;
+ switch(book.getCHelpType()){
+ case ICHelpBook.HELP_TYPE_CPP:
+ bMatches = unit.isCXXLanguage();
+ break;
+ case ICHelpBook.HELP_TYPE_C:
+ bMatches = unit.isCLanguage() || unit.isCXXLanguage();
+ break;
+ case ICHelpBook.HELP_TYPE_ASM:
+ bMatches = unit.isASMLanguage();
+ break;
+ default:
+ bMatches = true;
+ }
+ return bMatches;
+ }
+
+ public void enable(boolean enable){
+ fEnabled = enable;
+ }
+
+ public ICHelpBook getCHelpBook(){
+ return fCHelpBook;
+ }
+
+ public void serialize(Document doc, Element parentElement){
+ Element bookElement = doc.createElement(ELEMENT_BOOK);
+ bookElement.setAttribute(ATTRIBUTE_TITLE,getCHelpBook().getTitle());
+ bookElement.setAttribute(ATTRIBUTE_ENABLED,fEnabled ? VALUE_TRUE : VALUE_FALSE);
+ parentElement.appendChild(bookElement);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
new file mode 100644
index 00000000000..ed2ad1f658d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
@@ -0,0 +1,180 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpProvider;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the CHelpProvider settings
+ *
+ * @since 2.1
+ */
+public class CHelpProviderDescriptor {
+ private static final String CLASS= "class"; //$NON-NLS-1$
+
+ final private static String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
+ final private static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+
+ private static Map fProvidersMap = null;
+
+ private ICHelpProvider fHelpProvider = null;
+ private IConfigurationElement fConfigElement;
+ private CHelpBookDescriptor fHelpBookDescriptors[] = null;
+ private IProject fProject;
+
+ public CHelpProviderDescriptor(IProject project, IConfigurationElement element){
+ this(project,element,null);
+ }
+
+ public CHelpProviderDescriptor(IProject project, IConfigurationElement configElement, Element parentElement){
+ fConfigElement = configElement;
+ fProject = project;
+
+ if(parentElement == null)
+ return;
+
+ NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROVIDER);
+ Element projectElement = getDescriptorElement(parentElement);
+
+ if(projectElement == null)
+ return;
+
+ getCHelpBookDescriptors(projectElement);
+ }
+
+ private Element getDescriptorElement(Element parentElement){
+ String id = getConfigurationElement().getAttribute(ATTRIBUTE_ID);
+ if(id == null || "".equals(id)) //$NON-NLS-1$
+ return null;
+
+ NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROVIDER);
+ for(int i = 0; i < nodes.getLength(); i++){
+ Element descriptorEl = (Element)nodes.item(i);
+ if(id.equals(descriptorEl.getAttribute(ATTRIBUTE_ID))){
+ return descriptorEl;
+ }
+ }
+ return null;
+ }
+
+ private static Map getProvidersMap(){
+ if(fProvidersMap == null){
+ fProvidersMap = new HashMap();
+ }
+ return fProvidersMap;
+ }
+
+ private static ICHelpProvider getCHelpProvider(IConfigurationElement element){
+ String id = element.getAttribute(ATTRIBUTE_ID);
+ if(id == null || "".equals(id)) //$NON-NLS-1$
+ return null;
+
+ Map providersMap = getProvidersMap();
+ try{
+ ICHelpProvider provider = (ICHelpProvider)providersMap.get(id);
+ if(provider == null){
+ provider = (ICHelpProvider)element.createExecutableExtension(CLASS);
+ providersMap.put(id,provider);
+ }
+ final ICHelpProvider c = provider;
+ // Run the initialiser the class
+ ISafeRunnable runnable = new ISafeRunnable() {
+ public void run() throws Exception {
+ // Initialize
+ c.initialize();
+ }
+ public void handleException(Throwable exception) {
+ }
+ };
+ Platform.run(runnable);
+ return provider;
+ }
+ catch(Exception e){
+ return null;
+ }
+ }
+
+ public IConfigurationElement getConfigurationElement(){
+ return fConfigElement;
+ }
+
+ public ICHelpProvider getCHelpProvider(){
+ if(fHelpProvider == null)
+ fHelpProvider = getCHelpProvider(fConfigElement);
+ return fHelpProvider;
+ }
+
+ public CHelpBookDescriptor [] getCHelpBookDescriptors(Element projectElement){
+ if(fHelpBookDescriptors == null || projectElement != null){
+ ICHelpProvider provider = getCHelpProvider();
+ if(provider != null){
+ ICHelpBook books[] = provider.getCHelpBooks();
+ if(books != null){
+ List descriptorList = new ArrayList();
+ for(int i = 0; i < books.length; i++){
+ CHelpBookDescriptor des = new CHelpBookDescriptor(books[i],projectElement);
+ if(des.matches(fProject))
+ descriptorList.add(des);
+ }
+ fHelpBookDescriptors = (CHelpBookDescriptor[])descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
+ }
+ }
+ if(fHelpBookDescriptors == null)
+ fHelpBookDescriptors = new CHelpBookDescriptor[0];
+ }
+ return fHelpBookDescriptors;
+ }
+
+ public CHelpBookDescriptor [] getCHelpBookDescriptors(){
+ return getCHelpBookDescriptors(null);
+ }
+
+ ICHelpBook[] getEnabledMatchedCHelpBooks(ICHelpInvocationContext context){
+ CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
+ if(bookDescriptors.length == 0)
+ return null;
+ List bookList = new ArrayList();
+ for(int i = 0; i < bookDescriptors.length; i++){
+ if(bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
+ bookList.add(bookDescriptors[i].getCHelpBook());
+ }
+ return (ICHelpBook[])bookList.toArray(new ICHelpBook[bookList.size()]);
+ }
+
+ public void serialize(Document doc, Element parentElement){
+ String id = getConfigurationElement().getAttribute(ATTRIBUTE_ID);
+ if(id == null || "".equals(id)) //$NON-NLS-1$
+ return;
+
+ CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
+ Element providerElement = doc.createElement(ELEMENT_PROVIDER);
+ providerElement.setAttribute(ATTRIBUTE_ID,id);
+ parentElement.appendChild(providerElement);
+
+ for(int i = 0; i < bookDescriptors.length; i++){
+ bookDescriptors[i].serialize(doc,providerElement);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
new file mode 100644
index 00000000000..b62d0489fe4
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
@@ -0,0 +1,186 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpProvider;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the Help settings for the current project
+ *
+ * @since 2.1
+ */
+public class CHelpSettings {
+ public static final String CONTRIBUTION_EXTENSION = "CHelpProvider"; //$NON-NLS-1$
+
+ final private static String ELEMENT_PROJECT = "project"; //$NON-NLS-1$
+ final private static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
+
+ private IProject fProject;
+ private static IConfigurationElement fConfigElements[] = null;
+ private CHelpProviderDescriptor fProviderDescriptors[] = null;
+
+ public CHelpSettings(IProject project){
+ this(project,null);
+ }
+
+ public CHelpSettings(IProject project, Element parentElement){
+ fProject = project;
+
+ if(parentElement == null)
+ return;
+
+ Element projectElement = getProjectElement(parentElement);
+ if(projectElement == null)
+ return;
+
+ getCHelpProviderDescriptors(projectElement);
+ }
+
+ private Element getProjectElement(Element parentElement){
+ NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROJECT);
+ for(int i = 0; i < nodes.getLength(); i++){
+ Element curProject = (Element)nodes.item(i);
+ if(getProject().getName().equals(curProject.getAttribute(ATTRIBUTE_NAME)))
+ return curProject;
+ }
+ return null;
+ }
+
+ public IProject getProject(){
+ return fProject;
+ }
+
+ public CHelpProviderDescriptor[] getCHelpProviderDescriptors(Element projectElement){
+ if(fProviderDescriptors == null || projectElement != null){
+ IConfigurationElement congifElements[] = getConfigElements();
+ fProviderDescriptors = new CHelpProviderDescriptor[congifElements.length];
+ for(int i = 0; i < congifElements.length; i++){
+ fProviderDescriptors[i] = new CHelpProviderDescriptor(fProject,congifElements[i],projectElement);
+ }
+ }
+ return fProviderDescriptors;
+ }
+
+ public CHelpProviderDescriptor[] getCHelpProviderDescriptors(){
+ return getCHelpProviderDescriptors(null);
+ }
+
+ public CHelpBookDescriptor[] getCHelpBookDescriptors(){
+ CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+ if(providerDescriptors.length == 0)
+ return new CHelpBookDescriptor[0];
+
+ List bookList = new ArrayList();
+ for(int i = 0; i < providerDescriptors.length; i++){
+ CHelpBookDescriptor bookDescriptors[] = providerDescriptors[i].getCHelpBookDescriptors();
+ if(bookDescriptors.length != 0)
+ bookList.addAll(Arrays.asList(bookDescriptors));
+ }
+ return (CHelpBookDescriptor[])bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
+ }
+
+ private static IConfigurationElement[] getConfigElements(){
+ if(fConfigElements == null){
+ fConfigElements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, CONTRIBUTION_EXTENSION);
+ if(fConfigElements == null)
+ fConfigElements = new IConfigurationElement[0];
+ }
+ return fConfigElements;
+ }
+
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name){
+ CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+ for(int i = 0; i < providerDescriptors.length; i++){
+ ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
+ if(books != null && books.length != 0){
+ ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
+ if(provider != null){
+ IFunctionSummary summary = provider.getFunctionInfo(context,books,name);
+ if(summary != null)
+ return summary;
+ }
+ }
+ }
+ return null;
+ }
+
+ public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag){
+ CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+ List sumaryList = new ArrayList();
+ for(int i = 0; i < providerDescriptors.length; i++){
+ ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
+ if(books != null && books.length != 0){
+ ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
+ if(provider != null){
+ IFunctionSummary summaries[] = provider.getMatchingFunctions(context,books,frag);
+ if(summaries != null && summaries.length != 0)
+ sumaryList.addAll(Arrays.asList(summaries));
+ }
+ }
+ }
+ if(sumaryList.size() == 0)
+ return null;
+
+ return (IFunctionSummary[])sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
+ }
+
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
+ CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+ List resourcesList = new ArrayList();
+ for(int i = 0; i < providerDescriptors.length; i++){
+ ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
+ if(books != null && books.length != 0){
+ ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
+ if(provider != null){
+ ICHelpResourceDescriptor resources[] = provider.getHelpResources(context,books,name);
+ if(resources != null && resources.length != 0)
+ resourcesList.addAll(Arrays.asList(resources));
+ }
+ }
+ }
+ if(resourcesList.size() == 0)
+ return null;
+
+ return (ICHelpResourceDescriptor[])resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
+ }
+
+ public void serialize(Document doc, Element parentElement){
+ CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+ Element oldProjectElement = getProjectElement(parentElement);
+
+ Element projectElement = doc.createElement(ELEMENT_PROJECT);
+ projectElement.setAttribute(ATTRIBUTE_NAME,getProject().getName());
+
+ if(oldProjectElement != null)
+ parentElement.replaceChild(projectElement,oldProjectElement);
+ else
+ parentElement.appendChild(projectElement);
+
+ for(int i = 0; i < providerDescriptors.length; i++){
+ providerDescriptors[i].serialize(doc,projectElement);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
index 8b82ca7ff61..65737197cf9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
@@ -12,13 +12,13 @@ package org.eclipse.cdt.internal.ui.text.c.hover;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
-import org.eclipse.cdt.ui.text.ICCompletionInvocationContext;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
@@ -52,7 +52,7 @@ public class CDocHover extends AbstractCEditorTextHover {
// call the Help to get info
- ICCompletionInvocationContext context = new ICCompletionInvocationContext() {
+ ICHelpInvocationContext context = new ICHelpInvocationContext() {
public IProject getProject() {
ITranslationUnit unit = getTranslationUnit();
@@ -68,7 +68,7 @@ public class CDocHover extends AbstractCEditorTextHover {
}
};
- IFunctionSummary fs = CCompletionContributorManager.getDefault().getFunctionInfo(context, expression);
+ IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
if (fs != null) {
buffer.append(CEditorMessages.getString("DefaultCEditorTextHover.html.name")); //$NON-NLS-1$
buffer.append(HTMLPrinter.convertToHTMLContent(fs.getName()));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java
index 086363dcb4b..a084f4392ec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.corext.template.ContextType;
import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
import org.eclipse.cdt.internal.corext.template.ITemplateEditor;
-import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.internal.ui.editor.CEditor;
@@ -35,7 +35,7 @@ import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.text.ICCompletionInvocationContext;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -451,7 +451,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
IFunctionSummary[] summary;
- ICCompletionInvocationContext context = new ICCompletionInvocationContext() {
+ ICHelpInvocationContext context = new ICHelpInvocationContext() {
public IProject getProject() {
return fCurrentSourceUnit.getCProject().getProject();
@@ -461,7 +461,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
return fCurrentSourceUnit;
}
};
- summary = CCompletionContributorManager.getDefault().getMatchingFunctions(context, prefix);
+ summary = CHelpProviderManager.getDefault().getMatchingFunctions(context, prefix);
if(summary == null) {
return;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java
new file mode 100644
index 00000000000..6dcc4b65214
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java
@@ -0,0 +1,130 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.help.HelpSystem;
+import org.eclipse.help.IContext;
+import org.eclipse.help.IHelpResource;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+/**
+ *
+ * @since 2.1
+ */
+public class CHelpDisplayContext implements IContext {
+ private IHelpResource[] fHelpResources;
+ private String fText;
+
+ public static void displayHelp(String contextId, CEditor editor) throws CoreException {
+ String selected = getSelectedString(editor);
+ IContext context= HelpSystem.getContext(contextId);
+ if (context != null) {
+ if (selected != null && selected.length() > 0) {
+ context= new CHelpDisplayContext(context, editor, selected);
+ }
+ WorkbenchHelp.displayHelp(context);
+ }
+ }
+
+ private static String getSelectedString(CEditor editor){
+ String expression = null;
+ try{
+ ITextSelection selection = (ITextSelection)editor.getSite().getSelectionProvider().getSelection();
+ IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ IRegion region = CWordFinder.findWord(document, selection.getOffset());
+ expression = document.get(region.getOffset(), region.getLength());
+ }
+ catch(Exception e){
+ }
+ return expression;
+ }
+
+ public CHelpDisplayContext(IContext context, final CEditor editor , String selected) throws CoreException {
+
+ List helpResources= new ArrayList();
+
+ ICHelpInvocationContext invocationContext = new ICHelpInvocationContext() {
+
+ public IProject getProject() {
+ ITranslationUnit unit = getTranslationUnit();
+ if (unit != null) {
+ return unit.getCProject().getProject();
+ }
+ return null;
+ }
+
+ public ITranslationUnit getTranslationUnit() {
+ IEditorInput editorInput= editor.getEditorInput();
+ return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+ }
+ };
+
+ if (context != null) {
+ IHelpResource[] resources= context.getRelatedTopics();
+ if (resources != null){
+ helpResources.addAll(Arrays.asList(resources));
+ }
+ }
+
+ ICHelpResourceDescriptor providerResources[] = CHelpProviderManager.getDefault().getHelpResources(invocationContext,selected);
+ if(providerResources != null){
+ for(int i = 0; i < providerResources.length; i++){
+ helpResources.addAll(Arrays.asList(providerResources[i].getHelpResources()));
+ }
+ }
+
+ fHelpResources= (IHelpResource[]) helpResources.toArray(new IHelpResource[helpResources.size()]);
+ if (fText == null || fText.length() == 0) {
+ if (context != null) {
+ fText= context.getText();
+ }
+ }
+ if (fText != null && fText.length() == 0) {
+ fText= null;
+ }
+ }
+
+ private boolean doesNotExist(URL url) {
+ if (url.getProtocol().equals("file")) { //$NON-NLS-1$
+ File file= new File(url.getFile());
+ return !file.exists();
+ }
+ return false;
+ }
+
+ public IHelpResource[] getRelatedTopics() {
+ return fHelpResources;
+ }
+
+ public String getText() {
+ return fText;
+ }
+}
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java
new file mode 100644
index 00000000000..108c1da8326
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java
@@ -0,0 +1,55 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.HelpEvent;
+import org.eclipse.swt.events.HelpListener;
+
+/**
+ *
+ * @since 2.1
+ */
+public class CUIHelp {
+
+ public static void setHelp(CEditor editor, StyledText text, String contextId) {
+ CUIHelpListener listener= new CUIHelpListener(editor, contextId);
+ text.addHelpListener(listener);
+ }
+
+ private static class CUIHelpListener implements HelpListener {
+
+ private String fContextId;
+ private CEditor fEditor;
+
+ public CUIHelpListener(CEditor editor, String contextId) {
+ fContextId= contextId;
+ fEditor= editor;
+ }
+
+ /*
+ * @see HelpListener#helpRequested(HelpEvent)
+ *
+ */
+ public void helpRequested(HelpEvent e) {
+ try {
+ CHelpDisplayContext.displayHelp(fContextId, fEditor);
+ } catch (CoreException x) {
+ CUIPlugin.getDefault().log(x);
+ }
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICCompletionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICCompletionContributor.java
deleted file mode 100644
index bbe34032b49..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICCompletionContributor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.ui;
-
-import org.eclipse.cdt.ui.text.ICCompletionInvocationContext;
-
-
-public interface ICCompletionContributor {
-
- /**
- * Initialize the completion contributor class
- */
- void initialize();
-
- /**
- * get the matching function of a given name
- */
- IFunctionSummary getFunctionInfo(ICCompletionInvocationContext context, String name);
-
- /**
- * Get array of matching functions starting with this prefix
- */
- IFunctionSummary[] getMatchingFunctions(ICCompletionInvocationContext context, String prefix);
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java
new file mode 100644
index 00000000000..2ecab4389cf
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java
@@ -0,0 +1,36 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui;
+
+/**
+ * Represents the help book, that is a set of articles on some topic.
+ * Such as "C functions", "Qt library", etc., provided by help provider.
+ * @see ICHelpProvider
+ * @since 2.1
+ */
+public interface ICHelpBook {
+ public static final int HELP_TYPE_C = 1;
+ public static final int HELP_TYPE_CPP = 2;
+ public static final int HELP_TYPE_ASM = 3;
+
+ /**
+ * returns the tytle of the Help Book
+ * @return String representing the HelpBook tytle
+ */
+ String getTitle();
+
+ /**
+ * gets the type of Help provided with this book that might be ine of ICHelpBook.HELP_TYPE_XXX
+ * @return one of ICHelpBook.HELP_TYPE_XXX representing the type of Provided help
+ */
+ int getCHelpType();
+}
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java
new file mode 100644
index 00000000000..a5f078d6c21
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java
@@ -0,0 +1,58 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+/**
+ * Represents the C/C++ help provider
+ *
+ * @since 2.1
+ */
+public interface ICHelpProvider {
+
+ /**
+ * Initialize the completion contributor class
+ */
+ void initialize();
+
+ /**
+ * Get available help books
+ * @return The ICHelpBook[]
array of available help books
+ */
+ ICHelpBook[] getCHelpBooks();
+
+ /**
+ * get the matching function of a given name
+ *
+ * @param helpBooks the array of help books to be searched for help
+ * @param name the function name for which help is needed
+ * @return the IFunctionSummary interface
+ */
+ IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name);
+
+ /**
+ * Get array of matching functions starting with this prefix
+ *
+ * @param helpBooks the array of help books to be searched for help
+ * @param prefix the function name prefix
+ * @return the IFunctionSummary[] array
+ */
+ IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String prefix);
+
+ /**
+ *
+ * @param helpBooks the array of help books to be searched for help
+ * @param name the C/C++ element name for which help is needed
+ * @return the ICHelpResourceDescriptor[] array representing found help resources
+ */
+ ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name);
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java
new file mode 100644
index 00000000000..6fd8d49529c
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java
@@ -0,0 +1,36 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.help.IHelpResource;
+
+/**
+ * This interface represents Help Resources found in the certain Help Book
+ * provided by certain CHelpProvider
+ * @see ICHelpProvider
+ * @since 2.1
+ */
+public interface ICHelpResourceDescriptor {
+ /**
+ * represents the Help Book, where help resources represented by getHelpResources()
+ * method were found
+ * @return ICHelpBook interface representing the help book where help was found
+ */
+ ICHelpBook getCHelpBook();
+
+ /**
+ * gets the array of help resources found in the HelpBook represented
+ * by getCHelpBook() method
+ * @return the IHelpResource[] array
+ */
+ IHelpResource[] getHelpResources();
+}
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java
new file mode 100644
index 00000000000..74487d3cb9f
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java
@@ -0,0 +1,176 @@
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+import org.eclipse.cdt.internal.ui.util.PixelConverter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * This class defines a project property page
+ * for C/C++ project help settings configuration
+ * @since 2.1
+ */
+public class CHelpConfigurationPropertyPage extends PropertyPage implements
+ IWorkbenchPreferencePage {
+
+ private CHelpSettingsDisplay fCHelpSettingsDisplay;
+
+ private class CHelpBookListLabelProvider extends LabelProvider {
+ private ImageDescriptor fHelpProviderIcon;
+ private ImageDescriptorRegistry fRegistry;
+
+ public CHelpBookListLabelProvider() {
+ fRegistry= CUIPlugin.getImageDescriptorRegistry();
+ fHelpProviderIcon= CPluginImages.DESC_OBJS_LIBRARY;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof CHelpBookDescriptor) {
+ return ((CHelpBookDescriptor)element).getCHelpBook().getTitle();
+ }
+ return super.getText(element);
+ }
+
+ public Image getImage(Object element) {
+ if (element instanceof CHelpBookDescriptor) {
+ return fRegistry.get(fHelpProviderIcon);
+ }
+ return null;
+ }
+ }
+
+ private class CHelpSettingsDisplay {
+ private CheckedListDialogField fCHelpBookList;
+ private IProject fProject;
+ private CHelpBookDescriptor fCHelpBookDescriptors[];
+
+ public CHelpSettingsDisplay() {
+
+ String[] buttonLabels= new String[] {
+ /* 0 */ CUIMessages.getString("CHelpConfigurationPropertyPage.buttonLabels.CheckAll"), //NewWizardMessages.getString("BuildPathsBlock.classpath.checkall.button"), //$NON-NLS-1$
+ /* 1 */ CUIMessages.getString("CHelpConfigurationPropertyPage.buttonLabels.UncheckAll") //NewWizardMessages.getString("BuildPathsBlock.classpath.uncheckall.button") //$NON-NLS-1$
+ };
+
+ fCHelpBookList= new CheckedListDialogField(null, buttonLabels, new CHelpBookListLabelProvider());
+ fCHelpBookList.setLabelText(CUIMessages.getString("CHelpConfigurationPropertyPage.HelpBooks")); //$NON-NLS-1$
+ fCHelpBookList.setCheckAllButtonIndex(0);
+ fCHelpBookList.setUncheckAllButtonIndex(1);
+ }
+
+ public Control createControl(Composite parent){
+ PixelConverter converter= new PixelConverter(parent);
+
+ Composite composite= new Composite(parent, SWT.NONE);
+
+ LayoutUtil.doDefaultLayout(composite, new DialogField[] { fCHelpBookList }, true);
+ LayoutUtil.setHorizontalGrabbing(fCHelpBookList.getListControl(null));
+
+ int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
+ fCHelpBookList.setButtonsMinWidth(buttonBarWidth);
+
+ return composite;
+ }
+
+ public void init(final IResource resource) {
+ if(!(resource instanceof IProject))
+ return;
+ fProject = (IProject)resource;
+ fCHelpBookDescriptors = CHelpProviderManager.getDefault().getCHelpBookDescriptors(new ICHelpInvocationContext(){
+ public IProject getProject(){return (IProject)resource;}
+ public ITranslationUnit getTranslationUnit(){return null;}
+ }
+ );
+
+ List allTopicsList= Arrays.asList(fCHelpBookDescriptors);
+ List enabledTopicsList= getEnabledEntries(allTopicsList);
+
+ fCHelpBookList.setElements(allTopicsList);
+ fCHelpBookList.setCheckedElements(enabledTopicsList);
+ }
+
+ private List getEnabledEntries(List list) {
+ int size = list.size();
+ List desList= new ArrayList();
+
+ for (int i= 0; i < size; i++) {
+ CHelpBookDescriptor el = (CHelpBookDescriptor)list.get(i);
+ if(el.isEnabled())
+ desList.add(el);
+ }
+ return desList;
+ }
+
+ public void performOk(){
+ List list = fCHelpBookList.getElements();
+ final IProject project = fProject;
+
+ for(int i = 0; i < list.size(); i++){
+ Object obj = list.get(i);
+ if(obj != null && obj instanceof CHelpBookDescriptor){
+ ((CHelpBookDescriptor)obj).enable(fCHelpBookList.isChecked(obj));
+ }
+ }
+ CHelpProviderManager.getDefault().serialize(new ICHelpInvocationContext(){
+ public IProject getProject(){return project;}
+ public ITranslationUnit getTranslationUnit(){return null;}
+ });
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(Composite parent) {
+ fCHelpSettingsDisplay= new CHelpSettingsDisplay();
+ fCHelpSettingsDisplay.init((IResource)getElement());
+ return fCHelpSettingsDisplay.createControl(parent);
+ }
+
+ public boolean performOk() {
+ fCHelpSettingsDisplay.performOk();
+ super.performOk();
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
similarity index 70%
rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionInvocationContext.java
rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
index 5a208ff2bd6..f27ad4cc793 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionInvocationContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
@@ -1,13 +1,13 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation 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
- *******************************************************************************/
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
package org.eclipse.cdt.ui.text;
@@ -15,9 +15,9 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.resources.IProject;
/**
- * Invocation context for the ICCompletionContributor
+ * Invocation context for the CHelpProviderManager
*/
-public interface ICCompletionInvocationContext {
+public interface ICHelpInvocationContext {
/**
* @return the project