Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87186 Details for
Bug 215091
Create Context Help Editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
215091ContextHelpAwesomeEditors.patch (text/plain), 188.10 KB, created by
Curtis Windatt
on 2008-01-17 13:28:51 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2008-01-17 13:28:51 EST
Size:
188.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java,v >retrieving revision 1.5 >diff -u -r1.5 TocFileValidator.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java 16 Jan 2008 17:08:27 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java 17 Jan 2008 18:16:02 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -48,12 +48,12 @@ > } > IFile file = (IFile) selection[0]; > // Ensure we have a TOC file >- if (!TocExtensionUtil.isTOCFile(file.getFullPath())) { >+ if (!HelpEditorUtil.isTOCFile(file.getFullPath())) { > return errorStatus(PDEUIMessages.TocFileValidator_errorInvalidTOC); > } > > //Ensure that the TOC file selected isn't the current file >- if (TocExtensionUtil.isCurrentResource(file.getFullPath(), fModel)) { >+ if (HelpEditorUtil.isCurrentResource(file.getFullPath(), fModel)) { > return errorStatus(PDEUIMessages.TocFileValidator_errorSameTOC); > } > >@@ -62,18 +62,10 @@ > > } > >- /** >- * @param message >- * @return >- */ > private IStatus errorStatus(String message) { > return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.ERROR, message, null); > } > >- /** >- * @param message >- * @return >- */ > private IStatus okStatus(String message) { > return new Status(IStatus.OK, PDEPlugin.getPluginId(), IStatus.OK, message, null); > } >Index: src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java,v >retrieving revision 1.12 >diff -u -r1.12 TocTreeSection.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java 16 Jan 2008 17:08:27 -0000 1.12 >+++ src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java 17 Jan 2008 18:16:02 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -356,11 +356,11 @@ > > TocObject parent = tocObject.getParent(); > if (sel.size() == 1 && (tocObject.getType() == ITocConstants.TYPE_TOC || parent.getType() == ITocConstants.TYPE_TOPIC || parent.getType() == ITocConstants.TYPE_TOC)) { /* Semantic rule: >- * As long as the selection is a child of a >- * TOC root or a topic, or the selection itself >- * is a TOC root, then a new object can be added >- * either to the selection or to the parent >- */ >+ * As long as the selection is a child of a >+ * TOC root or a topic, or the selection itself >+ * is a TOC root, then a new object can be added >+ * either to the selection or to the parent >+ */ > canAddObject = true; > } > >@@ -670,13 +670,13 @@ > String message = null; > > if (tocFile) { >- if (TocExtensionUtil.isTOCFile(path)) { >+ if (HelpEditorUtil.isTOCFile(path)) { > return true; > } > > message = PDEUIMessages.TocPage_invalidTocFile; > } else { >- if (TocExtensionUtil.hasValidPageExtension(path)) { >+ if (HelpEditorUtil.hasValidPageExtension(path)) { > return true; > } > >@@ -739,7 +739,7 @@ > * > * @param dropTarget The target that the drop occurs near/on > * @param dropLocation The location of the drop relative to the target >- * @return >+ * @return parent > */ > private TocTopic determineParent(TocObject dropTarget, int dropLocation) { > //We must determine what object will be the parent of the >@@ -755,14 +755,14 @@ > } else { //In all other cases, it depends on the location of the drop > //relative to the drop target > switch (dropLocation) { >- case TocDropAdapter.LOCATION_JUST_AFTER : { //if the drop occured after an expanded node >+ case TocDropAdapter.LOCATION_JUST_AFTER : { //if the drop occurred after an expanded node > //and all of its children, > //make the drop target's parent the target parent object > if (!fTocTree.getExpandedState(dropTarget)) { > return (TocTopic) dropTarget.getParent(); > } > //otherwise, the target parent is the drop target, >- //since the drop occured between it and its first child >+ //since the drop occurred between it and its first child > } > case ViewerDropAdapter.LOCATION_ON : { //the drop location is directly on the drop target > //set the parent object to be the drop target >@@ -811,11 +811,11 @@ > // If the path is to a valid TOC file > // and it isn't the file in this model > // then make a link >- if (TocExtensionUtil.isTOCFile(path) && !TocExtensionUtil.isCurrentResource(path, fModel)) { >+ if (HelpEditorUtil.isTOCFile(path) && !HelpEditorUtil.isCurrentResource(path, fModel)) { > tocObjects.add(makeNewTocLink(targetParent, file)); > } > // If the path is to a file with an HTML page extension, make a topic >- else if (TocExtensionUtil.hasValidPageExtension(path)) { >+ else if (HelpEditorUtil.hasValidPageExtension(path)) { > TocTopic topic = makeNewTocTopic(targetParent, file); > String title = generateTitle(targetParent, path); > >Index: src/org/eclipse/pde/internal/ui/editor/toc/TocExtensionUtil.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/toc/TocExtensionUtil.java >diff -N src/org/eclipse/pde/internal/ui/editor/toc/TocExtensionUtil.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocExtensionUtil.java 16 Jan 2008 17:08:27 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,100 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.pde.internal.ui.editor.toc; >- >-import java.util.HashSet; >-import java.util.Locale; >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.pde.core.IBaseModel; >-import org.eclipse.pde.core.IModel; >-import org.eclipse.pde.internal.core.itoc.ITocConstants; >-import org.eclipse.pde.internal.ui.util.XMLRootElementMatcher; >- >-public class TocExtensionUtil { >- public static final String[] pageExtensions = {"htm", "shtml", "html", "xhtml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ >- public static final String tocExtension = "xml"; //$NON-NLS-1$ >- private static HashSet pageExtensionSet = new HashSet(pageExtensions.length); >- >- private static void populateHashSet() { >- for (int i = 0; i < pageExtensions.length; ++i) { >- pageExtensionSet.add(pageExtensions[i]); >- } >- } >- >- public static boolean hasValidPageExtension(IPath path) { >- String fileExtension = path.getFileExtension(); >- if (fileExtension != null) { >- fileExtension = fileExtension.toLowerCase(Locale.ENGLISH); >- if (pageExtensionSet.isEmpty()) { >- populateHashSet(); >- } >- >- return pageExtensionSet.contains(fileExtension); >- } >- >- return false; >- } >- >- private static boolean hasValidTocExtension(IPath path) { >- String fileExtension = path.getFileExtension(); >- return fileExtension != null && fileExtension.equals(tocExtension); >- } >- >- /** >- * @param file >- */ >- public static boolean isTOCFile(IPath path) { >- if (!hasValidTocExtension(path)) >- return false; >- >- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- >- IResource resource = root.findMember(path); >- if (resource != null && resource instanceof IFile) { >- return XMLRootElementMatcher.fileMatchesElement((IFile) resource, ITocConstants.ELEMENT_TOC); >- } >- >- return XMLRootElementMatcher.fileMatchesElement(path.toFile(), ITocConstants.ELEMENT_TOC); >- } >- >- public static boolean isCurrentResource(IPath path, IBaseModel model) { >- if (model instanceof IModel) { >- IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); >- IPath fullPath; >- >- if (workspacePath.isPrefixOf(path)) { >- fullPath = ((IModel) model).getUnderlyingResource().getLocation(); >- } else { >- fullPath = ((IModel) model).getUnderlyingResource().getFullPath(); >- } >- >- return fullPath.equals(path); >- } >- >- return false; >- } >- >- public static String getPageExtensionList() { >- StringBuffer buf = new StringBuffer(); >- >- for (int i = 0; i < pageExtensions.length; ++i) { >- buf.append('.'); >- buf.append(pageExtensions[i]); >- if (i != pageExtensions.length - 1) { >- buf.append(", "); //$NON-NLS-1$ >- } >- } >- >- return buf.toString(); >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java,v >retrieving revision 1.7 >diff -u -r1.7 TocDropAdapter.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java 16 Jan 2008 17:08:27 -0000 1.7 >+++ src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java 17 Jan 2008 18:16:02 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -166,14 +166,15 @@ > return; > } > >- if (!TocExtensionUtil.hasValidPageExtension(path) && !TocExtensionUtil.isTOCFile(path)) { >- event.detail = DND.DROP_NONE; >+ if(!HelpEditorUtil.hasValidPageExtension(path) >+ && !HelpEditorUtil.isTOCFile(path)) >+ { event.detail = DND.DROP_NONE; > return; > } > > // Make sure that the user isn't dropping a TOC into itself >- if (TocExtensionUtil.isCurrentResource(path, model)) { >- event.detail = DND.DROP_NONE; >+ if(HelpEditorUtil.isCurrentResource(path, model)) >+ { event.detail = DND.DROP_NONE; > return; > } > } >Index: src/org/eclipse/pde/internal/ui/editor/toc/details/TocPageFilter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/toc/details/TocPageFilter.java >diff -N src/org/eclipse/pde/internal/ui/editor/toc/details/TocPageFilter.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocPageFilter.java 16 Jan 2008 17:08:34 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,47 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.pde.internal.ui.editor.toc.details; >- >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerFilter; >-import org.eclipse.pde.internal.ui.editor.toc.TocExtensionUtil; >- >-public class TocPageFilter extends ViewerFilter { >- public boolean select(Viewer viewer, Object parent, Object element) { >- if (element instanceof IFile) { >- IPath path = ((IFile) element).getFullPath(); >- >- return TocExtensionUtil.hasValidPageExtension(path); >- } >- >- if (element instanceof IProject && !((IProject) element).isOpen()) { >- return false; >- } >- >- if (element instanceof IContainer) { >- try { >- IResource[] resources = ((IContainer) element).members(); >- for (int i = 0; i < resources.length; i++) { >- if (select(viewer, parent, resources[i])) { >- return true; >- } >- } >- } catch (CoreException e) { >- } >- } >- >- return false; >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java,v >retrieving revision 1.4 >diff -u -r1.4 TocDetails.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java 16 Jan 2008 17:08:34 -0000 1.4 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java 17 Jan 2008 18:16:02 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -182,7 +182,7 @@ > dialog.setAllowMultiple(false); > dialog.setTitle(PDEUIMessages.TocDetails_browseSelection); > dialog.setMessage(PDEUIMessages.TocDetails_browseMessage); >- dialog.addFilter(new TocPageFilter()); >+ dialog.addFilter(new HelpEditorFilter()); > > dialog.setInput(PDEPlugin.getWorkspace().getRoot()); > >Index: src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java,v >retrieving revision 1.6 >diff -u -r1.6 TocLinkDetails.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java 16 Jan 2008 17:08:34 -0000 1.6 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java 17 Jan 2008 18:16:02 -0000 >@@ -125,7 +125,7 @@ > dialog.setAllowMultiple(false); > dialog.setTitle(PDEUIMessages.TocLinkDetails_browseSelection); > dialog.setMessage(PDEUIMessages.TocLinkDetails_browseMessage); >- dialog.addFilter(new FileExtensionFilter(TocExtensionUtil.tocExtension)); >+ dialog.addFilter(new FileExtensionFilter(HelpEditorUtil.tocExtension)); > > dialog.setInput(PDEPlugin.getWorkspace().getRoot()); > >Index: src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java,v >retrieving revision 1.5 >diff -u -r1.5 TocTopicDetails.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java 16 Jan 2008 17:08:34 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java 17 Jan 2008 18:16:02 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -8,7 +8,6 @@ > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >- > package org.eclipse.pde.internal.ui.editor.toc.details; > > import org.eclipse.core.resources.IFile; >@@ -150,10 +149,10 @@ > > dialog.setValidator(new FileValidator()); > dialog.setAllowMultiple(false); >- dialog.setTitle(PDEUIMessages.TocDetails_browseSelection); >- dialog.setMessage(PDEUIMessages.TocDetails_browseMessage); >- dialog.addFilter(new TocPageFilter()); >- >+ dialog.setTitle(PDEUIMessages.TocDetails_browseSelection); >+ dialog.setMessage(PDEUIMessages.TocDetails_browseMessage); >+ dialog.addFilter(new HelpEditorFilter()); >+ > dialog.setInput(PDEPlugin.getWorkspace().getRoot()); > > if (dialog.open() == Window.OK) { >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.957 >diff -u -r1.957 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 16 Jan 2008 00:55:01 -0000 1.957 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 17 Jan 2008 18:16:01 -0000 >@@ -2405,6 +2405,38 @@ > SplashConfigurationSection_msgDecorationTemplateSupport=This template will only work with products built on Eclipse 3.3 and higher > RemoveSplashHandlerBindingAction_msgProgressRemoveProductBindings=Removing product bindings from extension ''{0}'' ... > CSAbstractPage_msgRegisterThisCheatSheet=Register this cheat sheet >+CtxHelpCommandDetails_command=Command: >+CtxHelpCommandDetails_commandDetails=Command Details >+CtxHelpCommandDetails_label=Label: >+CtxHelpCommandDetails_specifyDisplayLabel=Specify the display label for this command: >+CtxHelpCommandDetails_specifyTheCommand=Specify the command to invoke: >+CtxHelpContextDetails_contextDetails=Context Details >+CtxHelpContextDetails_description=Description: >+CtxHelpContextDetails_id=ID: >+CtxHelpContextDetails_specifyDescription=Specify the context description that will be displayed to the user: >+CtxHelpContextDetails_specifyID=Specify the help context id: >+CtxHelpContextDetails_specifyTitle=Override the default title by specifying one here: >+CtxHelpContextDetails_title=Title: >+CtxHelpDescriptionDetails_description=Description: >+CtxHelpDescriptionDetails_specifyDescription=Specify the context description that will be displayed to the user: >+CtxHelpPage_contextHelp=Context Help >+CtxHelpPage_errorParsing=An error occurred while parsing the context help xml file. >+CtxHelpPage_failedToLoad=Failed to load context help contents >+CtxHelpTopicDetails_label=Label: >+CtxHelpTopicDetails_location=Location: >+CtxHelpTopicDetails_specifyLabel=Specify the display label for this topic: >+CtxHelpTopicDetails_specifyLocation=Specify the location of an HTML file containing content: >+CtxHelpTreeSection_addCommand=Add Command >+CtxHelpTreeSection_addContext=Add Context >+CtxHelpTreeSection_addTopic=Add Topic >+CtxHelpTreeSection_contextHelp=Context Help >+CtxHelpTreeSection_defaultCommandName=Help_Command >+CtxHelpTreeSection_defaultContextName=Help_Context >+CtxHelpTreeSection_defaultTopicName=Help_Topic >+CtxHelpTreeSection_editContextHelpStructure=Edit the structure of the context help file in this section. >+CtxHelpTreeSection_newCommand=Command >+CtxHelpTreeSection_newContext=Context >+CtxHelpTreeSection_newTopic=Topic > StateViewPage_requiredBundles=Required Plug-ins > StateViewPage_importedPackages=Imported Packages > StateViewPage_focusActionToolTip=Focus on selected item >Index: src/org/eclipse/pde/internal/ui/IPDEUIConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPDEUIConstants.java,v >retrieving revision 1.30 >diff -u -r1.30 IPDEUIConstants.java >--- src/org/eclipse/pde/internal/ui/IPDEUIConstants.java 16 Jan 2008 17:08:37 -0000 1.30 >+++ src/org/eclipse/pde/internal/ui/IPDEUIConstants.java 17 Jan 2008 18:15:59 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -24,6 +24,7 @@ > String SIMPLE_CHEAT_SHEET_EDITOR_ID = PLUGIN_ID + ".simpleCheatSheetEditor"; //$NON-NLS-1$ > String COMPOSITE_CHEAT_SHEET_EDITOR_ID = PLUGIN_ID + ".compositeCheatSheetEditor"; //$NON-NLS-1$ > String TABLE_OF_CONTENTS_EDITOR_ID = PLUGIN_ID + ".tocEditor"; //$NON-NLS-1$ >+ String CONTEXT_HELP_EDITOR_ID = PLUGIN_ID + ".helpContextEditor"; //$NON-NLS-1$ > String TARGET_EDITOR_ID = PLUGIN_ID + ".targetEditor"; //$NON-NLS-1$ > String PLUGINS_VIEW_ID = "org.eclipse.pde.ui.PluginsView"; //$NON-NLS-1$ > String DEPENDENCIES_VIEW_ID = "org.eclipse.pde.ui.DependenciesView"; //$NON-NLS-1$ >Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v >retrieving revision 1.352 >diff -u -r1.352 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 16 Jan 2008 00:55:01 -0000 1.352 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 17 Jan 2008 18:16:00 -0000 >@@ -2833,6 +2833,70 @@ > > public static String CompilersConfigurationTab_buildPropertiesErrors; > >+ public static String CtxHelpCommandDetails_command; >+ >+ public static String CtxHelpCommandDetails_commandDetails; >+ >+ public static String CtxHelpCommandDetails_label; >+ >+ public static String CtxHelpCommandDetails_specifyDisplayLabel; >+ >+ public static String CtxHelpCommandDetails_specifyTheCommand; >+ >+ public static String CtxHelpContextDetails_contextDetails; >+ >+ public static String CtxHelpContextDetails_description; >+ >+ public static String CtxHelpContextDetails_id; >+ >+ public static String CtxHelpContextDetails_specifyDescription; >+ >+ public static String CtxHelpContextDetails_specifyID; >+ >+ public static String CtxHelpContextDetails_specifyTitle; >+ >+ public static String CtxHelpContextDetails_title; >+ >+ public static String CtxHelpDescriptionDetails_description; >+ >+ public static String CtxHelpDescriptionDetails_specifyDescription; >+ >+ public static String CtxHelpPage_contextHelp; >+ >+ public static String CtxHelpPage_errorParsing; >+ >+ public static String CtxHelpPage_failedToLoad; >+ >+ public static String CtxHelpTopicDetails_label; >+ >+ public static String CtxHelpTopicDetails_location; >+ >+ public static String CtxHelpTopicDetails_specifyLabel; >+ >+ public static String CtxHelpTopicDetails_specifyLocation; >+ >+ public static String CtxHelpTreeSection_addCommand; >+ >+ public static String CtxHelpTreeSection_addContext; >+ >+ public static String CtxHelpTreeSection_addTopic; >+ >+ public static String CtxHelpTreeSection_contextHelp; >+ >+ public static String CtxHelpTreeSection_defaultCommandName; >+ >+ public static String CtxHelpTreeSection_defaultContextName; >+ >+ public static String CtxHelpTreeSection_defaultTopicName; >+ >+ public static String CtxHelpTreeSection_editContextHelpStructure; >+ >+ public static String CtxHelpTreeSection_newCommand; >+ >+ public static String CtxHelpTreeSection_newContext; >+ >+ public static String CtxHelpTreeSection_newTopic; >+ > public static String PluginsView_description; > > public static String TargetProfileWindow_additionalLocations; >Index: src/org/eclipse/pde/internal/ui/PDELabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDELabelProvider.java,v >retrieving revision 1.89 >diff -u -r1.89 PDELabelProvider.java >--- src/org/eclipse/pde/internal/ui/PDELabelProvider.java 4 Jan 2008 20:10:15 -0000 1.89 >+++ src/org/eclipse/pde/internal/ui/PDELabelProvider.java 17 Jan 2008 18:15:59 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -28,6 +28,7 @@ > import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject; > import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants; > import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject; >+import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants; > import org.eclipse.pde.internal.core.ifeature.*; > import org.eclipse.pde.internal.core.iproduct.IProductFeature; > import org.eclipse.pde.internal.core.iproduct.IProductPlugin; >@@ -37,6 +38,7 @@ > import org.eclipse.pde.internal.core.itoc.ITocConstants; > import org.eclipse.pde.internal.core.plugin.ImportObject; > import org.eclipse.pde.internal.core.text.bundle.*; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; > import org.eclipse.pde.internal.core.text.toc.TocObject; > import org.eclipse.pde.internal.core.util.PDETextHelper; > import org.eclipse.pde.internal.ui.elements.NamedElement; >@@ -93,6 +95,9 @@ > if (obj instanceof TocObject) { > return getObjectText((TocObject) obj); > } >+ if (obj instanceof CtxHelpObject) { >+ return getObjectText((CtxHelpObject) obj); >+ } > if (obj instanceof FeaturePlugin) { > return getObjectText((FeaturePlugin) obj); > } >@@ -288,6 +293,13 @@ > return PDETextHelper.translateReadText(obj.getName()); > } > >+ /** >+ * @param obj >+ */ >+ public String getObjectText(CtxHelpObject obj) { >+ return PDETextHelper.translateReadText(obj.getName()); >+ } >+ > public String getObjectText(FeaturePlugin obj) { > String name = isFullNameModeEnabled() ? obj.getLabel() : obj.getId(); > String version = obj.getVersion(); >@@ -442,6 +454,9 @@ > if (obj instanceof TocObject) { > return getObjectImage((TocObject) obj); > } >+ if (obj instanceof CtxHelpObject) { >+ return getObjectImage((CtxHelpObject) obj); >+ } > if (obj instanceof ISchemaAttribute) { > return getObjectImage((ISchemaAttribute) obj); > } >@@ -717,6 +732,31 @@ > } > } > >+ /** >+ * @param object >+ */ >+ private Image getObjectImage(CtxHelpObject object) { >+ switch (object.getType()) { >+ case ICtxHelpConstants.TYPE_ROOT : { >+ return get(PDEPluginImages.DESC_TOC_OBJ); >+ } >+ case ICtxHelpConstants.TYPE_CONTEXT : { >+ return get(PDEPluginImages.DESC_CTXHELP_CONTEXT_OBJ); >+ } >+ case ICtxHelpConstants.TYPE_DESCRIPTION : { >+ return get(PDEPluginImages.DESC_CTXHELP_DESC_OBJ); >+ } >+ case ICtxHelpConstants.TYPE_TOPIC : { >+ return get(PDEPluginImages.DESC_TOC_LEAFTOPIC_OBJ); >+ } >+ case ICtxHelpConstants.TYPE_COMMAND : { >+ return get(PDEPluginImages.DESC_CTXHELP_COMMAND_OBJ); >+ } >+ default : >+ return get(PDEPluginImages.DESC_SIMPLECS_OBJ, F_ERROR); >+ } >+ } >+ > private Image getObjectImage(ISchemaElement element) { > int flags = 0; > if (element instanceof ISchemaObjectReference && ((ISchemaObjectReference) element).getReferencedObject() == null) >Index: src/org/eclipse/pde/internal/ui/PDEPluginImages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java,v >retrieving revision 1.105 >diff -u -r1.105 PDEPluginImages.java >--- src/org/eclipse/pde/internal/ui/PDEPluginImages.java 16 Jan 2008 17:08:37 -0000 1.105 >+++ src/org/eclipse/pde/internal/ui/PDEPluginImages.java 17 Jan 2008 18:15:59 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -111,6 +111,10 @@ > public static final ImageDescriptor DESC_TOC_LINK_OBJ = create(PATH_OBJ, "toc_link_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_TOC_ANCHOR_OBJ = create(PATH_OBJ, "toc_anchor_obj.gif"); //$NON-NLS-1$ > >+ public static final ImageDescriptor DESC_CTXHELP_CONTEXT_OBJ = create(PATH_OBJ, "ctxhelp_context_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_CTXHELP_DESC_OBJ = create(PATH_OBJ, "ctxhelp_desc_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_CTXHELP_COMMAND_OBJ = create(PATH_OBJ, "ctxhelp_command_obj.gif"); //$NON-NLS-1$ >+ > public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$ > >Index: src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java,v >retrieving revision 1.3 >diff -u -r1.3 TocHTMLWizardPage.java >--- src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java 16 Jan 2008 17:08:24 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java 17 Jan 2008 18:16:02 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,7 +16,7 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.editor.toc.TocExtensionUtil; >+import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.dialogs.WizardNewFileCreationPage; > >@@ -55,9 +55,11 @@ > return false; > } > >- if (!TocExtensionUtil.hasValidPageExtension(new Path(fLastFilename))) { >- String message = NLS.bind(PDEUIMessages.TocHTMLWizardPage_badExtension, TocExtensionUtil.getPageExtensionList()); >- >+ if(!HelpEditorUtil.hasValidPageExtension(new Path(fLastFilename))) >+ { String message = NLS.bind( >+ PDEUIMessages.TocHTMLWizardPage_badExtension, >+ HelpEditorUtil.getPageExtensionList()); >+ > setErrorMessage(message); > return false; > } >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/plugin.properties,v >retrieving revision 1.208 >diff -u -r1.208 plugin.properties >--- plugin.properties 11 Dec 2007 18:03:22 -0000 1.208 >+++ plugin.properties 17 Jan 2008 18:15:58 -0000 >@@ -195,6 +195,7 @@ > composite.cheat.sheat.editor.name = Composite Cheat Sheet Editor > > toc.editor = Table of Contents Editor >+ctxhelp.editor = Context Help Editor > > page.name.0 = OSGi Frameworks > >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/plugin.xml,v >retrieving revision 1.435 >diff -u -r1.435 plugin.xml >--- plugin.xml 14 Jan 2008 16:04:44 -0000 1.435 >+++ plugin.xml 17 Jan 2008 18:15:59 -0000 >@@ -422,6 +422,17 @@ > contentTypeId="org.eclipse.pde.tocFile"> > </contentTypeBinding> > </editor> >+ <editor >+ class="org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpEditor" >+ contributorClass="org.eclipse.pde.internal.ui.editor.toc.TocEditorContributor" >+ default="true" >+ icon="$nl$/icons/obj16/toc_obj.gif" >+ id="org.eclipse.pde.ui.ctxHelpEditor" >+ name="%ctxhelp.editor"> >+ <contentTypeBinding >+ contentTypeId="org.eclipse.pde.ctxHelpFile"> >+ </contentTypeBinding> >+ </editor> > </extension> > <extension > point="org.eclipse.ui.views"> >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractDetails.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractDetails.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,212 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.pde.core.IModelChangedEvent; >+import org.eclipse.pde.internal.ui.editor.*; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.ui.forms.IFormPart; >+import org.eclipse.ui.forms.widgets.*; >+ >+/** >+ * Abstract details class that acts as the base for the details section of the context >+ * help editor. The details section will display a form specific to the current tree >+ * selection, allowing the user to edit the fields. >+ * @since 3.4 >+ */ >+public abstract class CtxHelpAbstractDetails extends PDEDetails { >+ >+ /** >+ * Number of columns the detail section will have >+ */ >+ private static final int NUM_COLUMNS = 3; >+ >+ private CtxHelpTreeSection fMasterSection; >+ private Section fMainSection; >+ private String fContextID; >+ >+ public CtxHelpAbstractDetails(CtxHelpTreeSection masterSection, String contextID) { >+ fMasterSection = masterSection; >+ fContextID = contextID; >+ fMainSection = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createContents(Composite parent) { >+ parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1)); >+ createDetails(parent); >+ hookListeners(); >+ } >+ >+ /** >+ * Create the UI elements for the detail section >+ * @param parent parent composite to create the details in >+ */ >+ public void createDetails(Composite parent) { // Create the main section >+ int style = ExpandableComposite.TITLE_BAR; >+ >+ if (getDetailsDescription() != null) >+ style |= Section.DESCRIPTION; >+ >+ fMainSection = getPage().createUISection(parent, getDetailsTitle(), getDetailsDescription(), style); >+ // Align the master and details section headers (misalignment caused >+ // by section toolbar icons) >+ getPage().alignSectionHeaders(getMasterSection().getSection(), fMainSection); >+ // Create the container for the main section >+ Composite sectionClient = getPage().createUISectionContainer(fMainSection, NUM_COLUMNS); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ fMainSection.setLayoutData(data); >+ createFields(sectionClient); >+ >+ // Bind widgets >+ getManagedForm().getToolkit().paintBordersFor(sectionClient); >+ fMainSection.setClient(sectionClient); >+ markDetailsPart(fMainSection); >+ } >+ >+ /** >+ * Subclasses must use this method to create the fields that allow user input. >+ * @param parent parent composite >+ */ >+ protected abstract void createFields(Composite parent); >+ >+ /** >+ * @return the title to display at the top of the details section >+ */ >+ protected abstract String getDetailsTitle(); >+ >+ /** >+ * @return the description to display at the top of the details section >+ */ >+ protected abstract String getDetailsDescription(); >+ >+ /** >+ * Subclasses should add there listeners by overriding this method. >+ */ >+ public abstract void hookListeners(); >+ >+ /** >+ * Subclasses should update the form entries using their CtxHelpObject. This method >+ * should be called from subclasses implementation of {@link #selectionChanged(IFormPart, ISelection)} >+ */ >+ public abstract void updateFields(); >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IFormPart part, ISelection selection) { >+ // NO-OP >+ // Children to override >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.IContextPart#fireSaveNeeded() >+ */ >+ public void fireSaveNeeded() { >+ markDirty(); >+ getPage().getPDEEditor().fireSaveNeeded(getContextId(), false); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.IContextPart#getContextId() >+ */ >+ public String getContextId() { >+ return fContextID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.IContextPart#getPage() >+ */ >+ public PDEFormPage getPage() { >+ return (PDEFormPage) getManagedForm().getContainer(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.IContextPart#isEditable() >+ */ >+ public boolean isEditable() { >+ return fMasterSection.isEditable(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >+ */ >+ public void modelChanged(IModelChangedEvent event) { >+ // NO-OP >+ } >+ >+ /** >+ * @return whether the section is editable >+ */ >+ public boolean isEditableElement() { >+ return fMasterSection.isEditable(); >+ } >+ >+ /** >+ * @return the toolkit to use to create the form elements >+ */ >+ public FormToolkit getToolkit() { >+ return getManagedForm().getToolkit(); >+ } >+ >+ /** >+ * @return the tree section that controls this details section >+ */ >+ public CtxHelpTreeSection getMasterSection() { >+ return fMasterSection; >+ } >+ >+ /** >+ * Create a new label in the given composite using the appropriate style >+ * as defined by the toolkit. >+ * @param parent composite to create the label in >+ * @param toolkit toolkit that will define the style of the label >+ * @param text label text >+ */ >+ protected void createLabel(Composite parent, FormToolkit toolkit, String text) { >+ Label label = toolkit.createLabel(parent, text, SWT.WRAP); >+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ gd.horizontalSpan = NUM_COLUMNS; >+ label.setLayoutData(gd); >+ } >+ >+ /** >+ * Creates an empty label generating empty space in the parent composite. >+ * @param parent composite to create the space in >+ */ >+ protected void createSpace(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), ""); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns the first object from the selection or <code>null</code>. >+ * @param selection selection to get the object from >+ * @return first object in the selection or <code>null</code> >+ */ >+ protected Object getFirstSelectedObject(ISelection selection) { >+ // Get the structured selection (obtained from the master tree viewer) >+ IStructuredSelection structuredSel = ((IStructuredSelection) selection); >+ // Ensure we have a selection >+ if (structuredSel == null) { >+ return null; >+ } >+ return structuredSel.getFirstElement(); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpFormOutlinePage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpFormOutlinePage.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpFormOutlinePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpFormOutlinePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import java.util.List; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.core.util.PDETextHelper; >+import org.eclipse.pde.internal.ui.editor.FormOutlinePage; >+import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >+ >+/** >+ * The outline page for the context help editor >+ * @since 3.4 >+ * @see CtxHelpEditor >+ */ >+public class CtxHelpFormOutlinePage extends FormOutlinePage { >+ >+ public CtxHelpFormOutlinePage(PDEFormEditor editor) { >+ super(editor); >+ } >+ >+ /** >+ * Label provider for the outline >+ * @author cwindatt >+ * >+ */ >+ private class CtxHelpLabelProvider extends BasicLabelProvider { >+ public String getText(Object obj) { >+ if (obj instanceof CtxHelpObject) { >+ return PDETextHelper.translateReadText(((CtxHelpObject) obj).getName()); >+ } >+ return super.getText(obj); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.FormOutlinePage#getChildren(java.lang.Object) >+ */ >+ protected Object[] getChildren(Object parent) { >+ if (parent instanceof CtxHelpPage) { >+ CtxHelpModel model = (CtxHelpModel) fEditor.getAggregateModel(); >+ if (model != null && model.isLoaded()) { >+ Object[] list = new Object[1]; >+ list[0] = model.getCtxHelpRoot(); >+ return list; >+ } >+ } else if (parent instanceof CtxHelpObject) { >+ List list = ((CtxHelpObject) parent).getChildren(); >+ // List is never null >+ if (list.size() > 0) { >+ return list.toArray(); >+ } >+ } >+ >+ return super.getChildren(parent); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.FormOutlinePage#createLabelProvider() >+ */ >+ public ILabelProvider createLabelProvider() { >+ return new CtxHelpLabelProvider(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.FormOutlinePage#getParentPageId(java.lang.Object) >+ */ >+ protected String getParentPageId(Object item) { >+ return CtxHelpPage.PAGE_ID; >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpPage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpPage.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,154 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import org.eclipse.jface.text.source.ISourceViewer; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.pde.core.IModelChangedEvent; >+import org.eclipse.pde.core.IModelChangedListener; >+import org.eclipse.pde.internal.core.text.*; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.editor.PDEFormPage; >+import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.ui.forms.IManagedForm; >+import org.eclipse.ui.forms.editor.FormEditor; >+import org.eclipse.ui.forms.editor.IFormPage; >+import org.eclipse.ui.forms.widgets.ScrolledForm; >+ >+/** >+ * The main page for the context help editor. Contains a tree displaying the >+ * structure of the xml and a details section. UI elements are handled by >+ * CtxHelpBlock. >+ * @since 3.4 >+ * @see CtxHelpEditor >+ * @see CtxHelpBlock >+ */ >+public class CtxHelpPage extends PDEFormPage implements IModelChangedListener { >+ public static final String PAGE_ID = "ctxHelpPage"; //$NON-NLS-1$ >+ >+ private CtxHelpBlock fBlock; >+ >+ public CtxHelpPage(FormEditor editor) { >+ super(editor, PAGE_ID, PDEUIMessages.TocPage_title); >+ fBlock = new CtxHelpBlock(this); >+ } >+ >+ /** >+ * @return the CtxHelpBlock containing ui elements >+ */ >+ public PDEMasterDetailsBlock getBlock() { >+ return fBlock; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) >+ */ >+ protected void createFormContent(IManagedForm managedForm) { >+ ScrolledForm form = managedForm.getForm(); >+ CtxHelpModel model = (CtxHelpModel) getModel(); >+ >+ // Ensure the model was loaded properly >+ if ((model == null) || (model.isLoaded() == false)) { >+ createFormErrorContent(managedForm, PDEUIMessages.CtxHelpPage_failedToLoad, PDEUIMessages.CtxHelpPage_errorParsing, null); >+ return; >+ } >+ >+ // TODO Add Help context >+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TOC_EDITOR); >+ >+ // Create the rest of the actions in the form title area >+ super.createFormContent(managedForm); >+ // Form image >+ form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_CTXHELP_CONTEXT_OBJ)); >+ form.setText(PDEUIMessages.CtxHelpPage_contextHelp); >+ // Create the master details block >+ fBlock.createContent(managedForm); >+ // Force the selection in the masters tree section to load the >+ // proper details section >+ fBlock.getMasterSection().fireSelection(); >+ // Register this page to be informed of model change events >+ model.addModelChangedListener(this); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#dispose() >+ */ >+ public void dispose() { >+ CtxHelpModel model = (CtxHelpModel) getModel(); >+ if (model != null) { >+ model.removeModelChangedListener(this); >+ } >+ super.dispose(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >+ */ >+ public void modelChanged(IModelChangedEvent event) { >+ fBlock.modelChanged(event); >+ } >+ >+ /** >+ * @return the current selection of the ui block >+ */ >+ public ISelection getSelection() { >+ return fBlock.getSelection(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#setActive(boolean) >+ */ >+ public void setActive(boolean active) { >+ super.setActive(active); >+ if (active) { >+ IFormPage page = getPDEEditor().findPage(CtxHelpInputContext.CONTEXT_ID); >+ if (page instanceof CtxHelpSourcePage && ((CtxHelpSourcePage) page).getInputContext().isInSourceMode()) { >+ ISourceViewer viewer = ((CtxHelpSourcePage) page).getViewer(); >+ if (viewer == null) { >+ return; >+ } >+ >+ StyledText text = viewer.getTextWidget(); >+ if (text == null) { >+ return; >+ } >+ >+ int offset = text.getCaretOffset(); >+ if (offset < 0) { >+ return; >+ } >+ >+ IDocumentRange range = ((CtxHelpSourcePage) page).getRangeElement(offset, true); >+ if (range instanceof IDocumentAttributeNode) { >+ range = ((IDocumentAttributeNode) range).getEnclosingElement(); >+ } else if (range instanceof IDocumentTextNode) { >+ range = ((IDocumentTextNode) range).getEnclosingElement(); >+ } >+ >+ if (range instanceof CtxHelpObject) { >+ fBlock.getMasterSection().setSelection(new StructuredSelection(range)); >+ } >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#getHelpResource() >+ */ >+ protected String getHelpResource() { >+ // TODO Fix help >+ return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/toc_editor/page_toc.htm"; //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContextManager.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContextManager.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContextManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContextManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import org.eclipse.pde.core.IBaseModel; >+import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >+import org.eclipse.pde.internal.ui.editor.context.InputContext; >+import org.eclipse.pde.internal.ui.editor.context.InputContextManager; >+ >+/** >+ * Input context manager for the context help editor. >+ * @since 3.4 >+ * @see CtxHelpEditor >+ */ >+public class CtxHelpInputContextManager extends InputContextManager { >+ >+ public CtxHelpInputContextManager(PDEFormEditor editor) { >+ super(editor); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.InputContextManager#getAggregateModel() >+ */ >+ public IBaseModel getAggregateModel() { >+ InputContext context = findContext(CtxHelpInputContext.CONTEXT_ID); >+ if (context == null) { >+ return null; >+ } >+ return context.getModel(); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpContextDetails.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpContextDetails.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpContextDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpContextDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,143 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpContext; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.IFormPart; >+ >+/** >+ * Details section for context entries. >+ * @since 3.4 >+ * @see CtxHelpAbstractDetails >+ * @see CtxHelpContext >+ */ >+public class CtxHelpContextDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpContext fContext; >+ private FormEntry fIdEntry; >+ private FormEntry fTitleEntry; >+ private FormEntry fDescEntry; >+ >+ public CtxHelpContextDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#createFields(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpContextDetails_specifyID); >+ fIdEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpContextDetails_id, SWT.NONE); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpContextDetails_specifyDescription); >+ fDescEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpContextDetails_description, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.heightHint = 50; >+ fDescEntry.getText().setLayoutData(data); >+ data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END); >+ fDescEntry.getLabel().setLayoutData(data); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpContextDetails_specifyTitle); >+ fTitleEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpContextDetails_title, SWT.NONE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle() >+ */ >+ protected String getDetailsTitle() { >+ return PDEUIMessages.CtxHelpContextDetails_contextDetails; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription() >+ */ >+ protected String getDetailsDescription() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#hookListeners() >+ */ >+ public void hookListeners() { >+ fIdEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ if (fContext != null) { >+ fContext.setID(fIdEntry.getValue()); >+ } >+ } >+ }); >+ fDescEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ if (fContext != null) { >+ if (fDescEntry.getValue().trim().length() > 0) { >+ fContext.setDescription(fDescEntry.getValue()); >+ } else { >+ // Pass null to delete the description node because it is empty >+ fContext.setDescription(null); >+ } >+ } >+ } >+ }); >+ fTitleEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { // Ensure data object is defined >+ if (fContext != null) { >+ fContext.setTitle(fTitleEntry.getValue()); >+ } >+ } >+ }); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#updateFields() >+ */ >+ public void updateFields() { >+ if (fContext != null) { >+ fIdEntry.setValue(fContext.getId(), true); >+ fIdEntry.setEditable(isEditableElement()); >+ fDescEntry.setValue(fContext.getDescription(), true); >+ fDescEntry.setEditable(isEditableElement()); >+ fTitleEntry.setValue(fContext.getTitle(), true); >+ fTitleEntry.setEditable(isEditableElement()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) >+ */ >+ public void commit(boolean onSave) { >+ super.commit(onSave); >+ // Only required for form entries >+ fIdEntry.commit(); >+ fDescEntry.commit(); >+ fTitleEntry.commit(); >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IFormPart part, ISelection selection) { >+ Object object = getFirstSelectedObject(selection); >+ if (object instanceof CtxHelpContext) { >+ fContext = (CtxHelpContext) object; >+ updateFields(); >+ } >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpContentProvider.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpContentProvider.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import java.util.List; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.ui.elements.DefaultContentProvider; >+ >+/** >+ * Content provider for the tree section of the context help editor. Gets the children of >+ * each element. >+ * @since 3.4 >+ * @see CtxHelpTreeSection >+ */ >+public class CtxHelpContentProvider extends DefaultContentProvider implements ITreeContentProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) >+ */ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof CtxHelpModel) { >+ CtxHelpObject root = ((CtxHelpModel) parentElement).getCtxHelpRoot(); >+ return new Object[] {root}; >+ } else if (parentElement instanceof CtxHelpObject) { >+ List list = ((CtxHelpObject) parentElement).getChildren(); >+ return list.toArray(); >+ } >+ return new Object[0]; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) >+ */ >+ public Object getParent(Object element) { >+ if (element instanceof CtxHelpObject) { >+ return ((CtxHelpObject) element).getParent(); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) >+ */ >+ public boolean hasChildren(Object element) { >+ return (getChildren(element).length > 0); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ */ >+ public Object[] getElements(Object inputElement) { >+ return getChildren(inputElement); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpTreeSection.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpTreeSection.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpTreeSection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpTreeSection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,931 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import java.util.*; >+import java.util.List; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jface.action.*; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.core.IModelChangedEvent; >+import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants; >+import org.eclipse.pde.internal.core.text.IDocumentElementNode; >+import org.eclipse.pde.internal.core.text.ctxhelp.*; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.PDEFormPage; >+import org.eclipse.pde.internal.ui.editor.TreeSection; >+import org.eclipse.pde.internal.ui.editor.actions.CollapseAction; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractAddAction; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpRemoveAction; >+import org.eclipse.pde.internal.ui.editor.plugin.FormFilteredTree; >+import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil; >+import org.eclipse.pde.internal.ui.parts.TreePart; >+import org.eclipse.pde.internal.ui.util.PDELabelUtility; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.dnd.DND; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.graphics.Cursor; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.actions.ActionFactory; >+import org.eclipse.ui.actions.ContributionItemFactory; >+import org.eclipse.ui.dialogs.PatternFilter; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+import org.eclipse.ui.forms.widgets.Section; >+import org.eclipse.ui.ide.IDE; >+import org.eclipse.ui.keys.IBindingService; >+ >+/** >+ * Tree section for the context help editor. Displays the structure >+ * of the xml file and adds actions allowing manipulation of the structure. >+ * @since 3.4 >+ * @see CtxHelpEditor >+ */ >+public class CtxHelpTreeSection extends TreeSection { >+ private CtxHelpModel fModel; >+ private TreeViewer fTree; >+ private FormFilteredTree fFilteredTree; >+ >+ /* The indices for each button attached to the Tree Viewer. >+ * This type of UI form does not permit direct access to each particular >+ * button. However, using these indices, one can perform any typical SWT >+ * operation on any button. >+ */ >+ private static final int F_BUTTON_ADD_CONTEXT = 0; >+ private static final int F_BUTTON_ADD_TOPIC = 2; >+ private static final int F_BUTTON_ADD_COMMAND = 3; >+ private static final int F_BUTTON_REMOVE = 5; >+ private static final int F_BUTTON_UP = 6; >+ private static final int F_BUTTON_DOWN = 7; >+ >+ // When one of the move buttons is pressed, a flag is used to determine the direction >+ private static final int F_UP_FLAG = -1; >+ private static final int F_DOWN_FLAG = 1; >+ >+ // The actions that will add each type of object >+ private CtxHelpAbstractAddAction fAddContextAction; >+ private CtxHelpAbstractAddAction fAddTopicAction; >+ private CtxHelpAbstractAddAction fAddCommandAction; >+ >+ // The object removal action >+ private CtxHelpRemoveAction fRemoveObjectAction; >+ >+ // The action for opening a link from the context menu >+ private OpenLinkAction fOpenLinkAction; >+ >+ // Used to temporarily store the target of a drop operation >+ // so that it does not have be be recalculated >+ private CtxHelpObject fDropTargetParent; >+ private CtxHelpObject fDropTargetSibling; >+ >+ /** If items are dragged and dropped within this tree, then >+ * this flag inhibits reselection on the removal (drag) action, >+ * thus ensuring that the selected objects are the ones that were >+ * dropped. >+ */ >+ private boolean fDragFromHere; >+ >+ /** >+ * Action that allows a linked file to be opened in the editor >+ * @since 3.4 >+ */ >+ class OpenLinkAction extends Action { >+ private CtxHelpTopic fOpenTarget; >+ >+ public OpenLinkAction() { >+ super(PDEUIMessages.Actions_open_label); >+ } >+ >+ public void setTarget(CtxHelpTopic target) { >+ fOpenTarget = target; >+ } >+ >+ public void run() { >+ if (fOpenTarget != null) { >+ open(fOpenTarget); >+ } >+ } >+ } >+ >+ public CtxHelpTreeSection(PDEFormPage formPage, Composite parent) { >+ super(formPage, parent, Section.DESCRIPTION, new String[] {PDEUIMessages.CtxHelpTreeSection_addContext, null, PDEUIMessages.CtxHelpTreeSection_addTopic, PDEUIMessages.CtxHelpTreeSection_addCommand, null, PDEUIMessages.TocPage_remove, PDEUIMessages.TocPage_up, PDEUIMessages.TocPage_down}); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) >+ */ >+ protected void createClient(Section section, FormToolkit toolkit) { >+ fModel = (CtxHelpModel) getPage().getModel(); >+ >+ Composite container = createClientContainer(section, 2, toolkit); >+ createTree(container, toolkit); >+ toolkit.paintBordersFor(container); >+ >+ section.setText(PDEUIMessages.CtxHelpTreeSection_contextHelp); >+ section.setDescription(PDEUIMessages.CtxHelpTreeSection_editContextHelpStructure); >+ section.setClient(container); >+ >+ createCommands(); >+ >+ initializeTreeViewer(); >+ createSectionToolbar(section, toolkit); >+ >+ // Create the adapted listener for the filter entry field >+ fFilteredTree.createUIListenerEntryFilter(this); >+ } >+ >+ /** >+ * Creates the commands used in this section. >+ */ >+ private void createCommands() { >+ fAddContextAction = new CtxHelpAbstractAddAction() { >+ public void run() { >+ if (fParentObject != null) { >+ CtxHelpContext context = fParentObject.getModel().getFactory().createContext(); >+ String id = PDELabelUtility.generateName(getChildNames(), PDEUIMessages.CtxHelpTreeSection_defaultContextName); >+ context.setID(id); >+ addChild(context); >+ } >+ } >+ }; >+ fAddContextAction.setText(PDEUIMessages.CtxHelpTreeSection_newContext); >+ fAddTopicAction = new CtxHelpAbstractAddAction() { >+ public void run() { >+ if (fParentObject != null) { >+ CtxHelpTopic topic = fParentObject.getModel().getFactory().createTopic(); >+ String label = PDELabelUtility.generateName(getChildNames(), PDEUIMessages.CtxHelpTreeSection_defaultTopicName); >+ topic.setLabel(label); >+ addChild(topic); >+ } >+ } >+ }; >+ fAddTopicAction.setText(PDEUIMessages.CtxHelpTreeSection_newTopic); >+ fAddCommandAction = new CtxHelpAbstractAddAction() { >+ public void run() { >+ if (fParentObject != null) { >+ CtxHelpCommand command = fParentObject.getModel().getFactory().createCommand(); >+ String label = PDELabelUtility.generateName(getChildNames(), PDEUIMessages.CtxHelpTreeSection_defaultCommandName); >+ command.setLabel(label); >+ addChild(command); >+ } >+ } >+ }; >+ fAddCommandAction.setText(PDEUIMessages.CtxHelpTreeSection_newCommand); >+ >+ fRemoveObjectAction = new CtxHelpRemoveAction(); >+ fOpenLinkAction = new OpenLinkAction(); >+ } >+ >+ /** >+ * Adds a link (with hand cursor) for tree 'Collapse All' action, >+ * which collapses the tree down to the second level >+ * >+ * @param section The section that the toolbar will belong to >+ * @param toolkit The toolkit that will be used to make the toolbar >+ */ >+ private void createSectionToolbar(Section section, FormToolkit toolkit) { >+ ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); >+ ToolBar toolbar = toolBarManager.createControl(section); >+ >+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); >+ toolbar.setCursor(handCursor); >+ // Cursor needs to be explicitly disposed >+ toolbar.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ if ((handCursor != null) && (handCursor.isDisposed() == false)) { >+ handCursor.dispose(); >+ } >+ } >+ }); >+ >+ // Add collapse action to the tool bar >+ toolBarManager.add(new CollapseAction(fTree, PDEUIMessages.ExtensionsPage_collapseAll, 1, fModel.getCtxHelpRoot())); >+ toolBarManager.update(true); >+ section.setTextClient(toolbar); >+ } >+ >+ /** >+ * Create the tree widget that will contain the structure >+ * >+ * @param container The container of the tree widget >+ * @param toolkit The toolkit used to create the tree >+ */ >+ private void createTree(Composite container, FormToolkit toolkit) { >+ TreePart treePart = getTreePart(); >+ createViewerPartControl(container, SWT.MULTI, 2, toolkit); >+ >+ fTree = treePart.getTreeViewer(); >+ fTree.setContentProvider(new CtxHelpContentProvider()); >+ fTree.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); >+ >+ PDEPlugin.getDefault().getLabelProvider().connect(this); >+ >+ // Create listener for the outline view 'link with editor' toggle button >+ fTree.addPostSelectionChangedListener(getPage().getPDEEditor().new PDEFormEditorChangeListener()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.TreeSection#createTreeViewer(org.eclipse.swt.widgets.Composite, int) >+ */ >+ protected TreeViewer createTreeViewer(Composite parent, int style) { >+ fFilteredTree = new FormFilteredTree(parent, style, new PatternFilter()); >+ parent.setData("filtered", Boolean.TRUE); //$NON-NLS-1$ >+ return fFilteredTree.getViewer(); >+ } >+ >+ /** >+ * Initialize the tree viewer widget and its buttons. >+ */ >+ private void initializeTreeViewer() { >+ if (fModel == null) { >+ return; >+ } >+ >+ CtxHelpRoot root = fModel.getCtxHelpRoot(); >+ fTree.setInput(root); >+ >+ // Buttons must be disabled if file is not editable >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, isEditable()); >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, isEditable()); >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_TOPIC, isEditable()); >+ >+ getTreePart().setButtonEnabled(F_BUTTON_REMOVE, false); >+ getTreePart().setButtonEnabled(F_BUTTON_UP, false); >+ getTreePart().setButtonEnabled(F_BUTTON_DOWN, false); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#setFormInput(java.lang.Object) >+ */ >+ public boolean setFormInput(Object object) { >+ // This method allows the outline view to select items in the tree >+ // (Invoked by org.eclipse.ui.forms.editor.IFormPage.selectReveal(Object object)) >+ if (object instanceof CtxHelpObject) { >+ fTree.setSelection(new StructuredSelection(object), true); >+ >+ // Verify that something was actually selected >+ ISelection selection = fTree.getSelection(); >+ if (selection != null && !selection.isEmpty()) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * @return the selection of the tree >+ */ >+ public ISelection getSelection() { >+ return fTree.getSelection(); >+ } >+ >+ /** >+ * @param selection the new selection for the tree section >+ */ >+ public void setSelection(ISelection selection) { >+ fTree.setSelection(selection); >+ } >+ >+ /** >+ * Fire a selection change event and refresh the viewer's selection >+ */ >+ public void fireSelection() { >+ fTree.setSelection(fTree.getSelection()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.TreeSection#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection) >+ */ >+ protected void selectionChanged(IStructuredSelection selection) { >+ getPage().getPDEEditor().setSelection(selection); >+ updateButtons(); >+ } >+ >+ /** >+ * Update the buttons in the section based on the current selection >+ */ >+ public void updateButtons() { >+ if (!fModel.isEditable()) { >+ return; >+ } >+ >+ IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); >+ CtxHelpObject firstSelectedObject = (CtxHelpObject) selection.getFirstElement(); >+ >+ // Add Context >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, true); >+ >+ // Add Topic >+ boolean enableAdd = false; >+ if (firstSelectedObject != null) { >+ if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) { >+ enableAdd = true; >+ } else if (firstSelectedObject.canAddChild(ICtxHelpConstants.TYPE_TOPIC)) { >+ enableAdd = true; >+ } >+ } >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_TOPIC, enableAdd); >+ >+ // Add Command >+ enableAdd = false; >+ if (firstSelectedObject != null) { >+ if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) { >+ enableAdd = true; >+ } else if (firstSelectedObject.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) { >+ enableAdd = true; >+ } >+ } >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, enableAdd); >+ >+ // Remove button >+ getTreePart().setButtonEnabled(F_BUTTON_REMOVE, getRemovableObjectFromSelection(selection).size() > 0); >+ >+ // Up and Down buttons >+ boolean canMoveUp = true; >+ boolean canMoveDown = true; >+ if (firstSelectedObject == null || firstSelectedObject.getType() == ICtxHelpConstants.TYPE_ROOT || firstSelectedObject.getType() == ICtxHelpConstants.TYPE_DESCRIPTION || selection.size() > 1) { >+ canMoveUp = false; >+ canMoveDown = false; >+ } else { >+ CtxHelpObject parent = firstSelectedObject.getParent(); >+ if (parent != null) { >+ if (parent.isFirstChildNode(firstSelectedObject, firstSelectedObject.getClass())) { >+ canMoveUp = false; >+ } >+ if (parent.isLastChildNode(firstSelectedObject, firstSelectedObject.getClass())) { >+ canMoveDown = false; >+ } >+ } >+ } >+ getTreePart().setButtonEnabled(F_BUTTON_UP, canMoveUp); >+ getTreePart().setButtonEnabled(F_BUTTON_DOWN, canMoveDown); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager) >+ */ >+ protected void fillContextMenu(IMenuManager manager) { >+ IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); >+ Object object = selection.getFirstElement(); >+ // Has to be null or a CtxHelpObject object >+ CtxHelpObject firstSelectedObject = (CtxHelpObject) object; >+ >+ // Populate the "New" sub-menu >+ if (firstSelectedObject != null) { >+ MenuManager submenu = new MenuManager(PDEUIMessages.Menus_new_label); >+ boolean addMenu = false; >+ if (updateAddContextActionWithSelection(firstSelectedObject)) { >+ submenu.add(fAddContextAction); >+ addMenu = true; >+ } >+ if (updateAddTopicActionWithSelection(firstSelectedObject)) { >+ submenu.add(fAddTopicAction); >+ addMenu = true; >+ } >+ if (updateAddCommandActionWithSelection(firstSelectedObject)) { >+ submenu.add(fAddCommandAction); >+ addMenu = true; >+ } >+ if (addMenu) { >+ manager.add(submenu); >+ manager.add(new Separator()); >+ } >+ } >+ >+ // Add the open link and show in actions >+ if (firstSelectedObject instanceof CtxHelpTopic && ((CtxHelpTopic) firstSelectedObject).getLocation() != null) { >+ fOpenLinkAction.setTarget((CtxHelpTopic) firstSelectedObject); >+ manager.add(fOpenLinkAction); >+ fillContextMenuShowInAction(manager); >+ manager.add(new Separator()); >+ } >+ >+ // Add clipboard actions >+ getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); >+ manager.add(new Separator()); >+ >+ // Add remove action >+ if (updateRemoveActionWithSelection(selection)) { >+ manager.add(fRemoveObjectAction); >+ manager.add(new Separator()); >+ } >+ >+ } >+ >+ /** >+ * Creates and a new submenu in the given menu manager and adds actions to >+ * allow a linked file to be opened in various views. >+ * @param manager menu manager to add the submenu to >+ */ >+ private void fillContextMenuShowInAction(IMenuManager manager) { >+ String showInLabel = PDEUIMessages.PluginsView_showIn; >+ >+ // Add a label for the keybinding for Show In action, if one exists >+ IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); >+ if (bindingService != null) { >+ String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.ui.navigate.showInQuickMenu"); //$NON-NLS-1$ >+ if (keyBinding != null) { >+ showInLabel += '\t' + keyBinding; >+ } >+ } >+ >+ IMenuManager showInMenu = new MenuManager(showInLabel); >+ showInMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getPage().getSite().getWorkbenchWindow())); >+ >+ manager.add(showInMenu); >+ } >+ >+ /** >+ * Updates the add context action if the action should be available for the selection. >+ * Updates enablement, parent object and target object. Returns true if the action >+ * should be available to the selection. >+ * @param selectedObject selected object >+ * @return true if the action should be available for the current selection, false otherwise >+ */ >+ private boolean updateAddContextActionWithSelection(CtxHelpObject selectedObject) { >+ if (selectedObject != null && selectedObject.canAddSibling(ICtxHelpConstants.TYPE_CONTEXT)) { >+ fAddContextAction.setParentObject(selectedObject.getParent()); >+ fAddContextAction.setTargetObject(selectedObject); >+ fAddContextAction.setEnabled(fModel.isEditable()); >+ return true; >+ } else if (selectedObject != null && selectedObject.canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) { >+ fAddContextAction.setParentObject(selectedObject); >+ fAddContextAction.setTargetObject(null); >+ fAddContextAction.setEnabled(fModel.isEditable()); >+ return true; >+ } else if (fModel.getCtxHelpRoot().canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) { >+ fAddContextAction.setParentObject(fModel.getCtxHelpRoot()); >+ fAddContextAction.setTargetObject(null); >+ fAddContextAction.setEnabled(fModel.isEditable()); >+ return true; >+ } >+ return false; >+ } >+ >+ /** >+ * Updates the add topic action if the action should be available for the selection. >+ * Updates enablement, parent object and target object. Returns true if the action >+ * should be available to the selection. >+ * @param selectedObject selected object >+ * @return true if the action should be available for the current selection, false otherwise >+ */ >+ private boolean updateAddTopicActionWithSelection(CtxHelpObject selectedObject) { >+ if (selectedObject != null) { >+ if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) { >+ fAddTopicAction.setParentObject(selectedObject.getParent()); >+ fAddTopicAction.setTargetObject(selectedObject); >+ fAddTopicAction.setEnabled(fModel.isEditable()); >+ return true; >+ } else if (selectedObject.canAddChild(ICtxHelpConstants.TYPE_TOPIC)) { >+ fAddTopicAction.setParentObject(selectedObject); >+ fAddTopicAction.setTargetObject(null); >+ fAddTopicAction.setEnabled(fModel.isEditable()); >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Updates the add topic action if the action should be available for the selection. >+ * Updates enablement, parent object and target object. Returns true if the action >+ * should be available to the selection. >+ * @param selectedObject selected object >+ * @return true if the action should be available for the current selection, false otherwise >+ */ >+ private boolean updateAddCommandActionWithSelection(CtxHelpObject selectedObject) { >+ if (selectedObject != null) { >+ if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) { >+ fAddCommandAction.setParentObject(selectedObject.getParent()); >+ fAddCommandAction.setTargetObject(selectedObject); >+ fAddCommandAction.setEnabled(fModel.isEditable()); >+ return true; >+ } else if (selectedObject.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) { >+ fAddCommandAction.setParentObject(selectedObject); >+ fAddCommandAction.setTargetObject(null); >+ fAddCommandAction.setEnabled(fModel.isEditable()); >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Updates the remove action if the action should be available for the selection. >+ * Updates enablement, parent object and target object. Returns true if the action >+ * should be available to the selection. >+ * @param selectedObject selected object >+ * @return true if the action should be available for the current selection, false otherwise >+ */ >+ private boolean updateRemoveActionWithSelection(IStructuredSelection selection) { >+ List objectsToRemove = getRemovableObjectFromSelection(selection); >+ fRemoveObjectAction.setToRemove((CtxHelpObject[]) objectsToRemove.toArray(new CtxHelpObject[objectsToRemove.size()])); >+ fRemoveObjectAction.setEnabled(fModel.isEditable()); >+ return objectsToRemove.size() > 0; >+ } >+ >+ /** >+ * Returns a list of objects that is the subset of objects in the selection that >+ * can be removed. >+ * @param selection the selection >+ * @return list of {@link CtxHelpObject}s that can be removed, possibly empty. >+ */ >+ private List getRemovableObjectFromSelection(IStructuredSelection selection) { >+ List objectsToRemove = new ArrayList(); >+ for (Iterator iterator = selection.iterator(); iterator.hasNext();) { >+ Object currentObject = iterator.next(); >+ if (currentObject instanceof CtxHelpObject && ((CtxHelpObject) currentObject).canBeRemoved()) { >+ objectsToRemove.add(currentObject); >+ } >+ } >+ return objectsToRemove; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang.String) >+ */ >+ public boolean doGlobalAction(String actionId) { >+ boolean cutAction = actionId.equals(ActionFactory.CUT.getId()); >+ >+ if (cutAction || actionId.equals(ActionFactory.DELETE.getId())) { >+ updateRemoveActionWithSelection((IStructuredSelection) fTree.getSelection()); >+ fRemoveObjectAction.run(); >+ return !cutAction; >+ } >+ >+ if (actionId.equals(ActionFactory.PASTE.getId())) { >+ doPaste(); >+ return true; >+ } >+ >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canPaste(java.lang.Object, java.lang.Object[]) >+ */ >+ protected boolean canPaste(Object targetObject, Object[] sourceObjects) { >+ return canDropCopy(targetObject, sourceObjects, ViewerDropAdapter.LOCATION_ON); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doPaste(java.lang.Object, java.lang.Object[]) >+ */ >+ protected void doPaste(Object targetObject, Object[] sourceObjects) { >+ doDropCopy(targetObject, sourceObjects, ViewerDropAdapter.LOCATION_ON); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.TreeSection#handleDoubleClick(org.eclipse.jface.viewers.IStructuredSelection) >+ */ >+ protected void handleDoubleClick(IStructuredSelection selection) { >+ Object selected = selection.getFirstElement(); >+ if (selected instanceof CtxHelpTopic) { >+ open((CtxHelpTopic) selected); >+ } else if (selected instanceof CtxHelpObject) { >+ fTree.expandToLevel(selected, 1); >+ } >+ } >+ >+ /** >+ * Opens the file that is linked in the given topic. >+ * @param topic the topic containing a link to a file >+ */ >+ public void open(CtxHelpTopic topic) { >+ IPath resourcePath = topic.getLocation(); >+ if (!isEditable() || resourcePath == null || resourcePath.isEmpty()) { >+ MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, PDEUIMessages.WindowImagesSection_emptyPath); >+ return; >+ } >+ >+ IResource resource = fModel.getUnderlyingResource().getProject().findMember(resourcePath); >+ if (resource != null && resource instanceof IFile) { >+ IPath path = resource.getFullPath(); >+ if (HelpEditorUtil.hasValidPageExtension(path)) { >+ try { >+ IDE.openEditor(PDEPlugin.getActivePage(), (IFile) resource, true); >+ } catch (PartInitException e) { //suppress exception >+ } >+ } else { >+ MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, PDEUIMessages.TocPage_invalidHTMLFile); >+ } >+ } else { >+ MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, PDEUIMessages.WindowImagesSection_warning); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int) >+ */ >+ protected void buttonSelected(int index) { >+ IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); >+ Object object = selection.getFirstElement(); >+ CtxHelpObject firstSelectedObject = (CtxHelpObject) object; >+ switch (index) { >+ case F_BUTTON_ADD_CONTEXT : >+ updateAddContextActionWithSelection(firstSelectedObject); >+ fAddContextAction.run(); >+ break; >+ case F_BUTTON_ADD_TOPIC : >+ updateAddTopicActionWithSelection(firstSelectedObject); >+ fAddTopicAction.run(); >+ break; >+ case F_BUTTON_ADD_COMMAND : >+ updateAddCommandActionWithSelection(firstSelectedObject); >+ fAddCommandAction.run(); >+ break; >+ case F_BUTTON_REMOVE : >+ updateRemoveActionWithSelection(selection); >+ fRemoveObjectAction.run(); >+ break; >+ case F_BUTTON_UP : >+ handleMoveAction(F_UP_FLAG); >+ break; >+ case F_BUTTON_DOWN : >+ handleMoveAction(F_DOWN_FLAG); >+ break; >+ } >+ } >+ >+ /** >+ * Move an object within the structure. >+ * >+ * @param positionFlag The direction that the object will move, either F_UP_FLAG or F_DOWN_FLAG >+ */ >+ private void handleMoveAction(int positionFlag) { >+ IStructuredSelection sel = (IStructuredSelection) fTree.getSelection(); >+ >+ Object object = sel.getFirstElement(); >+ if (object == null) { >+ return; >+ } else if (object instanceof CtxHelpObject) { >+ CtxHelpObject ctxHelpObject = (CtxHelpObject) object; >+ CtxHelpObject parent = ctxHelpObject.getParent(); >+ if (parent != null) { >+ parent.moveChild(ctxHelpObject, positionFlag); >+ fTree.setSelection(new StructuredSelection(ctxHelpObject), true); >+ } >+ } >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#refresh() >+ */ >+ public void refresh() { >+ CtxHelpModel model = (CtxHelpModel) getPage().getModel(); >+ fTree.setInput(model); >+ fTree.expandToLevel(2); >+ fTree.setSelection(new StructuredSelection(model.getCtxHelpRoot()), true); >+ getManagedForm().fireSelectionChanged(this, fTree.getSelection()); >+ super.refresh(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#dispose() >+ */ >+ public void dispose() { >+ PDEPlugin.getDefault().getLabelProvider().disconnect(this); >+ super.dispose(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#isDragAndDropEnabled() >+ */ >+ protected boolean isDragAndDropEnabled() { >+ // TODO DND turned off because the inserted element would often be placed in the wrong location in the xml >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#getSupportedDNDOperations() >+ */ >+ public int getSupportedDNDOperations() { >+ return DND.DROP_MOVE | DND.DROP_COPY; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDropCopy(java.lang.Object, java.lang.Object[], int) >+ */ >+ public void doDropCopy(Object targetObject, Object[] sourceObjects, int targetLocation) { >+ if (fDropTargetParent != null) { >+ if (fDropTargetSibling != null) { >+ if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) { >+ for (int i = 0; i < sourceObjects.length; i++) { >+ fDropTargetParent.addChild((CtxHelpObject) sourceObjects[i], fDropTargetSibling, true); >+ } >+ } else { >+ for (int i = sourceObjects.length - 1; i >= 0; i--) { >+ fDropTargetParent.addChild((CtxHelpObject) sourceObjects[i], fDropTargetSibling, false); >+ } >+ } >+ } else { >+ for (int i = 0; i < sourceObjects.length; i++) { >+ fDropTargetParent.addChild((CtxHelpObject) sourceObjects[i]); >+ } >+ } >+ } >+ fDropTargetParent = null; >+ fDropTargetSibling = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDropMove(java.lang.Object, java.lang.Object[], int) >+ */ >+ public void doDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) { >+ doDropCopy(targetObject, sourceObjects, targetLocation); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDropCopy(java.lang.Object, java.lang.Object[], int) >+ */ >+ public boolean canDropCopy(Object targetObject, Object[] sourceObjects, int targetLocation) { >+ // Add as a child of the root >+ if (targetObject == null || !(targetObject instanceof CtxHelpObject || ((CtxHelpObject) targetObject).getType() == ICtxHelpConstants.TYPE_ROOT)) { >+ for (int i = 0; i < sourceObjects.length; i++) { >+ if (!(sourceObjects[i] instanceof CtxHelpObject) || !fModel.getCtxHelpRoot().canAddChild(((CtxHelpObject) sourceObjects[i]).getType())) { >+ return false; >+ } >+ } >+ fDropTargetParent = fModel.getCtxHelpRoot(); >+ fDropTargetSibling = null; >+ return true; >+ } >+ >+ CtxHelpObject dropTarget = (CtxHelpObject) targetObject; >+ >+ // Add as a child of the target >+ if (targetLocation == ViewerDropAdapter.LOCATION_ON) { >+ boolean result = true; >+ for (int i = 0; i < sourceObjects.length; i++) { >+ if (!(sourceObjects[i] instanceof CtxHelpObject) || !dropTarget.canAddChild(((CtxHelpObject) sourceObjects[i]).getType())) { >+ result = false; >+ break; >+ } >+ } >+ // If adding as a child works, do so, otherwise try as a sibling >+ if (result) { >+ fDropTargetParent = dropTarget; >+ fDropTargetSibling = null; >+ return true; >+ } >+ } >+ >+ // Add as a sibling of the target >+ for (int i = 0; i < sourceObjects.length; i++) { >+ if (!(sourceObjects[i] instanceof CtxHelpObject) || !dropTarget.canAddSibling(((CtxHelpObject) sourceObjects[i]).getType())) { >+ return false; >+ } >+ } >+ fDropTargetParent = dropTarget.getParent(); >+ fDropTargetSibling = dropTarget; >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDropMove(java.lang.Object, java.lang.Object[], int) >+ */ >+ public boolean canDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) { >+ // Same as drop copy operation >+ return canDropCopy(targetObject, sourceObjects, targetLocation); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDragCopy(java.lang.Object[]) >+ */ >+ public boolean canDragCopy(Object[] sourceObjects) { >+ // Allow anything to be drag copied >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDragMove(java.lang.Object[]) >+ */ >+ public boolean canDragMove(Object[] sourceObjects) { >+ for (int i = 0; i < sourceObjects.length; i++) { >+ if (!(sourceObjects[i] instanceof CtxHelpObject) || !((CtxHelpObject) sourceObjects[i]).canBeRemoved()) { >+ return false; >+ } >+ } >+ fDragFromHere = true; >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDragRemove(java.lang.Object[]) >+ */ >+ public void doDragRemove(Object[] sourceObjects) { >+ updateRemoveActionWithSelection(new StructuredSelection(sourceObjects)); >+ fRemoveObjectAction.run(); >+ fDragFromHere = false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >+ */ >+ public void modelChanged(IModelChangedEvent event) { >+ // No need to call super, world changed event handled here >+ if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { >+ handleModelEventWorldChanged(event); >+ } else if (event.getChangeType() == IModelChangedEvent.INSERT) { >+ handleModelInsertType(event); >+ } else if (event.getChangeType() == IModelChangedEvent.REMOVE) { >+ handleModelRemoveType(event); >+ } else if ((event.getChangeType() == IModelChangedEvent.CHANGE) && (event.getChangedProperty().equals(IDocumentElementNode.F_PROPERTY_CHANGE_TYPE_SWAP))) { >+ handleModelChangeTypeSwap(event); >+ } else if (event.getChangeType() == IModelChangedEvent.CHANGE) { >+ handleModelChangeType(event); >+ } >+ } >+ >+ /** >+ * Handles the swap event >+ * @param event the swap event >+ */ >+ private void handleModelChangeTypeSwap(IModelChangedEvent event) { >+ Object[] objects = event.getChangedObjects(); >+ CtxHelpObject object = (CtxHelpObject) objects[0]; >+ >+ if (object != null) { >+ fTree.refresh(object); >+ } >+ } >+ >+ /** >+ * The model is stale, refresh the UI >+ * @param event The world-change event >+ */ >+ private void handleModelEventWorldChanged(IModelChangedEvent event) { >+ markStale(); >+ } >+ >+ /** >+ * Handle insertions in the model >+ * @param event the insertion event >+ */ >+ private void handleModelInsertType(IModelChangedEvent event) { >+ Object[] objects = event.getChangedObjects(); >+ for (int i = 0; i < objects.length; i++) { >+ CtxHelpObject object = (CtxHelpObject) objects[i]; >+ if (object != null) { >+ if (object.getType() != ICtxHelpConstants.TYPE_ROOT) { >+ fTree.refresh(object.getParent()); >+ // Select the new object in the tree, unless it is a description node >+ if (!(object instanceof CtxHelpDescription)) { >+ fTree.setSelection(new StructuredSelection(object), true); >+ } >+ } >+ } >+ } >+ } >+ >+ /** >+ * Handle removals in the model >+ * @param event the removal event >+ */ >+ private void handleModelRemoveType(IModelChangedEvent event) { >+ Object[] objects = event.getChangedObjects(); >+ for (int i = 0; i < objects.length; i++) { >+ if (objects[i] != null) { >+ CtxHelpObject object = (CtxHelpObject) objects[i]; >+ fTree.remove(object); >+ CtxHelpObject nextSelection = fRemoveObjectAction.getNextSelection(); >+ if (nextSelection != null) { >+ fTree.refresh(object.getParent()); >+ if (!fDragFromHere) { >+ fTree.setSelection(new StructuredSelection(nextSelection), true); >+ } >+ fRemoveObjectAction.clearNextSelection(); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Handle an update to an object's properties >+ * @param event the update event >+ */ >+ private void handleModelChangeType(IModelChangedEvent event) { >+ Object[] objects = event.getChangedObjects(); >+ CtxHelpObject object = (CtxHelpObject) objects[0]; >+ >+ if (object != null) { >+ fTree.update(object, null); >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/toc/details/HelpEditorFilter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/toc/details/HelpEditorFilter.java >diff -N src/org/eclipse/pde/internal/ui/editor/toc/details/HelpEditorFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/HelpEditorFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.pde.internal.ui.editor.toc.details; >+ >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil; >+ >+public class HelpEditorFilter extends ViewerFilter { >+ public boolean select(Viewer viewer, Object parent, Object element) { >+ if (element instanceof IFile) { >+ IPath path = ((IFile) element).getFullPath(); >+ >+ return HelpEditorUtil.hasValidPageExtension(path); >+ } >+ >+ if (element instanceof IProject && !((IProject) element).isOpen()) { >+ return false; >+ } >+ >+ if (element instanceof IContainer) { >+ try { >+ IResource[] resources = ((IContainer) element).members(); >+ for (int i = 0; i < resources.length; i++) { >+ if (select(viewer, parent, resources[i])) { >+ return true; >+ } >+ } >+ } catch (CoreException e) { >+ } >+ } >+ >+ return false; >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractAddAction.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractAddAction.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractAddAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractAddAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+ >+/** >+ * Abstract action that allows new nodes to be added to the context help >+ * model. >+ * @since 3.4 >+ */ >+public abstract class CtxHelpAbstractAddAction extends Action { >+ >+ protected CtxHelpObject fParentObject; >+ >+ //The target object to insert after >+ protected CtxHelpObject fTargetObject; >+ >+ /** >+ * Set the parent object that this action will add >+ * objects to. >+ * >+ * @param parent The new parent object for this action >+ */ >+ public void setParentObject(CtxHelpObject parent) { >+ fParentObject = parent; >+ } >+ >+ /** >+ * Set the target object that this action will add >+ * objects after. >+ * >+ * @param target The new target object for this action >+ */ >+ public void setTargetObject(CtxHelpObject target) { >+ fTargetObject = target; >+ } >+ >+ /** >+ * Returns the names of the children of the parent object. Used >+ * to find a new name that doesn't conflict. Will return an empty >+ * array if the parent is not set. >+ * @return children names or an empty array >+ */ >+ public String[] getChildNames() { >+ if (fParentObject != null) { >+ int numChildren = fParentObject.getChildren().size(); >+ CtxHelpObject[] ctxHelpObjects = (CtxHelpObject[]) fParentObject.getChildren().toArray(new CtxHelpObject[numChildren]); >+ >+ String[] ctxHelpObjectNames = new String[ctxHelpObjects.length]; >+ >+ for (int i = 0; i < numChildren; ++i) { >+ ctxHelpObjectNames[i] = ctxHelpObjects[i].getName(); >+ } >+ return ctxHelpObjectNames; >+ } >+ return new String[0]; >+ } >+ >+ /** >+ * Add the child to the parent object. If a target object is specified, >+ * add the child as a sibling after that object. >+ * >+ * @param child The object to add to the parent >+ */ >+ protected void addChild(CtxHelpObject child) { >+ if (fTargetObject == null) { >+ fParentObject.addChild(child); >+ } else { >+ fParentObject.addChild(child, fTargetObject, false); >+ } >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpCommandDetails.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpCommandDetails.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpCommandDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpCommandDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpCommand; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.IFormPart; >+ >+/** >+ * Details section for command entries. >+ * @since 3.4 >+ * @see CtxHelpAbstractDetails >+ * @see CtxHelpCommand >+ */ >+public class CtxHelpCommandDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpCommand fCommand; >+ private FormEntry fLabelEntry; >+ private FormEntry fSerialEntry; >+ >+ public CtxHelpCommandDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#createFields(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpCommandDetails_specifyDisplayLabel); >+ fLabelEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpCommandDetails_label, SWT.NONE); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpCommandDetails_specifyTheCommand); >+ fSerialEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpCommandDetails_command, SWT.NONE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle() >+ */ >+ protected String getDetailsTitle() { >+ return PDEUIMessages.CtxHelpCommandDetails_commandDetails; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription() >+ */ >+ protected String getDetailsDescription() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#hookListeners() >+ */ >+ public void hookListeners() { >+ fLabelEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ if (fCommand != null) { >+ fCommand.setLabel(fLabelEntry.getValue()); >+ } >+ } >+ }); >+ fSerialEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { // Ensure data object is defined >+ if (fCommand != null) { >+ fCommand.setSerialization(fSerialEntry.getValue()); >+ } >+ } >+ }); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#updateFields() >+ */ >+ public void updateFields() { >+ if (fCommand != null) { >+ fLabelEntry.setValue(fCommand.getLabel(), true); >+ fLabelEntry.setEditable(isEditableElement()); >+ fSerialEntry.setValue(fCommand.getSerialization(), true); >+ fSerialEntry.setEditable(isEditableElement()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) >+ */ >+ public void commit(boolean onSave) { >+ super.commit(onSave); >+ // Only required for form entries >+ fLabelEntry.commit(); >+ fSerialEntry.commit(); >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IFormPart part, ISelection selection) { >+ Object object = getFirstSelectedObject(selection); >+ if (object instanceof CtxHelpCommand) { >+ fCommand = (CtxHelpCommand) object; >+ updateFields(); >+ } >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpSourcePage.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpSourcePage.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpSourcePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpSourcePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,127 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.text.*; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.PDEFormEditor; >+import org.eclipse.pde.internal.ui.editor.XMLSourcePage; >+ >+/** >+ * Source page for the context help editor. Displays the >+ * xml source. >+ * @since 3.4 >+ * @see CtxHelpEditor >+ */ >+public class CtxHelpSourcePage extends XMLSourcePage { >+ >+ public CtxHelpSourcePage(PDEFormEditor editor, String id, String title) { >+ super(editor, id, title); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEProjectionSourcePage#isQuickOutlineEnabled() >+ */ >+ public boolean isQuickOutlineEnabled() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineComparator() >+ */ >+ public ViewerComparator createOutlineComparator() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineContentProvider() >+ */ >+ public ITreeContentProvider createOutlineContentProvider() { >+ return new CtxHelpContentProvider(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineLabelProvider() >+ */ >+ public ILabelProvider createOutlineLabelProvider() { >+ return PDEPlugin.getDefault().getLabelProvider(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.part.EditorPart#setPartName(java.lang.String) >+ */ >+ protected void setPartName(String partName) { >+ super.setPartName(PDEUIMessages.EditorSourcePage_name); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#isSelectionListener() >+ */ >+ protected boolean isSelectionListener() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#updateSelection(java.lang.Object) >+ */ >+ public void updateSelection(Object object) { >+ if ((object instanceof IDocumentElementNode) && !((IDocumentElementNode) object).isErrorNode()) { >+ setSelectedObject(object); >+ setHighlightRange((IDocumentElementNode) object, true); >+ setSelectedRange((IDocumentElementNode) object, false); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#findRange() >+ */ >+ protected IDocumentRange findRange() { >+ if (getSelection() instanceof IDocumentElementNode) { >+ return (IDocumentElementNode) getSelection(); >+ } >+ >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#getRangeElement(int, boolean) >+ */ >+ public IDocumentRange getRangeElement(int offset, boolean searchChildren) { >+ CtxHelpObject root = ((CtxHelpModel) getInputContext().getModel()).getCtxHelpRoot(); >+ return findNode(root, offset, searchChildren); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#synchronizeOutlinePage(int) >+ */ >+ protected void synchronizeOutlinePage(int offset) { >+ IDocumentRange rangeElement = getRangeElement(offset, true); >+ updateHighlightRange(rangeElement); >+ // TODO: MP: TEO: LOW: Generalize for parent - search children = true and handle attributes >+ if (rangeElement instanceof IDocumentAttributeNode) { >+ rangeElement = ((IDocumentAttributeNode) rangeElement).getEnclosingElement(); >+ } >+ updateOutlinePageSelection(rangeElement); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor() >+ */ >+ protected void initializeEditor() { >+ super.initializeEditor(); >+ // TODO Fix help context >+ // setHelpContextId(IHelpContextIds.TOC_EDITOR); >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpDescriptionDetails.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpDescriptionDetails.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpDescriptionDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpDescriptionDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,110 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpDescription; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.IFormPart; >+ >+/** >+ * Details section for description entries. >+ * @since 3.4 >+ * @see CtxHelpAbstractDetails >+ * @see CtxHelpDescription >+ */ >+public class CtxHelpDescriptionDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpDescription fDescription; >+ private FormEntry fDescEntry; >+ >+ public CtxHelpDescriptionDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#createFields(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpDescriptionDetails_specifyDescription); >+ fDescEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpDescriptionDetails_description, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.heightHint = 50; >+ fDescEntry.getText().setLayoutData(data); >+ data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END); >+ fDescEntry.getLabel().setLayoutData(data); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle() >+ */ >+ protected String getDetailsTitle() { >+ return PDEUIMessages.TocTopicDetails_title; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription() >+ */ >+ protected String getDetailsDescription() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#hookListeners() >+ */ >+ public void hookListeners() { >+ fDescEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ if (fDescription != null) { >+ fDescription.setDescription(fDescEntry.getValue()); >+ } >+ } >+ }); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#updateFields() >+ */ >+ public void updateFields() { >+ if (fDescription != null) { >+ fDescEntry.setValue(fDescription.getDescription(), true); >+ fDescEntry.setEditable(isEditableElement()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) >+ */ >+ public void commit(boolean onSave) { >+ super.commit(onSave); >+ // Only required for form entries >+ fDescEntry.commit(); >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IFormPart part, ISelection selection) { >+ Object object = getFirstSelectedObject(selection); >+ if (object instanceof CtxHelpDescription) { >+ fDescription = (CtxHelpDescription) object; >+ updateFields(); >+ } >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpEditor.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpEditor.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,270 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import java.io.File; >+import java.util.ArrayList; >+import java.util.Iterator; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jdt.ui.JavaUI; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.text.ctxhelp.*; >+import org.eclipse.pde.internal.ui.IPDEUIConstants; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.editor.*; >+import org.eclipse.pde.internal.ui.editor.context.InputContext; >+import org.eclipse.pde.internal.ui.editor.context.InputContextManager; >+import org.eclipse.ui.*; >+import org.eclipse.ui.forms.editor.IFormPage; >+import org.eclipse.ui.part.*; >+ >+/** >+ * Main UI class for the context help editor. This editor provides a convenient way to >+ * explore and edit the xml files containing context help entries. The editor will >+ * have two pages, one displaying the xml source, the other displaying a form editor. >+ * @since 3.4 >+ * @see CtxHelpSourcePage >+ * @see CtxHelpPage >+ */ >+public class CtxHelpEditor extends MultiSourceEditor { >+ >+ public CtxHelpEditor() { >+ super(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID() >+ */ >+ protected String getEditorID() { >+ return IPDEUIConstants.CONTEXT_HELP_EDITOR_ID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter(Class adapter) { >+ if (isShowInApplicable()) { >+ if (adapter == IShowInSource.class) { >+ return getShowInSource(); >+ } else if (adapter == IShowInTargetList.class) { >+ return getShowInTargetList(); >+ } >+ } >+ return super.getAdapter(adapter); >+ } >+ >+ /** >+ * @return whether there is a selection that requires the "Show In" menu to be available >+ */ >+ private boolean isShowInApplicable() { >+ if (getSelection().isEmpty()) { >+ return false; >+ } >+ if (getSelection() instanceof IStructuredSelection) { >+ IStructuredSelection selection = (IStructuredSelection) getSelection(); >+ for (Iterator iter = selection.iterator(); iter.hasNext();) { >+ Object obj = iter.next(); >+ if (obj instanceof CtxHelpTopic && ((CtxHelpTopic) obj).getLocation() != null) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Returns the <code>IShowInSource</code> for this editor. >+ * @return the <code>IShowInSource</code> >+ */ >+ private IShowInSource getShowInSource() { >+ return new IShowInSource() { >+ public ShowInContext getShowInContext() { >+ ArrayList resourceList = new ArrayList(); >+ IStructuredSelection selection = (IStructuredSelection) getSelection(); >+ IStructuredSelection resources; >+ if (selection.isEmpty()) { >+ resources = null; >+ } else { >+ IWorkspaceRoot root = PDEPlugin.getWorkspace().getRoot(); >+ for (Iterator iter = selection.iterator(); iter.hasNext();) { >+ Object obj = iter.next(); >+ if (obj instanceof CtxHelpTopic) { >+ IPath path = ((CtxHelpTopic) obj).getLocation(); >+ if (path != null && !path.isEmpty()) { >+ CtxHelpModel model = (CtxHelpModel) getAggregateModel(); >+ IPath pluginPath = model.getUnderlyingResource().getProject().getFullPath(); >+ IResource resource = root.findMember(pluginPath.append(path)); >+ if (resource != null) { >+ resourceList.add(resource); >+ } >+ } >+ } >+ } >+ resources = new StructuredSelection(resourceList); >+ } >+ return new ShowInContext(null, resources); >+ } >+ }; >+ } >+ >+ /** >+ * Returns the <code>IShowInTargetList</code> for this editor. >+ * @return the <code>IShowInTargetList</code> >+ */ >+ private IShowInTargetList getShowInTargetList() { >+ return new IShowInTargetList() { >+ public String[] getShowInTargetIds() { >+ return new String[] {JavaUI.ID_PACKAGES, IPageLayout.ID_RES_NAV}; >+ } >+ }; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#isSaveAsAllowed() >+ */ >+ public boolean isSaveAsAllowed() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getContextIDForSaveAs() >+ */ >+ public String getContextIDForSaveAs() { >+ return CtxHelpInputContext.CONTEXT_ID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#addEditorPages() >+ */ >+ protected void addEditorPages() { >+ try { >+ addPage(new CtxHelpPage(this)); >+ } catch (PartInitException e) { >+ PDEPlugin.logException(e); >+ } >+ addSourcePage(CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createContentOutline() >+ */ >+ protected ISortableContentOutlinePage createContentOutline() { >+ return new CtxHelpFormOutlinePage(this); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createInputContextManager() >+ */ >+ protected InputContextManager createInputContextManager() { >+ return new CtxHelpInputContextManager(this); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createResourceContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IFileEditorInput) >+ */ >+ protected void createResourceContexts(InputContextManager contexts, IFileEditorInput input) { >+ contexts.putContext(input, new CtxHelpInputContext(this, input, true)); >+ contexts.monitorFile(input.getFile()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createStorageContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IStorageEditorInput) >+ */ >+ protected void createStorageContexts(InputContextManager contexts, IStorageEditorInput input) { >+ contexts.putContext(input, new CtxHelpInputContext(this, input, true)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createSystemFileContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.pde.internal.ui.editor.SystemFileEditorInput) >+ */ >+ protected void createSystemFileContexts(InputContextManager contexts, SystemFileEditorInput input) { >+ File file = (File) input.getAdapter(File.class); >+ if (file != null) { >+ IEditorInput in = new SystemFileEditorInput(file); >+ contexts.putContext(in, new CtxHelpInputContext(this, in, true)); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#editorContextAdded(org.eclipse.pde.internal.ui.editor.context.InputContext) >+ */ >+ public void editorContextAdded(InputContext context) { >+ // Add the source page >+ addSourcePage(context.getId()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getInputContext(java.lang.Object) >+ */ >+ protected InputContext getInputContext(Object object) { >+ return fInputContextManager.findContext(CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextRemoved(org.eclipse.pde.internal.ui.editor.context.InputContext) >+ */ >+ public void contextRemoved(InputContext context) { >+ close(false); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileAdded(org.eclipse.core.resources.IFile) >+ */ >+ public void monitoredFileAdded(IFile monitoredFile) { >+ // NO-OP >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileRemoved(org.eclipse.core.resources.IFile) >+ */ >+ public boolean monitoredFileRemoved(IFile monitoredFile) { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getSelection() >+ */ >+ public ISelection getSelection() { >+ IFormPage formPage = getActivePageInstance(); >+ if ((formPage != null) && (formPage instanceof CtxHelpPage)) { >+ // Synchronizes the selection made in the master tree view with the >+ // selection in the outline view when the link with editor button >+ // is toggled on >+ return ((CtxHelpPage) formPage).getSelection(); >+ } >+ return super.getSelection(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#canCut(org.eclipse.jface.viewers.ISelection) >+ */ >+ public boolean canCut(ISelection selection) { >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection sel = (IStructuredSelection) selection; >+ for (Iterator iter = sel.iterator(); iter.hasNext();) { >+ Object obj = iter.next(); >+ if (obj instanceof CtxHelpObject && ((CtxHelpObject) obj).canBeRemoved()) { >+ return canCopy(selection); >+ } >+ } >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.MultiSourceEditor#createSourcePage(org.eclipse.pde.internal.ui.editor.PDEFormEditor, java.lang.String, java.lang.String, java.lang.String) >+ */ >+ protected PDESourcePage createSourcePage(PDEFormEditor editor, String title, String name, String contextId) { >+ return new CtxHelpSourcePage(editor, title, name); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/toc/HelpEditorUtil.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/toc/HelpEditorUtil.java >diff -N src/org/eclipse/pde/internal/ui/editor/toc/HelpEditorUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/toc/HelpEditorUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.toc; >+ >+import java.util.HashSet; >+import java.util.Locale; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.pde.core.IBaseModel; >+import org.eclipse.pde.core.IModel; >+import org.eclipse.pde.internal.core.itoc.ITocConstants; >+import org.eclipse.pde.internal.ui.util.XMLRootElementMatcher; >+ >+public class HelpEditorUtil { >+ public static final String[] pageExtensions = {"htm","shtml","html","xhtml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ >+ public static final String tocExtension = "xml"; //$NON-NLS-1$ >+ private static HashSet pageExtensionSet = new HashSet(pageExtensions.length); >+ >+ private static void populateHashSet() >+ { for(int i = 0; i < pageExtensions.length; ++i) >+ { pageExtensionSet.add(pageExtensions[i]); >+ } >+ } >+ >+ public static boolean hasValidPageExtension(IPath path) >+ { String fileExtension = path.getFileExtension(); >+ if(fileExtension != null) >+ { fileExtension = fileExtension.toLowerCase(Locale.ENGLISH); >+ if(pageExtensionSet.isEmpty()) >+ { populateHashSet(); >+ } >+ >+ return pageExtensionSet.contains(fileExtension); >+ } >+ >+ return false; >+ } >+ >+ private static boolean hasValidTocExtension(IPath path) >+ { String fileExtension = path.getFileExtension(); >+ return fileExtension != null && fileExtension.equals(tocExtension); >+ } >+ >+ /** >+ * @param file >+ */ >+ public static boolean isTOCFile(IPath path) { >+ if(!hasValidTocExtension(path)) >+ return false; >+ >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ >+ IResource resource = root.findMember(path); >+ if(resource != null && resource instanceof IFile) >+ { return XMLRootElementMatcher.fileMatchesElement((IFile)resource, ITocConstants.ELEMENT_TOC); >+ } >+ >+ return XMLRootElementMatcher.fileMatchesElement(path.toFile(), ITocConstants.ELEMENT_TOC); >+ } >+ >+ public static boolean isCurrentResource(IPath path, IBaseModel model) >+ { if(model instanceof IModel) >+ { IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); >+ IPath fullPath; >+ >+ if(workspacePath.isPrefixOf(path)) >+ { fullPath = ((IModel)model).getUnderlyingResource().getLocation(); >+ } >+ else >+ { fullPath = ((IModel)model).getUnderlyingResource().getFullPath(); >+ } >+ >+ return fullPath.equals(path); >+ } >+ >+ return false; >+ } >+ >+ public static String getPageExtensionList() { >+ StringBuffer buf = new StringBuffer(); >+ >+ for(int i = 0; i < pageExtensions.length; ++i) >+ { buf.append('.'); >+ buf.append(pageExtensions[i]); >+ if(i != pageExtensions.length - 1) >+ { buf.append(", "); //$NON-NLS-1$ >+ } >+ } >+ >+ return buf.toString(); >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpBlock.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpBlock.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.pde.core.IModelChangedEvent; >+import org.eclipse.pde.core.IModelChangedListener; >+import org.eclipse.pde.internal.core.text.ctxhelp.*; >+import org.eclipse.pde.internal.ui.editor.*; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.details.*; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.*; >+ >+/** >+ * Block containing the UI elements for the context editor. Extends from PDEMasterDetailsBlock >+ * which splits the editor into two areas, a tree section and a details section. >+ * @since 3.4 >+ * @see CtxHelpTreeSection >+ * @see CtxHelpAbstractDetails >+ */ >+public class CtxHelpBlock extends PDEMasterDetailsBlock implements IModelChangedListener, IDetailsPageProvider { >+ >+ private CtxHelpTreeSection fMasterSection; >+ >+ public CtxHelpBlock(PDEFormPage page) { >+ super(page); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock#createMasterSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) >+ */ >+ protected PDESection createMasterSection(IManagedForm managedForm, Composite parent) { >+ fMasterSection = new CtxHelpTreeSection(getPage(), parent); >+ return fMasterSection; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart) >+ */ >+ protected void registerPages(DetailsPart detailsPart) { >+ // Only static pages to be defined. Do not cache pages >+ detailsPart.setPageLimit(0); >+ detailsPart.registerPage(CtxHelpContextDetails.class, new CtxHelpContextDetails(fMasterSection)); >+ detailsPart.registerPage(CtxHelpDescriptionDetails.class, new CtxHelpDescriptionDetails(fMasterSection)); >+ detailsPart.registerPage(CtxHelpTopicDetails.class, new CtxHelpTopicDetails(fMasterSection)); >+ detailsPart.registerPage(CtxHelpCommandDetails.class, new CtxHelpCommandDetails(fMasterSection)); >+ detailsPart.setPageProvider(this); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent) >+ */ >+ public void modelChanged(IModelChangedEvent event) { >+ if (fMasterSection != null) { >+ fMasterSection.modelChanged(event); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.IDetailsPageProvider#getPage(java.lang.Object) >+ */ >+ public IDetailsPage getPage(Object key) { >+ // No dynamic pages. Static pages already registered >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.IDetailsPageProvider#getPageKey(java.lang.Object) >+ */ >+ public Object getPageKey(Object object) { >+ ISelection selection = getSelection(); >+ if (!(selection instanceof IStructuredSelection) || ((IStructuredSelection) selection).size() > 1) { >+ return object.getClass(); >+ } >+ >+ if (object instanceof CtxHelpContext) { >+ return CtxHelpContextDetails.class; >+ } else if (object instanceof CtxHelpDescription) { >+ return CtxHelpDescriptionDetails.class; >+ } else if (object instanceof CtxHelpTopic) { >+ return CtxHelpTopicDetails.class; >+ } else if (object instanceof CtxHelpCommand) { >+ return CtxHelpCommandDetails.class; >+ } >+ >+ return object.getClass(); >+ } >+ >+ /** >+ * @return the current selection of the tree section >+ */ >+ public ISelection getSelection() { >+ if (fMasterSection != null) { >+ return fMasterSection.getSelection(); >+ } >+ return null; >+ } >+ >+ /** >+ * @return the tree section >+ */ >+ public CtxHelpTreeSection getMasterSection() { >+ return fMasterSection; >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpTopicDetails.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpTopicDetails.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpTopicDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpTopicDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,184 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpTopic; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext; >+import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection; >+import org.eclipse.pde.internal.ui.editor.toc.details.HelpEditorFilter; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.pde.internal.ui.util.FileValidator; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; >+import org.eclipse.ui.forms.IFormPart; >+import org.eclipse.ui.forms.events.HyperlinkEvent; >+import org.eclipse.ui.model.WorkbenchContentProvider; >+import org.eclipse.ui.model.WorkbenchLabelProvider; >+ >+/** >+ * Details section for topic entries. >+ * @since 3.4 >+ * @see CtxHelpAbstractDetails >+ * @see CtxHelpTopic >+ */ >+public class CtxHelpTopicDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpTopic fTopic; >+ private FormEntry fLabelEntry; >+ private FormEntry fLinkEntry; >+ >+ public CtxHelpTopicDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#createFields(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpTopicDetails_specifyLabel); >+ fLabelEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpTopicDetails_label, SWT.NONE); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpTopicDetails_specifyLocation); >+ fLinkEntry = new FormEntry(parent, getManagedForm().getToolkit(), PDEUIMessages.CtxHelpTopicDetails_location, PDEUIMessages.GeneralInfoSection_browse, isEditable()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle() >+ */ >+ protected String getDetailsTitle() { >+ return PDEUIMessages.TocTopicDetails_title; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription() >+ */ >+ protected String getDetailsDescription() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#hookListeners() >+ */ >+ public void hookListeners() { >+ fLabelEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { >+ if (fTopic != null) { >+ fTopic.setLabel(fLabelEntry.getValue()); >+ } >+ } >+ }); >+ fLinkEntry.setFormEntryListener(new FormEntryAdapter(this) { >+ public void textValueChanged(FormEntry entry) { // Ensure data object is defined >+ if (fTopic != null) { >+ // TODO Do we need better testing for path validity? >+ fTopic.setLocation(new Path(fLinkEntry.getValue())); >+ } >+ } >+ >+ public void browseButtonSelected(FormEntry entry) { >+ handleBrowse(); >+ } >+ >+ public void linkActivated(HyperlinkEvent e) { >+ handleOpen(); >+ } >+ }); >+ } >+ >+ /** >+ * Handle when the browse button is pressed. Open up a file selection dialog. >+ */ >+ private void handleBrowse() { >+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getPage().getSite().getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); >+ >+ dialog.setValidator(new FileValidator()); >+ dialog.setAllowMultiple(false); >+ dialog.setTitle(PDEUIMessages.TocDetails_browseSelection); >+ dialog.setMessage(PDEUIMessages.TocDetails_browseMessage); >+ dialog.addFilter(new HelpEditorFilter()); >+ >+ dialog.setInput(PDEPlugin.getWorkspace().getRoot()); >+ >+ if (dialog.open() == Window.OK) { >+ IFile file = (IFile) dialog.getFirstResult(); >+ setPathEntry(file); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#updateFields() >+ */ >+ public void updateFields() { >+ if (fTopic != null) { >+ fLabelEntry.setValue(fTopic.getLabel(), true); >+ fLabelEntry.setEditable(isEditableElement()); >+ if (fTopic.getLocation() == null) { >+ fLinkEntry.setValue("", true); //$NON-NLS-1$ >+ } else { >+ fLinkEntry.setValue(fTopic.getLocation().toPortableString(), true); >+ } >+ fLinkEntry.setEditable(isEditableElement()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean) >+ */ >+ public void commit(boolean onSave) { >+ super.commit(onSave); >+ // Only required for form entries >+ fLabelEntry.commit(); >+ fLinkEntry.commit(); >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IFormPart part, ISelection selection) { >+ Object object = getFirstSelectedObject(selection); >+ if (object instanceof CtxHelpTopic) { >+ fTopic = (CtxHelpTopic) object; >+ updateFields(); >+ } >+ } >+ >+ /** >+ * Sets the text of the form entry used to supply a link >+ * @param file >+ */ >+ protected void setPathEntry(IFile file) { >+ IPath path = file.getFullPath(); >+ if (file.getProject().equals(fTopic.getModel().getUnderlyingResource().getProject())) { >+ fLinkEntry.setValue(path.removeFirstSegments(1).toString()); >+ } else { >+ fLinkEntry.setValue(".." + path.toString()); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * Handle when the link is pressed. Try opening the file at the specified path. >+ */ >+ protected void handleOpen() { >+ getMasterSection().open(fTopic); >+ // TODO Consider having a wizard open to create a new file if the path does not exist >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContext.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContext.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp; >+ >+import java.io.File; >+import java.util.ArrayList; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.pde.core.IBaseModel; >+import org.eclipse.pde.internal.core.text.AbstractEditingModel; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel; >+import org.eclipse.pde.internal.ui.editor.*; >+import org.eclipse.pde.internal.ui.editor.context.XMLInputContext; >+import org.eclipse.ui.*; >+ >+/** >+ * The input context for the context help editor, based on an xml file containing >+ * help context ids. >+ * @since 3.4 >+ */ >+public class CtxHelpInputContext extends XMLInputContext { >+ >+ public static final String CONTEXT_ID = "ctxhelp-context"; //$NON-NLS-1$ >+ >+ public CtxHelpInputContext(PDEFormEditor editor, IEditorInput input, boolean primary) { >+ super(editor, input, primary); >+ create(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.InputContext#createModel(org.eclipse.ui.IEditorInput) >+ */ >+ protected IBaseModel createModel(IEditorInput input) throws CoreException { >+ if (input instanceof IStorageEditorInput) { >+ boolean isReconciling = input instanceof IFileEditorInput; >+ IDocument document = getDocumentProvider().getDocument(input); >+ >+ CtxHelpModel model = new CtxHelpModel(document, isReconciling); >+ >+ if (input instanceof IFileEditorInput) { >+ IFile file = ((IFileEditorInput) input).getFile(); >+ model.setUnderlyingResource(file); >+ model.setCharset(file.getCharset()); >+ } else if (input instanceof SystemFileEditorInput) { >+ File file = (File) ((SystemFileEditorInput) input).getAdapter(File.class); >+ model.setInstallLocation(file.getParent()); >+ model.setCharset(getDefaultCharset()); >+ } else if (input instanceof JarEntryEditorInput) { >+ File file = (File) ((JarEntryEditorInput) input).getAdapter(File.class); >+ model.setInstallLocation(file.toString()); >+ model.setCharset(getDefaultCharset()); >+ } else { >+ model.setCharset(getDefaultCharset()); >+ } >+ >+ model.load(); >+ >+ return model; >+ } >+ >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.InputContext#getId() >+ */ >+ public String getId() { >+ return CONTEXT_ID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.XMLInputContext#reorderInsertEdits(java.util.ArrayList) >+ */ >+ protected void reorderInsertEdits(ArrayList ops) { >+ // NO-OP >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.InputContext#doRevert() >+ */ >+ public void doRevert() { >+ fEditOperations.clear(); >+ fOperationTable.clear(); >+ fMoveOperations.clear(); >+ AbstractEditingModel model = (AbstractEditingModel) getModel(); >+ model.reconciled(model.getDocument()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.context.InputContext#getPartitionName() >+ */ >+ protected String getPartitionName() { >+ return "___ctxhelp_partition"; //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpRemoveAction.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpRemoveAction.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpRemoveAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpRemoveAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.ctxhelp.details; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+ >+/** >+ * The action used to remove one or more elements from the context help xml. >+ * @since 3.4 >+ */ >+public class CtxHelpRemoveAction extends Action { >+ >+ private CtxHelpObject[] fObjects; >+ >+ //The next object to be selected after the >+ //selected object is removed >+ private CtxHelpObject fObjectToSelect; >+ >+ public CtxHelpRemoveAction() { >+ // Adds the 'Delete' keybinding to the action when displayed >+ // in a context menu >+ setActionDefinitionId("org.eclipse.ui.edit.delete"); //$NON-NLS-1$ >+ setText(PDEUIMessages.TocPage_remove); >+ } >+ >+ /** >+ * Sets the objects to be removed when this action is run. >+ * @param objects objects to remove >+ */ >+ public void setToRemove(CtxHelpObject[] objects) { >+ fObjects = objects; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#run() >+ */ >+ public void run() { >+ if (fObjects == null) >+ return; >+ >+ for (int i = 0; i < fObjects.length; ++i) { >+ if (fObjects[i] != null && fObjects[i].canBeRemoved()) { >+ CtxHelpObject parent = fObjects[i].getParent(); >+ if (parent != null) { >+ determineNextSelection(parent, i); >+ parent.removeChild(fObjects[i]); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Determine the next object that should be selected >+ * after the designated object has been removed >+ * >+ * @param parent The parent of the deleted object >+ */ >+ private void determineNextSelection(CtxHelpObject parent, int index) { >+ // Select the next sibling >+ fObjectToSelect = parent.getNextSibling(fObjects[index]); >+ if (fObjectToSelect == null) { >+ // No next sibling >+ // Select the previous sibling >+ fObjectToSelect = parent.getPreviousSibling(fObjects[index]); >+ if (fObjectToSelect == null) { >+ // No previous sibling >+ // Select the parent >+ fObjectToSelect = parent; >+ } >+ } >+ } >+ >+ /** >+ * Returns the object that should be selected after the action is run. >+ * @return the object to select or <code>null</code> >+ */ >+ public CtxHelpObject getNextSelection() { >+ return fObjectToSelect; >+ } >+ >+ /** >+ * Clears the next selection returned by {@link #getNextSelection()}. >+ */ >+ public void clearNextSelection() { >+ fObjectToSelect = null; >+ } >+ >+} >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/itoc/ITocConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/itoc/ITocConstants.java,v >retrieving revision 1.3 >diff -u -r1.3 ITocConstants.java >--- src/org/eclipse/pde/internal/core/itoc/ITocConstants.java 2 Jan 2008 15:56:24 -0000 1.3 >+++ src/org/eclipse/pde/internal/core/itoc/ITocConstants.java 17 Jan 2008 18:16:04 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -14,6 +14,7 @@ > /** > * ITocConstants > * This interface contains all of the constants relevant to the TOC editor >+ * @since 3.4 > */ > public interface ITocConstants { > >@@ -33,13 +34,13 @@ > > public static final String ATTRIBUTE_LABEL = "label"; //$NON-NLS-1$ > >- public static final String ATTRIBUTE_TOPIC = ELEMENT_TOPIC; //$NON-NLS-1$ >+ public static final String ATTRIBUTE_TOPIC = ELEMENT_TOPIC; > > public static final String ATTRIBUTE_HREF = "href"; //$NON-NLS-1$ > > public static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ > >- public static final String ATTRIBUTE_TOC = ELEMENT_TOC; //$NON-NLS-1$ >+ public static final String ATTRIBUTE_TOC = ELEMENT_TOC; > > // Types > >@@ -51,22 +52,4 @@ > > public static final int TYPE_LINK = 3; > >- // Enablement Elements >- >- public static final String ELEMENT_ENABLEMENT = "enablement"; //$NON-NLS-1$ >- >- public static final String ELEMENT_TEST = "test"; //$NON-NLS-1$ >- >- // Enablement Attributes >- >- public static final String ATTRIBUTE_PROPERTY = "property"; //$NON-NLS-1$ >- >- public static final String ATTRIBUTE_ARGS = "args"; //$NON-NLS-1$ >- >- // Enablement Types >- >- public static final int TYPE_ENABLEMENT = 4; >- >- public static final int TYPE_TEST = 5; >- > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/META-INF/MANIFEST.MF,v >retrieving revision 1.30 >diff -u -r1.30 MANIFEST.MF >--- META-INF/MANIFEST.MF 12 Sep 2007 14:03:38 -0000 1.30 >+++ META-INF/MANIFEST.MF 17 Jan 2008 18:16:04 -0000 >@@ -22,6 +22,7 @@ > org.eclipse.pde.internal.core.icheatsheet;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.icheatsheet.comp;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.icheatsheet.simple;x-friends:="org.eclipse.pde.ui", >+ org.eclipse.pde.internal.core.ictxhelp;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui", >@@ -39,6 +40,7 @@ > org.eclipse.pde.internal.core.text.build;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.text.bundle;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.text.cheatsheet.simple;x-friends:="org.eclipse.pde.ui", >+ org.eclipse.pde.internal.core.text.ctxhelp;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.text.plugin;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.text.toc;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.util;x-friends:="org.eclipse.pde.ui", >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDescription.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDescription.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDescription.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDescription.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+/** >+ * Represents a description entry in context help. There may be one description >+ * element for each context. A description element will contain a CDATA string >+ * explaining the context that the user will see in dynamic help. Descriptions >+ * are leaf objects. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public class CtxHelpDescription extends CtxHelpObject { >+ >+ private static final long serialVersionUID = 1L; >+ >+ public CtxHelpDescription(CtxHelpModel model) { >+ super(model, ELEMENT_DESCRIPTION); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent() >+ */ >+ public boolean canBeParent() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getType() >+ */ >+ public int getType() { >+ return TYPE_DESCRIPTION; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getName() >+ */ >+ public String getName() { >+ return getDescription(); >+ } >+ >+ /** >+ * @return the XML content of this element containing the description or <code>null</code> >+ */ >+ public String getDescription() { >+ return getXMLContent(); >+ } >+ >+ /** >+ * Sets the XML content of this element to the given description string. >+ * Passing <code>null</code> will set the content to be empty. >+ * @param description new content >+ */ >+ public void setDescription(String description) { >+ setXMLContent(description); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject) >+ */ >+ public boolean canAddChild(int objectType) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int) >+ */ >+ public boolean canAddSibling(int objectType) { >+ return objectType == TYPE_COMMAND || objectType == TYPE_TOPIC; >+ } >+} >Index: src/org/eclipse/pde/internal/core/ictxhelp/ICtxHelpConstants.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/core/ictxhelp/ICtxHelpConstants.java >diff -N src/org/eclipse/pde/internal/core/ictxhelp/ICtxHelpConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/core/ictxhelp/ICtxHelpConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.ictxhelp; >+ >+/** >+ * Interface containing constants used for the context help editor. >+ * >+ * @since 3.4 >+ */ >+public interface ICtxHelpConstants { >+ >+ // Elements >+ >+ public static final String ELEMENT_ROOT = "contexts"; //$NON-NLS-1$ >+ >+ public static final String ELEMENT_CONTEXT = "context"; //$NON-NLS-1$ >+ >+ public static final String ELEMENT_DESCRIPTION = "description"; //$NON-NLS-1$ >+ >+ public static final String ELEMENT_TOPIC = "topic"; //$NON-NLS-1$ >+ >+ public static final String ELEMENT_COMMAND = "command"; //$NON-NLS-1$ >+ >+ // Attributes >+ >+ public static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ >+ >+ public static final String ATTRIBUTE_TITLE = "title"; //$NON-NLS-1$ >+ >+ public static final String ATTRIBUTE_LABEL = "label"; //$NON-NLS-1$ >+ >+ public static final String ATTRIBUTE_HREF = "href"; //$NON-NLS-1$ >+ >+ public static final String ATTRIBUTE_SERIAL = "serialization"; //$NON-NLS-1$ >+ >+ public static final String ATTRIBUTE_FILTER = "filter"; //$NON-NLS-1$ >+ >+ // Types >+ >+ public static final int TYPE_ROOT = 0; >+ >+ public static final int TYPE_CONTEXT = 1; >+ >+ public static final int TYPE_DESCRIPTION = 2; >+ >+ public static final int TYPE_TOPIC = 3; >+ >+ public static final int TYPE_COMMAND = 4; >+ >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpModel.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpModel.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.pde.core.IModel; >+import org.eclipse.pde.core.IWritable; >+import org.eclipse.pde.internal.core.NLResourceHelper; >+import org.eclipse.pde.internal.core.text.XMLEditingModel; >+import org.xml.sax.helpers.DefaultHandler; >+ >+/** >+ * Model describing the elements of a context help xml file. >+ * >+ * @since 3.4 >+ * @see CtxHelpRoot >+ * @see CtxHelpDocumentFactory >+ * @see CtxHelpDocumentHandler >+ */ >+public class CtxHelpModel extends XMLEditingModel { >+ >+ private CtxHelpDocumentHandler fHandler; >+ private CtxHelpDocumentFactory fFactory; >+ private CtxHelpRoot fRoot; >+ >+ public CtxHelpModel(IDocument document, boolean isReconciling) { >+ super(document, isReconciling); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.XMLEditingModel#createDocumentHandler(org.eclipse.pde.core.IModel, boolean) >+ */ >+ protected DefaultHandler createDocumentHandler(IModel model, boolean reconciling) { >+ if (fHandler == null) { >+ fHandler = new CtxHelpDocumentHandler(this, reconciling); >+ } >+ return fHandler; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.AbstractEditingModel#createNLResourceHelper() >+ */ >+ protected NLResourceHelper createNLResourceHelper() { >+ // Not needed >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.icheatsheet.simple.ITocModel#getFactory() >+ */ >+ public CtxHelpDocumentFactory getFactory() { >+ if (fFactory == null) { >+ fFactory = new CtxHelpDocumentFactory(this); >+ } >+ return fFactory; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.icheatsheet.simple.ITocModel#getToc() >+ */ >+ public CtxHelpRoot getCtxHelpRoot() { >+ if (fRoot == null) { >+ fRoot = getFactory().createRoot(); >+ } >+ return fRoot; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.XMLEditingModel#getRoot() >+ */ >+ protected IWritable getRoot() { >+ return getCtxHelpRoot(); >+ } >+ >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentFactory.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentFactory.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants; >+import org.eclipse.pde.internal.core.text.*; >+ >+/** >+ * Handles the creation of document nodes representing the types of elements that >+ * can exist in a context help xml file. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentHandler >+ */ >+public class CtxHelpDocumentFactory extends DocumentNodeFactory implements IDocumentNodeFactory { >+ private CtxHelpModel fModel; >+ >+ public CtxHelpDocumentFactory(CtxHelpModel model) { >+ fModel = model; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.IDocumentNodeFactory#createDocumentNode(java.lang.String, org.eclipse.pde.internal.core.text.IDocumentElementNode) >+ */ >+ public IDocumentElementNode createDocumentNode(String name, IDocumentElementNode parent) { >+ if (isRoot(name)) { // Root >+ return createRoot(); >+ } >+ if (isContext(name)) { // Context >+ return createContext(); >+ } >+ if (isDescription(name)) { // Link >+ return createDescription(); >+ } >+ if (isTopic(name)) { // Anchor >+ return createTopic(); >+ } >+ if (isCommand(name)) { // Anchor >+ return createCommand(); >+ } >+ return super.createDocumentNode(name, parent); >+ } >+ >+ private boolean isRoot(String name) { >+ return name.equals(ICtxHelpConstants.ELEMENT_ROOT); >+ } >+ >+ private boolean isContext(String name) { >+ return name.equals(ICtxHelpConstants.ELEMENT_CONTEXT); >+ } >+ >+ private boolean isDescription(String name) { >+ return name.equals(ICtxHelpConstants.ELEMENT_DESCRIPTION); >+ } >+ >+ private boolean isTopic(String name) { >+ return name.equals(ICtxHelpConstants.ELEMENT_TOPIC); >+ } >+ >+ private boolean isCommand(String name) { >+ return name.equals(ICtxHelpConstants.ELEMENT_COMMAND); >+ } >+ >+ /** >+ * @return a new root object based on the current model >+ */ >+ public CtxHelpRoot createRoot() { >+ return new CtxHelpRoot(fModel); >+ } >+ >+ /** >+ * @return a new context object based on the current model >+ */ >+ public CtxHelpContext createContext() { >+ return new CtxHelpContext(fModel); >+ } >+ >+ /** >+ * @return a new description object based on the current model >+ */ >+ public CtxHelpDescription createDescription() { >+ return new CtxHelpDescription(fModel); >+ } >+ >+ /** >+ * @return a new topic object based on the current model >+ */ >+ public CtxHelpTopic createTopic() { >+ return new CtxHelpTopic(fModel); >+ } >+ >+ /** >+ * @return a new command object based on the current model >+ */ >+ public CtxHelpCommand createCommand() { >+ return new CtxHelpCommand(fModel); >+ } >+ >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpCommand.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpCommand.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,96 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+/** >+ * Represents a command entry in context help. Commands are used to launch >+ * actions when clicked on by the user. Commands are leaf objects. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public class CtxHelpCommand extends CtxHelpObject { >+ >+ private static final long serialVersionUID = 1L; >+ >+ public CtxHelpCommand(CtxHelpModel model) { >+ super(model, ELEMENT_COMMAND); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent() >+ */ >+ public boolean canBeParent() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getType() >+ */ >+ public int getType() { >+ return TYPE_COMMAND; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getName() >+ */ >+ public String getName() { >+ return getLabel(); >+ } >+ >+ /** >+ * @return the value of the label attribute or <code>null</code> if the attribute does not exist >+ */ >+ public String getLabel() { >+ return getXMLAttributeValue(ATTRIBUTE_LABEL); >+ } >+ >+ /** >+ * Set the label attribute, passing <code>null</code> will set the >+ * attribute to be empty. >+ * @param label new value >+ */ >+ public void setLabel(String label) { >+ setXMLAttribute(ATTRIBUTE_LABEL, label); >+ } >+ >+ /** >+ * @return the value of the serialization attribute or <code>null</code> if the attribute does not exist >+ */ >+ public String getSerialization() { >+ return getXMLAttributeValue(ATTRIBUTE_SERIAL); >+ } >+ >+ /** >+ * Set the serialization attribute, passing <code>null</code> will set the >+ * attribute to be empty. >+ * @param serialization new value >+ */ >+ public void setSerialization(String serialization) { >+ setXMLAttribute(ATTRIBUTE_HREF, serialization); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject) >+ */ >+ public boolean canAddChild(int objectType) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int) >+ */ >+ public boolean canAddSibling(int objectType) { >+ return objectType == TYPE_COMMAND || objectType == TYPE_TOPIC; >+ } >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpTopic.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpTopic.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpTopic.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpTopic.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,107 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+ >+/** >+ * Represents a topic entry in context help. Topics are used to open related >+ * help in other files. Topics are leaf objects. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public class CtxHelpTopic extends CtxHelpObject { >+ >+ private static final long serialVersionUID = 1L; >+ >+ public CtxHelpTopic(CtxHelpModel model) { >+ super(model, ELEMENT_TOPIC); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent() >+ */ >+ public boolean canBeParent() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getType() >+ */ >+ public int getType() { >+ return TYPE_TOPIC; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getName() >+ */ >+ public String getName() { >+ return getLabel(); >+ } >+ >+ /** >+ * @return the value of the label attribute or <code>null</code> if the attribute does not exist >+ */ >+ public String getLabel() { >+ return getXMLAttributeValue(ATTRIBUTE_LABEL); >+ } >+ >+ /** >+ * Set the label attribute, passing <code>null</code> will set the >+ * attribute to be empty. >+ * @param label new value >+ */ >+ public void setLabel(String label) { >+ setXMLAttribute(ATTRIBUTE_LABEL, label); >+ } >+ >+ /** >+ * @return the value of the href attribute as a path or <code>null</code> >+ */ >+ public IPath getLocation() { >+ String value = getXMLAttributeValue(ATTRIBUTE_HREF); >+ if (value != null) { >+ return new Path(value); >+ } >+ return null; >+ } >+ >+ /** >+ * Set the href (link) attribute, passing <code>null</code> will set the >+ * attribute to be empty. >+ * @param path new value >+ */ >+ public void setLocation(IPath path) { >+ if (path == null) { >+ setXMLAttribute(ATTRIBUTE_HREF, null); >+ } else { >+ setXMLAttribute(ATTRIBUTE_HREF, path.toPortableString()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject) >+ */ >+ public boolean canAddChild(int objectType) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int) >+ */ >+ public boolean canAddSibling(int objectType) { >+ return objectType == TYPE_COMMAND || objectType == TYPE_TOPIC; >+ } >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentHandler.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentHandler.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.pde.internal.core.text.IDocumentElementNode; >+import org.eclipse.pde.internal.core.text.NodeDocumentHandler; >+ >+/** >+ * Document handler for context help xml files. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public class CtxHelpDocumentHandler extends NodeDocumentHandler { >+ >+ private CtxHelpModel fModel; >+ >+ public CtxHelpDocumentHandler(CtxHelpModel model, boolean reconciling) { >+ super(reconciling, model.getFactory()); >+ fModel = model; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.DocumentHandler#getDocument() >+ */ >+ protected IDocument getDocument() { >+ return fModel.getDocument(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.NodeDocumentHandler#getRootNode() >+ */ >+ protected IDocumentElementNode getRootNode() { >+ return (IDocumentElementNode) fModel.getRoot(); >+ } >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpRoot.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpRoot.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpRoot.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpRoot.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+/** >+ * Represents the root "contexts" entry in a context help xml file. There may >+ * be only one root node in the file and all other nodes must be inside the root. >+ * The root may contain many context elements. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public class CtxHelpRoot extends CtxHelpObject { >+ >+ private static final long serialVersionUID = 1L; >+ >+ public CtxHelpRoot(CtxHelpModel model) { >+ super(model, ELEMENT_ROOT); >+ setInTheModel(true); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.plugin.PluginDocumentNode#isRoot() >+ */ >+ public boolean isRoot() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getType() >+ */ >+ public int getType() { >+ return TYPE_ROOT; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canBeParent() >+ */ >+ public boolean canBeParent() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#getName() >+ */ >+ public String getName() { >+ return ELEMENT_ROOT; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject) >+ */ >+ public boolean canAddChild(int objectType) { >+ return objectType == TYPE_CONTEXT; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int) >+ */ >+ public boolean canAddSibling(int objectType) { >+ return false; >+ } >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpContext.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpContext.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,135 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+import org.eclipse.pde.internal.core.text.IDocumentElementNode; >+ >+/** >+ * Represents a context entry in context help. Contexts have a specific id >+ * that allows UI elements to be associated with a list of commands and topics >+ * that are stored in the context. Contexts may have one optional description >+ * element and as many topic and command elements as needed. >+ * >+ * @since 3.4 >+ * @see CtxHelpObject >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public class CtxHelpContext extends CtxHelpObject { >+ >+ private static final long serialVersionUID = 1L; >+ >+ public CtxHelpContext(CtxHelpModel model) { >+ super(model, ELEMENT_CONTEXT); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent() >+ */ >+ public boolean canBeParent() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getType() >+ */ >+ public int getType() { >+ return TYPE_CONTEXT; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#getName() >+ */ >+ public String getName() { >+ return getId(); >+ } >+ >+ /** >+ * @return the value of the id attribute or <code>null</code> if the attribute does not exist >+ */ >+ public String getId() { >+ return getXMLAttributeValue(ATTRIBUTE_ID); >+ } >+ >+ /** >+ * Set the id attribute, passing <code>null</code> will set the >+ * attribute to be empty. >+ * @param id new value >+ */ >+ public void setID(String id) { >+ setXMLAttribute(ATTRIBUTE_ID, id); >+ } >+ >+ /** >+ * @return the value of the title attribute or <code>null</code> if the attribute does not exist >+ */ >+ public String getTitle() { >+ return getXMLAttributeValue(ATTRIBUTE_TITLE); >+ } >+ >+ /** >+ * Set the title attribute, passing <code>null</code> will set the >+ * attribute to be empty. >+ * @param title new value >+ */ >+ public void setTitle(String title) { >+ setXMLAttribute(ATTRIBUTE_TITLE, title); >+ } >+ >+ /** >+ * Searches for a child description node and returns the string contents of that node. >+ * Returns <code>null</code> if no description node exists. >+ * @return description associated with this context or <code>null</code> no description exists >+ */ >+ public String getDescription() { >+ IDocumentElementNode node = getChildNode(CtxHelpDescription.class); >+ if (node instanceof CtxHelpDescription) { >+ return ((CtxHelpDescription) node).getDescription(); >+ } >+ return null; >+ } >+ >+ /** >+ * Set the description to be associated with this context. Searches for a child description node >+ * and updates the content with the given string. If a description node does not exist, one will >+ * be created. Passing <code>null</code> will remove any description node if one exists. >+ * @param description new value >+ */ >+ public void setDescription(String description) { >+ IDocumentElementNode node = getChildNode(CtxHelpDescription.class); >+ if (node instanceof CtxHelpDescription) { >+ if (description == null) { >+ removeChildNode(node, true); >+ } else { >+ ((CtxHelpDescription) node).setDescription(description); >+ } >+ } else if (description != null) { >+ CtxHelpDescription newDescription = getModel().getFactory().createDescription(); >+ newDescription.setDescription(description); >+ addChildNode(newDescription, 0, true); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject) >+ */ >+ public boolean canAddChild(int objectType) { >+ return objectType == TYPE_TOPIC || objectType == TYPE_COMMAND; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int) >+ */ >+ public boolean canAddSibling(int objectType) { >+ return objectType == TYPE_CONTEXT; >+ } >+ >+} >Index: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpObject.java >=================================================================== >RCS file: text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpObject.java >diff -N text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpObject.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpObject.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,196 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.text.ctxhelp; >+ >+import java.io.Serializable; >+import java.util.ArrayList; >+import java.util.List; >+import org.eclipse.pde.core.IModel; >+import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants; >+import org.eclipse.pde.internal.core.text.DocumentObject; >+import org.eclipse.pde.internal.core.text.IDocumentElementNode; >+ >+/** >+ * All modeled objects of a context help xml file must extend from this >+ * abstract class. >+ * >+ * @since 3.4 >+ * @see CtxHelpModel >+ * @see CtxHelpDocumentFactory >+ */ >+public abstract class CtxHelpObject extends DocumentObject implements ICtxHelpConstants, Serializable { >+ >+ private static final long serialVersionUID = 1L; >+ >+ /** >+ * Constructs the CtxHelpObject and initializes its attributes. >+ * >+ * @param model The model to associate with this CtxHelpObject >+ * @param tagName The xml tag name for this object >+ */ >+ public CtxHelpObject(CtxHelpModel model, String tagName) { >+ super(model, tagName); >+ } >+ >+ /** >+ * @return the children of the object or an empty List if none exist. >+ */ >+ public List getChildren() { >+ //Create a copy of the child list instead of >+ //returning the list itself. That way, our list >+ //of children cannot be altered from outside >+ ArrayList list = new ArrayList(); >+ >+ // Add children of this topic >+ IDocumentElementNode[] childNodes = getChildNodes(); >+ if (childNodes.length > 0) { >+ for (int i = 0; i < childNodes.length; ++i) { >+ if (childNodes[i] instanceof CtxHelpObject) { >+ list.add(childNodes[i]); >+ } >+ } >+ } >+ >+ return list; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.DocumentElementNode#isLeafNode() >+ */ >+ public boolean isLeafNode() { >+ return !canBeParent(); >+ } >+ >+ /** >+ * @return true iff this object is capable of containing children. >+ */ >+ public abstract boolean canBeParent(); >+ >+ public abstract boolean canAddChild(int objectType); >+ >+ public abstract boolean canAddSibling(int objectType); >+ >+ // public abstract boolean canAddSibling(int objectType); >+ >+ public void addChild(CtxHelpObject newObject, CtxHelpObject targetSibling, boolean insertBefore) { >+ if (canAddChild(newObject.getType())) { >+ int currentIndex = indexOf(targetSibling); >+ if (!insertBefore) { >+ currentIndex++; >+ } >+ addChildNode(newObject, currentIndex, true); >+ } >+ } >+ >+ public void addChild(CtxHelpObject newObject) { >+ if (canAddChild(newObject.getType())) { >+ addChildNode(newObject, true); >+ } >+ } >+ >+ /** >+ * @return the root model object that is an ancestor to this object. >+ */ >+ public CtxHelpModel getModel() { >+ final IModel sharedModel = getSharedModel(); >+ if (sharedModel instanceof CtxHelpModel) { >+ return (CtxHelpModel) sharedModel; >+ } >+ return null; >+ } >+ >+ /** >+ * @return the root element that is an ancestor to this object. >+ */ >+ public CtxHelpRoot getRoot() { >+ final CtxHelpModel model = getModel(); >+ if (model != null) { >+ return model.getCtxHelpRoot(); >+ } >+ return null; >+ } >+ >+ /** >+ * @return the identifier for this object to be used when displaying the element to the user >+ */ >+ public abstract String getName(); >+ >+ /** >+ * Get the concrete type of this object, must be one of the TYPE constants defined in ICtxHelpConstants. >+ * @see ICtxHelpConstants >+ */ >+ public abstract int getType(); >+ >+ /** >+ * @return the parent of this object, or <code>null</code> if there is no parent. >+ */ >+ public CtxHelpObject getParent() { >+ IDocumentElementNode parent = getParentNode(); >+ return parent instanceof CtxHelpObject ? (CtxHelpObject) parent : null; >+ } >+ >+ /** >+ * Check if the object is a direct or indirect descendant >+ * of the object parameter. >+ * >+ * @param obj The object to find in this object's ancestry >+ * @return true iff obj is an ancestor of this object >+ */ >+ public boolean descendsFrom(CtxHelpObject obj) { >+ if (this.equals(obj)) { >+ return true; >+ } >+ if (getParent() != null && obj.canBeParent()) { >+ return getParent().descendsFrom(obj); >+ } >+ return false; >+ } >+ >+ /** >+ * @param ctxHelpObject the child used to locate a sibling >+ * @return the object preceding the specified one in the list of children >+ */ >+ public CtxHelpObject getPreviousSibling(CtxHelpObject ctxHelpObject) { >+ return (CtxHelpObject) getPreviousSibling(ctxHelpObject, CtxHelpObject.class); >+ } >+ >+ /** >+ * @param ctxHelpObject the child used to locate a sibling >+ * @return the object proceeding the specified one in the list of children >+ */ >+ public CtxHelpObject getNextSibling(CtxHelpObject ctxHelpObject) { >+ return (CtxHelpObject) getNextSibling(ctxHelpObject, CtxHelpObject.class); >+ } >+ >+ /** >+ * @return true iff a this object can be removed >+ */ >+ public boolean canBeRemoved() { >+ if (getType() == TYPE_ROOT) { //Semantic Rule: The root element can never be removed >+ return false; >+ } >+ return true; >+ } >+ >+ public void removeChild(CtxHelpObject object) { >+ if (object.canBeRemoved()) { >+ removeChildNode(object, true); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.toc.TocObject#moveChild(org.eclipse.pde.internal.core.toc.TocObject, int) >+ */ >+ public void moveChild(CtxHelpObject object, int newRelativeIndex) { >+ moveChildNode(object, newRelativeIndex, true); >+ } >+ >+} >#P org.eclipse.pde >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde/plugin.xml,v >retrieving revision 1.72 >diff -u -r1.72 plugin.xml >--- plugin.xml 31 Jul 2007 18:22:38 -0000 1.72 >+++ plugin.xml 17 Jan 2008 18:16:06 -0000 >@@ -181,6 +181,20 @@ > </parameter> > </describer> > </content-type> >+ <content-type >+ base-type="org.eclipse.core.runtime.xml" >+ file-extensions="xml" >+ id="ctxHelpFile" >+ name="%contextHelp" >+ priority="high"> >+ <describer >+ class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber"> >+ <parameter >+ name="element" >+ value="contexts"> >+ </parameter> >+ </describer> >+ </content-type> > </extension> > > >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde/plugin.properties,v >retrieving revision 1.35 >diff -u -r1.35 plugin.properties >--- plugin.properties 23 Nov 2007 22:30:29 -0000 1.35 >+++ plugin.properties 17 Jan 2008 18:16:06 -0000 >@@ -23,6 +23,7 @@ > bundleManifest = Bundle Manifest File > target.profile.content = Target Profile File > tableOfContents = Table of Contents File >+contextHelp = Context Help File > > #Cheatsheets > cheatsheet.category.pde = Plug-in Development
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 215091
:
86722
|
87186
|
87187
|
87291