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 86722 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]
Work in progress
215091ContextHelpAwesomeEditors.patch (text/plain), 215.98 KB, created by
Curtis Windatt
on 2008-01-11 16:42:59 EST
(
hide
)
Description:
Work in progress
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2008-01-11 16:42:59 EST
Size:
215.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug.ui >Index: ui/org/eclipse/jdt/internal/debug/ui/actions/JavaObjectValueEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/JavaObjectValueEditor.java,v >retrieving revision 1.17 >diff -u -r1.17 JavaObjectValueEditor.java >--- ui/org/eclipse/jdt/internal/debug/ui/actions/JavaObjectValueEditor.java 18 Jul 2006 19:33:11 -0000 1.17 >+++ ui/org/eclipse/jdt/internal/debug/ui/actions/JavaObjectValueEditor.java 11 Jan 2008 21:40:55 -0000 >@@ -198,6 +198,9 @@ > throw new DebugException(status); > } > return result.getValue(); >+ } else { >+ IStatus status= new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Could not find a project to complete the evaluation.", null); >+ throw new DebugException(status); > } > } > return 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 11 Jan 2008 21:40:56 -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 { > >@@ -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 11 Jan 2008 21:40:56 -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,203 @@ >+/******************************************************************************* >+ * 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); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.text.DocumentElementNode#getAttributeIndent() >+ */ >+ protected String getAttributeIndent() { >+ return "\t"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * @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.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.4 >diff -u -r1.4 TocFileValidator.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java 23 Aug 2007 12:28:21 -0000 1.4 >+++ src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java 11 Jan 2008 21:41:00 -0000 >@@ -37,7 +37,7 @@ > * @see org.eclipse.ui.dialogs.ISelectionStatusValidator#validate(java.lang.Object[]) > */ > public IStatus validate(Object[] selection) { >- >+ > // Ensure something was selected > if (selection.length == 0) { > return errorStatus(""); //$NON-NLS-1$ >@@ -46,46 +46,36 @@ > if ((selection[0] instanceof IFile) == false) { > return errorStatus(""); //$NON-NLS-1$ > } >- IFile file = (IFile)selection[0]; >+ 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)) >- { return errorStatus(PDEUIMessages.TocFileValidator_errorSameTOC); >+ if (HelpEditorUtil.isCurrentResource(file.getFullPath(), fModel)) { >+ return errorStatus(PDEUIMessages.TocFileValidator_errorSameTOC); > } > > // If we got this far, we have a valid file > return okStatus(""); //$NON-NLS-1$ >- >+ > } >- >+ > /** > * @param message > * @return > */ > private IStatus errorStatus(String message) { >- return new Status( >- IStatus.ERROR, >- PDEPlugin.getPluginId(), >- IStatus.ERROR, >- message, >- null); >+ 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); >+ 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.11 >diff -u -r1.11 TocTreeSection.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java 29 Aug 2007 15:29:34 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java 11 Jan 2008 21:41:00 -0000 >@@ -736,14 +736,14 @@ > 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; > } > >@@ -897,12 +897,12 @@ > // 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 29 Aug 2007 15:29:34 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,105 +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.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 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.6 >diff -u -r1.6 TocDropAdapter.java >--- src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java 24 Aug 2007 18:22:42 -0000 1.6 >+++ src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java 11 Jan 2008 21:41:00 -0000 >@@ -175,14 +175,14 @@ > return; > } > >- if(!TocExtensionUtil.hasValidPageExtension(path) >- && !TocExtensionUtil.isTOCFile(path)) >+ 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)) >+ 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 31 Jul 2007 18:22:34 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,50 +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.IContainer; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-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.3 >diff -u -r1.3 TocDetails.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java 22 Aug 2007 12:52:43 -0000 1.3 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java 11 Jan 2008 21:41:00 -0000 >@@ -189,7 +189,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.5 >diff -u -r1.5 TocLinkDetails.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java 23 Aug 2007 12:28:21 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java 11 Jan 2008 21:41:00 -0000 >@@ -19,7 +19,7 @@ > 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.toc.TocExtensionUtil; >+import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil; > import org.eclipse.pde.internal.ui.editor.toc.TocFileValidator; > import org.eclipse.pde.internal.ui.editor.toc.TocInputContext; > import org.eclipse.pde.internal.ui.editor.toc.TocTreeSection; >@@ -135,7 +135,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.4 >diff -u -r1.4 TocTopicDetails.java >--- src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java 22 Aug 2007 12:52:43 -0000 1.4 >+++ src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java 11 Jan 2008 21:41:00 -0000 >@@ -159,7 +159,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/IPDEUIConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPDEUIConstants.java,v >retrieving revision 1.29 >diff -u -r1.29 IPDEUIConstants.java >--- src/org/eclipse/pde/internal/ui/IPDEUIConstants.java 28 Aug 2007 15:18:15 -0000 1.29 >+++ src/org/eclipse/pde/internal/ui/IPDEUIConstants.java 11 Jan 2008 21:40: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,33 +24,29 @@ > 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$ > String PERSPECTIVE_ID = "org.eclipse.pde.ui.PDEPerspective"; //$NON-NLS-1$ >- >+ > String RUN_LAUNCHER_ID = PLUGIN_ID + "." + "WorkbenchRunLauncher"; //$NON-NLS-1$ //$NON-NLS-2$ > String DEBUG_LAUNCHER_ID = PLUGIN_ID + "." + "WorkbenchDebugLauncher"; //$NON-NLS-1$ //$NON-NLS-2$ >- String MARKER_SYSTEM_FILE_PATH = PLUGIN_ID + "."+ "systemFilePath"; //$NON-NLS-1$ //$NON-NLS-2$ >+ String MARKER_SYSTEM_FILE_PATH = PLUGIN_ID + "." + "systemFilePath"; //$NON-NLS-1$ //$NON-NLS-2$ > >- QualifiedName PROPERTY_EDITOR_PAGE_KEY = >- new QualifiedName(PLUGIN_ID, "editor-page-key"); //$NON-NLS-1$ >- QualifiedName PROPERTY_MANIFEST_EDITOR_PAGE_KEY = >- new QualifiedName(PLUGIN_ID, "manifest-editor-page-key"); //$NON-NLS-1$ >- QualifiedName DEFAULT_PRODUCT_EXPORT_LOCATION = >- new QualifiedName(PLUGIN_ID, "product-export-location"); //$NON-NLS-1$ >- QualifiedName DEFAULT_PRODUCT_EXPORT_DIR = >- new QualifiedName(PLUGIN_ID, "product-export-type"); //$NON-NLS-1$ >- QualifiedName DEFAULT_PRODUCT_EXPORT_ROOT = >- new QualifiedName(PLUGIN_ID, "product-export-root"); //$NON-NLS-1$ >+ QualifiedName PROPERTY_EDITOR_PAGE_KEY = new QualifiedName(PLUGIN_ID, "editor-page-key"); //$NON-NLS-1$ >+ QualifiedName PROPERTY_MANIFEST_EDITOR_PAGE_KEY = new QualifiedName(PLUGIN_ID, "manifest-editor-page-key"); //$NON-NLS-1$ >+ QualifiedName DEFAULT_PRODUCT_EXPORT_LOCATION = new QualifiedName(PLUGIN_ID, "product-export-location"); //$NON-NLS-1$ >+ QualifiedName DEFAULT_PRODUCT_EXPORT_DIR = new QualifiedName(PLUGIN_ID, "product-export-type"); //$NON-NLS-1$ >+ QualifiedName DEFAULT_PRODUCT_EXPORT_ROOT = new QualifiedName(PLUGIN_ID, "product-export-root"); //$NON-NLS-1$ > > String PLUGIN_DOC_ROOT = "/org.eclipse.pde.doc.user/"; //$NON-NLS-1$ >- >+ > // JUnit application identifiers > String LEGACY_UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.legacytestapplication"; //$NON-NLS-1$ > String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$ > String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$ >- >+ > /** > * Launch configuration attribute key. The value is a boolean specifies > * whether the launch configuration is being restarted. This does not need to >@@ -69,5 +65,5 @@ > String LAUNCHER_PDE_VERSION = "pde.version"; //$NON-NLS-1$ > String APPEND_ARGS_EXPLICITLY = "append.args"; //$NON-NLS-1$ > String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$ >- >+ > } >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.104 >diff -u -r1.104 PDEPluginImages.java >--- src/org/eclipse/pde/internal/ui/PDEPluginImages.java 19 Nov 2007 19:06:55 -0000 1.104 >+++ src/org/eclipse/pde/internal/ui/PDEPluginImages.java 11 Jan 2008 21:41:00 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.pde.internal.ui; > > import java.net.URL; >- > import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.Path; > import org.eclipse.jface.resource.ImageDescriptor; >@@ -23,20 +22,20 @@ > */ > public class PDEPluginImages { > >- private static final String NAME_PREFIX= PDEPlugin.getPluginId()+"."; //$NON-NLS-1$ >+ private static final String NAME_PREFIX = PDEPlugin.getPluginId() + "."; //$NON-NLS-1$ > > private static ImageRegistry PLUGIN_REGISTRY; >- >+ > public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$ > > /** > * Set of predefined Image Descriptors. > */ >- >- private static final String PATH_OBJ= ICONS_PATH+"obj16/"; //$NON-NLS-1$ >- private static final String PATH_VIEW = ICONS_PATH+"view16/"; //$NON-NLS-1$ >- private static final String PATH_LCL= ICONS_PATH+"elcl16/"; //$NON-NLS-1$ >- private static final String PATH_LCL_DISABLED= ICONS_PATH+"dlcl16/"; //$NON-NLS-1$ >+ >+ private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$ >+ private static final String PATH_VIEW = ICONS_PATH + "view16/"; //$NON-NLS-1$ >+ private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$ >+ private static final String PATH_LCL_DISABLED = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$ > private static final String PATH_TOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$ > private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$ > private static final String PATH_WIZBAN = ICONS_PATH + "wizban/"; //$NON-NLS-1$ >@@ -44,49 +43,49 @@ > /** > * Frequently used images > */ >- public static final String IMG_FORM_WIZ = NAME_PREFIX+"FORM_WIZ"; //$NON-NLS-1$ >- public static final String IMG_FORM_BANNER = NAME_PREFIX+"FORM_BANNER"; //$NON-NLS-1$ >+ public static final String IMG_FORM_WIZ = NAME_PREFIX + "FORM_WIZ"; //$NON-NLS-1$ >+ public static final String IMG_FORM_BANNER = NAME_PREFIX + "FORM_BANNER"; //$NON-NLS-1$ > public static final String IMG_ATT_CLASS_OBJ = NAME_PREFIX + "IMG_ATT_CLASS_OBJ"; //$NON-NLS-1$ >- public static final String IMG_ATT_FILE_OBJ = NAME_PREFIX + "IMG_ATT_FILE_OBJ"; //$NON-NLS-1$ >- public static final String IMG_ATT_IMPL_OBJ = NAME_PREFIX + "IMG_ATT_IMPL_OBJ"; //$NON-NLS-1$ >- public static final String IMG_ATT_REQ_OBJ = NAME_PREFIX + "IMG_ATT_REQ_OBJ"; //$NON-NLS-1$ >- public static final String IMG_GENERIC_XML_OBJ = NAME_PREFIX + "IMG_GENERIC_XML_OBJ"; //$NON-NLS-1$ >- public static final String OBJ_DESC_GENERATE_CLASS = NAME_PREFIX + "OBJ_DESC_GENERATE_CLASS"; //$NON-NLS-1$ >- public static final String OBJ_DESC_GENERATE_INTERFACE = NAME_PREFIX + "OBJ_DESC_GENERATE_INTERFACE"; //$NON-NLS-1$ >+ public static final String IMG_ATT_FILE_OBJ = NAME_PREFIX + "IMG_ATT_FILE_OBJ"; //$NON-NLS-1$ >+ public static final String IMG_ATT_IMPL_OBJ = NAME_PREFIX + "IMG_ATT_IMPL_OBJ"; //$NON-NLS-1$ >+ public static final String IMG_ATT_REQ_OBJ = NAME_PREFIX + "IMG_ATT_REQ_OBJ"; //$NON-NLS-1$ >+ public static final String IMG_GENERIC_XML_OBJ = NAME_PREFIX + "IMG_GENERIC_XML_OBJ"; //$NON-NLS-1$ >+ public static final String OBJ_DESC_GENERATE_CLASS = NAME_PREFIX + "OBJ_DESC_GENERATE_CLASS"; //$NON-NLS-1$ >+ public static final String OBJ_DESC_GENERATE_INTERFACE = NAME_PREFIX + "OBJ_DESC_GENERATE_INTERFACE"; //$NON-NLS-1$ > public static final String OBJ_DESC_PACKAGE = NAME_PREFIX + "OBJ_DESC_PACKAGE"; //$NON-NLS-1$ > public static final String OBJ_DESC_BUNDLE = NAME_PREFIX + "OBJ_DESC_BUNDLE"; //$NON-NLS-1$ >- >+ > /** > * OBJ16 > */ >- public static final ImageDescriptor DESC_MAIN_TAB = create(PATH_OBJ, "main_tab.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ALL_SC_OBJ = create(PATH_OBJ, "all_sc_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_MAIN_TAB = create(PATH_OBJ, "main_tab.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ALL_SC_OBJ = create(PATH_OBJ, "all_sc_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_ATT_CLASS_OBJ = create(PATH_OBJ, "att_class_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ATT_FILE_OBJ = create(PATH_OBJ, "att_file_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ATT_IMPL_OBJ = create(PATH_OBJ, "att_impl_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ATT_REQ_OBJ = create(PATH_OBJ, "att_req_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ATT_URI_OBJ = create(PATH_OBJ, "att_URI_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ATT_FILE_OBJ = create(PATH_OBJ, "att_file_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ATT_IMPL_OBJ = create(PATH_OBJ, "att_impl_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ATT_REQ_OBJ = create(PATH_OBJ, "att_req_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ATT_URI_OBJ = create(PATH_OBJ, "att_URI_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_BUNDLE_OBJ = create(PATH_OBJ, "bundle_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_CHOICE_SC_OBJ = create(PATH_OBJ, "choice_sc_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FEATURE_JAR_OBJ = create(PATH_OBJ, "ftr_jar_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FEATURE_MF_OBJ = create(PATH_OBJ, "ftr_mf_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FEATURE_OBJ = create(PATH_OBJ, "feature_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FEATURE_JAR_OBJ = create(PATH_OBJ, "ftr_jar_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FEATURE_MF_OBJ = create(PATH_OBJ, "ftr_mf_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FEATURE_OBJ = create(PATH_OBJ, "feature_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_NOREF_FEATURE_OBJ = create(PATH_OBJ, "noref_feature_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ELREF_SC_OBJ = create(PATH_OBJ, "elref_sc_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ELREF_SC_OBJ = create(PATH_OBJ, "elref_sc_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_EXTENSIONS_OBJ = create(PATH_OBJ, "extensions_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_EXTENSION_OBJ = create(PATH_OBJ, "extension_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_EXT_PLUGIN_OBJ = create(PATH_OBJ, "ext_plugin_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_EXT_FRAGMENT_OBJ = create(PATH_OBJ, "external_frgmt_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_EXT_POINTS_OBJ = create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_EXT_POINT_OBJ = create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_GEL_SC_OBJ = create(PATH_OBJ, "gel_sc_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_EXT_PLUGIN_OBJ = create(PATH_OBJ, "ext_plugin_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_EXT_FRAGMENT_OBJ = create(PATH_OBJ, "external_frgmt_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_EXT_POINTS_OBJ = create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_EXT_POINT_OBJ = create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_GEL_SC_OBJ = create(PATH_OBJ, "gel_sc_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_GENERIC_XML_OBJ = create(PATH_OBJ, "generic_xml_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_GROUP_SC_OBJ = create(PATH_OBJ, "group_sc_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_JAR_OBJ = create(PATH_OBJ, "jar_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_JAR_LIB_OBJ = create(PATH_OBJ, "jar_l_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_JAVA_LIB_OBJ = create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_OVERVIEW_OBJ = create(PATH_OBJ, "overview_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_PAGE_OBJ = create(PATH_OBJ, "page_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_GROUP_SC_OBJ = create(PATH_OBJ, "group_sc_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_JAR_OBJ = create(PATH_OBJ, "jar_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_JAR_LIB_OBJ = create(PATH_OBJ, "jar_l_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_JAVA_LIB_OBJ = create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_OVERVIEW_OBJ = create(PATH_OBJ, "overview_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_PAGE_OBJ = create(PATH_OBJ, "page_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_PLUGIN_MF_OBJ = create(PATH_OBJ, "plugin_mf_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_FRAGMENT_MF_OBJ = create(PATH_OBJ, "frgmt_mf_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_BUILD_VAR_OBJ = create(PATH_OBJ, "build_var_obj.gif"); //$NON-NLS-1$ >@@ -105,29 +104,33 @@ > public static final ImageDescriptor DESC_CSCONCLUSION_OBJ = create(PATH_OBJ, "cheatsheet_conclusion_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_CSUNSUPPORTED_OBJ = create(PATH_OBJ, "cheatsheet_unsupported_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_CHEATSHEET_OBJ = create(PATH_OBJ, "cheatsheet_obj.gif"); //$NON-NLS-1$ >- >+ > public static final ImageDescriptor DESC_TOC_OBJ = create(PATH_OBJ, "toc_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_TOC_TOPIC_OBJ = create(PATH_OBJ, "toc_topic_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_TOC_LEAFTOPIC_OBJ = create(PATH_OBJ, "toc_leaftopic_obj.gif"); //$NON-NLS-1$ > 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$ >- >- public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_SETTINGS_OBJ = create(PATH_OBJ, "settings.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FRAGMENT_OBJ = create(PATH_OBJ, "frgmt_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FRAGMENT_DIS_OBJ = create(PATH_OBJ, "frgmt_dis_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FRAGMENTS_OBJ = create(PATH_OBJ, "frgmts_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_RUNTIME_OBJ = create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_SCHEMA_OBJ = create(PATH_OBJ, "schema_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_SETTINGS_OBJ = create(PATH_OBJ, "settings.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FRAGMENT_OBJ = create(PATH_OBJ, "frgmt_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FRAGMENT_DIS_OBJ = create(PATH_OBJ, "frgmt_dis_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FRAGMENTS_OBJ = create(PATH_OBJ, "frgmts_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_RUNTIME_OBJ = create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_SCHEMA_OBJ = create(PATH_OBJ, "schema_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_SCOMP_JAR_OBJ = create(PATH_OBJ, "scomp_jar_obj.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_SEQ_SC_OBJ = create(PATH_OBJ, "seq_sc_obj.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_SEQ_SC_OBJ = create(PATH_OBJ, "seq_sc_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_DOC_SECTION_OBJ = create(PATH_OBJ, "doc_section_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_ALERT_OBJ = create(PATH_OBJ, "alert_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_TSK_ALERT_OBJ = create(PATH_OBJ, "tsk_alert_obj.gif"); //$NON-NLS-1$ >@@ -158,22 +161,22 @@ > public static final ImageDescriptor DESC_SITE_XML_OBJ = create(PATH_OBJ, "site_xml_obj.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_IMAGE_APPLICATION = create(PATH_OBJ, "image_application.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_FOCUS_ON = create(PATH_OBJ, "focus.gif"); //$NON-NLS-1$ >- >+ > /** > * OVR16 > */ >- public static final ImageDescriptor DESC_DOC_CO = create(PATH_OVR, "doc_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_WARNING_CO = create(PATH_OVR, "warning_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_ERROR_CO = create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_EXPORT_CO = create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_EXTERNAL_CO = create(PATH_OVR, "external_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_BINARY_CO = create(PATH_OVR, "binary_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_JAVA_CO = create(PATH_OVR, "java_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_JAR_CO = create(PATH_OVR, "jar_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_PROJECT_CO = create(PATH_OVR, "project_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_OPTIONAL_CO = create(PATH_OVR, "optional_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_INTERNAL_CO = create(PATH_OVR, "internal_co.gif"); //$NON-NLS-1$ >- public static final ImageDescriptor DESC_FRIEND_CO = create(PATH_OVR, "friend_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_DOC_CO = create(PATH_OVR, "doc_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_WARNING_CO = create(PATH_OVR, "warning_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ERROR_CO = create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_EXPORT_CO = create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_EXTERNAL_CO = create(PATH_OVR, "external_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_BINARY_CO = create(PATH_OVR, "binary_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_JAVA_CO = create(PATH_OVR, "java_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_JAR_CO = create(PATH_OVR, "jar_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_PROJECT_CO = create(PATH_OVR, "project_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_OPTIONAL_CO = create(PATH_OVR, "optional_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_INTERNAL_CO = create(PATH_OVR, "internal_co.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_FRIEND_CO = create(PATH_OVR, "friend_co.gif"); //$NON-NLS-1$ > > /** > * TOOL16 >@@ -193,7 +196,7 @@ > public static final ImageDescriptor DESC_EXPORT_PRODUCT_TOOL = create(PATH_TOOL, "exp_product.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_EXPORT_FEATURE_TOOL = create(PATH_TOOL, "exp_deployfeat.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_BUILD_TOOL = create(PATH_TOOL, "build_exec.gif"); //$NON-NLS-1$ >- >+ > /** > * LCL > */ >@@ -226,7 +229,7 @@ > public static final ImageDescriptor DESC_HISTORY_LIST = create(PATH_LCL, "history_list.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_CLEAR = create(PATH_LCL, "clear.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_FILTER = create(PATH_LCL, "filter_ps.gif"); //$NON-NLS-1$ >- >+ > public static final ImageDescriptor DESC_ADD_ATT_DISABLED = create(PATH_LCL_DISABLED, "add_att.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_ALPHAB_SORT_CO_DISABLED = create(PATH_LCL_DISABLED, "alphab_sort_co.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_CLONE_ATT_DISABLED = create(PATH_LCL_DISABLED, "clone_att.gif"); //$NON-NLS-1$ >@@ -248,16 +251,15 @@ > public static final ImageDescriptor DESC_HISTORY_LIST_DISABLED = create(PATH_LCL_DISABLED, "history_list.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_DCLEAR = create(PATH_LCL_DISABLED, "clear.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_FILTER_DISABLED = create(PATH_LCL_DISABLED, "filter_ps.gif"); //$NON-NLS-1$ >- >+ > public static final ImageDescriptor DESC_RUN_EXC = create(PATH_OBJ, "run_exc.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_DEBUG_EXC = create(PATH_OBJ, "debug_exc.gif"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_PROFILE_EXC = create(PATH_OBJ, "profile_exc.gif"); //$NON-NLS-1$ > >- > /** > * WIZ > */ >- public static final ImageDescriptor DESC_NEWPPRJ_WIZ = create(PATH_WIZBAN, "newpprj_wiz.png"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_NEWPPRJ_WIZ = create(PATH_WIZBAN, "newpprj_wiz.png"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_NEWFRAGPRJ_WIZ = create(PATH_WIZBAN, "newfprj_wiz.png"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_DEFCON_WIZ = create(PATH_WIZBAN, "defcon_wiz.png"); //$NON-NLS-1$ > public static final ImageDescriptor DESC_TARGET_WIZ = create(PATH_WIZBAN, "target_wiz.png"); //$NON-NLS-1$ >@@ -285,37 +287,40 @@ > /** > * View > */ >- public static final ImageDescriptor DESC_ARGUMENT_TAB = create(PATH_VIEW, "variable_tab.gif"); //$NON-NLS-1$ >+ public static final ImageDescriptor DESC_ARGUMENT_TAB = create(PATH_VIEW, "variable_tab.gif"); //$NON-NLS-1$ >+ > private static ImageDescriptor create(String prefix, String name) { > return ImageDescriptor.createFromURL(makeImageURL(prefix, name)); > } >+ > public static Image get(String key) { >- if (PLUGIN_REGISTRY==null) initialize(); >+ if (PLUGIN_REGISTRY == null) >+ initialize(); > return PLUGIN_REGISTRY.get(key); > } > >-/* package */ >-private static final void initialize() { >- PLUGIN_REGISTRY = new ImageRegistry(); >- manage(IMG_ATT_CLASS_OBJ,DESC_ATT_CLASS_OBJ); >- manage(IMG_ATT_FILE_OBJ, DESC_ATT_FILE_OBJ); >- manage(IMG_ATT_IMPL_OBJ, DESC_ATT_IMPL_OBJ); >- manage(IMG_ATT_REQ_OBJ, DESC_ATT_REQ_OBJ); >- manage(IMG_GENERIC_XML_OBJ, DESC_GENERIC_XML_OBJ); >- manage(OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS); >- manage(OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE); >- manage(OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ); >- manage(OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ); >-} >+ /* package */ >+ private static final void initialize() { >+ PLUGIN_REGISTRY = new ImageRegistry(); >+ manage(IMG_ATT_CLASS_OBJ, DESC_ATT_CLASS_OBJ); >+ manage(IMG_ATT_FILE_OBJ, DESC_ATT_FILE_OBJ); >+ manage(IMG_ATT_IMPL_OBJ, DESC_ATT_IMPL_OBJ); >+ manage(IMG_ATT_REQ_OBJ, DESC_ATT_REQ_OBJ); >+ manage(IMG_GENERIC_XML_OBJ, DESC_GENERIC_XML_OBJ); >+ manage(OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS); >+ manage(OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE); >+ manage(OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ); >+ manage(OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ); >+ } > >-private static URL makeImageURL(String prefix, String name) { >- String path = "$nl$/" + prefix + name; //$NON-NLS-1$ >- return FileLocator.find(PDEPlugin.getDefault().getBundle(), new Path(path), null); >-} >+ private static URL makeImageURL(String prefix, String name) { >+ String path = "$nl$/" + prefix + name; //$NON-NLS-1$ >+ return FileLocator.find(PDEPlugin.getDefault().getBundle(), new Path(path), null); >+ } > >-public static Image manage(String key, ImageDescriptor desc) { >- Image image = desc.createImage(); >- PLUGIN_REGISTRY.put(key, image); >- return image; >-} >+ public static Image manage(String key, ImageDescriptor desc) { >+ Image image = desc.createImage(); >+ PLUGIN_REGISTRY.put(key, image); >+ return image; >+ } > } >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 11 Jan 2008 21:40: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/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.2 >diff -u -r1.2 TocHTMLWizardPage.java >--- src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java 29 Aug 2007 15:29:34 -0000 1.2 >+++ src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java 11 Jan 2008 21:41:00 -0000 >@@ -18,7 +18,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; > >@@ -58,10 +58,10 @@ > return false; > } > >- if(!TocExtensionUtil.hasValidPageExtension(new Path(fLastFilename))) >+ if(!HelpEditorUtil.hasValidPageExtension(new Path(fLastFilename))) > { String message = NLS.bind( > PDEUIMessages.TocHTMLWizardPage_badExtension, >- TocExtensionUtil.getPageExtensionList()); >+ HelpEditorUtil.getPageExtensionList()); > > setErrorMessage(message); > return false; >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/plugin.xml,v >retrieving revision 1.434 >diff -u -r1.434 plugin.xml >--- plugin.xml 2 Jan 2008 23:19:15 -0000 1.434 >+++ plugin.xml 11 Jan 2008 21:40: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="Context Help Editor"> >+ <contentTypeBinding >+ contentTypeId="org.eclipse.help.contexts"> >+ </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,200 @@ >+/******************************************************************************* >+ * 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.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.*; >+ >+/** >+ * TocAbstractDetails >+ * >+ */ >+public abstract class CtxHelpAbstractDetails extends PDEDetails { >+ >+ 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) { >+ configureParentLayout(parent); >+ createDetails(parent); >+ hookListeners(); >+ } >+ >+ /** >+ * @param parent >+ */ >+ private void configureParentLayout(Composite parent) { >+ parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1)); >+ } >+ >+ /** >+ * @param parent >+ */ >+ 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); >+ } >+ >+ /** >+ * >+ */ >+ protected abstract void createFields(Composite parent); >+ >+ /** >+ * >+ */ >+ protected abstract String getDetailsTitle(); >+ >+ /** >+ * >+ */ >+ protected abstract String getDetailsDescription(); >+ >+ /** >+ * >+ */ >+ public abstract void updateFields(); >+ >+ /** >+ * >+ */ >+ public abstract void hookListeners(); >+ >+ /* (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 >+ */ >+ public boolean isEditableElement() { >+ return fMasterSection.isEditable(); >+ } >+ >+ /** >+ * @return >+ */ >+ public FormToolkit getToolkit() { >+ return getManagedForm().getToolkit(); >+ } >+ >+ /** >+ * @return >+ */ >+ public CtxHelpTreeSection getMasterSection() { >+ return fMasterSection; >+ } >+ >+ /** >+ * @param selection >+ * @return >+ */ >+ 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(); >+ } >+ >+ protected void createLabel(Composite client, FormToolkit toolkit, String text) { >+ Label label = toolkit.createLabel(client, text, SWT.WRAP); >+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ gd.horizontalSpan = NUM_COLUMNS; >+ label.setLayoutData(gd); >+ } >+ >+ protected void createSpace(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), ""); //$NON-NLS-1$ >+ } >+ >+} >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,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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; >+ >+/** >+ * TocFormOutlinePage >+ * >+ */ >+public class CtxHelpFormOutlinePage extends FormOutlinePage { >+ /** >+ * @param editor >+ */ >+ public CtxHelpFormOutlinePage(PDEFormEditor editor) { >+ super(editor); >+ } >+ >+ /** >+ * TocLabelProvider >+ * >+ */ >+ private class CtxHelpLabelProvider extends BasicLabelProvider { >+ public String getText(Object obj) { >+ if (obj instanceof CtxHelpObject) { >+ return getObjectText((CtxHelpObject) obj); >+ } >+ return super.getText(obj); >+ } >+ } >+ >+ /** >+ * @param obj >+ * @return >+ */ >+ protected String getObjectText(CtxHelpObject obj) { >+ return PDETextHelper.translateReadText(obj.getName()); >+ } >+ >+ /* (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,157 @@ >+/******************************************************************************* >+ * 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.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; >+ >+/** >+ * TocPage >+ * >+ */ >+public class CtxHelpPage extends PDEFormPage implements IModelChangedListener { >+ public static final String PAGE_ID = "ctxHelpPage"; //$NON-NLS-1$ >+ >+ private CtxHelpBlock fBlock; >+ >+ /** >+ * @param editor >+ */ >+ public CtxHelpPage(FormEditor editor) { >+ super(editor, PAGE_ID, PDEUIMessages.TocPage_title); >+ fBlock = new CtxHelpBlock(this); >+ } >+ >+ /** >+ * @return >+ */ >+ 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)) { >+ createErrorContent(managedForm, model); >+ 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("Context-Sensitive Help Content"); >+ // 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); >+ } >+ >+ private void createErrorContent(IManagedForm managedForm, CtxHelpModel model) { >+ // Create a formatted error page >+ createFormErrorContent(managedForm, PDEUIMessages.TocPage_msgTOCLoadFailure, PDEUIMessages.TocPage_msgTOCParsingFailure, null); >+ } >+ >+ /* (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) { >+ // Inform the block >+ fBlock.modelChanged(event); >+ } >+ >+ /** >+ * @return >+ */ >+ public ISelection getSelection() { >+ return fBlock.getSelection(); >+ } >+ >+ 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,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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; >+ >+public class CtxHelpInputContextManager extends InputContextManager { >+ >+ /** >+ * @param editor >+ */ >+ 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/CtxHelpDropAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDropAdapter.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDropAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDropAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,228 @@ >+/******************************************************************************* >+ * 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.ctxhelp; >+ >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.ViewerDropAdapter; >+import org.eclipse.pde.core.IBaseModel; >+import org.eclipse.pde.internal.ui.editor.ModelDataTransfer; >+import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil; >+import org.eclipse.swt.dnd.*; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Item; >+ >+/** >+ * TocDropAdapter - implements drop behaviour for the TOC Tree Section. >+ * It extends ViewerDropAdapter for advanced feedback behaviour, but >+ * mostly overrides the specified drop behaviour. >+ */ >+public class CtxHelpDropAdapter extends ViewerDropAdapter { >+ private CtxHelpTreeSection fSection; >+ >+ /** >+ * Constant describing the position of the cursor relative >+ * to the target object. This means the mouse is positioned >+ * slightly after the target, but not after its children if it is >+ * expanded. >+ * @see #getCurrentLocation() >+ */ >+ public static final int LOCATION_JUST_AFTER = 5; >+ >+ public CtxHelpDropAdapter(TreeViewer tocTree, CtxHelpTreeSection section) { >+ super(tocTree); >+ fSection = section; >+ } >+ >+ /** >+ * Returns the position of the given event's coordinates relative to its target. >+ * The position is determined to be before, after, or on the item, based on >+ * some threshold value. >+ * >+ * @param event the event >+ * @return one of the <code>LOCATION_* </code>constants defined in this class >+ */ >+ protected int determineLocation(DropTargetEvent event) { >+ if (!(event.item instanceof Item)) { >+ return LOCATION_NONE; >+ } >+ Item item = (Item) event.item; >+ Point coordinates = new Point(event.x, event.y); >+ coordinates = getViewer().getControl().toControl(coordinates); >+ if (item != null) { >+ Rectangle bounds = getBounds(item); >+ if (bounds == null) { >+ return LOCATION_NONE; >+ } >+ if ((coordinates.y - bounds.y) < 5) { >+ return LOCATION_BEFORE; >+ } >+ if ((bounds.y + bounds.height - coordinates.y) < 5) { >+ if ((bounds.y - coordinates.y) < 5) { >+ return LOCATION_JUST_AFTER; >+ } >+ return LOCATION_AFTER; >+ } >+ } >+ return LOCATION_ON; >+ } >+ >+ /* (non-Javadoc) >+ * A new drag has entered the widget. Do file validation if necessary, >+ * and then set the Drag and Drop mode. >+ */ >+ public void dragEnter(DropTargetEvent event) { >+ validateFileDrop(event); >+ setDNDMode(event); >+ } >+ >+ /* (non-Javadoc) >+ * Override the dragOver behaviour to directly supply event feedback >+ * but do nothing else. >+ */ >+ public void dragOver(DropTargetEvent event) { >+ int currentLocation = determineLocation(event); >+ switch (currentLocation) { >+ case LOCATION_BEFORE : >+ event.feedback = DND.FEEDBACK_INSERT_BEFORE; >+ break; >+ case LOCATION_AFTER : >+ case LOCATION_JUST_AFTER : >+ event.feedback = DND.FEEDBACK_INSERT_AFTER; >+ break; >+ case LOCATION_ON : >+ default : >+ event.feedback = DND.FEEDBACK_SELECT; >+ break; >+ } >+ >+ event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL; >+ } >+ >+ /* (non-Javadoc) >+ * The Drag and Drop operation changed. Change the operation to a valid one >+ * if necessary. >+ */ >+ public void dragOperationChanged(DropTargetEvent event) { >+ validateFileDrop(event); >+ setDNDMode(event); >+ } >+ >+ /** >+ * Set the Drag and Drop mode depending on the dragged items and event >+ * details. Files can only be copied, not linked or moved. >+ * Model data objects can have any operation occur. >+ * >+ * All other objects cannot be dropped. >+ * >+ * @param event The drop event to change. >+ */ >+ private void setDNDMode(DropTargetEvent event) { >+ if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) { //If a file is being dragged >+ if (event.detail == DND.DROP_DEFAULT) { //If no modifier key is pressed >+ //set the operation to DROP_COPY if available >+ //DROP_NONE otherwise >+ event.detail = (event.operations & DND.DROP_COPY); >+ } else { //If a modifier key is pressed for a file and the operation isn't a copy, >+ //disallow it >+ event.detail &= DND.DROP_COPY; >+ } >+ } >+ //The only other transfer type allowed is a Model Data Transfer >+ else if (!ModelDataTransfer.getInstance().isSupportedType(event.currentDataType)) { //disallow drag if the transfer is not Model Data or Files >+ event.detail = DND.DROP_NONE; >+ } >+ } >+ >+ /** >+ * Ensure that, if files are being dropped, they have valid >+ * file extensions for the TOC Editor (HTML pages and XML documents). >+ * >+ * Invalidate the drop if this condition is not met. >+ * >+ * @param event The drop event containing the transfer. >+ */ >+ private void validateFileDrop(DropTargetEvent event) { >+ if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) { >+ IBaseModel model = fSection.getPage().getModel(); >+ String[] fileNames = (String[]) FileTransfer.getInstance().nativeToJava(event.currentDataType); >+ for (int i = 0; i < fileNames.length; i++) { >+ IPath path = new Path(fileNames[i]); >+ >+ // Make sure that the file is in the workspace >+ if (ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path) == null) { >+ event.detail = DND.DROP_NONE; >+ return; >+ } >+ >+ 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 (HelpEditorUtil.isCurrentResource(path, model)) { >+ event.detail = DND.DROP_NONE; >+ return; >+ } >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * Override the drop behaviour in order to directly manage the drop event >+ */ >+ public void drop(DropTargetEvent event) { >+ Object target = determineTarget(event); >+ int location = determineLocation(event); >+ if (!fSection.performDrop(target, event.data, location)) { >+ event.detail = DND.DROP_NONE; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * Override the behaviour of ViewerDropAdapter#dragLeave(org.eclipse.swt.dnd.DropTargetEvent) >+ * >+ * @see org.eclipse.swt.dnd.DropTargetAdapter#dragLeave(org.eclipse.swt.dnd.DropTargetEvent) >+ */ >+ public void dragLeave(DropTargetEvent event) { //NO-OP >+ } >+ >+ /* (non-Javadoc) >+ * Override the behaviour of ViewerDropAdapter#dropAccept(org.eclipse.swt.dnd.DropTargetEvent) >+ * >+ * @see org.eclipse.swt.dnd.DropTargetAdapter#dropAccept(org.eclipse.swt.dnd.DropTargetEvent) >+ */ >+ public void dropAccept(DropTargetEvent event) { //NO-OP >+ } >+ >+ //These methods are never called because much of ViewerDropAdapter's >+ //behaviour is overridden, but they must be implemented. >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object) >+ */ >+ public boolean performDrop(Object data) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData) >+ */ >+ public boolean validateDrop(Object target, int operation, TransferData transferType) { >+ return false; >+ } >+ >+} >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,140 @@ >+/******************************************************************************* >+ * 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.ctxhelp.details; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpContext; >+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; >+ >+public class CtxHelpContextDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpContext fContext; >+ private FormEntry fIdEntry; >+ private FormEntry fTitleEntry; >+ private FormEntry fDescEntry; >+ >+ /** >+ * @param masterSection >+ */ >+ public CtxHelpContextDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the help context id:"); >+ fIdEntry = new FormEntry(parent, getManagedForm().getToolkit(), "ID:", SWT.NONE); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the context description that will be displayed to the user:"); >+ fDescEntry = new FormEntry(parent, getManagedForm().getToolkit(), "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(), "Override the default title by specifying one here:"); >+ fTitleEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Title:", SWT.NONE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle() >+ */ >+ protected String getDetailsTitle() { >+ return "Context Details"; >+ } >+ >+ /* (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.toc.TocAbstractDetails#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.toc.TocAbstractDetails#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.ui.forms.IPartSelectionListener#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/CtxHelpRemoveAction.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpRemoveAction.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpRemoveAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpRemoveAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/******************************************************************************* >+ * 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.ctxhelp; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+ >+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); >+ } >+ >+ 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); >+ // Remove the TOC object >+ 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; >+ } >+ } >+ } >+ >+ /** >+ * @return the object that should be selected >+ * after the current one is removed >+ */ >+ public CtxHelpObject getNextSelection() { >+ return fObjectToSelect; >+ } >+ >+ public void clearNextSelection() { >+ fObjectToSelect = null; >+ } >+ >+} >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,63 @@ >+/******************************************************************************* >+ * 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.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; >+ >+/** >+ * TocContentProvider >+ */ >+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,1178 @@ >+/******************************************************************************* >+ * 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.ctxhelp; >+ >+import java.util.*; >+import java.util.List; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+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.*; >+import org.eclipse.pde.internal.ui.editor.actions.CollapseAction; >+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.*; >+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; >+ >+/** >+ * TocTreeSection - The section that displays the TOC >+ * tree structure and any buttons used to manipulate it. >+ * This is the main section that the user will interact >+ * with the TOC through. >+ */ >+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; >+ >+ private static final int F_UP_FLAG = -1; >+ private static final int F_DOWN_FLAG = 1; >+ >+ // The action that collapses down the TOC tree >+ private CollapseAction fCollapseAction; >+ >+ // The actions that will add each type of TOC 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; >+ >+ // The adapter that will listen for drag events in the tree >+ private CtxHelpDragAdapter fDragAdapter; >+ >+ /** 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; >+ >+ 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); >+ } >+ } >+ } >+ >+ /** >+ * Constructs a new TOC tree section. >+ * >+ * @param formPage The page that will hold this new tree section >+ * @param parent The parent composite in the page that will contain the section widgets >+ */ >+ public CtxHelpTreeSection(PDEFormPage formPage, Composite parent) { >+ >+ /* Create a new section with a description area, and some buttons. >+ * The null entries in the String array will become blank space >+ * separators between the buttons. >+ */ >+ super(formPage, parent, Section.DESCRIPTION, new String[] {"Add Context", null, "Add Topic", "Add Command", 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) { >+ // Get the model >+ fModel = (CtxHelpModel) getPage().getModel(); >+ >+ // Create a container in the section >+ Composite container = createClientContainer(section, 2, toolkit); >+ // Create a TOC tree in the new container >+ createTree(container, toolkit); >+ toolkit.paintBordersFor(container); >+ section.setText(PDEUIMessages.TocTreeSection_title); >+ section.setDescription(PDEUIMessages.TocTreeSection_sectionDescription); >+ section.setClient(container); >+ >+ createCommands(); >+ >+ initializeTreeViewer(); >+ createSectionToolbar(section, toolkit); >+ >+ // Create the adapted listener for the filter entry field >+ fFilteredTree.createUIListenerEntryFilter(this); >+ } >+ >+ private void createCommands() { >+ fAddContextAction = new CtxHelpAbstractAddAction() { >+ public void run() { >+ if (fParentObject != null) { >+ CtxHelpContext context = fParentObject.getModel().getFactory().createContext(); >+ String id = PDELabelUtility.generateName(getChildNames(), "Help_Context"); >+ context.setID(id); >+ addChild(context); >+ } >+ } >+ }; >+ fAddContextAction.setText("Context"); >+ fAddTopicAction = new CtxHelpAbstractAddAction() { >+ public void run() { >+ if (fParentObject != null) { >+ CtxHelpTopic topic = fParentObject.getModel().getFactory().createTopic(); >+ String label = PDELabelUtility.generateName(getChildNames(), "Help_Topic"); >+ topic.setLabel(label); >+ addChild(topic); >+ } >+ } >+ }; >+ fAddTopicAction.setText("Topic"); >+ fAddCommandAction = new CtxHelpAbstractAddAction() { >+ public void run() { >+ if (fParentObject != null) { >+ CtxHelpCommand command = fParentObject.getModel().getFactory().createCommand(); >+ String label = PDELabelUtility.generateName(getChildNames(), "Help_Command"); >+ command.setLabel(label); >+ addChild(command); >+ } >+ } >+ }; >+ fAddCommandAction.setText("Command"); >+ >+ fRemoveObjectAction = new CtxHelpRemoveAction(); >+ >+ fOpenLinkAction = new OpenLinkAction(); >+ } >+ >+ /** >+ * Adds a link (with hand cursor) for tree 'Collapse All' action, >+ * which collapses the TOC 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 >+ fCollapseAction = new CollapseAction(fTree, PDEUIMessages.ExtensionsPage_collapseAll, 1, fModel.getCtxHelpRoot()); >+ toolBarManager.add(fCollapseAction); >+ >+ toolBarManager.update(true); >+ section.setTextClient(toolbar); >+ } >+ >+ /** >+ * Create the tree widget that will contain the TOC >+ * >+ * @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); >+ >+ createTreeListeners(); >+ initDragAndDrop(); >+ } >+ >+ /** >+ * Initialize the section's drag and drop capabilities >+ */ >+ private void initDragAndDrop() { >+ int ops = DND.DROP_COPY; >+ if (isEditable()) { >+ ops |= DND.DROP_MOVE; >+ } >+ >+ //Content dragged from the tree viewer can be treated as model objects (TocObjects) >+ //or as text (XML representation of the TocObjects) >+ Transfer[] dragTransfers = new Transfer[] {ModelDataTransfer.getInstance(), TextTransfer.getInstance()}; >+ fDragAdapter = new CtxHelpDragAdapter(this); >+ fTree.addDragSupport(ops, dragTransfers, fDragAdapter); >+ >+ if (isEditable()) { //Model objects and files can be dropped onto the viewer >+ //TODO: Consider allowing drops/pastes of pure XML text >+ Transfer[] dropTransfers = new Transfer[] {ModelDataTransfer.getInstance(), FileTransfer.getInstance()}; >+ fTree.addDropSupport(ops | DND.DROP_DEFAULT, dropTransfers, new CtxHelpDropAdapter(fTree, this)); >+ } >+ } >+ >+ /** >+ * Create the action listeners for the tree. >+ */ >+ private void createTreeListeners() { >+ // Create listener for the outline view 'link with editor' toggle button >+ fTree.addPostSelectionChangedListener(getPage().getPDEEditor().new PDEFormEditorChangeListener()); >+ } >+ >+ /** >+ * 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 ineditable >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, isEditable()); >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, isEditable()); >+ getTreePart().setButtonEnabled(F_BUTTON_ADD_TOPIC, isEditable()); >+ >+ // Set to false because initial node selected is the root TOC node >+ getTreePart().setButtonEnabled(F_BUTTON_REMOVE, false); >+ // Set to false because initial node selected is the root TOC node >+ getTreePart().setButtonEnabled(F_BUTTON_UP, false); >+ // Set to false because initial node selected is the root TOC node >+ getTreePart().setButtonEnabled(F_BUTTON_DOWN, false); >+ >+ //Initially, the root TOC element is selected >+ // fTree.setSelection(new StructuredSelection(root), true); >+ // fTree.expandToLevel(0); >+ } >+ >+ /* (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) { // Select the item in the tree >+ 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 section >+ */ >+ 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) { >+ // Get the current selection >+ IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); >+ Object object = selection.getFirstElement(); >+ // Has to be null or a CtxHelpObject object >+ CtxHelpObject firstSelectedObject = (CtxHelpObject) object; >+ >+ if (firstSelectedObject != null) { >+ MenuManager submenu = new MenuManager(PDEUIMessages.Menus_new_label); >+ >+ // Populate the "New" sub-menu >+ 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()); >+ } >+ } >+ >+ 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()); >+ >+ if (updateRemoveActionWithSelection(selection)) { >+ manager.add(fRemoveObjectAction); >+ manager.add(new Separator()); >+ } >+ >+ } >+ >+ 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; >+ } >+ } >+ >+ // Add the "Show In" action and its contributions >+ IMenuManager showInMenu = new MenuManager(showInLabel); >+ showInMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getPage().getSite().getWorkbenchWindow())); >+ >+ manager.add(showInMenu); >+ } >+ >+ 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; >+ } >+ >+ 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; >+ } >+ >+ 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; >+ } >+ >+ 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; >+ } >+ >+ 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.StructuredViewerSection#canPaste(java.lang.Object, java.lang.Object[]) >+ */ >+ protected boolean canPaste(Object targetObject, Object[] sourceObjects) { >+ return true; >+ } >+ >+ /* (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#doPaste(java.lang.Object, java.lang.Object[]) >+ */ >+ protected void doPaste(Object targetObject, Object[] sourceObjects) { >+ performDrop(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 a document with the specified path >+ * >+ * @param path a path to a resource, relative to this TOC's root project >+ */ >+ private 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 = findResource(resourcePath); >+ if (resource != null && resource instanceof IFile) { >+ openResource(resource); >+ } else { >+ MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, PDEUIMessages.WindowImagesSection_warning); >+ } >+ } >+ >+ public IFile openFile(String stringPath) { >+ IPath path = new Path(stringPath); >+ if (isEditable()) { >+ if (!path.isEmpty()) { >+ IResource page = findResource(path); >+ if (page != null && page instanceof IFile) { >+ openResource(page); >+ return null; >+ } >+ } >+ >+ // TODO Consider having a new wizard >+ // return showNewWizard(path, isTOCFile); >+ } >+ >+ return null; >+ } >+ >+ // private IFile showNewWizard(String path, boolean tocWizard) { >+ // TocHTMLWizard wizard; >+ // if (tocWizard) { >+ // wizard = new NewTocFileWizard(); >+ // } else { >+ // wizard = new TocHTMLWizard(); >+ // } >+ // >+ // // By default, the file will be created in the same project as the TOC >+ // IResource selectedFolder = fModel.getUnderlyingResource().getProject(); >+ // String filename = null; >+ // >+ // // Find the folder associated with the specified path >+ // IPath initialFolder = new Path(path.trim()); >+ // if (!initialFolder.isEmpty()) { >+ // IPath newPath = selectedFolder.getFullPath().append(initialFolder); >+ // >+ // IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ // IResource newFolder = root.findMember(newPath); >+ // >+ // if (newFolder == null) { >+ // if (!newPath.hasTrailingSeparator()) { >+ // filename = newPath.lastSegment(); >+ // } >+ // } >+ // >+ // while (newFolder == null && !newPath.isEmpty()) { >+ // newPath = newPath.removeLastSegments(1); >+ // newFolder = root.findMember(newPath); >+ // } >+ // >+ // if (newFolder != null) { >+ // selectedFolder = newFolder; >+ // } >+ // } >+ // >+ // // Select the project in the wizard >+ // wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(selectedFolder)); >+ // >+ // // Create the dialog for the wizard >+ // WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard); >+ // dialog.create(); >+ // // Get the wizard page >+ // IWizardPage wizardPage; >+ // wizardPage = wizard.getStartingPage(); >+ // if (!(wizardPage instanceof WizardNewFileCreationPage)) { >+ // return null; >+ // } >+ // >+ // WizardNewFileCreationPage page = (WizardNewFileCreationPage) wizardPage; >+ // if (filename != null) { >+ // page.setFileName(filename); >+ // // Inhibit the error message when the wizard is first opened >+ // page.setErrorMessage(null); >+ // } >+ // >+ // if (dialog.open() == Window.OK) { >+ // return wizard.getNewResource(); >+ // } >+ // >+ // return null; >+ // } >+ // >+ private IResource findResource(IPath resourcePath) { >+ IProject pluginProject = fModel.getUnderlyingResource().getProject(); >+ return pluginProject.findMember(resourcePath); >+ } >+ >+ private void openResource(IResource resource) { >+ IPath path = resource.getFullPath(); >+ if (isFileValidInContext(path)) { >+ try { >+ IDE.openEditor(PDEPlugin.getActivePage(), (IFile) resource, true); >+ } catch (PartInitException e) { //suppress exception >+ } >+ } >+ } >+ >+ private boolean isFileValidInContext(IPath path) { >+ String message = null; >+ >+ if (HelpEditorUtil.hasValidPageExtension(path)) { >+ return true; >+ } >+ message = PDEUIMessages.TocPage_invalidHTMLFile; >+ MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, message); >+ return false; >+ } >+ >+ /** >+ * Perform a drop of the specified objects on the target in the widget >+ * >+ * @param currentTarget The object that the drop will occur near/on >+ * @param dropped The dropped objects >+ * @param location The location of the drop relative to the target >+ * >+ * @return true iff the drop was successful >+ */ >+ public boolean performDrop(Object currentTarget, Object dropped, int location) { >+ if (dropped instanceof Object[]) { >+ CtxHelpObject target = (CtxHelpObject) currentTarget; >+ // Determine the object that the dropped objects will be the >+ // children of >+ >+ CtxHelpObject targetParent = determineParent(target, location); >+ >+ if (location == CtxHelpDropAdapter.LOCATION_JUST_AFTER && targetParent == target && !target.getChildren().isEmpty() && fTree.getExpandedState(target)) { >+ // If the drop occurs just after a parentable object >+ // and it is expanded, then insert the dropped items >+ // as the first children of the parent >+ location = ViewerDropAdapter.LOCATION_BEFORE; >+ target = (CtxHelpObject) target.getChildren().get(0); >+ } >+ >+ if (targetParent != null) { // Get the TocObject versions of the dropped objects >+ ArrayList objectsToAdd = getObjectsToAdd((Object[]) dropped, targetParent); >+ >+ if (objectsToAdd != null && !objectsToAdd.isEmpty()) { >+ if (fDragAdapter.getDraggedElements() != null && fDragAdapter.getDraggedElements().size() == 1 && currentTarget == fDragAdapter.getDraggedElements().get(0)) { // Last-minute check: ignore drops of an object onto/near itself >+ // to avoid unnecessarily dirtying the page >+ return false; >+ } >+ >+ boolean insertBefore = (location == ViewerDropAdapter.LOCATION_BEFORE); >+ >+ // Add the objects >+ handleMultiAddAction(objectsToAdd, target, insertBefore, targetParent); >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Determine the parent object that a drop will occur under, >+ * based on the relative location of the drop and the ability >+ * of the target to be a parent >+ * >+ * @param dropTarget The target that the drop occurs near/on >+ * @param dropLocation The location of the drop relative to the target >+ * @return >+ */ >+ private CtxHelpObject determineParent(CtxHelpObject dropTarget, int dropLocation) { >+ //We must determine what object will be the parent of the >+ //dropped objects. This is done by looking at the drop location >+ //and drop target type >+ >+ if (dropTarget == null || dropTarget.getType() == ICtxHelpConstants.TYPE_ROOT) { >+ //Since the TOC root has no parent, it must be the target parent >+ return fModel.getCtxHelpRoot(); >+ } >+ switch (dropLocation) { >+ case CtxHelpDropAdapter.LOCATION_JUST_AFTER : { //if the drop occured after an expanded node >+ //and all of its children, >+ //make the drop target's parent the target parent object >+ if (!fTree.getExpandedState(dropTarget)) { >+ return dropTarget.getParent(); >+ } >+ //otherwise, the target parent is the drop target, >+ //since the drop occured between it and its first child >+ } >+ case ViewerDropAdapter.LOCATION_ON : { //the drop location is directly on the drop target >+ return dropTarget; >+ } >+ case ViewerDropAdapter.LOCATION_BEFORE : >+ case ViewerDropAdapter.LOCATION_AFTER : { //if the drop is before or after the drop target, >+ //make the drop target's parent the target parent object >+ return dropTarget.getParent(); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Get the TocObject representations of a group of dropped objects. >+ * >+ * @param droppings The objects that are dropped; can be file path Strings or >+ * deserialized TocObjects >+ * >+ * @param targetParent The designated parent of the dropped objects >+ * >+ * @return a list of the (reconnected) TocObject representations of the dropped objects >+ */ >+ private ArrayList getObjectsToAdd(Object[] droppings, CtxHelpObject targetParent) { >+ ArrayList ctxHelpObjects = new ArrayList(droppings.length); >+ >+ if (fDragAdapter.getDraggedElements() != null) { // If there are items in the drag adapter, then the current drag must be from >+ // this section >+ fDragFromHere = fDragAdapter.getDraggedElements().size() == droppings.length; >+ } >+ >+ for (int i = 0; i < droppings.length; ++i) { >+ // TODO Finish drop >+// if (droppings[i] instanceof String) { >+// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+// >+// // If the array contains Strings, we treat them as file paths >+// Path path = new Path((String) droppings[i]); >+// IFile file = root.getFileForLocation(path); >+// if (file == null) { >+// continue; >+// } >+// >+// // 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)) { >+// 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)) { >+// TocTopic topic = makeNewTocTopic(targetParent, file); >+// String title = generateTitle(targetParent, path); >+// >+// topic.setFieldLabel(title); >+// tocObjects.add(topic); >+// } >+// } else >+ if (droppings[i] instanceof CtxHelpObject) { >+ ArrayList dragged = fDragAdapter.getDraggedElements(); >+ if (fDragFromHere) { >+ CtxHelpObject draggedObj = (CtxHelpObject) dragged.get(i); >+ >+ //Nesting an object inside itself or its children >+ //is so stupid and ridiculous that I get a headache >+ //just thinking about it. Thus, this drag is not going to complete. >+ if (targetParent.descendsFrom(draggedObj)) { >+ return null; >+ } >+ } >+ >+ //Reconnect this TocObject, since it was deserialized >+ ((CtxHelpObject) droppings[i]).reconnect(targetParent, fModel); >+ ctxHelpObjects.add(droppings[i]); >+ } >+ } >+ >+ return ctxHelpObjects; >+ } >+ >+ /** >+ * Generate the title of a Topic created via dragging in an HTML page. >+ * Use the title of the HTML page, or generate a name based on the target >+ * parent if no title exists. >+ * >+ * @param targetParent The designated parent of this topic >+ * @param path The path to the HTML file >+ * >+ * @return The generated name of the Topic. >+ */ >+// private String generateTitle(TocTopic targetParent, Path path) { >+// String title = TocHTMLTitleUtil.findTitle(path.toFile()); >+// if (title == null) { >+// int numChildren = targetParent.getChildren().size(); >+// TocObject[] children = (TocObject[]) targetParent.getChildren().toArray(new TocObject[numChildren]); >+// >+// String[] tocObjectNames = new String[children.length]; >+// >+// for (int j = 0; j < numChildren; ++j) { >+// tocObjectNames[j] = children[j].getName(); >+// } >+// >+// title = PDELabelUtility.generateName(tocObjectNames, PDEUIMessages.TocPage_TocTopic); >+// } >+// return title; >+// } >+ /* (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; >+ } >+ } >+ >+ /** >+ * Handle the addition of multiple initialized objects to the TOC. >+ * >+ * @param objectsToAdd The objects to be added >+ * @param target The target to add these objects relative to >+ * @param insertBefore Whether or not the insertion occurs before the target >+ * @param targetParent The parent object of the newly added objects >+ */ >+ private void handleMultiAddAction(List objectsToAdd, CtxHelpObject target, boolean insertBefore, CtxHelpObject targetParent) { >+ CtxHelpObject[] tocObjects = (CtxHelpObject[]) objectsToAdd.toArray(new CtxHelpObject[objectsToAdd.size()]); >+ if (tocObjects == null) >+ return; >+ >+ for (int i = 0; i < tocObjects.length; ++i) { >+ if (tocObjects[i] != null) { >+ if (targetParent != null && targetParent.canBeParent() && targetParent.canAddChild(tocObjects[i].getType())) { >+ if (target != null && target != targetParent) { // Add the object as a direct sibling of the target >+ targetParent.addChild(tocObjects[i], target, insertBefore); >+ } else { // Add the object as the last child of the target parent >+ targetParent.addChild(tocObjects[i]); >+ } >+ } >+ } >+ } >+ } >+ >+ // >+ // /** >+ // * Remove the selected objects from the TOC tree >+ // */ >+ // private void handleDeleteAction() { >+ // ArrayList objects = new ArrayList(((IStructuredSelection) fTree.getSelection()).toList()); >+ // boolean beep = false; >+ // >+ // // Iterate through the list of selected objects, removing ones >+ // // that cannot be removed >+ // for (Iterator i = objects.iterator(); i.hasNext();) { >+ // Object object = i.next(); >+ // if (object instanceof TocObject) { >+ // TocObject tocObject = (TocObject) object; >+ // >+ // if (!tocObject.canBeRemoved()) { >+ // i.remove(); >+ // beep = true; >+ // } >+ // } >+ // } >+ // >+ // if (beep) { // If any object cannot be removed, beep to notify the user >+ // Display.getCurrent().beep(); >+ // } >+ // >+ // // Remove the remaining objects >+ // handleRemove(objects); >+ // } >+ // >+ // /** >+ // * Remove the items listed from the TOC. >+ // * >+ // * @param itemsToRemove The list of items to remove from the TOC >+ // */ >+ // public void handleRemove(List itemsToRemove) { >+ // if (!itemsToRemove.isEmpty()) { // Target the objects for removal >+ // fRemoveObjectAction.setToRemove((TocObject[]) itemsToRemove.toArray(new TocObject[itemsToRemove.size()])); >+ // >+ // // Run the removal action >+ // fRemoveObjectAction.run(); >+ // } >+ // } >+ >+ /** >+ * Handle the dragging of objects out of this TOC. >+ * >+ * @param itemsDragged The items dragged out of the TOC >+ */ >+ public void handleDrag(List itemsDragged) { >+ // TODO Handle multi drag, with instanceof checks >+ CtxHelpObject object = (CtxHelpObject) itemsDragged.get(0); >+ if (object != null && object.canBeRemoved()) { >+ if (updateRemoveActionWithSelection(new StructuredSelection(itemsDragged))) { >+ fRemoveObjectAction.run(); >+ } >+ } >+ >+ // The drag is finished, so there is no intra-editor DND operation occuring now >+ fDragFromHere = false; >+ } >+ >+ /** >+ * Move an object within the TOC. >+ * >+ * @param positionFlag The direction that the object will move >+ */ >+ 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.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); >+ } >+ } >+ >+ /** >+ * @param event >+ */ >+ private void handleModelChangeTypeSwap(IModelChangedEvent event) { >+ // Swap event >+ // Get the changed object >+ Object[] objects = event.getChangedObjects(); >+ CtxHelpObject object = (CtxHelpObject) objects[0]; >+ >+ if (object != null) { // Update the element in the tree viewer >+ 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) { >+ // Insert event >+ Object[] objects = event.getChangedObjects(); >+ CtxHelpObject object = (CtxHelpObject) objects[0]; >+ if (object != null) { >+ if (object.getType() != ICtxHelpConstants.TYPE_ROOT) { >+ // Refresh the parent element in the tree viewer >+ // TODO: Can we get away with an update instead of a refresh here? >+ 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) { >+ // Remove event >+ Object[] objects = event.getChangedObjects(); >+ if (objects[0] != null) { >+ CtxHelpObject object = (CtxHelpObject) objects[0]; >+ fTree.remove(object); >+ CtxHelpObject nextSelection = fRemoveObjectAction.getNextSelection(); >+ if (nextSelection != null) { >+ if (nextSelection.equals(object.getParent())) { >+ fTree.refresh(object.getParent()); >+ } >+ if (!fDragFromHere) { >+ fTree.setSelection(new StructuredSelection(nextSelection), true); >+ } >+ fRemoveObjectAction.clearNextSelection(); >+ } >+ } >+ } >+ >+ /** >+ * Handle an update to a TocObject's properties >+ * @param event the update event >+ */ >+ private void handleModelChangeType(IModelChangedEvent event) { >+ // Get the changed object >+ Object[] objects = event.getChangedObjects(); >+ CtxHelpObject object = (CtxHelpObject) objects[0]; >+ >+ if (object != null) { // Update the element in the tree viewer >+ fTree.update(object, null); >+ } >+ } >+ >+ 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.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(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.forms.AbstractFormPart#dispose() >+ */ >+ public void dispose() { >+ PDEPlugin.getDefault().getLabelProvider().disconnect(this); >+ super.dispose(); >+ } >+} >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 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/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,115 @@ >+/******************************************************************************* >+ * 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.ctxhelp.details; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpCommand; >+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; >+ >+public class CtxHelpCommandDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpCommand fCommand; >+ private FormEntry fLabelEntry; >+ private FormEntry fSerialEntry; >+ >+ /** >+ * @param masterSection >+ */ >+ public CtxHelpCommandDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the display label for this command:"); >+ fLabelEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Label:", SWT.NONE); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the command to invoke:"); >+ fSerialEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Command:", SWT.NONE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle() >+ */ >+ protected String getDetailsTitle() { >+ return "Command Details"; >+ } >+ >+ /* (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.toc.TocAbstractDetails#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.toc.TocAbstractDetails#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.ui.forms.IPartSelectionListener#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,122 @@ >+/******************************************************************************* >+ * 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.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; >+ >+/** >+ * TocSourcePage >+ */ >+public class CtxHelpSourcePage extends XMLSourcePage { >+ >+ /** >+ * @param editor >+ * @param id >+ * @param title >+ */ >+ 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); >+ } >+ >+ protected boolean isSelectionListener() { >+ return true; >+ } >+ >+ // TODO Consider adding custom hyperlink detector >+ // public Object getAdapter(Class adapter) { >+ // if (IHyperlinkDetector.class.equals(adapter)) >+ // return new TocHyperlinkDetector(this); >+ // return super.getAdapter(adapter); >+ // } >+ >+ /* (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); >+ } >+ } >+ >+ protected IDocumentRange findRange() { >+ if (getSelection() instanceof IDocumentElementNode) { >+ return (IDocumentElementNode) getSelection(); >+ } >+ >+ return null; >+ } >+ >+ public IDocumentRange getRangeElement(int offset, boolean searchChildren) { >+ CtxHelpObject root = ((CtxHelpModel) getInputContext().getModel()).getCtxHelpRoot(); >+ return findNode(root, offset, searchChildren); >+ } >+ >+ 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); >+ } >+ >+ 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,108 @@ >+/******************************************************************************* >+ * 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.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; >+ >+public class CtxHelpDescriptionDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpDescription fDescription; >+ private FormEntry fDescEntry; >+ >+ /** >+ * @param masterSection >+ */ >+ public CtxHelpDescriptionDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the context description that will be displayed to the user:"); >+ fDescEntry = new FormEntry(parent, getManagedForm().getToolkit(), "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.toc.TocAbstractDetails#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.toc.TocAbstractDetails#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.ui.forms.IPartSelectionListener#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,263 @@ >+/******************************************************************************* >+ * 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.*; >+ >+/** >+ * TocEditor >+ * @since 3.4 >+ * >+ */ >+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); >+ } >+ >+ 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 section. >+ * @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 section. >+ * @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); >+ } >+ // Add source page >+ 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(); >+ } >+ >+ 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,105 @@ >+/******************************************************************************* >+ * 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.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,98 @@ >+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.*; >+ >+public class CtxHelpBlock extends PDEMasterDetailsBlock implements IModelChangedListener, IDetailsPageProvider { >+ >+ private CtxHelpTreeSection fMasterSection; >+ >+ // private TocAbstractDetails fDetails; >+ // private TocAnchorDetails fAnchorDetails; >+ // private TocLinkDetails fLinkDetails; >+ >+ /**TODO: Comment >+ * @param page >+ */ >+ 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(); >+ } >+ >+ public ISelection getSelection() { >+ if (fMasterSection != null) { >+ return fMasterSection.getSelection(); >+ } >+ return null; >+ } >+ >+ 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,176 @@ >+/******************************************************************************* >+ * 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.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; >+ >+public class CtxHelpTopicDetails extends CtxHelpAbstractDetails { >+ >+ private CtxHelpTopic fTopic; >+ private FormEntry fLabelEntry; >+ private FormEntry fLinkEntry; >+ >+ /** >+ * @param masterSection >+ */ >+ public CtxHelpTopicDetails(CtxHelpTreeSection masterSection) { >+ super(masterSection, CtxHelpInputContext.CONTEXT_ID); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createFields(Composite parent) { >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the display label for this topic:"); >+ fLabelEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Label:", SWT.NONE); >+ createSpace(parent); >+ createLabel(parent, getManagedForm().getToolkit(), "Specify the location of an HTML file containing content:"); >+ fLinkEntry = new FormEntry(parent, getManagedForm().getToolkit(), "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.toc.TocAbstractDetails#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(); >+ } >+ }); >+ } >+ >+ private void handleBrowse() { >+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getPage().getSite().getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); >+ >+ // TODO Fix browse >+ dialog.setValidator(new FileValidator()); >+ dialog.setAllowMultiple(false); >+ dialog.setTitle(PDEUIMessages.TocDetails_browseSelection); >+ dialog.setMessage(PDEUIMessages.TocDetails_browseMessage); >+ // Currently we can just use the TOC page filter (only allows html files from local projects/containers) >+ 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.toc.TocAbstractDetails#updateFields() >+ */ >+ public void updateFields() { >+ if (fTopic != null) { >+ fLabelEntry.setValue(fTopic.getLabel(), true); >+ fLabelEntry.setEditable(isEditableElement()); >+ if (fTopic.getLocation() == null) { >+ fLinkEntry.setValue("", true); >+ } 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.ui.forms.IPartSelectionListener#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(); >+ } >+ } >+ >+ 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$ >+ } >+ } >+ >+ protected void handleOpen() { >+ IFile file = getMasterSection().openFile(fLinkEntry.getValue()); >+ if (file != null) { >+ setPathEntry(file); >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDragAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDragAdapter.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDragAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDragAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,125 @@ >+/******************************************************************************* >+ * 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.ctxhelp; >+ >+import java.io.PrintWriter; >+import java.io.StringWriter; >+import java.util.ArrayList; >+import java.util.Iterator; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+import org.eclipse.pde.internal.ui.editor.ModelDataTransfer; >+import org.eclipse.swt.dnd.*; >+ >+/** >+ * TocDragAdapter implements the drag behaviour for the TOC tree section. >+ */ >+public class CtxHelpDragAdapter implements DragSourceListener { >+ //The Tree Section being dragged from >+ private CtxHelpTreeSection fSection; >+ //The dragged items >+ private ArrayList fDraggedItems; >+ >+ /** >+ * Constructs a new Drag Adapter with the specified selection >+ * provider and TocTreeSection >+ * >+ * @param provider The provider of the dragged items >+ * @param section The section that will handle removal >+ */ >+ public CtxHelpDragAdapter(CtxHelpTreeSection section) { >+ fSection = section; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent) >+ */ >+ public void dragStart(DragSourceEvent event) { >+ if (event.doit) { //The event should only be enabled if there is a selection to drag >+ event.doit = !fSection.getSelection().isEmpty(); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) >+ */ >+ public void dragSetData(DragSourceEvent event) { >+ //Check if the drag is still enabled >+ if (event.doit) { >+ IStructuredSelection sel = (IStructuredSelection) fSection.getSelection(); >+ >+ if (TextTransfer.getInstance().isSupportedType(event.dataType)) { //If the expected data is text, then write out the selection >+ //into its XML representation >+ >+ StringWriter sw = new StringWriter(); >+ PrintWriter writer = new PrintWriter(sw); >+ >+ //Write the XML representation of each selected object >+ for (Iterator iter = sel.iterator(); iter.hasNext();) { >+ Object obj = iter.next(); >+ if (obj instanceof CtxHelpObject) { >+ ((CtxHelpObject) obj).write("", writer); //$NON-NLS-1$ >+ } >+ } >+ >+ //Set the event's drag object to be this String >+ event.data = sw.toString(); >+ //Set the array of dragged items to null, >+ //since we are dragging a String >+ fDraggedItems = null; >+ } else if (ModelDataTransfer.getInstance().isSupportedType(event.dataType)) { >+ //If we are dragging items from the model >+ fDraggedItems = getSelectedObjects(sel); >+ CtxHelpObject[] selectedObjects = (CtxHelpObject[]) fDraggedItems.toArray(new CtxHelpObject[fDraggedItems.size()]); >+ if (selectedObjects.length == 0) { //disable the drag if there are no items selected >+ event.doit = false; >+ } else { //set the event's drag object to the selection >+ event.data = selectedObjects; >+ } >+ } >+ } >+ } >+ >+ /** >+ * @param selection The selection to place in the ArrayList >+ * @return an ArrayList containing all removable TocObjects in the selection >+ */ >+ private ArrayList getSelectedObjects(IStructuredSelection selection) { >+ ArrayList objects = new ArrayList(); >+ for (Iterator iter = selection.iterator(); iter.hasNext();) { >+ Object obj = iter.next(); >+ if (obj instanceof CtxHelpObject && ((CtxHelpObject) obj).canBeRemoved()) { //If the object is a removable CtxHelpObject, add it >+ objects.add(obj); >+ } else { //If the object is not a removable CtxHelpObject, >+ //we don't want to permit the drag, so return an empty list >+ return new ArrayList(); >+ } >+ } >+ >+ return objects; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished(org.eclipse.swt.dnd.DragSourceEvent) >+ */ >+ public void dragFinished(DragSourceEvent event) { >+ if (event.detail == DND.DROP_MOVE && fDraggedItems != null) { >+ fSection.handleDrag(fDraggedItems); >+ } >+ >+ fDraggedItems = null; >+ } >+ >+ public ArrayList getDraggedElements() { >+ return fDraggedItems; >+ } >+} >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,109 @@ >+/******************************************************************************* >+ * 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.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.*; >+ >+/** >+ * TocInputContext >+ * >+ */ >+public class CtxHelpInputContext extends XMLInputContext { >+ >+ public static final String CONTEXT_ID = "ctxhelp-context"; //$NON-NLS-1$ >+ >+ /** >+ * @param editor >+ * @param input >+ * @param primary >+ */ >+ 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/CtxHelpAbstractAddAction.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpAbstractAddAction.java >diff -N src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpAbstractAddAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpAbstractAddAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * 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.ctxhelp; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject; >+ >+/** >+ * TocAddObjectAction - the abstract implementation for >+ * adding objects to a TOC object. >+ */ >+public abstract class CtxHelpAbstractAddAction extends Action { >+ >+ CtxHelpObject fParentObject; >+ >+ //The target object to insert after >+ 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; >+ } >+ >+ /** >+ * @return The names of the children of this TOC object >+ */ >+ public String[] getChildNames() { >+ 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; >+ } >+ >+ /** >+ * Add the child to the parent object. If a target object is specified, >+ * add the child as a direct 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); >+ } >+ } >+}
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