Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 215091 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/debug/ui/actions/JavaObjectValueEditor.java (+3 lines)
Lines 198-203 Link Here
198
    			    throw new DebugException(status);
198
    			    throw new DebugException(status);
199
    			}
199
    			}
200
    			return result.getValue();
200
    			return result.getValue();
201
            } else {
202
            	IStatus status= new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Could not find a project to complete the evaluation.", null);
203
            	throw new DebugException(status);
201
            }
204
            }
202
        }
205
        }
203
        return null;
206
        return null;
(-)src/org/eclipse/pde/internal/core/itoc/ITocConstants.java (-19 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
/**
14
/**
15
 * ITocConstants
15
 * ITocConstants
16
 * This interface contains all of the constants relevant to the TOC editor
16
 * This interface contains all of the constants relevant to the TOC editor
17
 * @since 3.4
17
 */
18
 */
18
public interface ITocConstants {
19
public interface ITocConstants {
19
20
Lines 51-72 Link Here
51
52
52
	public static final int TYPE_LINK = 3;
53
	public static final int TYPE_LINK = 3;
53
54
54
	// Enablement Elements
55
56
	public static final String ELEMENT_ENABLEMENT = "enablement"; //$NON-NLS-1$
57
58
	public static final String ELEMENT_TEST = "test"; //$NON-NLS-1$
59
60
	// Enablement Attributes
61
62
	public static final String ATTRIBUTE_PROPERTY = "property"; //$NON-NLS-1$		
63
64
	public static final String ATTRIBUTE_ARGS = "args"; //$NON-NLS-1$
65
66
	// Enablement Types
67
68
	public static final int TYPE_ENABLEMENT = 4;
69
70
	public static final int TYPE_TEST = 5;
71
72
}
55
}
(-)META-INF/MANIFEST.MF (+2 lines)
Lines 22-27 Link Here
22
 org.eclipse.pde.internal.core.icheatsheet;x-friends:="org.eclipse.pde.ui",
22
 org.eclipse.pde.internal.core.icheatsheet;x-friends:="org.eclipse.pde.ui",
23
 org.eclipse.pde.internal.core.icheatsheet.comp;x-friends:="org.eclipse.pde.ui",
23
 org.eclipse.pde.internal.core.icheatsheet.comp;x-friends:="org.eclipse.pde.ui",
24
 org.eclipse.pde.internal.core.icheatsheet.simple;x-friends:="org.eclipse.pde.ui",
24
 org.eclipse.pde.internal.core.icheatsheet.simple;x-friends:="org.eclipse.pde.ui",
25
 org.eclipse.pde.internal.core.ictxhelp;x-friends:="org.eclipse.pde.ui",
25
 org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui",
26
 org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui",
26
 org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui",
27
 org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui",
27
 org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui",
28
 org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui",
Lines 39-44 Link Here
39
 org.eclipse.pde.internal.core.text.build;x-friends:="org.eclipse.pde.ui",
40
 org.eclipse.pde.internal.core.text.build;x-friends:="org.eclipse.pde.ui",
40
 org.eclipse.pde.internal.core.text.bundle;x-friends:="org.eclipse.pde.ui",
41
 org.eclipse.pde.internal.core.text.bundle;x-friends:="org.eclipse.pde.ui",
41
 org.eclipse.pde.internal.core.text.cheatsheet.simple;x-friends:="org.eclipse.pde.ui",
42
 org.eclipse.pde.internal.core.text.cheatsheet.simple;x-friends:="org.eclipse.pde.ui",
43
 org.eclipse.pde.internal.core.text.ctxhelp;x-friends:="org.eclipse.pde.ui",
42
 org.eclipse.pde.internal.core.text.plugin;x-friends:="org.eclipse.pde.ui",
44
 org.eclipse.pde.internal.core.text.plugin;x-friends:="org.eclipse.pde.ui",
43
 org.eclipse.pde.internal.core.text.toc;x-friends:="org.eclipse.pde.ui",
45
 org.eclipse.pde.internal.core.text.toc;x-friends:="org.eclipse.pde.ui",
44
 org.eclipse.pde.internal.core.util;x-friends:="org.eclipse.pde.ui",
46
 org.eclipse.pde.internal.core.util;x-friends:="org.eclipse.pde.ui",
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDescription.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
/**
14
 * Represents a description entry in context help.  There may be one description
15
 * element for each context.  A description element will contain a CDATA string
16
 * explaining the context that the user will see in dynamic help.  Descriptions
17
 * are leaf objects.
18
 * 
19
 * @since 3.4
20
 * @see CtxHelpObject
21
 * @see CtxHelpModel
22
 * @see CtxHelpDocumentFactory
23
 */
24
public class CtxHelpDescription extends CtxHelpObject {
25
26
	private static final long serialVersionUID = 1L;
27
28
	public CtxHelpDescription(CtxHelpModel model) {
29
		super(model, ELEMENT_DESCRIPTION);
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent()
34
	 */
35
	public boolean canBeParent() {
36
		return false;
37
	}
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
41
	 */
42
	public int getType() {
43
		return TYPE_DESCRIPTION;
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getName()
48
	 */
49
	public String getName() {
50
		return getDescription();
51
	}
52
53
	/**
54
	 * @return the XML content of this element containing the description or <code>null</code>
55
	 */
56
	public String getDescription() {
57
		return getXMLContent();
58
	}
59
60
	/**
61
	 * Sets the XML content of this element to the given description string.
62
	 * Passing <code>null</code> will set the content to be empty.
63
	 * @param description new content
64
	 */
65
	public void setDescription(String description) {
66
		setXMLContent(description);
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject)
71
	 */
72
	public boolean canAddChild(int objectType) {
73
		return false;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int)
78
	 */
79
	public boolean canAddSibling(int objectType) {
80
		return objectType == TYPE_COMMAND || objectType == TYPE_TOPIC;
81
	}
82
}
(-)src/org/eclipse/pde/internal/core/ictxhelp/ICtxHelpConstants.java (+58 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.ictxhelp;
12
13
/**
14
 * Interface containing constants used for the context help editor.
15
 * 
16
 * @since 3.4
17
 */
18
public interface ICtxHelpConstants {
19
20
	// Elements
21
22
	public static final String ELEMENT_ROOT = "contexts"; //$NON-NLS-1$
23
24
	public static final String ELEMENT_CONTEXT = "context"; //$NON-NLS-1$
25
26
	public static final String ELEMENT_DESCRIPTION = "description"; //$NON-NLS-1$
27
28
	public static final String ELEMENT_TOPIC = "topic"; //$NON-NLS-1$
29
30
	public static final String ELEMENT_COMMAND = "command"; //$NON-NLS-1$
31
32
	// Attributes
33
34
	public static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
35
36
	public static final String ATTRIBUTE_TITLE = "title"; //$NON-NLS-1$	
37
38
	public static final String ATTRIBUTE_LABEL = "label"; //$NON-NLS-1$		
39
40
	public static final String ATTRIBUTE_HREF = "href"; //$NON-NLS-1$
41
42
	public static final String ATTRIBUTE_SERIAL = "serialization"; //$NON-NLS-1$	
43
44
	public static final String ATTRIBUTE_FILTER = "filter"; //$NON-NLS-1$	
45
46
	// Types
47
48
	public static final int TYPE_ROOT = 0;
49
50
	public static final int TYPE_CONTEXT = 1;
51
52
	public static final int TYPE_DESCRIPTION = 2;
53
54
	public static final int TYPE_TOPIC = 3;
55
56
	public static final int TYPE_COMMAND = 4;
57
58
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpModel.java (+83 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
import org.eclipse.jface.text.IDocument;
14
import org.eclipse.pde.core.IModel;
15
import org.eclipse.pde.core.IWritable;
16
import org.eclipse.pde.internal.core.NLResourceHelper;
17
import org.eclipse.pde.internal.core.text.XMLEditingModel;
18
import org.xml.sax.helpers.DefaultHandler;
19
20
/**
21
 * Model describing the elements of a context help xml file.
22
 * 
23
 * @since 3.4
24
 * @see CtxHelpRoot
25
 * @see CtxHelpDocumentFactory
26
 * @see CtxHelpDocumentHandler
27
 */
28
public class CtxHelpModel extends XMLEditingModel {
29
30
	private CtxHelpDocumentHandler fHandler;
31
	private CtxHelpDocumentFactory fFactory;
32
	private CtxHelpRoot fRoot;
33
34
	public CtxHelpModel(IDocument document, boolean isReconciling) {
35
		super(document, isReconciling);
36
	}
37
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.pde.internal.core.text.XMLEditingModel#createDocumentHandler(org.eclipse.pde.core.IModel, boolean)
40
	 */
41
	protected DefaultHandler createDocumentHandler(IModel model, boolean reconciling) {
42
		if (fHandler == null) {
43
			fHandler = new CtxHelpDocumentHandler(this, reconciling);
44
		}
45
		return fHandler;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.pde.internal.core.text.AbstractEditingModel#createNLResourceHelper()
50
	 */
51
	protected NLResourceHelper createNLResourceHelper() {
52
		// Not needed
53
		return null;
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.pde.internal.core.icheatsheet.simple.ITocModel#getFactory()
58
	 */
59
	public CtxHelpDocumentFactory getFactory() {
60
		if (fFactory == null) {
61
			fFactory = new CtxHelpDocumentFactory(this);
62
		}
63
		return fFactory;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.pde.internal.core.icheatsheet.simple.ITocModel#getToc()
68
	 */
69
	public CtxHelpRoot getCtxHelpRoot() {
70
		if (fRoot == null) {
71
			fRoot = getFactory().createRoot();
72
		}
73
		return fRoot;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.pde.internal.core.text.XMLEditingModel#getRoot()
78
	 */
79
	protected IWritable getRoot() {
80
		return getCtxHelpRoot();
81
	}
82
83
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentFactory.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants;
14
import org.eclipse.pde.internal.core.text.*;
15
16
/**
17
 * Handles the creation of document nodes representing the types of elements that
18
 * can exist in a context help xml file.
19
 * 
20
 * @since 3.4
21
 * @see CtxHelpObject
22
 * @see CtxHelpModel
23
 * @see CtxHelpDocumentHandler
24
 */
25
public class CtxHelpDocumentFactory extends DocumentNodeFactory implements IDocumentNodeFactory {
26
	private CtxHelpModel fModel;
27
28
	public CtxHelpDocumentFactory(CtxHelpModel model) {
29
		fModel = model;
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.pde.internal.core.text.IDocumentNodeFactory#createDocumentNode(java.lang.String, org.eclipse.pde.internal.core.text.IDocumentElementNode)
34
	 */
35
	public IDocumentElementNode createDocumentNode(String name, IDocumentElementNode parent) {
36
		if (isRoot(name)) { // Root
37
			return createRoot();
38
		}
39
		if (isContext(name)) { // Context
40
			return createContext();
41
		}
42
		if (isDescription(name)) { // Link
43
			return createDescription();
44
		}
45
		if (isTopic(name)) { // Anchor
46
			return createTopic();
47
		}
48
		if (isCommand(name)) { // Anchor
49
			return createCommand();
50
		}
51
		return super.createDocumentNode(name, parent);
52
	}
53
54
	private boolean isRoot(String name) {
55
		return name.equals(ICtxHelpConstants.ELEMENT_ROOT);
56
	}
57
58
	private boolean isContext(String name) {
59
		return name.equals(ICtxHelpConstants.ELEMENT_CONTEXT);
60
	}
61
62
	private boolean isDescription(String name) {
63
		return name.equals(ICtxHelpConstants.ELEMENT_DESCRIPTION);
64
	}
65
66
	private boolean isTopic(String name) {
67
		return name.equals(ICtxHelpConstants.ELEMENT_TOPIC);
68
	}
69
70
	private boolean isCommand(String name) {
71
		return name.equals(ICtxHelpConstants.ELEMENT_COMMAND);
72
	}
73
74
	/**
75
	 * @return a new root object based on the current model
76
	 */
77
	public CtxHelpRoot createRoot() {
78
		return new CtxHelpRoot(fModel);
79
	}
80
81
	/**
82
	 * @return a new context object based on the current model
83
	 */
84
	public CtxHelpContext createContext() {
85
		return new CtxHelpContext(fModel);
86
	}
87
88
	/**
89
	 * @return a new description object based on the current model
90
	 */
91
	public CtxHelpDescription createDescription() {
92
		return new CtxHelpDescription(fModel);
93
	}
94
95
	/**
96
	 * @return a new topic object based on the current model
97
	 */
98
	public CtxHelpTopic createTopic() {
99
		return new CtxHelpTopic(fModel);
100
	}
101
102
	/**
103
	 * @return a new command object based on the current model
104
	 */
105
	public CtxHelpCommand createCommand() {
106
		return new CtxHelpCommand(fModel);
107
	}
108
109
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpCommand.java (+96 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
/**
14
 * Represents a command entry in context help.  Commands are used to launch
15
 * actions when clicked on by the user.  Commands are leaf objects.
16
 * 
17
 * @since 3.4
18
 * @see CtxHelpObject
19
 * @see CtxHelpModel
20
 * @see CtxHelpDocumentFactory
21
 */
22
public class CtxHelpCommand extends CtxHelpObject {
23
24
	private static final long serialVersionUID = 1L;
25
26
	public CtxHelpCommand(CtxHelpModel model) {
27
		super(model, ELEMENT_COMMAND);
28
	}
29
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent()
32
	 */
33
	public boolean canBeParent() {
34
		return false;
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
39
	 */
40
	public int getType() {
41
		return TYPE_COMMAND;
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getName()
46
	 */
47
	public String getName() {
48
		return getLabel();
49
	}
50
51
	/**
52
	 * @return the value of the label attribute or <code>null</code> if the attribute does not exist
53
	 */
54
	public String getLabel() {
55
		return getXMLAttributeValue(ATTRIBUTE_LABEL);
56
	}
57
58
	/**
59
	 * Set the label attribute, passing <code>null</code> will set the
60
	 * attribute to be empty.
61
	 * @param label new value
62
	 */
63
	public void setLabel(String label) {
64
		setXMLAttribute(ATTRIBUTE_LABEL, label);
65
	}
66
67
	/**
68
	 * @return the value of the serialization attribute or <code>null</code> if the attribute does not exist
69
	 */
70
	public String getSerialization() {
71
		return getXMLAttributeValue(ATTRIBUTE_SERIAL);
72
	}
73
74
	/**
75
	 * Set the serialization attribute, passing <code>null</code> will set the
76
	 * attribute to be empty.
77
	 * @param serialization new value
78
	 */
79
	public void setSerialization(String serialization) {
80
		setXMLAttribute(ATTRIBUTE_HREF, serialization);
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject)
85
	 */
86
	public boolean canAddChild(int objectType) {
87
		return false;
88
	}
89
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int)
92
	 */
93
	public boolean canAddSibling(int objectType) {
94
		return objectType == TYPE_COMMAND || objectType == TYPE_TOPIC;
95
	}
96
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpTopic.java (+107 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
import org.eclipse.core.runtime.IPath;
14
import org.eclipse.core.runtime.Path;
15
16
/**
17
 * Represents a topic entry in context help.  Topics are used to open related
18
 * help in other files.  Topics are leaf objects.
19
 * 
20
 * @since 3.4
21
 * @see CtxHelpObject
22
 * @see CtxHelpModel
23
 * @see CtxHelpDocumentFactory
24
 */
25
public class CtxHelpTopic extends CtxHelpObject {
26
27
	private static final long serialVersionUID = 1L;
28
29
	public CtxHelpTopic(CtxHelpModel model) {
30
		super(model, ELEMENT_TOPIC);
31
	}
32
33
	/* (non-Javadoc)
34
	 * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent()
35
	 */
36
	public boolean canBeParent() {
37
		return false;
38
	}
39
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
42
	 */
43
	public int getType() {
44
		return TYPE_TOPIC;
45
	}
46
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getName()
49
	 */
50
	public String getName() {
51
		return getLabel();
52
	}
53
54
	/**
55
	 * @return the value of the label attribute or <code>null</code> if the attribute does not exist
56
	 */
57
	public String getLabel() {
58
		return getXMLAttributeValue(ATTRIBUTE_LABEL);
59
	}
60
61
	/**
62
	 * Set the label attribute, passing <code>null</code> will set the
63
	 * attribute to be empty.
64
	 * @param label new value
65
	 */
66
	public void setLabel(String label) {
67
		setXMLAttribute(ATTRIBUTE_LABEL, label);
68
	}
69
70
	/**
71
	 * @return the value of the href attribute as a path or <code>null</code>
72
	 */
73
	public IPath getLocation() {
74
		String value = getXMLAttributeValue(ATTRIBUTE_HREF);
75
		if (value != null) {
76
			return new Path(value);
77
		}
78
		return null;
79
	}
80
81
	/**
82
	 * Set the href (link) attribute, passing <code>null</code> will set the
83
	 * attribute to be empty.
84
	 * @param path new value
85
	 */
86
	public void setLocation(IPath path) {
87
		if (path == null) {
88
			setXMLAttribute(ATTRIBUTE_HREF, null);
89
		} else {
90
			setXMLAttribute(ATTRIBUTE_HREF, path.toPortableString());
91
		}
92
	}
93
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject)
96
	 */
97
	public boolean canAddChild(int objectType) {
98
		return false;
99
	}
100
101
	/* (non-Javadoc)
102
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int)
103
	 */
104
	public boolean canAddSibling(int objectType) {
105
		return objectType == TYPE_COMMAND || objectType == TYPE_TOPIC;
106
	}
107
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpDocumentHandler.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
import org.eclipse.jface.text.IDocument;
14
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
15
import org.eclipse.pde.internal.core.text.NodeDocumentHandler;
16
17
/**
18
 * Document handler for context help xml files.
19
 * 
20
 * @since 3.4
21
 * @see CtxHelpObject
22
 * @see CtxHelpModel
23
 * @see CtxHelpDocumentFactory
24
 */
25
public class CtxHelpDocumentHandler extends NodeDocumentHandler {
26
27
	private CtxHelpModel fModel;
28
29
	public CtxHelpDocumentHandler(CtxHelpModel model, boolean reconciling) {
30
		super(reconciling, model.getFactory());
31
		fModel = model;
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.pde.internal.core.text.DocumentHandler#getDocument()
36
	 */
37
	protected IDocument getDocument() {
38
		return fModel.getDocument();
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.pde.internal.core.text.NodeDocumentHandler#getRootNode()
43
	 */
44
	protected IDocumentElementNode getRootNode() {
45
		return (IDocumentElementNode) fModel.getRoot();
46
	}
47
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpRoot.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
/**
14
 * Represents the root "contexts" entry in a context help xml file.  There may
15
 * be only one root node in the file and all other nodes must be inside the root.
16
 * The root may contain many context elements.
17
 * 
18
 * @since 3.4
19
 * @see CtxHelpObject
20
 * @see CtxHelpModel
21
 * @see CtxHelpDocumentFactory
22
 */
23
public class CtxHelpRoot extends CtxHelpObject {
24
25
	private static final long serialVersionUID = 1L;
26
27
	public CtxHelpRoot(CtxHelpModel model) {
28
		super(model, ELEMENT_ROOT);
29
		setInTheModel(true);
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.pde.internal.core.text.plugin.PluginDocumentNode#isRoot()
34
	 */
35
	public boolean isRoot() {
36
		return true;
37
	}
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
41
	 */
42
	public int getType() {
43
		return TYPE_ROOT;
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canBeParent()
48
	 */
49
	public boolean canBeParent() {
50
		return true;
51
	}
52
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#getName()
55
	 */
56
	public String getName() {
57
		return ELEMENT_ROOT;
58
	}
59
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject)
62
	 */
63
	public boolean canAddChild(int objectType) {
64
		return objectType == TYPE_CONTEXT;
65
	}
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int)
69
	 */
70
	public boolean canAddSibling(int objectType) {
71
		return false;
72
	}
73
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpContext.java (+135 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
14
15
/**
16
 * Represents a context entry in context help.  Contexts have a specific id
17
 * that allows UI elements to be associated with a list of commands and topics
18
 * that are stored in the context.  Contexts may have one optional description
19
 * element and as many topic and command elements as needed.
20
 * 
21
 * @since 3.4
22
 * @see CtxHelpObject
23
 * @see CtxHelpModel
24
 * @see CtxHelpDocumentFactory
25
 */
26
public class CtxHelpContext extends CtxHelpObject {
27
28
	private static final long serialVersionUID = 1L;
29
30
	public CtxHelpContext(CtxHelpModel model) {
31
		super(model, ELEMENT_CONTEXT);
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent()
36
	 */
37
	public boolean canBeParent() {
38
		return true;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
43
	 */
44
	public int getType() {
45
		return TYPE_CONTEXT;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.pde.internal.core.toc.TocObject#getName()
50
	 */
51
	public String getName() {
52
		return getId();
53
	}
54
55
	/**
56
	 * @return the value of the id attribute or <code>null</code> if the attribute does not exist
57
	 */
58
	public String getId() {
59
		return getXMLAttributeValue(ATTRIBUTE_ID);
60
	}
61
62
	/**
63
	 * Set the id attribute, passing <code>null</code> will set the
64
	 * attribute to be empty.
65
	 * @param id new value
66
	 */
67
	public void setID(String id) {
68
		setXMLAttribute(ATTRIBUTE_ID, id);
69
	}
70
71
	/**
72
	 * @return the value of the title attribute or <code>null</code> if the attribute does not exist
73
	 */
74
	public String getTitle() {
75
		return getXMLAttributeValue(ATTRIBUTE_TITLE);
76
	}
77
78
	/**
79
	 * Set the title attribute, passing <code>null</code> will set the
80
	 * attribute to be empty.
81
	 * @param title new value
82
	 */
83
	public void setTitle(String title) {
84
		setXMLAttribute(ATTRIBUTE_TITLE, title);
85
	}
86
87
	/**
88
	 * Searches for a child description node and returns the string contents of that node.
89
	 * Returns <code>null</code> if no description node exists.
90
	 * @return description associated with this context or <code>null</code> no description exists
91
	 */
92
	public String getDescription() {
93
		IDocumentElementNode node = getChildNode(CtxHelpDescription.class);
94
		if (node instanceof CtxHelpDescription) {
95
			return ((CtxHelpDescription) node).getDescription();
96
		}
97
		return null;
98
	}
99
100
	/**
101
	 * Set the description to be associated with this context.  Searches for a child description node
102
	 * and updates the content with the given string.  If a description node does not exist, one will
103
	 * be created.  Passing <code>null</code> will remove any description node if one exists.
104
	 * @param description new value
105
	 */
106
	public void setDescription(String description) {
107
		IDocumentElementNode node = getChildNode(CtxHelpDescription.class);
108
		if (node instanceof CtxHelpDescription) {
109
			if (description == null) {
110
				removeChildNode(node, true);
111
			} else {
112
				((CtxHelpDescription) node).setDescription(description);
113
			}
114
		} else if (description != null) {
115
			CtxHelpDescription newDescription = getModel().getFactory().createDescription();
116
			newDescription.setDescription(description);
117
			addChildNode(newDescription, 0, true);
118
		}
119
	}
120
121
	/* (non-Javadoc)
122
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddChild(org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject)
123
	 */
124
	public boolean canAddChild(int objectType) {
125
		return objectType == TYPE_TOPIC || objectType == TYPE_COMMAND;
126
	}
127
128
	/* (non-Javadoc)
129
	 * @see org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject#canAddSibling(int)
130
	 */
131
	public boolean canAddSibling(int objectType) {
132
		return objectType == TYPE_CONTEXT;
133
	}
134
135
}
(-)text/org/eclipse/pde/internal/core/text/ctxhelp/CtxHelpObject.java (+203 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.text.ctxhelp;
12
13
import java.io.Serializable;
14
import java.util.ArrayList;
15
import java.util.List;
16
import org.eclipse.pde.core.IModel;
17
import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants;
18
import org.eclipse.pde.internal.core.text.DocumentObject;
19
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
20
21
/**
22
 * All modeled objects of a context help xml file must extend from this
23
 * abstract class.
24
 * 
25
 * @since 3.4
26
 * @see CtxHelpModel
27
 * @see CtxHelpDocumentFactory
28
 */
29
public abstract class CtxHelpObject extends DocumentObject implements ICtxHelpConstants, Serializable {
30
31
	private static final long serialVersionUID = 1L;
32
33
	/**
34
	 * Constructs the CtxHelpObject and initializes its attributes.
35
	 * 
36
	 * @param model The model to associate with this CtxHelpObject
37
	 * @param tagName The xml tag name for this object
38
	 */
39
	public CtxHelpObject(CtxHelpModel model, String tagName) {
40
		super(model, tagName);
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.pde.internal.core.text.DocumentElementNode#getAttributeIndent()
45
	 */
46
	protected String getAttributeIndent() {
47
		return "\t"; //$NON-NLS-1$
48
	}
49
50
	/**
51
	 * @return the children of the object or an empty List if none exist.
52
	 */
53
	public List getChildren() {
54
		//Create a copy of the child list instead of 
55
		//returning the list itself. That way, our list
56
		//of children cannot be altered from outside
57
		ArrayList list = new ArrayList();
58
59
		// Add children of this topic
60
		IDocumentElementNode[] childNodes = getChildNodes();
61
		if (childNodes.length > 0) {
62
			for (int i = 0; i < childNodes.length; ++i) {
63
				if (childNodes[i] instanceof CtxHelpObject) {
64
					list.add(childNodes[i]);
65
				}
66
			}
67
		}
68
69
		return list;
70
	}
71
72
	/* (non-Javadoc)
73
	 * @see org.eclipse.pde.internal.core.text.DocumentElementNode#isLeafNode()
74
	 */
75
	public boolean isLeafNode() {
76
		return !canBeParent();
77
	}
78
79
	/**
80
	 * @return true iff this object is capable of containing children.
81
	 */
82
	public abstract boolean canBeParent();
83
84
	public abstract boolean canAddChild(int objectType);
85
86
	public abstract boolean canAddSibling(int objectType);
87
88
	//	public abstract boolean canAddSibling(int objectType);
89
90
	public void addChild(CtxHelpObject newObject, CtxHelpObject targetSibling, boolean insertBefore) {
91
		if (canAddChild(newObject.getType())) {
92
			int currentIndex = indexOf(targetSibling);
93
			if (!insertBefore) {
94
				currentIndex++;
95
			}
96
			addChildNode(newObject, currentIndex, true);
97
		}
98
	}
99
100
	public void addChild(CtxHelpObject newObject) {
101
		if (canAddChild(newObject.getType())) {
102
			addChildNode(newObject, true);
103
		}
104
	}
105
106
	/**
107
	 * @return the root model object that is an ancestor to this object.
108
	 */
109
	public CtxHelpModel getModel() {
110
		final IModel sharedModel = getSharedModel();
111
		if (sharedModel instanceof CtxHelpModel) {
112
			return (CtxHelpModel) sharedModel;
113
		}
114
		return null;
115
	}
116
117
	/**
118
	 * @return the root element that is an ancestor to this object.
119
	 */
120
	public CtxHelpRoot getRoot() {
121
		final CtxHelpModel model = getModel();
122
		if (model != null) {
123
			return model.getCtxHelpRoot();
124
		}
125
		return null;
126
	}
127
128
	/**
129
	 * @return the identifier for this object to be used when displaying the element to the user
130
	 */
131
	public abstract String getName();
132
133
	/**
134
	 * Get the concrete type of this object, must be one of the TYPE constants defined in ICtxHelpConstants.
135
	 * @see ICtxHelpConstants
136
	 */
137
	public abstract int getType();
138
139
	/**
140
	 * @return the parent of this object, or <code>null</code> if there is no parent.
141
	 */
142
	public CtxHelpObject getParent() {
143
		IDocumentElementNode parent = getParentNode();
144
		return parent instanceof CtxHelpObject ? (CtxHelpObject) parent : null;
145
	}
146
147
	/**
148
	 * Check if the object is a direct or indirect descendant
149
	 * of the object parameter.
150
	 * 
151
	 * @param obj The object to find in this object's ancestry
152
	 * @return true iff obj is an ancestor of this object
153
	 */
154
	public boolean descendsFrom(CtxHelpObject obj) {
155
		if (this.equals(obj)) {
156
			return true;
157
		}
158
		if (getParent() != null && obj.canBeParent()) {
159
			return getParent().descendsFrom(obj);
160
		}
161
		return false;
162
	}
163
164
	/**
165
	 * @param ctxHelpObject the child used to locate a sibling
166
	 * @return the object preceding the specified one in the list of children
167
	 */
168
	public CtxHelpObject getPreviousSibling(CtxHelpObject ctxHelpObject) {
169
		return (CtxHelpObject) getPreviousSibling(ctxHelpObject, CtxHelpObject.class);
170
	}
171
172
	/**
173
	 * @param ctxHelpObject the child used to locate a sibling
174
	 * @return the object proceeding the specified one in the list of children
175
	 */
176
	public CtxHelpObject getNextSibling(CtxHelpObject ctxHelpObject) {
177
		return (CtxHelpObject) getNextSibling(ctxHelpObject, CtxHelpObject.class);
178
	}
179
180
	/**
181
	 * @return true iff a this object can be removed
182
	 */
183
	public boolean canBeRemoved() {
184
		if (getType() == TYPE_ROOT) { //Semantic Rule: The root element can never be removed
185
			return false;
186
		}
187
		return true;
188
	}
189
190
	public void removeChild(CtxHelpObject object) {
191
		if (object.canBeRemoved()) {
192
			removeChildNode(object, true);
193
		}
194
	}
195
196
	/* (non-Javadoc)
197
	 * @see org.eclipse.pde.internal.core.toc.TocObject#moveChild(org.eclipse.pde.internal.core.toc.TocObject, int)
198
	 */
199
	public void moveChild(CtxHelpObject object, int newRelativeIndex) {
200
		moveChildNode(object, newRelativeIndex, true);
201
	}
202
203
}
(-)src/org/eclipse/pde/internal/ui/editor/toc/TocFileValidator.java (-21 / +11 lines)
Lines 37-43 Link Here
37
	 * @see org.eclipse.ui.dialogs.ISelectionStatusValidator#validate(java.lang.Object[])
37
	 * @see org.eclipse.ui.dialogs.ISelectionStatusValidator#validate(java.lang.Object[])
38
	 */
38
	 */
39
	public IStatus validate(Object[] selection) {
39
	public IStatus validate(Object[] selection) {
40
		
40
41
		// Ensure something was selected
41
		// Ensure something was selected
42
		if (selection.length == 0) {
42
		if (selection.length == 0) {
43
			return errorStatus(""); //$NON-NLS-1$
43
			return errorStatus(""); //$NON-NLS-1$
Lines 46-91 Link Here
46
		if ((selection[0] instanceof IFile) == false) {
46
		if ((selection[0] instanceof IFile) == false) {
47
			return errorStatus(""); //$NON-NLS-1$
47
			return errorStatus(""); //$NON-NLS-1$
48
		}
48
		}
49
		IFile file = (IFile)selection[0];
49
		IFile file = (IFile) selection[0];
50
		// Ensure we have a TOC file
50
		// Ensure we have a TOC file
51
		if (!TocExtensionUtil.isTOCFile(file.getFullPath())) {
51
		if (!HelpEditorUtil.isTOCFile(file.getFullPath())) {
52
			return errorStatus(PDEUIMessages.TocFileValidator_errorInvalidTOC);
52
			return errorStatus(PDEUIMessages.TocFileValidator_errorInvalidTOC);
53
		}
53
		}
54
		
54
55
		//Ensure that the TOC file selected isn't the current file
55
		//Ensure that the TOC file selected isn't the current file
56
		if(TocExtensionUtil.isCurrentResource(file.getFullPath(), fModel))
56
		if (HelpEditorUtil.isCurrentResource(file.getFullPath(), fModel)) {
57
		{	return errorStatus(PDEUIMessages.TocFileValidator_errorSameTOC);
57
			return errorStatus(PDEUIMessages.TocFileValidator_errorSameTOC);
58
		}
58
		}
59
59
60
		// If we got this far, we have a valid file
60
		// If we got this far, we have a valid file
61
		return okStatus(""); //$NON-NLS-1$
61
		return okStatus(""); //$NON-NLS-1$
62
		
62
63
	}
63
	}
64
	
64
65
	/**
65
	/**
66
	 * @param message
66
	 * @param message
67
	 * @return
67
	 * @return
68
	 */
68
	 */
69
	private IStatus errorStatus(String message) {
69
	private IStatus errorStatus(String message) {
70
		return new Status(
70
		return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.ERROR, message, null);
71
				IStatus.ERROR,
72
				PDEPlugin.getPluginId(),
73
				IStatus.ERROR,
74
				message,
75
				null);
76
	}
71
	}
77
	
72
78
	/**
73
	/**
79
	 * @param message
74
	 * @param message
80
	 * @return
75
	 * @return
81
	 */
76
	 */
82
	private IStatus okStatus(String message) {
77
	private IStatus okStatus(String message) {
83
		return new Status(
78
		return new Status(IStatus.OK, PDEPlugin.getPluginId(), IStatus.OK, message, null);
84
				IStatus.OK,
85
				PDEPlugin.getPluginId(),
86
				IStatus.OK,
87
				message, 
88
				null);		
89
	}
79
	}
90
80
91
}
81
}
(-)src/org/eclipse/pde/internal/ui/editor/toc/TocTreeSection.java (-5 / +5 lines)
Lines 736-749 Link Here
736
		String message = null;
736
		String message = null;
737
737
738
		if(tocFile)
738
		if(tocFile)
739
		{	if(TocExtensionUtil.isTOCFile(path))
739
		{	if(HelpEditorUtil.isTOCFile(path))
740
			{	return true;
740
			{	return true;
741
			}
741
			}
742
742
743
			message = PDEUIMessages.TocPage_invalidTocFile;
743
			message = PDEUIMessages.TocPage_invalidTocFile;
744
		}
744
		}
745
		else
745
		else
746
		{	if(TocExtensionUtil.hasValidPageExtension(path))
746
		{	if(HelpEditorUtil.hasValidPageExtension(path))
747
			{	return true;
747
			{	return true;
748
			}
748
			}
749
		
749
		
Lines 897-908 Link Here
897
				// If the path is to a valid TOC file
897
				// If the path is to a valid TOC file
898
				// and it isn't the file in this model
898
				// and it isn't the file in this model
899
				// then make a link
899
				// then make a link
900
				if(TocExtensionUtil.isTOCFile(path) 
900
				if(HelpEditorUtil.isTOCFile(path) 
901
						&& !TocExtensionUtil.isCurrentResource(path, fModel))
901
						&& !HelpEditorUtil.isCurrentResource(path, fModel))
902
				{	tocObjects.add(makeNewTocLink(targetParent, file));
902
				{	tocObjects.add(makeNewTocLink(targetParent, file));
903
				}
903
				}
904
				// If the path is to a file with an HTML page extension, make a topic
904
				// If the path is to a file with an HTML page extension, make a topic
905
				else if(TocExtensionUtil.hasValidPageExtension(path))
905
				else if(HelpEditorUtil.hasValidPageExtension(path))
906
				{	TocTopic topic = makeNewTocTopic(targetParent, file); 
906
				{	TocTopic topic = makeNewTocTopic(targetParent, file); 
907
					String title = generateTitle(targetParent, path);
907
					String title = generateTitle(targetParent, path);
908
908
(-)src/org/eclipse/pde/internal/ui/editor/toc/TocExtensionUtil.java (-105 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.toc;
13
14
import java.util.HashSet;
15
import java.util.Locale;
16
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.pde.core.IBaseModel;
23
import org.eclipse.pde.core.IModel;
24
import org.eclipse.pde.internal.core.itoc.ITocConstants;
25
import org.eclipse.pde.internal.ui.util.XMLRootElementMatcher;
26
27
public class TocExtensionUtil {
28
	public static final String[] pageExtensions = {"htm","shtml","html","xhtml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
29
	public static final String tocExtension = "xml"; //$NON-NLS-1$
30
	private static HashSet pageExtensionSet = new HashSet(pageExtensions.length);
31
32
	private static void populateHashSet()
33
	{	for(int i = 0; i < pageExtensions.length; ++i)
34
		{	pageExtensionSet.add(pageExtensions[i]);
35
		}
36
	}
37
	
38
	public static boolean hasValidPageExtension(IPath path)
39
	{	String fileExtension = path.getFileExtension();	
40
		if(fileExtension != null)
41
		{	fileExtension = fileExtension.toLowerCase(Locale.ENGLISH);
42
			if(pageExtensionSet.isEmpty())
43
			{	populateHashSet();
44
			}
45
			
46
			return pageExtensionSet.contains(fileExtension);
47
		}
48
49
		return false;
50
	}
51
52
	private static boolean hasValidTocExtension(IPath path)
53
	{	String fileExtension = path.getFileExtension();
54
		return fileExtension != null && fileExtension.equals(tocExtension); 
55
	}
56
57
	/**
58
	 * @param file
59
	 */
60
	public static boolean isTOCFile(IPath path) {
61
		if(!hasValidTocExtension(path))
62
			return false;
63
		
64
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
65
66
		IResource resource = root.findMember(path);
67
		if(resource != null && resource instanceof IFile)
68
		{	return XMLRootElementMatcher.fileMatchesElement((IFile)resource, ITocConstants.ELEMENT_TOC);
69
		}
70
71
		return XMLRootElementMatcher.fileMatchesElement(path.toFile(), ITocConstants.ELEMENT_TOC);
72
	}
73
74
	public static boolean isCurrentResource(IPath path, IBaseModel model)
75
	{	if(model instanceof IModel)
76
		{	IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
77
			IPath fullPath;	
78
79
			if(workspacePath.isPrefixOf(path))
80
			{	fullPath = ((IModel)model).getUnderlyingResource().getLocation();	
81
			}
82
			else
83
			{	fullPath = ((IModel)model).getUnderlyingResource().getFullPath();
84
			}
85
86
			return fullPath.equals(path);
87
		}
88
89
		return false;
90
	}
91
92
	public static String getPageExtensionList() {
93
		StringBuffer buf = new StringBuffer();
94
95
		for(int i = 0; i < pageExtensions.length; ++i)
96
		{	buf.append('.');
97
			buf.append(pageExtensions[i]);
98
			if(i != pageExtensions.length - 1)
99
			{	buf.append(", "); //$NON-NLS-1$
100
			}
101
		}
102
103
		return buf.toString();
104
	}
105
}
(-)src/org/eclipse/pde/internal/ui/editor/toc/TocDropAdapter.java (-3 / +3 lines)
Lines 175-188 Link Here
175
					return;
175
					return;
176
				}
176
				}
177
177
178
				if(!TocExtensionUtil.hasValidPageExtension(path)
178
				if(!HelpEditorUtil.hasValidPageExtension(path)
179
					&& !TocExtensionUtil.isTOCFile(path))
179
					&& !HelpEditorUtil.isTOCFile(path))
180
				{	event.detail = DND.DROP_NONE;
180
				{	event.detail = DND.DROP_NONE;
181
					return;
181
					return;
182
				}
182
				}
183
183
184
				// Make sure that the user isn't dropping a TOC into itself
184
				// Make sure that the user isn't dropping a TOC into itself
185
				if(TocExtensionUtil.isCurrentResource(path, model))
185
				if(HelpEditorUtil.isCurrentResource(path, model))
186
				{	event.detail = DND.DROP_NONE;
186
				{	event.detail = DND.DROP_NONE;
187
					return;
187
					return;
188
				}
188
				}
(-)src/org/eclipse/pde/internal/ui/editor/toc/details/TocPageFilter.java (-50 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.toc.details;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.jface.viewers.Viewer;
21
import org.eclipse.jface.viewers.ViewerFilter;
22
import org.eclipse.pde.internal.ui.editor.toc.TocExtensionUtil;
23
24
public class TocPageFilter extends ViewerFilter
25
{	public boolean select(Viewer viewer, Object parent, Object element)
26
	{	if (element instanceof IFile)
27
		{	IPath path = ((IFile)element).getFullPath();
28
29
			return TocExtensionUtil.hasValidPageExtension(path);
30
		}
31
32
		if (element instanceof IProject && !((IProject)element).isOpen())
33
		{	return false;
34
		}
35
36
		if (element instanceof IContainer)
37
		{	try {
38
				IResource[] resources = ((IContainer)element).members();
39
				for (int i = 0; i < resources.length; i++){
40
					if (select(viewer, parent, resources[i]))
41
					{	return true;
42
					}
43
				}
44
			} catch (CoreException e) {
45
			}
46
		}
47
48
		return false;
49
	}
50
}
(-)src/org/eclipse/pde/internal/ui/editor/toc/details/TocDetails.java (-1 / +1 lines)
Lines 189-195 Link Here
189
		dialog.setAllowMultiple(false);
189
		dialog.setAllowMultiple(false);
190
		dialog.setTitle(PDEUIMessages.TocDetails_browseSelection);  
190
		dialog.setTitle(PDEUIMessages.TocDetails_browseSelection);  
191
		dialog.setMessage(PDEUIMessages.TocDetails_browseMessage);  
191
		dialog.setMessage(PDEUIMessages.TocDetails_browseMessage);  
192
		dialog.addFilter(new TocPageFilter());
192
		dialog.addFilter(new HelpEditorFilter());
193
		
193
		
194
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
194
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
195
195
(-)src/org/eclipse/pde/internal/ui/editor/toc/details/TocLinkDetails.java (-2 / +2 lines)
Lines 19-25 Link Here
19
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEPlugin;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
21
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
21
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
22
import org.eclipse.pde.internal.ui.editor.toc.TocExtensionUtil;
22
import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil;
23
import org.eclipse.pde.internal.ui.editor.toc.TocFileValidator;
23
import org.eclipse.pde.internal.ui.editor.toc.TocFileValidator;
24
import org.eclipse.pde.internal.ui.editor.toc.TocInputContext;
24
import org.eclipse.pde.internal.ui.editor.toc.TocInputContext;
25
import org.eclipse.pde.internal.ui.editor.toc.TocTreeSection;
25
import org.eclipse.pde.internal.ui.editor.toc.TocTreeSection;
Lines 135-141 Link Here
135
		dialog.setAllowMultiple(false);
135
		dialog.setAllowMultiple(false);
136
		dialog.setTitle(PDEUIMessages.TocLinkDetails_browseSelection);  
136
		dialog.setTitle(PDEUIMessages.TocLinkDetails_browseSelection);  
137
		dialog.setMessage(PDEUIMessages.TocLinkDetails_browseMessage);
137
		dialog.setMessage(PDEUIMessages.TocLinkDetails_browseMessage);
138
		dialog.addFilter(new FileExtensionFilter(TocExtensionUtil.tocExtension));
138
		dialog.addFilter(new FileExtensionFilter(HelpEditorUtil.tocExtension));
139
139
140
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
140
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
141
141
(-)src/org/eclipse/pde/internal/ui/editor/toc/details/TocTopicDetails.java (-1 / +1 lines)
Lines 159-165 Link Here
159
		dialog.setAllowMultiple(false);
159
		dialog.setAllowMultiple(false);
160
		dialog.setTitle(PDEUIMessages.TocDetails_browseSelection);  
160
		dialog.setTitle(PDEUIMessages.TocDetails_browseSelection);  
161
		dialog.setMessage(PDEUIMessages.TocDetails_browseMessage);  
161
		dialog.setMessage(PDEUIMessages.TocDetails_browseMessage);  
162
		dialog.addFilter(new TocPageFilter());
162
		dialog.addFilter(new HelpEditorFilter());
163
		
163
		
164
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
164
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
165
165
(-)src/org/eclipse/pde/internal/ui/IPDEUIConstants.java (-16 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-56 Link Here
24
	String SIMPLE_CHEAT_SHEET_EDITOR_ID = PLUGIN_ID + ".simpleCheatSheetEditor"; //$NON-NLS-1$
24
	String SIMPLE_CHEAT_SHEET_EDITOR_ID = PLUGIN_ID + ".simpleCheatSheetEditor"; //$NON-NLS-1$
25
	String COMPOSITE_CHEAT_SHEET_EDITOR_ID = PLUGIN_ID + ".compositeCheatSheetEditor"; //$NON-NLS-1$
25
	String COMPOSITE_CHEAT_SHEET_EDITOR_ID = PLUGIN_ID + ".compositeCheatSheetEditor"; //$NON-NLS-1$
26
	String TABLE_OF_CONTENTS_EDITOR_ID = PLUGIN_ID + ".tocEditor"; //$NON-NLS-1$
26
	String TABLE_OF_CONTENTS_EDITOR_ID = PLUGIN_ID + ".tocEditor"; //$NON-NLS-1$
27
	String CONTEXT_HELP_EDITOR_ID = PLUGIN_ID + ".helpContextEditor"; //$NON-NLS-1$
27
	String TARGET_EDITOR_ID = PLUGIN_ID + ".targetEditor"; //$NON-NLS-1$
28
	String TARGET_EDITOR_ID = PLUGIN_ID + ".targetEditor"; //$NON-NLS-1$
28
	String PLUGINS_VIEW_ID = "org.eclipse.pde.ui.PluginsView"; //$NON-NLS-1$
29
	String PLUGINS_VIEW_ID = "org.eclipse.pde.ui.PluginsView"; //$NON-NLS-1$
29
	String DEPENDENCIES_VIEW_ID = "org.eclipse.pde.ui.DependenciesView"; //$NON-NLS-1$
30
	String DEPENDENCIES_VIEW_ID = "org.eclipse.pde.ui.DependenciesView"; //$NON-NLS-1$
30
	String PERSPECTIVE_ID = "org.eclipse.pde.ui.PDEPerspective"; //$NON-NLS-1$
31
	String PERSPECTIVE_ID = "org.eclipse.pde.ui.PDEPerspective"; //$NON-NLS-1$
31
	
32
32
	String RUN_LAUNCHER_ID = PLUGIN_ID + "." + "WorkbenchRunLauncher"; //$NON-NLS-1$ //$NON-NLS-2$
33
	String RUN_LAUNCHER_ID = PLUGIN_ID + "." + "WorkbenchRunLauncher"; //$NON-NLS-1$ //$NON-NLS-2$
33
	String DEBUG_LAUNCHER_ID = PLUGIN_ID + "." + "WorkbenchDebugLauncher"; //$NON-NLS-1$ //$NON-NLS-2$
34
	String DEBUG_LAUNCHER_ID = PLUGIN_ID + "." + "WorkbenchDebugLauncher"; //$NON-NLS-1$ //$NON-NLS-2$
34
	String MARKER_SYSTEM_FILE_PATH = PLUGIN_ID + "."+ "systemFilePath"; //$NON-NLS-1$ //$NON-NLS-2$
35
	String MARKER_SYSTEM_FILE_PATH = PLUGIN_ID + "." + "systemFilePath"; //$NON-NLS-1$ //$NON-NLS-2$
35
36
36
	QualifiedName PROPERTY_EDITOR_PAGE_KEY =
37
	QualifiedName PROPERTY_EDITOR_PAGE_KEY = new QualifiedName(PLUGIN_ID, "editor-page-key"); //$NON-NLS-1$
37
		new QualifiedName(PLUGIN_ID, "editor-page-key");	 //$NON-NLS-1$
38
	QualifiedName PROPERTY_MANIFEST_EDITOR_PAGE_KEY = new QualifiedName(PLUGIN_ID, "manifest-editor-page-key"); //$NON-NLS-1$
38
	QualifiedName PROPERTY_MANIFEST_EDITOR_PAGE_KEY =
39
	QualifiedName DEFAULT_PRODUCT_EXPORT_LOCATION = new QualifiedName(PLUGIN_ID, "product-export-location"); //$NON-NLS-1$
39
		new QualifiedName(PLUGIN_ID, "manifest-editor-page-key");	 //$NON-NLS-1$
40
	QualifiedName DEFAULT_PRODUCT_EXPORT_DIR = new QualifiedName(PLUGIN_ID, "product-export-type"); //$NON-NLS-1$
40
	QualifiedName DEFAULT_PRODUCT_EXPORT_LOCATION =
41
	QualifiedName DEFAULT_PRODUCT_EXPORT_ROOT = new QualifiedName(PLUGIN_ID, "product-export-root"); //$NON-NLS-1$
41
		new QualifiedName(PLUGIN_ID, "product-export-location");	 //$NON-NLS-1$
42
	QualifiedName DEFAULT_PRODUCT_EXPORT_DIR =
43
		new QualifiedName(PLUGIN_ID, "product-export-type");	 //$NON-NLS-1$
44
	QualifiedName DEFAULT_PRODUCT_EXPORT_ROOT =
45
		new QualifiedName(PLUGIN_ID, "product-export-root");	 //$NON-NLS-1$
46
42
47
	String PLUGIN_DOC_ROOT = "/org.eclipse.pde.doc.user/"; //$NON-NLS-1$
43
	String PLUGIN_DOC_ROOT = "/org.eclipse.pde.doc.user/"; //$NON-NLS-1$
48
		
44
49
	// JUnit application identifiers
45
	// JUnit application identifiers
50
	String LEGACY_UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.legacytestapplication"; //$NON-NLS-1$
46
	String LEGACY_UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.legacytestapplication"; //$NON-NLS-1$
51
	String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$
47
	String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$
52
	String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$
48
	String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$
53
	
49
54
	/**
50
	/**
55
	 * Launch configuration attribute key.  The value is a boolean specifies
51
	 * Launch configuration attribute key.  The value is a boolean specifies
56
	 * whether the launch configuration is being restarted.  This does not need to 
52
	 * whether the launch configuration is being restarted.  This does not need to 
Lines 69-73 Link Here
69
	String LAUNCHER_PDE_VERSION = "pde.version"; //$NON-NLS-1$
65
	String LAUNCHER_PDE_VERSION = "pde.version"; //$NON-NLS-1$
70
	String APPEND_ARGS_EXPLICITLY = "append.args"; //$NON-NLS-1$
66
	String APPEND_ARGS_EXPLICITLY = "append.args"; //$NON-NLS-1$
71
	String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$
67
	String GENERATED_CONFIG = "pde.generated.config"; //$NON-NLS-1$
72
	
68
73
}
69
}
(-)src/org/eclipse/pde/internal/ui/PDEPluginImages.java (-94 / +99 lines)
Lines 11-17 Link Here
11
package org.eclipse.pde.internal.ui;
11
package org.eclipse.pde.internal.ui;
12
12
13
import java.net.URL;
13
import java.net.URL;
14
15
import org.eclipse.core.runtime.FileLocator;
14
import org.eclipse.core.runtime.FileLocator;
16
import org.eclipse.core.runtime.Path;
15
import org.eclipse.core.runtime.Path;
17
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jface.resource.ImageDescriptor;
Lines 23-42 Link Here
23
 */
22
 */
24
public class PDEPluginImages {
23
public class PDEPluginImages {
25
24
26
	private static final String NAME_PREFIX= PDEPlugin.getPluginId()+"."; //$NON-NLS-1$
25
	private static final String NAME_PREFIX = PDEPlugin.getPluginId() + "."; //$NON-NLS-1$
27
26
28
	private static ImageRegistry PLUGIN_REGISTRY;
27
	private static ImageRegistry PLUGIN_REGISTRY;
29
	
28
30
	public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$
29
	public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$
31
30
32
	/**
31
	/**
33
	 * Set of predefined Image Descriptors.
32
	 * Set of predefined Image Descriptors.
34
	 */
33
	 */
35
	
34
36
	private static final String PATH_OBJ= ICONS_PATH+"obj16/"; //$NON-NLS-1$
35
	private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$
37
	private static final String PATH_VIEW = ICONS_PATH+"view16/"; //$NON-NLS-1$
36
	private static final String PATH_VIEW = ICONS_PATH + "view16/"; //$NON-NLS-1$
38
	private static final String PATH_LCL= ICONS_PATH+"elcl16/"; //$NON-NLS-1$
37
	private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$
39
	private static final String PATH_LCL_DISABLED= ICONS_PATH+"dlcl16/"; //$NON-NLS-1$
38
	private static final String PATH_LCL_DISABLED = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$
40
	private static final String PATH_TOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$
39
	private static final String PATH_TOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$
41
	private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$
40
	private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$
42
	private static final String PATH_WIZBAN = ICONS_PATH + "wizban/"; //$NON-NLS-1$
41
	private static final String PATH_WIZBAN = ICONS_PATH + "wizban/"; //$NON-NLS-1$
Lines 44-92 Link Here
44
	/**
43
	/**
45
	 * Frequently used images
44
	 * Frequently used images
46
	 */
45
	 */
47
	public static final String IMG_FORM_WIZ = NAME_PREFIX+"FORM_WIZ"; //$NON-NLS-1$
46
	public static final String IMG_FORM_WIZ = NAME_PREFIX + "FORM_WIZ"; //$NON-NLS-1$
48
	public static final String IMG_FORM_BANNER = NAME_PREFIX+"FORM_BANNER"; //$NON-NLS-1$
47
	public static final String IMG_FORM_BANNER = NAME_PREFIX + "FORM_BANNER"; //$NON-NLS-1$
49
	public static final String IMG_ATT_CLASS_OBJ = NAME_PREFIX + "IMG_ATT_CLASS_OBJ"; //$NON-NLS-1$
48
	public static final String IMG_ATT_CLASS_OBJ = NAME_PREFIX + "IMG_ATT_CLASS_OBJ"; //$NON-NLS-1$
50
	public static final String IMG_ATT_FILE_OBJ  = NAME_PREFIX + "IMG_ATT_FILE_OBJ"; //$NON-NLS-1$
49
	public static final String IMG_ATT_FILE_OBJ = NAME_PREFIX + "IMG_ATT_FILE_OBJ"; //$NON-NLS-1$
51
	public static final String IMG_ATT_IMPL_OBJ  = NAME_PREFIX + "IMG_ATT_IMPL_OBJ"; //$NON-NLS-1$
50
	public static final String IMG_ATT_IMPL_OBJ = NAME_PREFIX + "IMG_ATT_IMPL_OBJ"; //$NON-NLS-1$
52
	public static final String IMG_ATT_REQ_OBJ   = NAME_PREFIX + "IMG_ATT_REQ_OBJ"; //$NON-NLS-1$
51
	public static final String IMG_ATT_REQ_OBJ = NAME_PREFIX + "IMG_ATT_REQ_OBJ"; //$NON-NLS-1$
53
	public static final String IMG_GENERIC_XML_OBJ  = NAME_PREFIX + "IMG_GENERIC_XML_OBJ"; //$NON-NLS-1$
52
	public static final String IMG_GENERIC_XML_OBJ = NAME_PREFIX + "IMG_GENERIC_XML_OBJ"; //$NON-NLS-1$
54
	public static final String OBJ_DESC_GENERATE_CLASS  = NAME_PREFIX + "OBJ_DESC_GENERATE_CLASS"; //$NON-NLS-1$
53
	public static final String OBJ_DESC_GENERATE_CLASS = NAME_PREFIX + "OBJ_DESC_GENERATE_CLASS"; //$NON-NLS-1$
55
	public static final String OBJ_DESC_GENERATE_INTERFACE  = NAME_PREFIX + "OBJ_DESC_GENERATE_INTERFACE"; //$NON-NLS-1$
54
	public static final String OBJ_DESC_GENERATE_INTERFACE = NAME_PREFIX + "OBJ_DESC_GENERATE_INTERFACE"; //$NON-NLS-1$
56
	public static final String OBJ_DESC_PACKAGE = NAME_PREFIX + "OBJ_DESC_PACKAGE"; //$NON-NLS-1$
55
	public static final String OBJ_DESC_PACKAGE = NAME_PREFIX + "OBJ_DESC_PACKAGE"; //$NON-NLS-1$
57
	public static final String OBJ_DESC_BUNDLE = NAME_PREFIX + "OBJ_DESC_BUNDLE"; //$NON-NLS-1$
56
	public static final String OBJ_DESC_BUNDLE = NAME_PREFIX + "OBJ_DESC_BUNDLE"; //$NON-NLS-1$
58
	
57
59
	/**
58
	/**
60
	 * OBJ16
59
	 * OBJ16
61
	 */
60
	 */
62
	public static final ImageDescriptor DESC_MAIN_TAB  = create(PATH_OBJ, "main_tab.gif"); //$NON-NLS-1$
61
	public static final ImageDescriptor DESC_MAIN_TAB = create(PATH_OBJ, "main_tab.gif"); //$NON-NLS-1$
63
	public static final ImageDescriptor DESC_ALL_SC_OBJ    = create(PATH_OBJ, "all_sc_obj.gif"); //$NON-NLS-1$
62
	public static final ImageDescriptor DESC_ALL_SC_OBJ = create(PATH_OBJ, "all_sc_obj.gif"); //$NON-NLS-1$
64
	public static final ImageDescriptor DESC_ATT_CLASS_OBJ = create(PATH_OBJ, "att_class_obj.gif"); //$NON-NLS-1$
63
	public static final ImageDescriptor DESC_ATT_CLASS_OBJ = create(PATH_OBJ, "att_class_obj.gif"); //$NON-NLS-1$
65
	public static final ImageDescriptor DESC_ATT_FILE_OBJ  = create(PATH_OBJ, "att_file_obj.gif"); //$NON-NLS-1$
64
	public static final ImageDescriptor DESC_ATT_FILE_OBJ = create(PATH_OBJ, "att_file_obj.gif"); //$NON-NLS-1$
66
	public static final ImageDescriptor DESC_ATT_IMPL_OBJ  = create(PATH_OBJ, "att_impl_obj.gif"); //$NON-NLS-1$
65
	public static final ImageDescriptor DESC_ATT_IMPL_OBJ = create(PATH_OBJ, "att_impl_obj.gif"); //$NON-NLS-1$
67
	public static final ImageDescriptor DESC_ATT_REQ_OBJ   = create(PATH_OBJ, "att_req_obj.gif"); //$NON-NLS-1$
66
	public static final ImageDescriptor DESC_ATT_REQ_OBJ = create(PATH_OBJ, "att_req_obj.gif"); //$NON-NLS-1$
68
	public static final ImageDescriptor DESC_ATT_URI_OBJ   = create(PATH_OBJ, "att_URI_obj.gif"); //$NON-NLS-1$
67
	public static final ImageDescriptor DESC_ATT_URI_OBJ = create(PATH_OBJ, "att_URI_obj.gif"); //$NON-NLS-1$
69
	public static final ImageDescriptor DESC_BUNDLE_OBJ = create(PATH_OBJ, "bundle_obj.gif"); //$NON-NLS-1$
68
	public static final ImageDescriptor DESC_BUNDLE_OBJ = create(PATH_OBJ, "bundle_obj.gif"); //$NON-NLS-1$
70
	public static final ImageDescriptor DESC_CHOICE_SC_OBJ = create(PATH_OBJ, "choice_sc_obj.gif"); //$NON-NLS-1$
69
	public static final ImageDescriptor DESC_CHOICE_SC_OBJ = create(PATH_OBJ, "choice_sc_obj.gif"); //$NON-NLS-1$
71
	public static final ImageDescriptor DESC_FEATURE_JAR_OBJ  = create(PATH_OBJ, "ftr_jar_obj.gif"); //$NON-NLS-1$
70
	public static final ImageDescriptor DESC_FEATURE_JAR_OBJ = create(PATH_OBJ, "ftr_jar_obj.gif"); //$NON-NLS-1$
72
	public static final ImageDescriptor DESC_FEATURE_MF_OBJ   = create(PATH_OBJ, "ftr_mf_obj.gif"); //$NON-NLS-1$
71
	public static final ImageDescriptor DESC_FEATURE_MF_OBJ = create(PATH_OBJ, "ftr_mf_obj.gif"); //$NON-NLS-1$
73
	public static final ImageDescriptor DESC_FEATURE_OBJ   = create(PATH_OBJ, "feature_obj.gif"); //$NON-NLS-1$
72
	public static final ImageDescriptor DESC_FEATURE_OBJ = create(PATH_OBJ, "feature_obj.gif"); //$NON-NLS-1$
74
	public static final ImageDescriptor DESC_NOREF_FEATURE_OBJ = create(PATH_OBJ, "noref_feature_obj.gif"); //$NON-NLS-1$
73
	public static final ImageDescriptor DESC_NOREF_FEATURE_OBJ = create(PATH_OBJ, "noref_feature_obj.gif"); //$NON-NLS-1$
75
	public static final ImageDescriptor DESC_ELREF_SC_OBJ  = create(PATH_OBJ, "elref_sc_obj.gif"); //$NON-NLS-1$
74
	public static final ImageDescriptor DESC_ELREF_SC_OBJ = create(PATH_OBJ, "elref_sc_obj.gif"); //$NON-NLS-1$
76
	public static final ImageDescriptor DESC_EXTENSIONS_OBJ = create(PATH_OBJ, "extensions_obj.gif"); //$NON-NLS-1$
75
	public static final ImageDescriptor DESC_EXTENSIONS_OBJ = create(PATH_OBJ, "extensions_obj.gif"); //$NON-NLS-1$
77
	public static final ImageDescriptor DESC_EXTENSION_OBJ = create(PATH_OBJ, "extension_obj.gif"); //$NON-NLS-1$
76
	public static final ImageDescriptor DESC_EXTENSION_OBJ = create(PATH_OBJ, "extension_obj.gif"); //$NON-NLS-1$
78
	public static final ImageDescriptor DESC_EXT_PLUGIN_OBJ   = create(PATH_OBJ, "ext_plugin_obj.gif"); //$NON-NLS-1$
77
	public static final ImageDescriptor DESC_EXT_PLUGIN_OBJ = create(PATH_OBJ, "ext_plugin_obj.gif"); //$NON-NLS-1$
79
	public static final ImageDescriptor DESC_EXT_FRAGMENT_OBJ   = create(PATH_OBJ, "external_frgmt_obj.gif"); //$NON-NLS-1$
78
	public static final ImageDescriptor DESC_EXT_FRAGMENT_OBJ = create(PATH_OBJ, "external_frgmt_obj.gif"); //$NON-NLS-1$
80
	public static final ImageDescriptor DESC_EXT_POINTS_OBJ   = create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$
79
	public static final ImageDescriptor DESC_EXT_POINTS_OBJ = create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$
81
	public static final ImageDescriptor DESC_EXT_POINT_OBJ   = create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$
80
	public static final ImageDescriptor DESC_EXT_POINT_OBJ = create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$
82
	public static final ImageDescriptor DESC_GEL_SC_OBJ    = create(PATH_OBJ, "gel_sc_obj.gif"); //$NON-NLS-1$
81
	public static final ImageDescriptor DESC_GEL_SC_OBJ = create(PATH_OBJ, "gel_sc_obj.gif"); //$NON-NLS-1$
83
	public static final ImageDescriptor DESC_GENERIC_XML_OBJ = create(PATH_OBJ, "generic_xml_obj.gif"); //$NON-NLS-1$
82
	public static final ImageDescriptor DESC_GENERIC_XML_OBJ = create(PATH_OBJ, "generic_xml_obj.gif"); //$NON-NLS-1$
84
	public static final ImageDescriptor DESC_GROUP_SC_OBJ   = create(PATH_OBJ, "group_sc_obj.gif"); //$NON-NLS-1$
83
	public static final ImageDescriptor DESC_GROUP_SC_OBJ = create(PATH_OBJ, "group_sc_obj.gif"); //$NON-NLS-1$
85
	public static final ImageDescriptor DESC_JAR_OBJ   = create(PATH_OBJ, "jar_obj.gif"); //$NON-NLS-1$
84
	public static final ImageDescriptor DESC_JAR_OBJ = create(PATH_OBJ, "jar_obj.gif"); //$NON-NLS-1$
86
	public static final ImageDescriptor DESC_JAR_LIB_OBJ   = create(PATH_OBJ, "jar_l_obj.gif"); //$NON-NLS-1$
85
	public static final ImageDescriptor DESC_JAR_LIB_OBJ = create(PATH_OBJ, "jar_l_obj.gif"); //$NON-NLS-1$
87
	public static final ImageDescriptor DESC_JAVA_LIB_OBJ   = create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$
86
	public static final ImageDescriptor DESC_JAVA_LIB_OBJ = create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$
88
	public static final ImageDescriptor DESC_OVERVIEW_OBJ  = create(PATH_OBJ, "overview_obj.gif"); //$NON-NLS-1$
87
	public static final ImageDescriptor DESC_OVERVIEW_OBJ = create(PATH_OBJ, "overview_obj.gif"); //$NON-NLS-1$
89
	public static final ImageDescriptor DESC_PAGE_OBJ   = create(PATH_OBJ, "page_obj.gif"); //$NON-NLS-1$
88
	public static final ImageDescriptor DESC_PAGE_OBJ = create(PATH_OBJ, "page_obj.gif"); //$NON-NLS-1$
90
	public static final ImageDescriptor DESC_PLUGIN_MF_OBJ = create(PATH_OBJ, "plugin_mf_obj.gif"); //$NON-NLS-1$
89
	public static final ImageDescriptor DESC_PLUGIN_MF_OBJ = create(PATH_OBJ, "plugin_mf_obj.gif"); //$NON-NLS-1$
91
	public static final ImageDescriptor DESC_FRAGMENT_MF_OBJ = create(PATH_OBJ, "frgmt_mf_obj.gif"); //$NON-NLS-1$
90
	public static final ImageDescriptor DESC_FRAGMENT_MF_OBJ = create(PATH_OBJ, "frgmt_mf_obj.gif"); //$NON-NLS-1$
92
	public static final ImageDescriptor DESC_BUILD_VAR_OBJ = create(PATH_OBJ, "build_var_obj.gif"); //$NON-NLS-1$
91
	public static final ImageDescriptor DESC_BUILD_VAR_OBJ = create(PATH_OBJ, "build_var_obj.gif"); //$NON-NLS-1$
Lines 105-133 Link Here
105
	public static final ImageDescriptor DESC_CSCONCLUSION_OBJ = create(PATH_OBJ, "cheatsheet_conclusion_obj.gif"); //$NON-NLS-1$
104
	public static final ImageDescriptor DESC_CSCONCLUSION_OBJ = create(PATH_OBJ, "cheatsheet_conclusion_obj.gif"); //$NON-NLS-1$
106
	public static final ImageDescriptor DESC_CSUNSUPPORTED_OBJ = create(PATH_OBJ, "cheatsheet_unsupported_obj.gif"); //$NON-NLS-1$
105
	public static final ImageDescriptor DESC_CSUNSUPPORTED_OBJ = create(PATH_OBJ, "cheatsheet_unsupported_obj.gif"); //$NON-NLS-1$
107
	public static final ImageDescriptor DESC_CHEATSHEET_OBJ = create(PATH_OBJ, "cheatsheet_obj.gif"); //$NON-NLS-1$
106
	public static final ImageDescriptor DESC_CHEATSHEET_OBJ = create(PATH_OBJ, "cheatsheet_obj.gif"); //$NON-NLS-1$
108
	
107
109
	public static final ImageDescriptor DESC_TOC_OBJ = create(PATH_OBJ, "toc_obj.gif"); //$NON-NLS-1$
108
	public static final ImageDescriptor DESC_TOC_OBJ = create(PATH_OBJ, "toc_obj.gif"); //$NON-NLS-1$
110
	public static final ImageDescriptor DESC_TOC_TOPIC_OBJ = create(PATH_OBJ, "toc_topic_obj.gif"); //$NON-NLS-1$
109
	public static final ImageDescriptor DESC_TOC_TOPIC_OBJ = create(PATH_OBJ, "toc_topic_obj.gif"); //$NON-NLS-1$
111
	public static final ImageDescriptor DESC_TOC_LEAFTOPIC_OBJ = create(PATH_OBJ, "toc_leaftopic_obj.gif"); //$NON-NLS-1$
110
	public static final ImageDescriptor DESC_TOC_LEAFTOPIC_OBJ = create(PATH_OBJ, "toc_leaftopic_obj.gif"); //$NON-NLS-1$
112
	public static final ImageDescriptor DESC_TOC_LINK_OBJ = create(PATH_OBJ, "toc_link_obj.gif"); //$NON-NLS-1$
111
	public static final ImageDescriptor DESC_TOC_LINK_OBJ = create(PATH_OBJ, "toc_link_obj.gif"); //$NON-NLS-1$
113
	public static final ImageDescriptor DESC_TOC_ANCHOR_OBJ = create(PATH_OBJ, "toc_anchor_obj.gif"); //$NON-NLS-1$
112
	public static final ImageDescriptor DESC_TOC_ANCHOR_OBJ = create(PATH_OBJ, "toc_anchor_obj.gif"); //$NON-NLS-1$
114
	
113
114
	public static final ImageDescriptor DESC_CTXHELP_CONTEXT_OBJ = create(PATH_OBJ, "ctxhelp_context_obj.gif"); //$NON-NLS-1$
115
	public static final ImageDescriptor DESC_CTXHELP_DESC_OBJ = create(PATH_OBJ, "ctxhelp_desc_obj.gif"); //$NON-NLS-1$
116
	public static final ImageDescriptor DESC_CTXHELP_COMMAND_OBJ = create(PATH_OBJ, "ctxhelp_command_obj.gif"); //$NON-NLS-1$
117
115
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
118
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
116
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
119
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
117
	
120
118
	public static final ImageDescriptor DESC_PLUGIN_OBJ   = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
121
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
119
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ   = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
122
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
120
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
123
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
121
	public static final ImageDescriptor DESC_SETTINGS_OBJ   = create(PATH_OBJ, "settings.gif"); //$NON-NLS-1$
124
	public static final ImageDescriptor DESC_SETTINGS_OBJ = create(PATH_OBJ, "settings.gif"); //$NON-NLS-1$
122
	public static final ImageDescriptor DESC_FRAGMENT_OBJ   = create(PATH_OBJ, "frgmt_obj.gif"); //$NON-NLS-1$
125
	public static final ImageDescriptor DESC_FRAGMENT_OBJ = create(PATH_OBJ, "frgmt_obj.gif"); //$NON-NLS-1$
123
	public static final ImageDescriptor DESC_FRAGMENT_DIS_OBJ   = create(PATH_OBJ, "frgmt_dis_obj.gif"); //$NON-NLS-1$
126
	public static final ImageDescriptor DESC_FRAGMENT_DIS_OBJ = create(PATH_OBJ, "frgmt_dis_obj.gif"); //$NON-NLS-1$
124
	public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ   = create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$
127
	public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$
125
	public static final ImageDescriptor DESC_FRAGMENTS_OBJ   = create(PATH_OBJ, "frgmts_obj.gif"); //$NON-NLS-1$
128
	public static final ImageDescriptor DESC_FRAGMENTS_OBJ = create(PATH_OBJ, "frgmts_obj.gif"); //$NON-NLS-1$
126
	public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ   = create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$
127
	public static final ImageDescriptor DESC_RUNTIME_OBJ   = create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$
130
	public static final ImageDescriptor DESC_RUNTIME_OBJ = create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$
128
	public static final ImageDescriptor DESC_SCHEMA_OBJ   = create(PATH_OBJ, "schema_obj.gif"); //$NON-NLS-1$
131
	public static final ImageDescriptor DESC_SCHEMA_OBJ = create(PATH_OBJ, "schema_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_SCOMP_JAR_OBJ = create(PATH_OBJ, "scomp_jar_obj.gif"); //$NON-NLS-1$
132
	public static final ImageDescriptor DESC_SCOMP_JAR_OBJ = create(PATH_OBJ, "scomp_jar_obj.gif"); //$NON-NLS-1$
130
	public static final ImageDescriptor DESC_SEQ_SC_OBJ   = create(PATH_OBJ, "seq_sc_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_SEQ_SC_OBJ = create(PATH_OBJ, "seq_sc_obj.gif"); //$NON-NLS-1$
131
	public static final ImageDescriptor DESC_DOC_SECTION_OBJ = create(PATH_OBJ, "doc_section_obj.gif"); //$NON-NLS-1$
134
	public static final ImageDescriptor DESC_DOC_SECTION_OBJ = create(PATH_OBJ, "doc_section_obj.gif"); //$NON-NLS-1$
132
	public static final ImageDescriptor DESC_ALERT_OBJ = create(PATH_OBJ, "alert_obj.gif"); //$NON-NLS-1$
135
	public static final ImageDescriptor DESC_ALERT_OBJ = create(PATH_OBJ, "alert_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_TSK_ALERT_OBJ = create(PATH_OBJ, "tsk_alert_obj.gif"); //$NON-NLS-1$
136
	public static final ImageDescriptor DESC_TSK_ALERT_OBJ = create(PATH_OBJ, "tsk_alert_obj.gif"); //$NON-NLS-1$
Lines 158-179 Link Here
158
	public static final ImageDescriptor DESC_SITE_XML_OBJ = create(PATH_OBJ, "site_xml_obj.gif"); //$NON-NLS-1$
161
	public static final ImageDescriptor DESC_SITE_XML_OBJ = create(PATH_OBJ, "site_xml_obj.gif"); //$NON-NLS-1$
159
	public static final ImageDescriptor DESC_IMAGE_APPLICATION = create(PATH_OBJ, "image_application.gif"); //$NON-NLS-1$
162
	public static final ImageDescriptor DESC_IMAGE_APPLICATION = create(PATH_OBJ, "image_application.gif"); //$NON-NLS-1$
160
	public static final ImageDescriptor DESC_FOCUS_ON = create(PATH_OBJ, "focus.gif"); //$NON-NLS-1$
163
	public static final ImageDescriptor DESC_FOCUS_ON = create(PATH_OBJ, "focus.gif"); //$NON-NLS-1$
161
	
164
162
	/**
165
	/**
163
	 * OVR16
166
	 * OVR16
164
	 */
167
	 */
165
	public static final ImageDescriptor DESC_DOC_CO   = create(PATH_OVR, "doc_co.gif"); //$NON-NLS-1$
168
	public static final ImageDescriptor DESC_DOC_CO = create(PATH_OVR, "doc_co.gif"); //$NON-NLS-1$
166
	public static final ImageDescriptor DESC_WARNING_CO   = create(PATH_OVR, "warning_co.gif"); //$NON-NLS-1$
169
	public static final ImageDescriptor DESC_WARNING_CO = create(PATH_OVR, "warning_co.gif"); //$NON-NLS-1$
167
	public static final ImageDescriptor DESC_ERROR_CO   = create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$
170
	public static final ImageDescriptor DESC_ERROR_CO = create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$
168
	public static final ImageDescriptor DESC_EXPORT_CO   = create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$
171
	public static final ImageDescriptor DESC_EXPORT_CO = create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$
169
	public static final ImageDescriptor DESC_EXTERNAL_CO   = create(PATH_OVR, "external_co.gif"); //$NON-NLS-1$
172
	public static final ImageDescriptor DESC_EXTERNAL_CO = create(PATH_OVR, "external_co.gif"); //$NON-NLS-1$
170
	public static final ImageDescriptor DESC_BINARY_CO   = create(PATH_OVR, "binary_co.gif"); //$NON-NLS-1$
173
	public static final ImageDescriptor DESC_BINARY_CO = create(PATH_OVR, "binary_co.gif"); //$NON-NLS-1$
171
	public static final ImageDescriptor DESC_JAVA_CO   = create(PATH_OVR, "java_co.gif"); //$NON-NLS-1$
174
	public static final ImageDescriptor DESC_JAVA_CO = create(PATH_OVR, "java_co.gif"); //$NON-NLS-1$
172
	public static final ImageDescriptor DESC_JAR_CO   = create(PATH_OVR, "jar_co.gif"); //$NON-NLS-1$
175
	public static final ImageDescriptor DESC_JAR_CO = create(PATH_OVR, "jar_co.gif"); //$NON-NLS-1$
173
	public static final ImageDescriptor DESC_PROJECT_CO   = create(PATH_OVR, "project_co.gif"); //$NON-NLS-1$
176
	public static final ImageDescriptor DESC_PROJECT_CO = create(PATH_OVR, "project_co.gif"); //$NON-NLS-1$
174
	public static final ImageDescriptor DESC_OPTIONAL_CO   = create(PATH_OVR, "optional_co.gif"); //$NON-NLS-1$
177
	public static final ImageDescriptor DESC_OPTIONAL_CO = create(PATH_OVR, "optional_co.gif"); //$NON-NLS-1$
175
	public static final ImageDescriptor DESC_INTERNAL_CO   = create(PATH_OVR, "internal_co.gif"); //$NON-NLS-1$
178
	public static final ImageDescriptor DESC_INTERNAL_CO = create(PATH_OVR, "internal_co.gif"); //$NON-NLS-1$
176
	public static final ImageDescriptor DESC_FRIEND_CO   = create(PATH_OVR, "friend_co.gif"); //$NON-NLS-1$
179
	public static final ImageDescriptor DESC_FRIEND_CO = create(PATH_OVR, "friend_co.gif"); //$NON-NLS-1$
177
180
178
	/**
181
	/**
179
	 * TOOL16
182
	 * TOOL16
Lines 193-199 Link Here
193
	public static final ImageDescriptor DESC_EXPORT_PRODUCT_TOOL = create(PATH_TOOL, "exp_product.gif"); //$NON-NLS-1$
196
	public static final ImageDescriptor DESC_EXPORT_PRODUCT_TOOL = create(PATH_TOOL, "exp_product.gif"); //$NON-NLS-1$
194
	public static final ImageDescriptor DESC_EXPORT_FEATURE_TOOL = create(PATH_TOOL, "exp_deployfeat.gif"); //$NON-NLS-1$
197
	public static final ImageDescriptor DESC_EXPORT_FEATURE_TOOL = create(PATH_TOOL, "exp_deployfeat.gif"); //$NON-NLS-1$
195
	public static final ImageDescriptor DESC_BUILD_TOOL = create(PATH_TOOL, "build_exec.gif"); //$NON-NLS-1$
198
	public static final ImageDescriptor DESC_BUILD_TOOL = create(PATH_TOOL, "build_exec.gif"); //$NON-NLS-1$
196
	
199
197
	/**
200
	/**
198
	 * LCL
201
	 * LCL
199
	 */
202
	 */
Lines 226-232 Link Here
226
	public static final ImageDescriptor DESC_HISTORY_LIST = create(PATH_LCL, "history_list.gif"); //$NON-NLS-1$
229
	public static final ImageDescriptor DESC_HISTORY_LIST = create(PATH_LCL, "history_list.gif"); //$NON-NLS-1$
227
	public static final ImageDescriptor DESC_CLEAR = create(PATH_LCL, "clear.gif"); //$NON-NLS-1$
230
	public static final ImageDescriptor DESC_CLEAR = create(PATH_LCL, "clear.gif"); //$NON-NLS-1$
228
	public static final ImageDescriptor DESC_FILTER = create(PATH_LCL, "filter_ps.gif"); //$NON-NLS-1$
231
	public static final ImageDescriptor DESC_FILTER = create(PATH_LCL, "filter_ps.gif"); //$NON-NLS-1$
229
	
232
230
	public static final ImageDescriptor DESC_ADD_ATT_DISABLED = create(PATH_LCL_DISABLED, "add_att.gif"); //$NON-NLS-1$
233
	public static final ImageDescriptor DESC_ADD_ATT_DISABLED = create(PATH_LCL_DISABLED, "add_att.gif"); //$NON-NLS-1$
231
	public static final ImageDescriptor DESC_ALPHAB_SORT_CO_DISABLED = create(PATH_LCL_DISABLED, "alphab_sort_co.gif"); //$NON-NLS-1$
234
	public static final ImageDescriptor DESC_ALPHAB_SORT_CO_DISABLED = create(PATH_LCL_DISABLED, "alphab_sort_co.gif"); //$NON-NLS-1$
232
	public static final ImageDescriptor DESC_CLONE_ATT_DISABLED = create(PATH_LCL_DISABLED, "clone_att.gif"); //$NON-NLS-1$
235
	public static final ImageDescriptor DESC_CLONE_ATT_DISABLED = create(PATH_LCL_DISABLED, "clone_att.gif"); //$NON-NLS-1$
Lines 248-263 Link Here
248
	public static final ImageDescriptor DESC_HISTORY_LIST_DISABLED = create(PATH_LCL_DISABLED, "history_list.gif"); //$NON-NLS-1$
251
	public static final ImageDescriptor DESC_HISTORY_LIST_DISABLED = create(PATH_LCL_DISABLED, "history_list.gif"); //$NON-NLS-1$
249
	public static final ImageDescriptor DESC_DCLEAR = create(PATH_LCL_DISABLED, "clear.gif"); //$NON-NLS-1$
252
	public static final ImageDescriptor DESC_DCLEAR = create(PATH_LCL_DISABLED, "clear.gif"); //$NON-NLS-1$
250
	public static final ImageDescriptor DESC_FILTER_DISABLED = create(PATH_LCL_DISABLED, "filter_ps.gif"); //$NON-NLS-1$
253
	public static final ImageDescriptor DESC_FILTER_DISABLED = create(PATH_LCL_DISABLED, "filter_ps.gif"); //$NON-NLS-1$
251
	
254
252
	public static final ImageDescriptor DESC_RUN_EXC = create(PATH_OBJ, "run_exc.gif"); //$NON-NLS-1$
255
	public static final ImageDescriptor DESC_RUN_EXC = create(PATH_OBJ, "run_exc.gif"); //$NON-NLS-1$
253
	public static final ImageDescriptor DESC_DEBUG_EXC = create(PATH_OBJ, "debug_exc.gif"); //$NON-NLS-1$
256
	public static final ImageDescriptor DESC_DEBUG_EXC = create(PATH_OBJ, "debug_exc.gif"); //$NON-NLS-1$
254
	public static final ImageDescriptor DESC_PROFILE_EXC = create(PATH_OBJ, "profile_exc.gif"); //$NON-NLS-1$
257
	public static final ImageDescriptor DESC_PROFILE_EXC = create(PATH_OBJ, "profile_exc.gif"); //$NON-NLS-1$
255
258
256
257
	/**
259
	/**
258
	 * WIZ
260
	 * WIZ
259
	 */
261
	 */
260
 	public static final ImageDescriptor DESC_NEWPPRJ_WIZ = create(PATH_WIZBAN, "newpprj_wiz.png"); //$NON-NLS-1$
262
	public static final ImageDescriptor DESC_NEWPPRJ_WIZ = create(PATH_WIZBAN, "newpprj_wiz.png"); //$NON-NLS-1$
261
	public static final ImageDescriptor DESC_NEWFRAGPRJ_WIZ = create(PATH_WIZBAN, "newfprj_wiz.png"); //$NON-NLS-1$
263
	public static final ImageDescriptor DESC_NEWFRAGPRJ_WIZ = create(PATH_WIZBAN, "newfprj_wiz.png"); //$NON-NLS-1$
262
	public static final ImageDescriptor DESC_DEFCON_WIZ = create(PATH_WIZBAN, "defcon_wiz.png"); //$NON-NLS-1$
264
	public static final ImageDescriptor DESC_DEFCON_WIZ = create(PATH_WIZBAN, "defcon_wiz.png"); //$NON-NLS-1$
263
	public static final ImageDescriptor DESC_TARGET_WIZ = create(PATH_WIZBAN, "target_wiz.png"); //$NON-NLS-1$
265
	public static final ImageDescriptor DESC_TARGET_WIZ = create(PATH_WIZBAN, "target_wiz.png"); //$NON-NLS-1$
Lines 285-321 Link Here
285
	/**
287
	/**
286
	 * View
288
	 * View
287
	 */
289
	 */
288
	public static final ImageDescriptor DESC_ARGUMENT_TAB  = create(PATH_VIEW, "variable_tab.gif"); //$NON-NLS-1$
290
	public static final ImageDescriptor DESC_ARGUMENT_TAB = create(PATH_VIEW, "variable_tab.gif"); //$NON-NLS-1$
291
289
	private static ImageDescriptor create(String prefix, String name) {
292
	private static ImageDescriptor create(String prefix, String name) {
290
		return ImageDescriptor.createFromURL(makeImageURL(prefix, name));
293
		return ImageDescriptor.createFromURL(makeImageURL(prefix, name));
291
	}
294
	}
295
292
	public static Image get(String key) {
296
	public static Image get(String key) {
293
		if (PLUGIN_REGISTRY==null) initialize();
297
		if (PLUGIN_REGISTRY == null)
298
			initialize();
294
		return PLUGIN_REGISTRY.get(key);
299
		return PLUGIN_REGISTRY.get(key);
295
	}
300
	}
296
301
297
/* package */
302
	/* package */
298
private static final void initialize() {
303
	private static final void initialize() {
299
	PLUGIN_REGISTRY = new ImageRegistry();
304
		PLUGIN_REGISTRY = new ImageRegistry();
300
	manage(IMG_ATT_CLASS_OBJ,DESC_ATT_CLASS_OBJ);
305
		manage(IMG_ATT_CLASS_OBJ, DESC_ATT_CLASS_OBJ);
301
	manage(IMG_ATT_FILE_OBJ, DESC_ATT_FILE_OBJ);
306
		manage(IMG_ATT_FILE_OBJ, DESC_ATT_FILE_OBJ);
302
	manage(IMG_ATT_IMPL_OBJ, DESC_ATT_IMPL_OBJ);
307
		manage(IMG_ATT_IMPL_OBJ, DESC_ATT_IMPL_OBJ);
303
	manage(IMG_ATT_REQ_OBJ,  DESC_ATT_REQ_OBJ);
308
		manage(IMG_ATT_REQ_OBJ, DESC_ATT_REQ_OBJ);
304
	manage(IMG_GENERIC_XML_OBJ, DESC_GENERIC_XML_OBJ);
309
		manage(IMG_GENERIC_XML_OBJ, DESC_GENERIC_XML_OBJ);
305
	manage(OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS);
310
		manage(OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS);
306
	manage(OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE);
311
		manage(OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE);
307
	manage(OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ);
312
		manage(OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ);
308
	manage(OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ);
313
		manage(OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ);
309
}
314
	}
310
315
311
private static URL makeImageURL(String prefix, String name) {
316
	private static URL makeImageURL(String prefix, String name) {
312
	String path = "$nl$/" + prefix + name; //$NON-NLS-1$
317
		String path = "$nl$/" + prefix + name; //$NON-NLS-1$
313
	return FileLocator.find(PDEPlugin.getDefault().getBundle(), new Path(path), null);
318
		return FileLocator.find(PDEPlugin.getDefault().getBundle(), new Path(path), null);
314
}
319
	}
315
320
316
public static Image manage(String key, ImageDescriptor desc) {
321
	public static Image manage(String key, ImageDescriptor desc) {
317
	Image image = desc.createImage();
322
		Image image = desc.createImage();
318
	PLUGIN_REGISTRY.put(key, image);
323
		PLUGIN_REGISTRY.put(key, image);
319
	return image;
324
		return image;
320
}
325
	}
321
}
326
}
(-)src/org/eclipse/pde/internal/ui/PDELabelProvider.java (-1 / +41 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 28-33 Link Here
28
import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject;
28
import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject;
29
import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants;
29
import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants;
30
import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject;
30
import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject;
31
import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants;
31
import org.eclipse.pde.internal.core.ifeature.*;
32
import org.eclipse.pde.internal.core.ifeature.*;
32
import org.eclipse.pde.internal.core.iproduct.IProductFeature;
33
import org.eclipse.pde.internal.core.iproduct.IProductFeature;
33
import org.eclipse.pde.internal.core.iproduct.IProductPlugin;
34
import org.eclipse.pde.internal.core.iproduct.IProductPlugin;
Lines 37-42 Link Here
37
import org.eclipse.pde.internal.core.itoc.ITocConstants;
38
import org.eclipse.pde.internal.core.itoc.ITocConstants;
38
import org.eclipse.pde.internal.core.plugin.ImportObject;
39
import org.eclipse.pde.internal.core.plugin.ImportObject;
39
import org.eclipse.pde.internal.core.text.bundle.*;
40
import org.eclipse.pde.internal.core.text.bundle.*;
41
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
40
import org.eclipse.pde.internal.core.text.toc.TocObject;
42
import org.eclipse.pde.internal.core.text.toc.TocObject;
41
import org.eclipse.pde.internal.core.util.PDETextHelper;
43
import org.eclipse.pde.internal.core.util.PDETextHelper;
42
import org.eclipse.pde.internal.ui.elements.NamedElement;
44
import org.eclipse.pde.internal.ui.elements.NamedElement;
Lines 93-98 Link Here
93
		if (obj instanceof TocObject) {
95
		if (obj instanceof TocObject) {
94
			return getObjectText((TocObject) obj);
96
			return getObjectText((TocObject) obj);
95
		}
97
		}
98
		if (obj instanceof CtxHelpObject) {
99
			return getObjectText((CtxHelpObject) obj);
100
		}
96
		if (obj instanceof FeaturePlugin) {
101
		if (obj instanceof FeaturePlugin) {
97
			return getObjectText((FeaturePlugin) obj);
102
			return getObjectText((FeaturePlugin) obj);
98
		}
103
		}
Lines 288-293 Link Here
288
		return PDETextHelper.translateReadText(obj.getName());
293
		return PDETextHelper.translateReadText(obj.getName());
289
	}
294
	}
290
295
296
	/**
297
	 * @param obj
298
	 */
299
	public String getObjectText(CtxHelpObject obj) {
300
		return PDETextHelper.translateReadText(obj.getName());
301
	}
302
291
	public String getObjectText(FeaturePlugin obj) {
303
	public String getObjectText(FeaturePlugin obj) {
292
		String name = isFullNameModeEnabled() ? obj.getLabel() : obj.getId();
304
		String name = isFullNameModeEnabled() ? obj.getLabel() : obj.getId();
293
		String version = obj.getVersion();
305
		String version = obj.getVersion();
Lines 442-447 Link Here
442
		if (obj instanceof TocObject) {
454
		if (obj instanceof TocObject) {
443
			return getObjectImage((TocObject) obj);
455
			return getObjectImage((TocObject) obj);
444
		}
456
		}
457
		if (obj instanceof CtxHelpObject) {
458
			return getObjectImage((CtxHelpObject) obj);
459
		}
445
		if (obj instanceof ISchemaAttribute) {
460
		if (obj instanceof ISchemaAttribute) {
446
			return getObjectImage((ISchemaAttribute) obj);
461
			return getObjectImage((ISchemaAttribute) obj);
447
		}
462
		}
Lines 717-722 Link Here
717
		}
732
		}
718
	}
733
	}
719
734
735
	/**
736
	 * @param object
737
	 */
738
	private Image getObjectImage(CtxHelpObject object) {
739
		switch (object.getType()) {
740
			case ICtxHelpConstants.TYPE_ROOT : {
741
				return get(PDEPluginImages.DESC_TOC_OBJ);
742
			}
743
			case ICtxHelpConstants.TYPE_CONTEXT : {
744
				return get(PDEPluginImages.DESC_CTXHELP_CONTEXT_OBJ);
745
			}
746
			case ICtxHelpConstants.TYPE_DESCRIPTION : {
747
				return get(PDEPluginImages.DESC_CTXHELP_DESC_OBJ);
748
			}
749
			case ICtxHelpConstants.TYPE_TOPIC : {
750
				return get(PDEPluginImages.DESC_TOC_LEAFTOPIC_OBJ);
751
			}
752
			case ICtxHelpConstants.TYPE_COMMAND : {
753
				return get(PDEPluginImages.DESC_CTXHELP_COMMAND_OBJ);
754
			}
755
			default :
756
				return get(PDEPluginImages.DESC_SIMPLECS_OBJ, F_ERROR);
757
		}
758
	}
759
720
	private Image getObjectImage(ISchemaElement element) {
760
	private Image getObjectImage(ISchemaElement element) {
721
		int flags = 0;
761
		int flags = 0;
722
		if (element instanceof ISchemaObjectReference && ((ISchemaObjectReference) element).getReferencedObject() == null)
762
		if (element instanceof ISchemaObjectReference && ((ISchemaObjectReference) element).getReferencedObject() == null)
(-)src/org/eclipse/pde/internal/ui/wizards/toc/TocHTMLWizardPage.java (-3 / +3 lines)
Lines 18-24 Link Here
18
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEPlugin;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
20
import org.eclipse.pde.internal.ui.PDEUIMessages;
21
import org.eclipse.pde.internal.ui.editor.toc.TocExtensionUtil;
21
import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil;
22
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
23
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
24
24
Lines 58-67 Link Here
58
			return false;
58
			return false;
59
		}
59
		}
60
60
61
		if(!TocExtensionUtil.hasValidPageExtension(new Path(fLastFilename)))
61
		if(!HelpEditorUtil.hasValidPageExtension(new Path(fLastFilename)))
62
		{	String message = NLS.bind(
62
		{	String message = NLS.bind(
63
				PDEUIMessages.TocHTMLWizardPage_badExtension, 
63
				PDEUIMessages.TocHTMLWizardPage_badExtension, 
64
				TocExtensionUtil.getPageExtensionList());
64
				HelpEditorUtil.getPageExtensionList());
65
		
65
		
66
			setErrorMessage(message);
66
			setErrorMessage(message);
67
			return false;
67
			return false;
(-)plugin.xml (+11 lines)
Lines 422-427 Link Here
422
               contentTypeId="org.eclipse.pde.tocFile">
422
               contentTypeId="org.eclipse.pde.tocFile">
423
         </contentTypeBinding>
423
         </contentTypeBinding>
424
      </editor>
424
      </editor>
425
      <editor
426
            class="org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpEditor"
427
            contributorClass="org.eclipse.pde.internal.ui.editor.toc.TocEditorContributor"
428
            default="true"
429
            icon="$nl$/icons/obj16/toc_obj.gif"
430
            id="org.eclipse.pde.ui.ctxHelpEditor"
431
            name="Context Help Editor">
432
         <contentTypeBinding
433
               contentTypeId="org.eclipse.help.contexts">
434
         </contentTypeBinding>
435
      </editor>
425
   </extension>
436
   </extension>
426
   <extension
437
   <extension
427
         point="org.eclipse.ui.views">
438
         point="org.eclipse.ui.views">
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpAbstractDetails.java (+200 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp.details;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.pde.core.IModelChangedEvent;
17
import org.eclipse.pde.internal.ui.editor.*;
18
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Label;
23
import org.eclipse.ui.forms.IFormPart;
24
import org.eclipse.ui.forms.widgets.*;
25
26
/**
27
 * TocAbstractDetails
28
 *
29
 */
30
public abstract class CtxHelpAbstractDetails extends PDEDetails {
31
32
	private static final int NUM_COLUMNS = 3;
33
34
	private CtxHelpTreeSection fMasterSection;
35
	private Section fMainSection;
36
	private String fContextID;
37
38
	public CtxHelpAbstractDetails(CtxHelpTreeSection masterSection, String contextID) {
39
		fMasterSection = masterSection;
40
		fContextID = contextID;
41
		fMainSection = null;
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
46
	 */
47
	public void createContents(Composite parent) {
48
		configureParentLayout(parent);
49
		createDetails(parent);
50
		hookListeners();
51
	}
52
53
	/**
54
	 * @param parent
55
	 */
56
	private void configureParentLayout(Composite parent) {
57
		parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
58
	}
59
60
	/**
61
	 * @param parent
62
	 */
63
	public void createDetails(Composite parent) { // Create the main section
64
		int style = ExpandableComposite.TITLE_BAR;
65
66
		if (getDetailsDescription() != null)
67
			style |= Section.DESCRIPTION;
68
69
		fMainSection = getPage().createUISection(parent, getDetailsTitle(), getDetailsDescription(), style);
70
		// Align the master and details section headers (misalignment caused
71
		// by section toolbar icons)
72
		getPage().alignSectionHeaders(getMasterSection().getSection(), fMainSection);
73
		// Create the container for the main section
74
		Composite sectionClient = getPage().createUISectionContainer(fMainSection, NUM_COLUMNS);
75
		GridData data = new GridData(GridData.FILL_BOTH);
76
		fMainSection.setLayoutData(data);
77
		createFields(sectionClient);
78
79
		// Bind widgets
80
		getManagedForm().getToolkit().paintBordersFor(sectionClient);
81
		fMainSection.setClient(sectionClient);
82
		markDetailsPart(fMainSection);
83
	}
84
85
	/**
86
	 * 
87
	 */
88
	protected abstract void createFields(Composite parent);
89
90
	/**
91
	 * 
92
	 */
93
	protected abstract String getDetailsTitle();
94
95
	/**
96
	 * 
97
	 */
98
	protected abstract String getDetailsDescription();
99
100
	/**
101
	 * 
102
	 */
103
	public abstract void updateFields();
104
105
	/**
106
	 * 
107
	 */
108
	public abstract void hookListeners();
109
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
112
	 */
113
	public void selectionChanged(IFormPart part, ISelection selection) {
114
		// NO-OP
115
		// Children to override
116
	}
117
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.pde.internal.ui.editor.IContextPart#fireSaveNeeded()
120
	 */
121
	public void fireSaveNeeded() {
122
		markDirty();
123
		getPage().getPDEEditor().fireSaveNeeded(getContextId(), false);
124
	}
125
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.pde.internal.ui.editor.IContextPart#getContextId()
128
	 */
129
	public String getContextId() {
130
		return fContextID;
131
	}
132
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.pde.internal.ui.editor.IContextPart#getPage()
135
	 */
136
	public PDEFormPage getPage() {
137
		return (PDEFormPage) getManagedForm().getContainer();
138
	}
139
140
	/* (non-Javadoc)
141
	 * @see org.eclipse.pde.internal.ui.editor.IContextPart#isEditable()
142
	 */
143
	public boolean isEditable() {
144
		return fMasterSection.isEditable();
145
	}
146
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
149
	 */
150
	public void modelChanged(IModelChangedEvent event) {
151
		// NO-OP
152
	}
153
154
	/**
155
	 * @return
156
	 */
157
	public boolean isEditableElement() {
158
		return fMasterSection.isEditable();
159
	}
160
161
	/**
162
	 * @return
163
	 */
164
	public FormToolkit getToolkit() {
165
		return getManagedForm().getToolkit();
166
	}
167
168
	/**
169
	 * @return
170
	 */
171
	public CtxHelpTreeSection getMasterSection() {
172
		return fMasterSection;
173
	}
174
175
	/**
176
	 * @param selection
177
	 * @return
178
	 */
179
	protected Object getFirstSelectedObject(ISelection selection) {
180
		// Get the structured selection (obtained from the master tree viewer)
181
		IStructuredSelection structuredSel = ((IStructuredSelection) selection);
182
		// Ensure we have a selection
183
		if (structuredSel == null) {
184
			return null;
185
		}
186
		return structuredSel.getFirstElement();
187
	}
188
189
	protected void createLabel(Composite client, FormToolkit toolkit, String text) {
190
		Label label = toolkit.createLabel(client, text, SWT.WRAP);
191
		GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
192
		gd.horizontalSpan = NUM_COLUMNS;
193
		label.setLayoutData(gd);
194
	}
195
196
	protected void createSpace(Composite parent) {
197
		createLabel(parent, getManagedForm().getToolkit(), ""); //$NON-NLS-1$
198
	}
199
200
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpFormOutlinePage.java (+90 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import java.util.List;
15
import org.eclipse.jface.viewers.ILabelProvider;
16
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel;
17
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
18
import org.eclipse.pde.internal.core.util.PDETextHelper;
19
import org.eclipse.pde.internal.ui.editor.FormOutlinePage;
20
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
21
22
/**
23
 * TocFormOutlinePage
24
 *
25
 */
26
public class CtxHelpFormOutlinePage extends FormOutlinePage {
27
	/**
28
	 * @param editor
29
	 */
30
	public CtxHelpFormOutlinePage(PDEFormEditor editor) {
31
		super(editor);
32
	}
33
34
	/**
35
	 * TocLabelProvider
36
	 *
37
	 */
38
	private class CtxHelpLabelProvider extends BasicLabelProvider {
39
		public String getText(Object obj) {
40
			if (obj instanceof CtxHelpObject) {
41
				return getObjectText((CtxHelpObject) obj);
42
			}
43
			return super.getText(obj);
44
		}
45
	}
46
47
	/**
48
	 * @param obj
49
	 * @return
50
	 */
51
	protected String getObjectText(CtxHelpObject obj) {
52
		return PDETextHelper.translateReadText(obj.getName());
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.pde.internal.ui.editor.FormOutlinePage#getChildren(java.lang.Object)
57
	 */
58
	protected Object[] getChildren(Object parent) {
59
		if (parent instanceof CtxHelpPage) {
60
			CtxHelpModel model = (CtxHelpModel) fEditor.getAggregateModel();
61
			if (model != null && model.isLoaded()) {
62
				Object[] list = new Object[1];
63
				list[0] = model.getCtxHelpRoot();
64
				return list;
65
			}
66
		} else if (parent instanceof CtxHelpObject) {
67
			List list = ((CtxHelpObject) parent).getChildren();
68
			// List is never null
69
			if (list.size() > 0) {
70
				return list.toArray();
71
			}
72
		}
73
74
		return super.getChildren(parent);
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.pde.internal.ui.editor.FormOutlinePage#createLabelProvider()
79
	 */
80
	public ILabelProvider createLabelProvider() {
81
		return new CtxHelpLabelProvider();
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.pde.internal.ui.editor.FormOutlinePage#getParentPageId(java.lang.Object)
86
	 */
87
	protected String getParentPageId(Object item) {
88
		return CtxHelpPage.PAGE_ID;
89
	}
90
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpPage.java (+157 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import org.eclipse.jface.text.source.ISourceViewer;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.pde.core.IModelChangedEvent;
18
import org.eclipse.pde.core.IModelChangedListener;
19
import org.eclipse.pde.internal.core.text.*;
20
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel;
21
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
22
import org.eclipse.pde.internal.ui.*;
23
import org.eclipse.pde.internal.ui.editor.PDEFormPage;
24
import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock;
25
import org.eclipse.swt.custom.StyledText;
26
import org.eclipse.ui.forms.IManagedForm;
27
import org.eclipse.ui.forms.editor.FormEditor;
28
import org.eclipse.ui.forms.editor.IFormPage;
29
import org.eclipse.ui.forms.widgets.ScrolledForm;
30
31
/**
32
 * TocPage
33
 *
34
 */
35
public class CtxHelpPage extends PDEFormPage implements IModelChangedListener {
36
	public static final String PAGE_ID = "ctxHelpPage"; //$NON-NLS-1$
37
38
	private CtxHelpBlock fBlock;
39
40
	/**
41
	 * @param editor
42
	 */
43
	public CtxHelpPage(FormEditor editor) {
44
		super(editor, PAGE_ID, PDEUIMessages.TocPage_title);
45
		fBlock = new CtxHelpBlock(this);
46
	}
47
48
	/**
49
	 * @return
50
	 */
51
	public PDEMasterDetailsBlock getBlock() {
52
		return fBlock;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
57
	 */
58
	protected void createFormContent(IManagedForm managedForm) {
59
		ScrolledForm form = managedForm.getForm();
60
		CtxHelpModel model = (CtxHelpModel) getModel();
61
62
		// Ensure the model was loaded properly
63
		if ((model == null) || (model.isLoaded() == false)) {
64
			createErrorContent(managedForm, model);
65
			return;
66
		}
67
68
		// TODO Add Help context
69
		//		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TOC_EDITOR);
70
71
		// Create the rest of the actions in the form title area
72
		super.createFormContent(managedForm);
73
		// Form image
74
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_CTXHELP_CONTEXT_OBJ));
75
		form.setText("Context-Sensitive Help Content");
76
		// Create the master details block
77
		fBlock.createContent(managedForm);
78
		// Force the selection in the masters tree section to load the 
79
		// proper details section
80
		fBlock.getMasterSection().fireSelection();
81
		// Register this page to be informed of model change events
82
		model.addModelChangedListener(this);
83
	}
84
85
	private void createErrorContent(IManagedForm managedForm, CtxHelpModel model) {
86
		// Create a formatted error page
87
		createFormErrorContent(managedForm, PDEUIMessages.TocPage_msgTOCLoadFailure, PDEUIMessages.TocPage_msgTOCParsingFailure, null);
88
	}
89
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#dispose()
92
	 */
93
	public void dispose() {
94
		CtxHelpModel model = (CtxHelpModel) getModel();
95
		if (model != null) {
96
			model.removeModelChangedListener(this);
97
		}
98
		super.dispose();
99
	}
100
101
	/* (non-Javadoc)
102
	 * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
103
	 */
104
	public void modelChanged(IModelChangedEvent event) {
105
		// Inform the block
106
		fBlock.modelChanged(event);
107
	}
108
109
	/**
110
	 * @return
111
	 */
112
	public ISelection getSelection() {
113
		return fBlock.getSelection();
114
	}
115
116
	public void setActive(boolean active) {
117
		super.setActive(active);
118
		if (active) {
119
			IFormPage page = getPDEEditor().findPage(CtxHelpInputContext.CONTEXT_ID);
120
			if (page instanceof CtxHelpSourcePage && ((CtxHelpSourcePage) page).getInputContext().isInSourceMode()) {
121
				ISourceViewer viewer = ((CtxHelpSourcePage) page).getViewer();
122
				if (viewer == null) {
123
					return;
124
				}
125
126
				StyledText text = viewer.getTextWidget();
127
				if (text == null) {
128
					return;
129
				}
130
131
				int offset = text.getCaretOffset();
132
				if (offset < 0) {
133
					return;
134
				}
135
136
				IDocumentRange range = ((CtxHelpSourcePage) page).getRangeElement(offset, true);
137
				if (range instanceof IDocumentAttributeNode) {
138
					range = ((IDocumentAttributeNode) range).getEnclosingElement();
139
				} else if (range instanceof IDocumentTextNode) {
140
					range = ((IDocumentTextNode) range).getEnclosingElement();
141
				}
142
143
				if (range instanceof CtxHelpObject) {
144
					fBlock.getMasterSection().setSelection(new StructuredSelection(range));
145
				}
146
			}
147
		}
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#getHelpResource()
152
	 */
153
	protected String getHelpResource() {
154
		// TODO Fix help
155
		return IPDEUIConstants.PLUGIN_DOC_ROOT + "guide/tools/editors/toc_editor/page_toc.htm"; //$NON-NLS-1$
156
	}
157
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContextManager.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.ctxhelp;
12
13
import org.eclipse.pde.core.IBaseModel;
14
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
15
import org.eclipse.pde.internal.ui.editor.context.InputContext;
16
import org.eclipse.pde.internal.ui.editor.context.InputContextManager;
17
18
public class CtxHelpInputContextManager extends InputContextManager {
19
20
	/**
21
	 * @param editor
22
	 */
23
	public CtxHelpInputContextManager(PDEFormEditor editor) {
24
		super(editor);
25
	}
26
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.pde.internal.ui.editor.context.InputContextManager#getAggregateModel()
29
	 */
30
	public IBaseModel getAggregateModel() {
31
		InputContext context = findContext(CtxHelpInputContext.CONTEXT_ID);
32
		if (context == null) {
33
			return null;
34
		}
35
		return context.getModel();
36
	}
37
38
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDropAdapter.java (+228 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.Path;
17
import org.eclipse.jface.viewers.TreeViewer;
18
import org.eclipse.jface.viewers.ViewerDropAdapter;
19
import org.eclipse.pde.core.IBaseModel;
20
import org.eclipse.pde.internal.ui.editor.ModelDataTransfer;
21
import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil;
22
import org.eclipse.swt.dnd.*;
23
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.widgets.Item;
26
27
/**
28
 * TocDropAdapter - implements drop behaviour for the TOC Tree Section.
29
 * It extends ViewerDropAdapter for advanced feedback behaviour, but
30
 * mostly overrides the specified drop behaviour.
31
 */
32
public class CtxHelpDropAdapter extends ViewerDropAdapter {
33
	private CtxHelpTreeSection fSection;
34
35
	/**
36
	 * Constant describing the position of the cursor relative 
37
	 * to the target object.  This means the mouse is positioned
38
	 * slightly after the target, but not after its children if it is
39
	 * expanded.
40
	 * @see #getCurrentLocation()
41
	 */
42
	public static final int LOCATION_JUST_AFTER = 5;
43
44
	public CtxHelpDropAdapter(TreeViewer tocTree, CtxHelpTreeSection section) {
45
		super(tocTree);
46
		fSection = section;
47
	}
48
49
	/**
50
	 * Returns the position of the given event's coordinates relative to its target.
51
	 * The position is determined to be before, after, or on the item, based on
52
	 * some threshold value.
53
	 *
54
	 * @param event the event
55
	 * @return one of the <code>LOCATION_* </code>constants defined in this class
56
	 */
57
	protected int determineLocation(DropTargetEvent event) {
58
		if (!(event.item instanceof Item)) {
59
			return LOCATION_NONE;
60
		}
61
		Item item = (Item) event.item;
62
		Point coordinates = new Point(event.x, event.y);
63
		coordinates = getViewer().getControl().toControl(coordinates);
64
		if (item != null) {
65
			Rectangle bounds = getBounds(item);
66
			if (bounds == null) {
67
				return LOCATION_NONE;
68
			}
69
			if ((coordinates.y - bounds.y) < 5) {
70
				return LOCATION_BEFORE;
71
			}
72
			if ((bounds.y + bounds.height - coordinates.y) < 5) {
73
				if ((bounds.y - coordinates.y) < 5) {
74
					return LOCATION_JUST_AFTER;
75
				}
76
				return LOCATION_AFTER;
77
			}
78
		}
79
		return LOCATION_ON;
80
	}
81
82
	/* (non-Javadoc)
83
	 * A new drag has entered the widget. Do file validation if necessary,
84
	 * and then set the Drag and Drop mode.
85
	 */
86
	public void dragEnter(DropTargetEvent event) {
87
		validateFileDrop(event);
88
		setDNDMode(event);
89
	}
90
91
	/* (non-Javadoc)
92
	 * Override the dragOver behaviour to directly supply event feedback
93
	 * but do nothing else.
94
	 */
95
	public void dragOver(DropTargetEvent event) {
96
		int currentLocation = determineLocation(event);
97
		switch (currentLocation) {
98
			case LOCATION_BEFORE :
99
				event.feedback = DND.FEEDBACK_INSERT_BEFORE;
100
				break;
101
			case LOCATION_AFTER :
102
			case LOCATION_JUST_AFTER :
103
				event.feedback = DND.FEEDBACK_INSERT_AFTER;
104
				break;
105
			case LOCATION_ON :
106
			default :
107
				event.feedback = DND.FEEDBACK_SELECT;
108
				break;
109
		}
110
111
		event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
112
	}
113
114
	/* (non-Javadoc)
115
	 * The Drag and Drop operation changed. Change the operation to a valid one
116
	 * if necessary.
117
	 */
118
	public void dragOperationChanged(DropTargetEvent event) {
119
		validateFileDrop(event);
120
		setDNDMode(event);
121
	}
122
123
	/**
124
	 * Set the Drag and Drop mode depending on the dragged items and event
125
	 * details. Files can only be copied, not linked or moved.
126
	 * Model data objects can have any operation occur.
127
	 * 
128
	 * All other objects cannot be dropped.
129
	 * 
130
	 * @param event The drop event to change.
131
	 */
132
	private void setDNDMode(DropTargetEvent event) {
133
		if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) { //If a file is being dragged
134
			if (event.detail == DND.DROP_DEFAULT) { //If no modifier key is pressed
135
				//set the operation to DROP_COPY if available
136
				//DROP_NONE otherwise
137
				event.detail = (event.operations & DND.DROP_COPY);
138
			} else { //If a modifier key is pressed for a file and the operation isn't a copy,
139
				//disallow it
140
				event.detail &= DND.DROP_COPY;
141
			}
142
		}
143
		//The only other transfer type allowed is a Model Data Transfer
144
		else if (!ModelDataTransfer.getInstance().isSupportedType(event.currentDataType)) { //disallow drag if the transfer is not Model Data or Files
145
			event.detail = DND.DROP_NONE;
146
		}
147
	}
148
149
	/**
150
	 * Ensure that, if files are being dropped, they have valid
151
	 * file extensions for the TOC Editor (HTML pages and XML documents).
152
	 * 
153
	 * Invalidate the drop if this condition is not met.
154
	 * 
155
	 * @param event The drop event containing the transfer.
156
	 */
157
	private void validateFileDrop(DropTargetEvent event) {
158
		if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
159
			IBaseModel model = fSection.getPage().getModel();
160
			String[] fileNames = (String[]) FileTransfer.getInstance().nativeToJava(event.currentDataType);
161
			for (int i = 0; i < fileNames.length; i++) {
162
				IPath path = new Path(fileNames[i]);
163
164
				// Make sure that the file is in the workspace
165
				if (ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path) == null) {
166
					event.detail = DND.DROP_NONE;
167
					return;
168
				}
169
170
				if (!HelpEditorUtil.hasValidPageExtension(path) && !HelpEditorUtil.isTOCFile(path)) {
171
					event.detail = DND.DROP_NONE;
172
					return;
173
				}
174
175
				// Make sure that the user isn't dropping a TOC into itself
176
				if (HelpEditorUtil.isCurrentResource(path, model)) {
177
					event.detail = DND.DROP_NONE;
178
					return;
179
				}
180
			}
181
		}
182
	}
183
184
	/* (non-Javadoc)
185
	 * Override the drop behaviour in order to directly manage the drop event
186
	 */
187
	public void drop(DropTargetEvent event) {
188
		Object target = determineTarget(event);
189
		int location = determineLocation(event);
190
		if (!fSection.performDrop(target, event.data, location)) {
191
			event.detail = DND.DROP_NONE;
192
		}
193
	}
194
195
	/* (non-Javadoc)
196
	 * Override the behaviour of ViewerDropAdapter#dragLeave(org.eclipse.swt.dnd.DropTargetEvent)
197
	 * 
198
	 * @see org.eclipse.swt.dnd.DropTargetAdapter#dragLeave(org.eclipse.swt.dnd.DropTargetEvent)
199
	 */
200
	public void dragLeave(DropTargetEvent event) { //NO-OP
201
	}
202
203
	/* (non-Javadoc)
204
	 * Override the behaviour of ViewerDropAdapter#dropAccept(org.eclipse.swt.dnd.DropTargetEvent)
205
	 * 
206
	 * @see org.eclipse.swt.dnd.DropTargetAdapter#dropAccept(org.eclipse.swt.dnd.DropTargetEvent)
207
	 */
208
	public void dropAccept(DropTargetEvent event) { //NO-OP
209
	}
210
211
	//These methods are never called because much of ViewerDropAdapter's
212
	//behaviour is overridden, but they must be implemented.
213
214
	/* (non-Javadoc)
215
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object)
216
	 */
217
	public boolean performDrop(Object data) {
218
		return false;
219
	}
220
221
	/* (non-Javadoc)
222
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
223
	 */
224
	public boolean validateDrop(Object target, int operation, TransferData transferType) {
225
		return false;
226
	}
227
228
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpContextDetails.java (+140 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp.details;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpContext;
16
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
17
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext;
18
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection;
19
import org.eclipse.pde.internal.ui.parts.FormEntry;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.ui.forms.IFormPart;
24
25
public class CtxHelpContextDetails extends CtxHelpAbstractDetails {
26
27
	private CtxHelpContext fContext;
28
	private FormEntry fIdEntry;
29
	private FormEntry fTitleEntry;
30
	private FormEntry fDescEntry;
31
32
	/**
33
	 * @param masterSection
34
	 */
35
	public CtxHelpContextDetails(CtxHelpTreeSection masterSection) {
36
		super(masterSection, CtxHelpInputContext.CONTEXT_ID);
37
	}
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite)
41
	 */
42
	public void createFields(Composite parent) {
43
		createLabel(parent, getManagedForm().getToolkit(), "Specify the help context id:");
44
		fIdEntry = new FormEntry(parent, getManagedForm().getToolkit(), "ID:", SWT.NONE);
45
		createSpace(parent);
46
		createLabel(parent, getManagedForm().getToolkit(), "Specify the context description that will be displayed to the user:");
47
		fDescEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Description:", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
48
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
49
		data.heightHint = 50;
50
		fDescEntry.getText().setLayoutData(data);
51
		data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
52
		fDescEntry.getLabel().setLayoutData(data);
53
		createSpace(parent);
54
		createLabel(parent, getManagedForm().getToolkit(), "Override the default title by specifying one here:");
55
		fTitleEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Title:", SWT.NONE);
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle()
60
	 */
61
	protected String getDetailsTitle() {
62
		return "Context Details";
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription()
67
	 */
68
	protected String getDetailsDescription() {
69
		return null;
70
	}
71
72
	/* (non-Javadoc)
73
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#hookListeners()
74
	 */
75
	public void hookListeners() {
76
		fIdEntry.setFormEntryListener(new FormEntryAdapter(this) {
77
			public void textValueChanged(FormEntry entry) {
78
				if (fContext != null) {
79
					fContext.setID(fIdEntry.getValue());
80
				}
81
			}
82
		});
83
		fDescEntry.setFormEntryListener(new FormEntryAdapter(this) {
84
			public void textValueChanged(FormEntry entry) {
85
				if (fContext != null) {
86
					if (fDescEntry.getValue().trim().length() > 0) {
87
						fContext.setDescription(fDescEntry.getValue());
88
					} else {
89
						// Pass null to delete the description node because it is empty
90
						fContext.setDescription(null);
91
					}
92
				}
93
			}
94
		});
95
		fTitleEntry.setFormEntryListener(new FormEntryAdapter(this) {
96
			public void textValueChanged(FormEntry entry) { // Ensure data object is defined
97
				if (fContext != null) {
98
					fContext.setTitle(fTitleEntry.getValue());
99
				}
100
			}
101
		});
102
	}
103
104
	/* (non-Javadoc)
105
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#updateFields()
106
	 */
107
	public void updateFields() {
108
		if (fContext != null) {
109
			fIdEntry.setValue(fContext.getId(), true);
110
			fIdEntry.setEditable(isEditableElement());
111
			fDescEntry.setValue(fContext.getDescription(), true);
112
			fDescEntry.setEditable(isEditableElement());
113
			fTitleEntry.setValue(fContext.getTitle(), true);
114
			fTitleEntry.setEditable(isEditableElement());
115
		}
116
	}
117
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
120
	 */
121
	public void commit(boolean onSave) {
122
		super.commit(onSave);
123
		// Only required for form entries
124
		fIdEntry.commit();
125
		fDescEntry.commit();
126
		fTitleEntry.commit();
127
128
	}
129
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
132
	 */
133
	public void selectionChanged(IFormPart part, ISelection selection) {
134
		Object object = getFirstSelectedObject(selection);
135
		if (object instanceof CtxHelpContext) {
136
			fContext = (CtxHelpContext) object;
137
			updateFields();
138
		}
139
	}
140
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpRemoveAction.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import org.eclipse.jface.action.Action;
15
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
16
import org.eclipse.pde.internal.ui.PDEUIMessages;
17
18
public class CtxHelpRemoveAction extends Action {
19
20
	private CtxHelpObject[] fObjects;
21
22
	//The next object to be selected after the
23
	//selected object is removed
24
	private CtxHelpObject fObjectToSelect;
25
26
	public CtxHelpRemoveAction() {
27
		// Adds the 'Delete' keybinding to the action when displayed
28
		// in a context menu
29
		setActionDefinitionId("org.eclipse.ui.edit.delete"); //$NON-NLS-1$
30
		setText(PDEUIMessages.TocPage_remove);
31
	}
32
33
	public void setToRemove(CtxHelpObject[] objects) {
34
		fObjects = objects;
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.jface.action.Action#run()
39
	 */
40
	public void run() {
41
		if (fObjects == null)
42
			return;
43
44
		for (int i = 0; i < fObjects.length; ++i) {
45
			if (fObjects[i] != null && fObjects[i].canBeRemoved()) {
46
				CtxHelpObject parent = fObjects[i].getParent();
47
				if (parent != null) {
48
					determineNextSelection(parent, i);
49
					// Remove the TOC object
50
					parent.removeChild(fObjects[i]);
51
				}
52
			}
53
		}
54
	}
55
56
	/**
57
	 * Determine the next object that should be selected
58
	 * after the designated object has been removed
59
	 * 
60
	 * @param parent The parent of the deleted object
61
	 */
62
	private void determineNextSelection(CtxHelpObject parent, int index) {
63
		// Select the next sibling
64
		fObjectToSelect = parent.getNextSibling(fObjects[index]);
65
		if (fObjectToSelect == null) {
66
			// No next sibling
67
			// Select the previous sibling
68
			fObjectToSelect = parent.getPreviousSibling(fObjects[index]);
69
			if (fObjectToSelect == null) {
70
				// No previous sibling
71
				// Select the parent
72
				fObjectToSelect = parent;
73
			}
74
		}
75
	}
76
77
	/**
78
	 * @return the object that should be selected
79
	 * after the current one is removed
80
	 */
81
	public CtxHelpObject getNextSelection() {
82
		return fObjectToSelect;
83
	}
84
85
	public void clearNextSelection() {
86
		fObjectToSelect = null;
87
	}
88
89
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpContentProvider.java (+63 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import java.util.List;
15
import org.eclipse.jface.viewers.ITreeContentProvider;
16
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel;
17
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
18
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
19
20
/**
21
 * TocContentProvider
22
 */
23
public class CtxHelpContentProvider extends DefaultContentProvider implements ITreeContentProvider {
24
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
27
	 */
28
	public Object[] getChildren(Object parentElement) {
29
		if (parentElement instanceof CtxHelpModel) {
30
			CtxHelpObject root = ((CtxHelpModel) parentElement).getCtxHelpRoot();
31
			return new Object[] {root};
32
		} else if (parentElement instanceof CtxHelpObject) {
33
			List list = ((CtxHelpObject) parentElement).getChildren();
34
			return list.toArray();
35
		}
36
		return new Object[0];
37
	}
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
41
	 */
42
	public Object getParent(Object element) {
43
		if (element instanceof CtxHelpObject) {
44
			return ((CtxHelpObject) element).getParent();
45
		}
46
		return null;
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
51
	 */
52
	public boolean hasChildren(Object element) {
53
		return (getChildren(element).length > 0);
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
58
	 */
59
	public Object[] getElements(Object inputElement) {
60
		return getChildren(inputElement);
61
	}
62
63
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpTreeSection.java (+1178 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import java.util.*;
15
import java.util.List;
16
import org.eclipse.core.resources.*;
17
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.jface.action.*;
20
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.jface.viewers.*;
22
import org.eclipse.pde.core.IModelChangedEvent;
23
import org.eclipse.pde.internal.core.ictxhelp.ICtxHelpConstants;
24
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
25
import org.eclipse.pde.internal.core.text.ctxhelp.*;
26
import org.eclipse.pde.internal.ui.PDEPlugin;
27
import org.eclipse.pde.internal.ui.PDEUIMessages;
28
import org.eclipse.pde.internal.ui.editor.*;
29
import org.eclipse.pde.internal.ui.editor.actions.CollapseAction;
30
import org.eclipse.pde.internal.ui.editor.plugin.FormFilteredTree;
31
import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil;
32
import org.eclipse.pde.internal.ui.parts.TreePart;
33
import org.eclipse.pde.internal.ui.util.PDELabelUtility;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.dnd.*;
36
import org.eclipse.swt.events.DisposeEvent;
37
import org.eclipse.swt.events.DisposeListener;
38
import org.eclipse.swt.graphics.Cursor;
39
import org.eclipse.swt.widgets.*;
40
import org.eclipse.ui.PartInitException;
41
import org.eclipse.ui.PlatformUI;
42
import org.eclipse.ui.actions.ActionFactory;
43
import org.eclipse.ui.actions.ContributionItemFactory;
44
import org.eclipse.ui.dialogs.PatternFilter;
45
import org.eclipse.ui.forms.widgets.FormToolkit;
46
import org.eclipse.ui.forms.widgets.Section;
47
import org.eclipse.ui.ide.IDE;
48
import org.eclipse.ui.keys.IBindingService;
49
50
/**
51
 * TocTreeSection - The section that displays the TOC
52
 * tree structure and any buttons used to manipulate it.
53
 * This is the main section that the user will interact
54
 * with the TOC through.
55
 */
56
public class CtxHelpTreeSection extends TreeSection {
57
	private CtxHelpModel fModel;
58
	private TreeViewer fTree;
59
	private FormFilteredTree fFilteredTree;
60
61
	/* The indices for each button attached to the Tree Viewer.
62
	 * This type of UI form does not permit direct access to each particular
63
	 * button. However, using these indices, one can perform any typical SWT
64
	 * operation on any button.
65
	 */
66
	private static final int F_BUTTON_ADD_CONTEXT = 0;
67
	private static final int F_BUTTON_ADD_TOPIC = 2;
68
	private static final int F_BUTTON_ADD_COMMAND = 3;
69
	private static final int F_BUTTON_REMOVE = 5;
70
	private static final int F_BUTTON_UP = 6;
71
	private static final int F_BUTTON_DOWN = 7;
72
73
	private static final int F_UP_FLAG = -1;
74
	private static final int F_DOWN_FLAG = 1;
75
76
	// The action that collapses down the TOC tree
77
	private CollapseAction fCollapseAction;
78
79
	// The actions that will add each type of TOC object
80
	private CtxHelpAbstractAddAction fAddContextAction;
81
	private CtxHelpAbstractAddAction fAddTopicAction;
82
	private CtxHelpAbstractAddAction fAddCommandAction;
83
84
	// The object removal action
85
	private CtxHelpRemoveAction fRemoveObjectAction;
86
87
	// The action for opening a link from the context menu
88
	private OpenLinkAction fOpenLinkAction;
89
90
	// The adapter that will listen for drag events in the tree
91
	private CtxHelpDragAdapter fDragAdapter;
92
93
	/** If items are dragged and dropped within this tree, then
94
	 * this flag inhibits reselection on the removal (drag) action,
95
	 * thus ensuring that the selected objects are the ones that were
96
	 * dropped.
97
	 */
98
	private boolean fDragFromHere;
99
100
	class OpenLinkAction extends Action {
101
102
		private CtxHelpTopic fOpenTarget;
103
104
		public OpenLinkAction() {
105
			super(PDEUIMessages.Actions_open_label);
106
		}
107
108
		public void setTarget(CtxHelpTopic target) {
109
			fOpenTarget = target;
110
		}
111
112
		public void run() {
113
			if (fOpenTarget != null) {
114
				open(fOpenTarget);
115
			}
116
		}
117
	}
118
119
	/**
120
	 * Constructs a new TOC tree section.
121
	 * 
122
	 * @param formPage The page that will hold this new tree section
123
	 * @param parent The parent composite in the page that will contain the section widgets
124
	 */
125
	public CtxHelpTreeSection(PDEFormPage formPage, Composite parent) {
126
127
		/* Create a new section with a description area, and some buttons.
128
		 * The null entries in the String array will become blank space 
129
		 * separators between the buttons.
130
		 */
131
		super(formPage, parent, Section.DESCRIPTION, new String[] {"Add Context", null, "Add Topic", "Add Command", null, PDEUIMessages.TocPage_remove, PDEUIMessages.TocPage_up, PDEUIMessages.TocPage_down});
132
	}
133
134
	/* (non-Javadoc)
135
	 * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
136
	 */
137
	protected void createClient(Section section, FormToolkit toolkit) {
138
		// Get the model
139
		fModel = (CtxHelpModel) getPage().getModel();
140
141
		// Create a container in the section
142
		Composite container = createClientContainer(section, 2, toolkit);
143
		// Create a TOC tree in the new container
144
		createTree(container, toolkit);
145
		toolkit.paintBordersFor(container);
146
		section.setText(PDEUIMessages.TocTreeSection_title);
147
		section.setDescription(PDEUIMessages.TocTreeSection_sectionDescription);
148
		section.setClient(container);
149
150
		createCommands();
151
152
		initializeTreeViewer();
153
		createSectionToolbar(section, toolkit);
154
155
		// Create the adapted listener for the filter entry field
156
		fFilteredTree.createUIListenerEntryFilter(this);
157
	}
158
159
	private void createCommands() {
160
		fAddContextAction = new CtxHelpAbstractAddAction() {
161
			public void run() {
162
				if (fParentObject != null) {
163
					CtxHelpContext context = fParentObject.getModel().getFactory().createContext();
164
					String id = PDELabelUtility.generateName(getChildNames(), "Help_Context");
165
					context.setID(id);
166
					addChild(context);
167
				}
168
			}
169
		};
170
		fAddContextAction.setText("Context");
171
		fAddTopicAction = new CtxHelpAbstractAddAction() {
172
			public void run() {
173
				if (fParentObject != null) {
174
					CtxHelpTopic topic = fParentObject.getModel().getFactory().createTopic();
175
					String label = PDELabelUtility.generateName(getChildNames(), "Help_Topic");
176
					topic.setLabel(label);
177
					addChild(topic);
178
				}
179
			}
180
		};
181
		fAddTopicAction.setText("Topic");
182
		fAddCommandAction = new CtxHelpAbstractAddAction() {
183
			public void run() {
184
				if (fParentObject != null) {
185
					CtxHelpCommand command = fParentObject.getModel().getFactory().createCommand();
186
					String label = PDELabelUtility.generateName(getChildNames(), "Help_Command");
187
					command.setLabel(label);
188
					addChild(command);
189
				}
190
			}
191
		};
192
		fAddCommandAction.setText("Command");
193
194
		fRemoveObjectAction = new CtxHelpRemoveAction();
195
196
		fOpenLinkAction = new OpenLinkAction();
197
	}
198
199
	/**
200
	 * Adds a link (with hand cursor) for tree 'Collapse All' action,
201
	 * which collapses the TOC tree down to the second level
202
	 * 
203
	 * @param section The section that the toolbar will belong to
204
	 * @param toolkit The toolkit that will be used to make the toolbar
205
	 */
206
	private void createSectionToolbar(Section section, FormToolkit toolkit) {
207
		ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
208
		ToolBar toolbar = toolBarManager.createControl(section);
209
210
		final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
211
		toolbar.setCursor(handCursor);
212
		// Cursor needs to be explicitly disposed
213
		toolbar.addDisposeListener(new DisposeListener() {
214
			public void widgetDisposed(DisposeEvent e) {
215
				if ((handCursor != null) && (handCursor.isDisposed() == false)) {
216
					handCursor.dispose();
217
				}
218
			}
219
		});
220
221
		// Add collapse action to the tool bar
222
		fCollapseAction = new CollapseAction(fTree, PDEUIMessages.ExtensionsPage_collapseAll, 1, fModel.getCtxHelpRoot());
223
		toolBarManager.add(fCollapseAction);
224
225
		toolBarManager.update(true);
226
		section.setTextClient(toolbar);
227
	}
228
229
	/**
230
	 * Create the tree widget that will contain the TOC
231
	 * 
232
	 * @param container The container of the tree widget
233
	 * @param toolkit The toolkit used to create the tree
234
	 */
235
	private void createTree(Composite container, FormToolkit toolkit) {
236
		TreePart treePart = getTreePart();
237
		createViewerPartControl(container, SWT.MULTI, 2, toolkit);
238
239
		fTree = treePart.getTreeViewer();
240
		fTree.setContentProvider(new CtxHelpContentProvider());
241
		fTree.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
242
243
		PDEPlugin.getDefault().getLabelProvider().connect(this);
244
245
		createTreeListeners();
246
		initDragAndDrop();
247
	}
248
249
	/**
250
	 * Initialize the section's drag and drop capabilities
251
	 */
252
	private void initDragAndDrop() {
253
		int ops = DND.DROP_COPY;
254
		if (isEditable()) {
255
			ops |= DND.DROP_MOVE;
256
		}
257
258
		//Content dragged from the tree viewer can be treated as model objects (TocObjects)
259
		//or as text (XML representation of the TocObjects)
260
		Transfer[] dragTransfers = new Transfer[] {ModelDataTransfer.getInstance(), TextTransfer.getInstance()};
261
		fDragAdapter = new CtxHelpDragAdapter(this);
262
		fTree.addDragSupport(ops, dragTransfers, fDragAdapter);
263
264
		if (isEditable()) { //Model objects and files can be dropped onto the viewer
265
			//TODO: Consider allowing drops/pastes of pure XML text
266
			Transfer[] dropTransfers = new Transfer[] {ModelDataTransfer.getInstance(), FileTransfer.getInstance()};
267
			fTree.addDropSupport(ops | DND.DROP_DEFAULT, dropTransfers, new CtxHelpDropAdapter(fTree, this));
268
		}
269
	}
270
271
	/**
272
	 * Create the action listeners for the tree.
273
	 */
274
	private void createTreeListeners() {
275
		// Create listener for the outline view 'link with editor' toggle button
276
		fTree.addPostSelectionChangedListener(getPage().getPDEEditor().new PDEFormEditorChangeListener());
277
	}
278
279
	/**
280
	 * Initialize the tree viewer widget and its buttons.
281
	 */
282
	private void initializeTreeViewer() {
283
		if (fModel == null) {
284
			return;
285
		}
286
287
		CtxHelpRoot root = fModel.getCtxHelpRoot();
288
		fTree.setInput(root);
289
290
		// Buttons must be disabled if file is ineditable
291
		getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, isEditable());
292
		getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, isEditable());
293
		getTreePart().setButtonEnabled(F_BUTTON_ADD_TOPIC, isEditable());
294
295
		// Set to false because initial node selected is the root TOC node
296
		getTreePart().setButtonEnabled(F_BUTTON_REMOVE, false);
297
		// Set to false because initial node selected is the root TOC node
298
		getTreePart().setButtonEnabled(F_BUTTON_UP, false);
299
		// Set to false because initial node selected is the root TOC node
300
		getTreePart().setButtonEnabled(F_BUTTON_DOWN, false);
301
302
		//Initially, the root TOC element is selected
303
		//		fTree.setSelection(new StructuredSelection(root), true);
304
		//		fTree.expandToLevel(0);
305
	}
306
307
	/* (non-Javadoc)
308
	 * @see org.eclipse.ui.forms.AbstractFormPart#setFormInput(java.lang.Object)
309
	 */
310
	public boolean setFormInput(Object object) {
311
		// This method allows the outline view to select items in the tree
312
		// (Invoked by org.eclipse.ui.forms.editor.IFormPage.selectReveal(Object object))
313
314
		if (object instanceof CtxHelpObject) { // Select the item in the tree
315
			fTree.setSelection(new StructuredSelection(object), true);
316
317
			// Verify that something was actually selected
318
			ISelection selection = fTree.getSelection();
319
			if (selection != null && !selection.isEmpty()) {
320
				return true;
321
			}
322
		}
323
324
		return false;
325
	}
326
327
	/**
328
	 * @return the selection of the tree section
329
	 */
330
	public ISelection getSelection() {
331
		return fTree.getSelection();
332
	}
333
334
	/**
335
	 * @param selection the new selection for the tree section
336
	 */
337
	public void setSelection(ISelection selection) {
338
		fTree.setSelection(selection);
339
	}
340
341
	/**
342
	 * Fire a selection change event and refresh the viewer's selection
343
	 */
344
	public void fireSelection() {
345
		fTree.setSelection(fTree.getSelection());
346
	}
347
348
	/* (non-Javadoc)
349
	 * @see org.eclipse.pde.internal.ui.editor.TreeSection#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
350
	 */
351
	protected void selectionChanged(IStructuredSelection selection) {
352
		getPage().getPDEEditor().setSelection(selection);
353
		updateButtons();
354
	}
355
356
	/**
357
	 * Update the buttons in the section based on the current selection
358
	 */
359
	public void updateButtons() {
360
361
		if (!fModel.isEditable()) {
362
			return;
363
		}
364
365
		IStructuredSelection selection = (IStructuredSelection) fTree.getSelection();
366
		CtxHelpObject firstSelectedObject = (CtxHelpObject) selection.getFirstElement();
367
368
		// Add Context
369
		getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, true);
370
371
		// Add Topic
372
		boolean enableAdd = false;
373
		if (firstSelectedObject != null) {
374
			if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) {
375
				enableAdd = true;
376
			} else if (firstSelectedObject.canAddChild(ICtxHelpConstants.TYPE_TOPIC)) {
377
				enableAdd = true;
378
			}
379
		}
380
		getTreePart().setButtonEnabled(F_BUTTON_ADD_TOPIC, enableAdd);
381
382
		// Add Command
383
		enableAdd = false;
384
		if (firstSelectedObject != null) {
385
			if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) {
386
				enableAdd = true;
387
			} else if (firstSelectedObject.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) {
388
				enableAdd = true;
389
			}
390
		}
391
		getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, enableAdd);
392
393
		// Remove button
394
		getTreePart().setButtonEnabled(F_BUTTON_REMOVE, getRemovableObjectFromSelection(selection).size() > 0);
395
396
		// Up and Down buttons
397
		boolean canMoveUp = true;
398
		boolean canMoveDown = true;
399
		if (firstSelectedObject == null || firstSelectedObject.getType() == ICtxHelpConstants.TYPE_ROOT || firstSelectedObject.getType() == ICtxHelpConstants.TYPE_DESCRIPTION || selection.size() > 1) {
400
			canMoveUp = false;
401
			canMoveDown = false;
402
		} else {
403
			CtxHelpObject parent = firstSelectedObject.getParent();
404
			if (parent != null) {
405
				if (parent.isFirstChildNode(firstSelectedObject, firstSelectedObject.getClass())) {
406
					canMoveUp = false;
407
				}
408
				if (parent.isLastChildNode(firstSelectedObject, firstSelectedObject.getClass())) {
409
					canMoveDown = false;
410
				}
411
			}
412
		}
413
		getTreePart().setButtonEnabled(F_BUTTON_UP, canMoveUp);
414
		getTreePart().setButtonEnabled(F_BUTTON_DOWN, canMoveDown);
415
	}
416
417
	/* (non-Javadoc)
418
	 * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager)
419
	 */
420
	protected void fillContextMenu(IMenuManager manager) {
421
		// Get the current selection
422
		IStructuredSelection selection = (IStructuredSelection) fTree.getSelection();
423
		Object object = selection.getFirstElement();
424
		// Has to be null or a CtxHelpObject object
425
		CtxHelpObject firstSelectedObject = (CtxHelpObject) object;
426
427
		if (firstSelectedObject != null) {
428
			MenuManager submenu = new MenuManager(PDEUIMessages.Menus_new_label);
429
430
			// Populate the "New" sub-menu
431
			boolean addMenu = false;
432
			if (updateAddContextActionWithSelection(firstSelectedObject)) {
433
				submenu.add(fAddContextAction);
434
				addMenu = true;
435
			}
436
			if (updateAddTopicActionWithSelection(firstSelectedObject)) {
437
				submenu.add(fAddTopicAction);
438
				addMenu = true;
439
			}
440
			if (updateAddCommandActionWithSelection(firstSelectedObject)) {
441
				submenu.add(fAddCommandAction);
442
				addMenu = true;
443
			}
444
			if (addMenu) {
445
				manager.add(submenu);
446
				manager.add(new Separator());
447
			}
448
		}
449
450
		if (firstSelectedObject instanceof CtxHelpTopic && ((CtxHelpTopic) firstSelectedObject).getLocation() != null) {
451
			fOpenLinkAction.setTarget((CtxHelpTopic) firstSelectedObject);
452
			manager.add(fOpenLinkAction);
453
			fillContextMenuShowInAction(manager);
454
			manager.add(new Separator());
455
		}
456
457
		// Add clipboard actions
458
		getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);
459
		manager.add(new Separator());
460
461
		if (updateRemoveActionWithSelection(selection)) {
462
			manager.add(fRemoveObjectAction);
463
			manager.add(new Separator());
464
		}
465
466
	}
467
468
	private void fillContextMenuShowInAction(IMenuManager manager) {
469
		String showInLabel = PDEUIMessages.PluginsView_showIn;
470
471
		// Add a label for the keybinding for Show In action, if one exists
472
		IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
473
		if (bindingService != null) {
474
			String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.ui.navigate.showInQuickMenu"); //$NON-NLS-1$
475
			if (keyBinding != null) {
476
				showInLabel += '\t' + keyBinding;
477
			}
478
		}
479
480
		// Add the "Show In" action and its contributions
481
		IMenuManager showInMenu = new MenuManager(showInLabel);
482
		showInMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getPage().getSite().getWorkbenchWindow()));
483
484
		manager.add(showInMenu);
485
	}
486
487
	private boolean updateAddContextActionWithSelection(CtxHelpObject selectedObject) {
488
		if (selectedObject != null && selectedObject.canAddSibling(ICtxHelpConstants.TYPE_CONTEXT)) {
489
			fAddContextAction.setParentObject(selectedObject.getParent());
490
			fAddContextAction.setTargetObject(selectedObject);
491
			fAddContextAction.setEnabled(fModel.isEditable());
492
			return true;
493
		} else if (selectedObject != null && selectedObject.canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) {
494
			fAddContextAction.setParentObject(selectedObject);
495
			fAddContextAction.setTargetObject(null);
496
			fAddContextAction.setEnabled(fModel.isEditable());
497
			return true;
498
		} else if (fModel.getCtxHelpRoot().canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) {
499
			fAddContextAction.setParentObject(fModel.getCtxHelpRoot());
500
			fAddContextAction.setTargetObject(null);
501
			fAddContextAction.setEnabled(fModel.isEditable());
502
			return true;
503
		}
504
		return false;
505
	}
506
507
	private boolean updateAddTopicActionWithSelection(CtxHelpObject selectedObject) {
508
		if (selectedObject != null) {
509
			if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) {
510
				fAddTopicAction.setParentObject(selectedObject.getParent());
511
				fAddTopicAction.setTargetObject(selectedObject);
512
				fAddTopicAction.setEnabled(fModel.isEditable());
513
				return true;
514
			} else if (selectedObject.canAddChild(ICtxHelpConstants.TYPE_TOPIC)) {
515
				fAddTopicAction.setParentObject(selectedObject);
516
				fAddTopicAction.setTargetObject(null);
517
				fAddTopicAction.setEnabled(fModel.isEditable());
518
				return true;
519
			}
520
		}
521
		return false;
522
	}
523
524
	private boolean updateAddCommandActionWithSelection(CtxHelpObject selectedObject) {
525
		if (selectedObject != null) {
526
			if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) {
527
				fAddCommandAction.setParentObject(selectedObject.getParent());
528
				fAddCommandAction.setTargetObject(selectedObject);
529
				fAddCommandAction.setEnabled(fModel.isEditable());
530
				return true;
531
			} else if (selectedObject.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) {
532
				fAddCommandAction.setParentObject(selectedObject);
533
				fAddCommandAction.setTargetObject(null);
534
				fAddCommandAction.setEnabled(fModel.isEditable());
535
				return true;
536
			}
537
		}
538
		return false;
539
	}
540
541
	private boolean updateRemoveActionWithSelection(IStructuredSelection selection) {
542
		List objectsToRemove = getRemovableObjectFromSelection(selection);
543
		fRemoveObjectAction.setToRemove((CtxHelpObject[]) objectsToRemove.toArray(new CtxHelpObject[objectsToRemove.size()]));
544
		fRemoveObjectAction.setEnabled(fModel.isEditable());
545
		return objectsToRemove.size() > 0;
546
	}
547
548
	private List getRemovableObjectFromSelection(IStructuredSelection selection) {
549
		List objectsToRemove = new ArrayList();
550
		for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
551
			Object currentObject = iterator.next();
552
			if (currentObject instanceof CtxHelpObject && ((CtxHelpObject) currentObject).canBeRemoved()) {
553
				objectsToRemove.add(currentObject);
554
			}
555
		}
556
		return objectsToRemove;
557
	}
558
559
	/* (non-Javadoc)
560
	 * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canPaste(java.lang.Object, java.lang.Object[])
561
	 */
562
	protected boolean canPaste(Object targetObject, Object[] sourceObjects) {
563
		return true;
564
	}
565
566
	/* (non-Javadoc)
567
	 * @see org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang.String)
568
	 */
569
	public boolean doGlobalAction(String actionId) {
570
		boolean cutAction = actionId.equals(ActionFactory.CUT.getId());
571
572
		if (cutAction || actionId.equals(ActionFactory.DELETE.getId())) {
573
			updateRemoveActionWithSelection((IStructuredSelection) fTree.getSelection());
574
			fRemoveObjectAction.run();
575
			return !cutAction;
576
		}
577
578
		if (actionId.equals(ActionFactory.PASTE.getId())) {
579
			doPaste();
580
			return true;
581
		}
582
583
		return false;
584
	}
585
586
	/* (non-Javadoc)
587
	 * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doPaste(java.lang.Object, java.lang.Object[])
588
	 */
589
	protected void doPaste(Object targetObject, Object[] sourceObjects) {
590
		performDrop(targetObject, sourceObjects, ViewerDropAdapter.LOCATION_ON);
591
	}
592
593
	/* (non-Javadoc)
594
	 * @see org.eclipse.pde.internal.ui.editor.TreeSection#handleDoubleClick(org.eclipse.jface.viewers.IStructuredSelection)
595
	 */
596
	protected void handleDoubleClick(IStructuredSelection selection) {
597
		Object selected = selection.getFirstElement();
598
		if (selected instanceof CtxHelpTopic) {
599
			open((CtxHelpTopic) selected);
600
		} else if (selected instanceof CtxHelpObject) {
601
			fTree.expandToLevel(selected, 1);
602
		}
603
	}
604
605
	/**
606
	 * Opens a document with the specified path
607
	 * 
608
	 * @param path a path to a resource, relative to this TOC's root project
609
	 */
610
	private void open(CtxHelpTopic topic) {
611
		IPath resourcePath = topic.getLocation();
612
		if (!isEditable() || resourcePath == null || resourcePath.isEmpty()) {
613
			MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, PDEUIMessages.WindowImagesSection_emptyPath);
614
			return;
615
		}
616
617
		IResource resource = findResource(resourcePath);
618
		if (resource != null && resource instanceof IFile) {
619
			openResource(resource);
620
		} else {
621
			MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, PDEUIMessages.WindowImagesSection_warning);
622
		}
623
	}
624
625
	public IFile openFile(String stringPath) {
626
		IPath path = new Path(stringPath);
627
		if (isEditable()) {
628
			if (!path.isEmpty()) {
629
				IResource page = findResource(path);
630
				if (page != null && page instanceof IFile) {
631
					openResource(page);
632
					return null;
633
				}
634
			}
635
636
			// TODO Consider having a new wizard
637
			//			return showNewWizard(path, isTOCFile);
638
		}
639
640
		return null;
641
	}
642
643
	//	private IFile showNewWizard(String path, boolean tocWizard) {
644
	//		TocHTMLWizard wizard;
645
	//		if (tocWizard) {
646
	//			wizard = new NewTocFileWizard();
647
	//		} else {
648
	//			wizard = new TocHTMLWizard();
649
	//		}
650
	//
651
	//		// By default, the file will be created in the same project as the TOC
652
	//		IResource selectedFolder = fModel.getUnderlyingResource().getProject();
653
	//		String filename = null;
654
	//
655
	//		// Find the folder associated with the specified path
656
	//		IPath initialFolder = new Path(path.trim());
657
	//		if (!initialFolder.isEmpty()) {
658
	//			IPath newPath = selectedFolder.getFullPath().append(initialFolder);
659
	//
660
	//			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
661
	//			IResource newFolder = root.findMember(newPath);
662
	//
663
	//			if (newFolder == null) {
664
	//				if (!newPath.hasTrailingSeparator()) {
665
	//					filename = newPath.lastSegment();
666
	//				}
667
	//			}
668
	//
669
	//			while (newFolder == null && !newPath.isEmpty()) {
670
	//				newPath = newPath.removeLastSegments(1);
671
	//				newFolder = root.findMember(newPath);
672
	//			}
673
	//
674
	//			if (newFolder != null) {
675
	//				selectedFolder = newFolder;
676
	//			}
677
	//		}
678
	//
679
	//		// Select the project in the wizard
680
	//		wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(selectedFolder));
681
	//
682
	//		// Create the dialog for the wizard
683
	//		WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
684
	//		dialog.create();
685
	//		// Get the wizard page
686
	//		IWizardPage wizardPage;
687
	//		wizardPage = wizard.getStartingPage();
688
	//		if (!(wizardPage instanceof WizardNewFileCreationPage)) {
689
	//			return null;
690
	//		}
691
	//
692
	//		WizardNewFileCreationPage page = (WizardNewFileCreationPage) wizardPage;
693
	//		if (filename != null) {
694
	//			page.setFileName(filename);
695
	//			// Inhibit the error message when the wizard is first opened
696
	//			page.setErrorMessage(null);
697
	//		}
698
	//
699
	//		if (dialog.open() == Window.OK) {
700
	//			return wizard.getNewResource();
701
	//		}
702
	//
703
	//		return null;
704
	//	}
705
	//
706
	private IResource findResource(IPath resourcePath) {
707
		IProject pluginProject = fModel.getUnderlyingResource().getProject();
708
		return pluginProject.findMember(resourcePath);
709
	}
710
711
	private void openResource(IResource resource) {
712
		IPath path = resource.getFullPath();
713
		if (isFileValidInContext(path)) {
714
			try {
715
				IDE.openEditor(PDEPlugin.getActivePage(), (IFile) resource, true);
716
			} catch (PartInitException e) { //suppress exception
717
			}
718
		}
719
	}
720
721
	private boolean isFileValidInContext(IPath path) {
722
		String message = null;
723
724
		if (HelpEditorUtil.hasValidPageExtension(path)) {
725
			return true;
726
		}
727
		message = PDEUIMessages.TocPage_invalidHTMLFile;
728
		MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.WindowImagesSection_open, message);
729
		return false;
730
	}
731
732
	/**
733
	 * Perform a drop of the specified objects on the target in the widget
734
	 * 
735
	 * @param currentTarget The object that the drop will occur near/on
736
	 * @param dropped The dropped objects
737
	 * @param location The location of the drop relative to the target
738
	 * 
739
	 * @return true iff the drop was successful
740
	 */
741
	public boolean performDrop(Object currentTarget, Object dropped, int location) {
742
		if (dropped instanceof Object[]) {
743
			CtxHelpObject target = (CtxHelpObject) currentTarget;
744
			// Determine the object that the dropped objects will be the
745
			// children of
746
747
			CtxHelpObject targetParent = determineParent(target, location);
748
749
			if (location == CtxHelpDropAdapter.LOCATION_JUST_AFTER && targetParent == target && !target.getChildren().isEmpty() && fTree.getExpandedState(target)) {
750
				// If the drop occurs just after a parentable object
751
				// and it is expanded, then insert the dropped items
752
				// as the first children of the parent
753
				location = ViewerDropAdapter.LOCATION_BEFORE;
754
				target = (CtxHelpObject) target.getChildren().get(0);
755
			}
756
757
			if (targetParent != null) { // Get the TocObject versions of the dropped objects
758
				ArrayList objectsToAdd = getObjectsToAdd((Object[]) dropped, targetParent);
759
760
				if (objectsToAdd != null && !objectsToAdd.isEmpty()) {
761
					if (fDragAdapter.getDraggedElements() != null && fDragAdapter.getDraggedElements().size() == 1 && currentTarget == fDragAdapter.getDraggedElements().get(0)) { // Last-minute check: ignore drops of an object onto/near itself
762
						// to avoid unnecessarily dirtying the page
763
						return false;
764
					}
765
766
					boolean insertBefore = (location == ViewerDropAdapter.LOCATION_BEFORE);
767
768
					// Add the objects
769
					handleMultiAddAction(objectsToAdd, target, insertBefore, targetParent);
770
					return true;
771
				}
772
			}
773
		}
774
		return false;
775
	}
776
777
	/**
778
	 * Determine the parent object that a drop will occur under,
779
	 * based on the relative location of the drop and the ability
780
	 * of the target to be a parent
781
	 * 
782
	 * @param dropTarget The target that the drop occurs near/on
783
	 * @param dropLocation The location of the drop relative to the target
784
	 * @return
785
	 */
786
	private CtxHelpObject determineParent(CtxHelpObject dropTarget, int dropLocation) {
787
		//We must determine what object will be the parent of the
788
		//dropped objects. This is done by looking at the drop location
789
		//and drop target type
790
791
		if (dropTarget == null || dropTarget.getType() == ICtxHelpConstants.TYPE_ROOT) {
792
			//Since the TOC root has no parent, it must be the target parent
793
			return fModel.getCtxHelpRoot();
794
		}
795
		switch (dropLocation) {
796
			case CtxHelpDropAdapter.LOCATION_JUST_AFTER : { //if the drop occured after an expanded node
797
				//and all of its children,
798
				//make the drop target's parent the target parent object
799
				if (!fTree.getExpandedState(dropTarget)) {
800
					return dropTarget.getParent();
801
				}
802
				//otherwise, the target parent is the drop target,
803
				//since the drop occured between it and its first child
804
			}
805
			case ViewerDropAdapter.LOCATION_ON : { //the drop location is directly on the drop target
806
				return dropTarget;
807
			}
808
			case ViewerDropAdapter.LOCATION_BEFORE :
809
			case ViewerDropAdapter.LOCATION_AFTER : { //if the drop is before or after the drop target,
810
				//make the drop target's parent the target parent object
811
				return dropTarget.getParent();
812
			}
813
		}
814
		return null;
815
	}
816
817
	/**
818
	 * Get the TocObject representations of a group of dropped objects.
819
	 * 
820
	 * @param droppings The objects that are dropped; can be file path Strings or
821
	 * deserialized TocObjects
822
	 * 
823
	 * @param targetParent The designated parent of the dropped objects
824
	 * 
825
	 * @return a list of the (reconnected) TocObject representations of the dropped objects
826
	 */
827
	private ArrayList getObjectsToAdd(Object[] droppings, CtxHelpObject targetParent) {
828
		ArrayList ctxHelpObjects = new ArrayList(droppings.length);
829
830
		if (fDragAdapter.getDraggedElements() != null) { // If there are items in the drag adapter, then the current drag must be from
831
			// this section
832
			fDragFromHere = fDragAdapter.getDraggedElements().size() == droppings.length;
833
		}
834
835
		for (int i = 0; i < droppings.length; ++i) {
836
			// TODO Finish drop
837
//			if (droppings[i] instanceof String) {
838
//				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
839
//
840
//				// If the array contains Strings, we treat them as file paths
841
//				Path path = new Path((String) droppings[i]);
842
//				IFile file = root.getFileForLocation(path);
843
//				if (file == null) {
844
//					continue;
845
//				}
846
//				
847
//				// If the path is to a valid TOC file
848
//				// and it isn't the file in this model
849
//				// then make a link
850
//				if (TocExtensionUtil.isTOCFile(path) && !TocExtensionUtil.isCurrentResource(path, fModel)) {
851
//					tocObjects.add(makeNewTocLink(targetParent, file));
852
//				}
853
//				// If the path is to a file with an HTML page extension, make a topic
854
//				else if (TocExtensionUtil.hasValidPageExtension(path)) {
855
//					TocTopic topic = makeNewTocTopic(targetParent, file);
856
//					String title = generateTitle(targetParent, path);
857
//
858
//					topic.setFieldLabel(title);
859
//					tocObjects.add(topic);
860
//				}
861
//			} else
862
			if (droppings[i] instanceof CtxHelpObject) {
863
				ArrayList dragged = fDragAdapter.getDraggedElements();
864
				if (fDragFromHere) {
865
					CtxHelpObject draggedObj = (CtxHelpObject) dragged.get(i);
866
867
					//Nesting an object inside itself or its children
868
					//is so stupid and ridiculous that I get a headache
869
					//just thinking about it. Thus, this drag is not going to complete.
870
					if (targetParent.descendsFrom(draggedObj)) {
871
						return null;
872
					}
873
				}
874
875
				//Reconnect this TocObject, since it was deserialized
876
				((CtxHelpObject) droppings[i]).reconnect(targetParent, fModel);
877
				ctxHelpObjects.add(droppings[i]);
878
			}
879
		}
880
881
		return ctxHelpObjects;
882
	}
883
884
	/**
885
	 * Generate the title of a Topic created via dragging in an HTML page.
886
	 * Use the title of the HTML page, or generate a name based on the target
887
	 * parent if no title exists.
888
	 * 
889
	 * @param targetParent The designated parent of this topic
890
	 * @param path The path to the HTML file
891
	 * 
892
	 * @return The generated name of the Topic.
893
	 */
894
//	private String generateTitle(TocTopic targetParent, Path path) {
895
//		String title = TocHTMLTitleUtil.findTitle(path.toFile());
896
//		if (title == null) {
897
//			int numChildren = targetParent.getChildren().size();
898
//			TocObject[] children = (TocObject[]) targetParent.getChildren().toArray(new TocObject[numChildren]);
899
//
900
//			String[] tocObjectNames = new String[children.length];
901
//
902
//			for (int j = 0; j < numChildren; ++j) {
903
//				tocObjectNames[j] = children[j].getName();
904
//			}
905
//
906
//			title = PDELabelUtility.generateName(tocObjectNames, PDEUIMessages.TocPage_TocTopic);
907
//		}
908
//		return title;
909
//	}
910
	/* (non-Javadoc)
911
	 * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int)
912
	 */
913
	protected void buttonSelected(int index) {
914
		IStructuredSelection selection = (IStructuredSelection) fTree.getSelection();
915
		Object object = selection.getFirstElement();
916
		CtxHelpObject firstSelectedObject = (CtxHelpObject) object;
917
		switch (index) {
918
			case F_BUTTON_ADD_CONTEXT :
919
				updateAddContextActionWithSelection(firstSelectedObject);
920
				fAddContextAction.run();
921
				break;
922
			case F_BUTTON_ADD_TOPIC :
923
				updateAddTopicActionWithSelection(firstSelectedObject);
924
				fAddTopicAction.run();
925
				break;
926
			case F_BUTTON_ADD_COMMAND :
927
				updateAddCommandActionWithSelection(firstSelectedObject);
928
				fAddCommandAction.run();
929
				break;
930
			case F_BUTTON_REMOVE :
931
				updateRemoveActionWithSelection(selection);
932
				fRemoveObjectAction.run();
933
				break;
934
			case F_BUTTON_UP :
935
				handleMoveAction(F_UP_FLAG);
936
				break;
937
			case F_BUTTON_DOWN :
938
				handleMoveAction(F_DOWN_FLAG);
939
				break;
940
		}
941
	}
942
943
	/**
944
	 * Handle the addition of multiple initialized objects to the TOC.
945
	 * 
946
	 * @param objectsToAdd The objects to be added
947
	 * @param target The target to add these objects relative to
948
	 * @param insertBefore Whether or not the insertion occurs before the target
949
	 * @param targetParent The parent object of the newly added objects
950
	 */
951
	private void handleMultiAddAction(List objectsToAdd, CtxHelpObject target, boolean insertBefore, CtxHelpObject targetParent) {
952
		CtxHelpObject[] tocObjects = (CtxHelpObject[]) objectsToAdd.toArray(new CtxHelpObject[objectsToAdd.size()]);
953
		if (tocObjects == null)
954
			return;
955
956
		for (int i = 0; i < tocObjects.length; ++i) {
957
			if (tocObjects[i] != null) {
958
				if (targetParent != null && targetParent.canBeParent() && targetParent.canAddChild(tocObjects[i].getType())) {
959
					if (target != null && target != targetParent) { // Add the object as a direct sibling of the target
960
						targetParent.addChild(tocObjects[i], target, insertBefore);
961
					} else { // Add the object as the last child of the target parent
962
						targetParent.addChild(tocObjects[i]);
963
					}
964
				}
965
			}
966
		}
967
	}
968
969
	//
970
	//	/**
971
	//	 * Remove the selected objects from the TOC tree
972
	//	 */
973
	//	private void handleDeleteAction() {
974
	//		ArrayList objects = new ArrayList(((IStructuredSelection) fTree.getSelection()).toList());
975
	//		boolean beep = false;
976
	//
977
	//		// Iterate through the list of selected objects, removing ones
978
	//		// that cannot be removed
979
	//		for (Iterator i = objects.iterator(); i.hasNext();) {
980
	//			Object object = i.next();
981
	//			if (object instanceof TocObject) {
982
	//				TocObject tocObject = (TocObject) object;
983
	//
984
	//				if (!tocObject.canBeRemoved()) {
985
	//					i.remove();
986
	//					beep = true;
987
	//				}
988
	//			}
989
	//		}
990
	//
991
	//		if (beep) { // If any object cannot be removed, beep to notify the user			
992
	//			Display.getCurrent().beep();
993
	//		}
994
	//
995
	//		// Remove the remaining objects
996
	//		handleRemove(objects);
997
	//	}
998
	//
999
	//	/**
1000
	//	 * Remove the items listed from the TOC.
1001
	//	 * 
1002
	//	 * @param itemsToRemove The list of items to remove from the TOC 
1003
	//	 */
1004
	//	public void handleRemove(List itemsToRemove) {
1005
	//		if (!itemsToRemove.isEmpty()) { // Target the objects for removal
1006
	//			fRemoveObjectAction.setToRemove((TocObject[]) itemsToRemove.toArray(new TocObject[itemsToRemove.size()]));
1007
	//
1008
	//			// Run the removal action
1009
	//			fRemoveObjectAction.run();
1010
	//		}
1011
	//	}
1012
1013
	/**
1014
	 * Handle the dragging of objects out of this TOC.
1015
	 * 
1016
	 * @param itemsDragged The items dragged out of the TOC
1017
	 */
1018
	public void handleDrag(List itemsDragged) {
1019
		// TODO Handle multi drag, with instanceof checks
1020
		CtxHelpObject object = (CtxHelpObject) itemsDragged.get(0);
1021
		if (object != null && object.canBeRemoved()) {
1022
			if (updateRemoveActionWithSelection(new StructuredSelection(itemsDragged))) {
1023
				fRemoveObjectAction.run();
1024
			}
1025
		}
1026
1027
		// The drag is finished, so there is no intra-editor DND operation occuring now
1028
		fDragFromHere = false;
1029
	}
1030
1031
	/**
1032
	 * Move an object within the TOC.
1033
	 * 
1034
	 * @param positionFlag The direction that the object will move
1035
	 */
1036
	private void handleMoveAction(int positionFlag) {
1037
		IStructuredSelection sel = (IStructuredSelection) fTree.getSelection();
1038
1039
		Object object = sel.getFirstElement();
1040
		if (object == null) {
1041
			return;
1042
		} else if (object instanceof CtxHelpObject) {
1043
			CtxHelpObject ctxHelpObject = (CtxHelpObject) object;
1044
			CtxHelpObject parent = ctxHelpObject.getParent();
1045
			if (parent != null) {
1046
				parent.moveChild(ctxHelpObject, positionFlag);
1047
				fTree.setSelection(new StructuredSelection(ctxHelpObject), true);
1048
			}
1049
		}
1050
1051
	}
1052
1053
	/* (non-Javadoc)
1054
	 * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
1055
	 */
1056
	public void modelChanged(IModelChangedEvent event) {
1057
		// No need to call super, world changed event handled here
1058
		if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
1059
			handleModelEventWorldChanged(event);
1060
		} else if (event.getChangeType() == IModelChangedEvent.INSERT) {
1061
			handleModelInsertType(event);
1062
		} else if (event.getChangeType() == IModelChangedEvent.REMOVE) {
1063
			handleModelRemoveType(event);
1064
		} else if ((event.getChangeType() == IModelChangedEvent.CHANGE) && (event.getChangedProperty().equals(IDocumentElementNode.F_PROPERTY_CHANGE_TYPE_SWAP))) {
1065
			handleModelChangeTypeSwap(event);
1066
		} else if (event.getChangeType() == IModelChangedEvent.CHANGE) {
1067
			handleModelChangeType(event);
1068
		}
1069
	}
1070
1071
	/**
1072
	 * @param event
1073
	 */
1074
	private void handleModelChangeTypeSwap(IModelChangedEvent event) {
1075
		// Swap event
1076
		// Get the changed object
1077
		Object[] objects = event.getChangedObjects();
1078
		CtxHelpObject object = (CtxHelpObject) objects[0];
1079
1080
		if (object != null) { // Update the element in the tree viewer
1081
			fTree.refresh(object);
1082
		}
1083
	}
1084
1085
	/**
1086
	 * The model is stale, refresh the UI
1087
	 * 
1088
	 * @param event The world-change event
1089
	 */
1090
	private void handleModelEventWorldChanged(IModelChangedEvent event) {
1091
		markStale();
1092
	}
1093
1094
	/**
1095
	 * Handle insertions in the model
1096
	 * @param event the insertion event
1097
	 */
1098
	private void handleModelInsertType(IModelChangedEvent event) {
1099
		// Insert event
1100
		Object[] objects = event.getChangedObjects();
1101
		CtxHelpObject object = (CtxHelpObject) objects[0];
1102
		if (object != null) {
1103
			if (object.getType() != ICtxHelpConstants.TYPE_ROOT) {
1104
				// Refresh the parent element in the tree viewer
1105
				// TODO: Can we get away with an update instead of a refresh here?
1106
				fTree.refresh(object.getParent());
1107
				// Select the new object in the tree, unless it is a description node
1108
				if (!(object instanceof CtxHelpDescription)) {
1109
					fTree.setSelection(new StructuredSelection(object), true);
1110
				}
1111
			}
1112
		}
1113
	}
1114
1115
	/**
1116
	 * Handle removals in the model
1117
	 * 
1118
	 * @param event the removal event
1119
	 */
1120
	private void handleModelRemoveType(IModelChangedEvent event) {
1121
		// Remove event
1122
		Object[] objects = event.getChangedObjects();
1123
		if (objects[0] != null) {
1124
			CtxHelpObject object = (CtxHelpObject) objects[0];
1125
			fTree.remove(object);
1126
			CtxHelpObject nextSelection = fRemoveObjectAction.getNextSelection();
1127
			if (nextSelection != null) {
1128
				if (nextSelection.equals(object.getParent())) {
1129
					fTree.refresh(object.getParent());
1130
				}
1131
				if (!fDragFromHere) {
1132
					fTree.setSelection(new StructuredSelection(nextSelection), true);
1133
				}
1134
				fRemoveObjectAction.clearNextSelection();
1135
			}
1136
		}
1137
	}
1138
1139
	/**
1140
	 * Handle an update to a TocObject's properties
1141
	 * @param event the update event
1142
	 */
1143
	private void handleModelChangeType(IModelChangedEvent event) {
1144
		// Get the changed object
1145
		Object[] objects = event.getChangedObjects();
1146
		CtxHelpObject object = (CtxHelpObject) objects[0];
1147
1148
		if (object != null) { // Update the element in the tree viewer
1149
			fTree.update(object, null);
1150
		}
1151
	}
1152
1153
	public void refresh() {
1154
		CtxHelpModel model = (CtxHelpModel) getPage().getModel();
1155
		fTree.setInput(model);
1156
		fTree.expandToLevel(2);
1157
		fTree.setSelection(new StructuredSelection(model.getCtxHelpRoot()), true);
1158
		getManagedForm().fireSelectionChanged(this, fTree.getSelection());
1159
		super.refresh();
1160
	}
1161
1162
	/* (non-Javadoc)
1163
	 * @see org.eclipse.pde.internal.ui.editor.TreeSection#createTreeViewer(org.eclipse.swt.widgets.Composite, int)
1164
	 */
1165
	protected TreeViewer createTreeViewer(Composite parent, int style) {
1166
		fFilteredTree = new FormFilteredTree(parent, style, new PatternFilter());
1167
		parent.setData("filtered", Boolean.TRUE); //$NON-NLS-1$
1168
		return fFilteredTree.getViewer();
1169
	}
1170
1171
	/* (non-Javadoc)
1172
	 * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
1173
	 */
1174
	public void dispose() {
1175
		PDEPlugin.getDefault().getLabelProvider().disconnect(this);
1176
		super.dispose();
1177
	}
1178
}
(-)src/org/eclipse/pde/internal/ui/editor/toc/details/HelpEditorFilter.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.toc.details;
13
14
import org.eclipse.core.resources.*;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.jface.viewers.Viewer;
18
import org.eclipse.jface.viewers.ViewerFilter;
19
import org.eclipse.pde.internal.ui.editor.toc.HelpEditorUtil;
20
21
public class HelpEditorFilter extends ViewerFilter {
22
	public boolean select(Viewer viewer, Object parent, Object element) {
23
		if (element instanceof IFile) {
24
			IPath path = ((IFile) element).getFullPath();
25
26
			return HelpEditorUtil.hasValidPageExtension(path);
27
		}
28
29
		if (element instanceof IProject && !((IProject) element).isOpen()) {
30
			return false;
31
		}
32
33
		if (element instanceof IContainer) {
34
			try {
35
				IResource[] resources = ((IContainer) element).members();
36
				for (int i = 0; i < resources.length; i++) {
37
					if (select(viewer, parent, resources[i])) {
38
						return true;
39
					}
40
				}
41
			} catch (CoreException e) {
42
			}
43
		}
44
45
		return false;
46
	}
47
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpCommandDetails.java (+115 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp.details;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpCommand;
16
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
17
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext;
18
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection;
19
import org.eclipse.pde.internal.ui.parts.FormEntry;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.ui.forms.IFormPart;
23
24
public class CtxHelpCommandDetails extends CtxHelpAbstractDetails {
25
26
	private CtxHelpCommand fCommand;
27
	private FormEntry fLabelEntry;
28
	private FormEntry fSerialEntry;
29
30
	/**
31
	 * @param masterSection
32
	 */
33
	public CtxHelpCommandDetails(CtxHelpTreeSection masterSection) {
34
		super(masterSection, CtxHelpInputContext.CONTEXT_ID);
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite)
39
	 */
40
	public void createFields(Composite parent) {
41
		createLabel(parent, getManagedForm().getToolkit(), "Specify the display label for this command:");
42
		fLabelEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Label:", SWT.NONE);
43
		createSpace(parent);
44
		createLabel(parent, getManagedForm().getToolkit(), "Specify the command to invoke:");
45
		fSerialEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Command:", SWT.NONE);
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle()
50
	 */
51
	protected String getDetailsTitle() {
52
		return "Command Details";
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription()
57
	 */
58
	protected String getDetailsDescription() {
59
		return null;
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#hookListeners()
64
	 */
65
	public void hookListeners() {
66
		fLabelEntry.setFormEntryListener(new FormEntryAdapter(this) {
67
			public void textValueChanged(FormEntry entry) {
68
				if (fCommand != null) {
69
					fCommand.setLabel(fLabelEntry.getValue());
70
				}
71
			}
72
		});
73
		fSerialEntry.setFormEntryListener(new FormEntryAdapter(this) {
74
			public void textValueChanged(FormEntry entry) { // Ensure data object is defined
75
				if (fCommand != null) {
76
					fCommand.setSerialization(fSerialEntry.getValue());
77
				}
78
			}
79
		});
80
	}
81
82
	/* (non-Javadoc)
83
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#updateFields()
84
	 */
85
	public void updateFields() {
86
		if (fCommand != null) {
87
			fLabelEntry.setValue(fCommand.getLabel(), true);
88
			fLabelEntry.setEditable(isEditableElement());
89
			fSerialEntry.setValue(fCommand.getSerialization(), true);
90
			fSerialEntry.setEditable(isEditableElement());
91
		}
92
	}
93
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
96
	 */
97
	public void commit(boolean onSave) {
98
		super.commit(onSave);
99
		// Only required for form entries
100
		fLabelEntry.commit();
101
		fSerialEntry.commit();
102
103
	}
104
105
	/* (non-Javadoc)
106
	 * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
107
	 */
108
	public void selectionChanged(IFormPart part, ISelection selection) {
109
		Object object = getFirstSelectedObject(selection);
110
		if (object instanceof CtxHelpCommand) {
111
			fCommand = (CtxHelpCommand) object;
112
			updateFields();
113
		}
114
	}
115
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpSourcePage.java (+122 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import org.eclipse.jface.viewers.*;
15
import org.eclipse.pde.internal.core.text.*;
16
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel;
17
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEUIMessages;
20
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
21
import org.eclipse.pde.internal.ui.editor.XMLSourcePage;
22
23
/**
24
 * TocSourcePage
25
 */
26
public class CtxHelpSourcePage extends XMLSourcePage {
27
28
	/**
29
	 * @param editor
30
	 * @param id
31
	 * @param title
32
	 */
33
	public CtxHelpSourcePage(PDEFormEditor editor, String id, String title) {
34
		super(editor, id, title);
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.pde.internal.ui.editor.PDEProjectionSourcePage#isQuickOutlineEnabled()
39
	 */
40
	public boolean isQuickOutlineEnabled() {
41
		return true;
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineComparator()
46
	 */
47
	public ViewerComparator createOutlineComparator() {
48
		return null;
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineContentProvider()
53
	 */
54
	public ITreeContentProvider createOutlineContentProvider() {
55
		return new CtxHelpContentProvider();
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineLabelProvider()
60
	 */
61
	public ILabelProvider createOutlineLabelProvider() {
62
		return PDEPlugin.getDefault().getLabelProvider();
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.ui.part.EditorPart#setPartName(java.lang.String)
67
	 */
68
	protected void setPartName(String partName) {
69
		super.setPartName(PDEUIMessages.EditorSourcePage_name);
70
	}
71
72
	protected boolean isSelectionListener() {
73
		return true;
74
	}
75
76
	// TODO Consider adding custom hyperlink detector
77
	//	public Object getAdapter(Class adapter) {
78
	//		if (IHyperlinkDetector.class.equals(adapter))
79
	//			return new TocHyperlinkDetector(this);
80
	//		return super.getAdapter(adapter);
81
	//	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#updateSelection(java.lang.Object)
85
	 */
86
	public void updateSelection(Object object) {
87
		if ((object instanceof IDocumentElementNode) && !((IDocumentElementNode) object).isErrorNode()) {
88
			setSelectedObject(object);
89
			setHighlightRange((IDocumentElementNode) object, true);
90
			setSelectedRange((IDocumentElementNode) object, false);
91
		}
92
	}
93
94
	protected IDocumentRange findRange() {
95
		if (getSelection() instanceof IDocumentElementNode) {
96
			return (IDocumentElementNode) getSelection();
97
		}
98
99
		return null;
100
	}
101
102
	public IDocumentRange getRangeElement(int offset, boolean searchChildren) {
103
		CtxHelpObject root = ((CtxHelpModel) getInputContext().getModel()).getCtxHelpRoot();
104
		return findNode(root, offset, searchChildren);
105
	}
106
107
	protected void synchronizeOutlinePage(int offset) {
108
		IDocumentRange rangeElement = getRangeElement(offset, true);
109
		updateHighlightRange(rangeElement);
110
		// TODO: MP: TEO: LOW: Generalize for parent - search children = true and handle attributes
111
		if (rangeElement instanceof IDocumentAttributeNode) {
112
			rangeElement = ((IDocumentAttributeNode) rangeElement).getEnclosingElement();
113
		}
114
		updateOutlinePageSelection(rangeElement);
115
	}
116
117
	protected void initializeEditor() {
118
		super.initializeEditor();
119
		// TODO Fix help context
120
		//		setHelpContextId(IHelpContextIds.TOC_EDITOR);
121
	}
122
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpDescriptionDetails.java (+108 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp.details;
13
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpDescription;
16
import org.eclipse.pde.internal.ui.PDEUIMessages;
17
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
18
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext;
19
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection;
20
import org.eclipse.pde.internal.ui.parts.FormEntry;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.ui.forms.IFormPart;
25
26
public class CtxHelpDescriptionDetails extends CtxHelpAbstractDetails {
27
28
	private CtxHelpDescription fDescription;
29
	private FormEntry fDescEntry;
30
31
	/**
32
	 * @param masterSection
33
	 */
34
	public CtxHelpDescriptionDetails(CtxHelpTreeSection masterSection) {
35
		super(masterSection, CtxHelpInputContext.CONTEXT_ID);
36
	}
37
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite)
40
	 */
41
	public void createFields(Composite parent) {
42
		createLabel(parent, getManagedForm().getToolkit(), "Specify the context description that will be displayed to the user:");
43
		fDescEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Description:", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
44
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
45
		data.heightHint = 50;
46
		fDescEntry.getText().setLayoutData(data);
47
		data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
48
		fDescEntry.getLabel().setLayoutData(data);
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle()
53
	 */
54
	protected String getDetailsTitle() {
55
		return PDEUIMessages.TocTopicDetails_title;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription()
60
	 */
61
	protected String getDetailsDescription() {
62
		return null;
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#hookListeners()
67
	 */
68
	public void hookListeners() {
69
		fDescEntry.setFormEntryListener(new FormEntryAdapter(this) {
70
			public void textValueChanged(FormEntry entry) {
71
				if (fDescription != null) {
72
					fDescription.setDescription(fDescEntry.getValue());
73
				}
74
			}
75
		});
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#updateFields()
80
	 */
81
	public void updateFields() {
82
		if (fDescription != null) {
83
			fDescEntry.setValue(fDescription.getDescription(), true);
84
			fDescEntry.setEditable(isEditableElement());
85
		}
86
	}
87
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
90
	 */
91
	public void commit(boolean onSave) {
92
		super.commit(onSave);
93
		// Only required for form entries
94
		fDescEntry.commit();
95
96
	}
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
100
	 */
101
	public void selectionChanged(IFormPart part, ISelection selection) {
102
		Object object = getFirstSelectedObject(selection);
103
		if (object instanceof CtxHelpDescription) {
104
			fDescription = (CtxHelpDescription) object;
105
			updateFields();
106
		}
107
	}
108
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpEditor.java (+263 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import java.io.File;
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.jdt.ui.JavaUI;
20
import org.eclipse.jface.viewers.*;
21
import org.eclipse.pde.internal.core.text.ctxhelp.*;
22
import org.eclipse.pde.internal.ui.IPDEUIConstants;
23
import org.eclipse.pde.internal.ui.PDEPlugin;
24
import org.eclipse.pde.internal.ui.editor.*;
25
import org.eclipse.pde.internal.ui.editor.context.InputContext;
26
import org.eclipse.pde.internal.ui.editor.context.InputContextManager;
27
import org.eclipse.ui.*;
28
import org.eclipse.ui.forms.editor.IFormPage;
29
import org.eclipse.ui.part.*;
30
31
/**
32
 * TocEditor
33
 * @since 3.4
34
 *
35
 */
36
public class CtxHelpEditor extends MultiSourceEditor {
37
38
	public CtxHelpEditor() {
39
		super();
40
	}
41
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID()
44
	 */
45
	protected String getEditorID() {
46
		return IPDEUIConstants.CONTEXT_HELP_EDITOR_ID;
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getAdapter(java.lang.Class)
51
	 */
52
	public Object getAdapter(Class adapter) {
53
		if (isShowInApplicable()) {
54
			if (adapter == IShowInSource.class) {
55
				return getShowInSource();
56
			} else if (adapter == IShowInTargetList.class) {
57
				return getShowInTargetList();
58
			}
59
		}
60
		return super.getAdapter(adapter);
61
	}
62
63
	private boolean isShowInApplicable() {
64
		if (getSelection().isEmpty()) {
65
			return false;
66
		}
67
		if (getSelection() instanceof IStructuredSelection) {
68
			IStructuredSelection selection = (IStructuredSelection) getSelection();
69
			for (Iterator iter = selection.iterator(); iter.hasNext();) {
70
				Object obj = iter.next();
71
				if (obj instanceof CtxHelpTopic && ((CtxHelpTopic) obj).getLocation() != null) {
72
					return true;
73
				}
74
			}
75
		}
76
		return false;
77
	}
78
79
	/**
80
	 * Returns the <code>IShowInSource</code> for this section.
81
	 * @return the <code>IShowInSource</code> 
82
	 */
83
	private IShowInSource getShowInSource() {
84
		return new IShowInSource() {
85
			public ShowInContext getShowInContext() {
86
				ArrayList resourceList = new ArrayList();
87
				IStructuredSelection selection = (IStructuredSelection) getSelection();
88
				IStructuredSelection resources;
89
				if (selection.isEmpty()) {
90
					resources = null;
91
				} else {
92
					IWorkspaceRoot root = PDEPlugin.getWorkspace().getRoot();
93
					for (Iterator iter = selection.iterator(); iter.hasNext();) {
94
						Object obj = iter.next();
95
						if (obj instanceof CtxHelpTopic) {
96
							IPath path = ((CtxHelpTopic) obj).getLocation();
97
							if (path != null && !path.isEmpty()) {
98
								CtxHelpModel model = (CtxHelpModel) getAggregateModel();
99
								IPath pluginPath = model.getUnderlyingResource().getProject().getFullPath();
100
								IResource resource = root.findMember(pluginPath.append(path));
101
								if (resource != null) {
102
									resourceList.add(resource);
103
								}
104
							}
105
						}
106
					}
107
					resources = new StructuredSelection(resourceList);
108
				}
109
				return new ShowInContext(null, resources);
110
			}
111
		};
112
	}
113
114
	/**
115
	 * Returns the <code>IShowInTargetList</code> for this section.
116
	 * @return the <code>IShowInTargetList</code> 
117
	 */
118
	private IShowInTargetList getShowInTargetList() {
119
		return new IShowInTargetList() {
120
			public String[] getShowInTargetIds() {
121
				return new String[] {JavaUI.ID_PACKAGES, IPageLayout.ID_RES_NAV};
122
			}
123
		};
124
	}
125
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#isSaveAsAllowed()
128
	 */
129
	public boolean isSaveAsAllowed() {
130
		return true;
131
	}
132
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getContextIDForSaveAs()
135
	 */
136
	public String getContextIDForSaveAs() {
137
		return CtxHelpInputContext.CONTEXT_ID;
138
	}
139
140
	/* (non-Javadoc)
141
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#addEditorPages()
142
	 */
143
	protected void addEditorPages() {
144
		try {
145
			addPage(new CtxHelpPage(this));
146
		} catch (PartInitException e) {
147
			PDEPlugin.logException(e);
148
		}
149
		// Add source page
150
		addSourcePage(CtxHelpInputContext.CONTEXT_ID);
151
	}
152
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createContentOutline()
155
	 */
156
	protected ISortableContentOutlinePage createContentOutline() {
157
		return new CtxHelpFormOutlinePage(this);
158
	}
159
160
	/* (non-Javadoc)
161
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createInputContextManager()
162
	 */
163
	protected InputContextManager createInputContextManager() {
164
		return new CtxHelpInputContextManager(this);
165
	}
166
167
	/* (non-Javadoc)
168
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createResourceContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IFileEditorInput)
169
	 */
170
	protected void createResourceContexts(InputContextManager contexts, IFileEditorInput input) {
171
		contexts.putContext(input, new CtxHelpInputContext(this, input, true));
172
		contexts.monitorFile(input.getFile());
173
	}
174
175
	/* (non-Javadoc)
176
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createStorageContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IStorageEditorInput)
177
	 */
178
	protected void createStorageContexts(InputContextManager contexts, IStorageEditorInput input) {
179
		contexts.putContext(input, new CtxHelpInputContext(this, input, true));
180
	}
181
182
	/* (non-Javadoc)
183
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createSystemFileContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.pde.internal.ui.editor.SystemFileEditorInput)
184
	 */
185
	protected void createSystemFileContexts(InputContextManager contexts, SystemFileEditorInput input) {
186
		File file = (File) input.getAdapter(File.class);
187
		if (file != null) {
188
			IEditorInput in = new SystemFileEditorInput(file);
189
			contexts.putContext(in, new CtxHelpInputContext(this, in, true));
190
		}
191
	}
192
193
	/* (non-Javadoc)
194
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#editorContextAdded(org.eclipse.pde.internal.ui.editor.context.InputContext)
195
	 */
196
	public void editorContextAdded(InputContext context) {
197
		// Add the source page
198
		addSourcePage(context.getId());
199
	}
200
201
	/* (non-Javadoc)
202
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getInputContext(java.lang.Object)
203
	 */
204
	protected InputContext getInputContext(Object object) {
205
		return fInputContextManager.findContext(CtxHelpInputContext.CONTEXT_ID);
206
	}
207
208
	/* (non-Javadoc)
209
	 * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextRemoved(org.eclipse.pde.internal.ui.editor.context.InputContext)
210
	 */
211
	public void contextRemoved(InputContext context) {
212
		close(false);
213
	}
214
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileAdded(org.eclipse.core.resources.IFile)
217
	 */
218
	public void monitoredFileAdded(IFile monitoredFile) {
219
		// NO-OP
220
	}
221
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileRemoved(org.eclipse.core.resources.IFile)
224
	 */
225
	public boolean monitoredFileRemoved(IFile monitoredFile) {
226
		return true;
227
	}
228
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getSelection()
231
	 */
232
	public ISelection getSelection() {
233
		IFormPage formPage = getActivePageInstance();
234
		if ((formPage != null) && (formPage instanceof CtxHelpPage)) {
235
			// Synchronizes the selection made in the master tree view with the
236
			// selection in the outline view when the link with editor button
237
			// is toggled on
238
			return ((CtxHelpPage) formPage).getSelection();
239
		}
240
		return super.getSelection();
241
	}
242
243
	public boolean canCut(ISelection selection) {
244
		if (selection instanceof IStructuredSelection) {
245
			IStructuredSelection sel = (IStructuredSelection) selection;
246
			for (Iterator iter = sel.iterator(); iter.hasNext();) {
247
				Object obj = iter.next();
248
				if (obj instanceof CtxHelpObject && ((CtxHelpObject) obj).canBeRemoved()) {
249
					return canCopy(selection);
250
				}
251
			}
252
		}
253
		return false;
254
	}
255
256
	/* (non-Javadoc)
257
	 * @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)
258
	 */
259
	protected PDESourcePage createSourcePage(PDEFormEditor editor, String title, String name, String contextId) {
260
		return new CtxHelpSourcePage(editor, title, name);
261
	}
262
263
}
(-)src/org/eclipse/pde/internal/ui/editor/toc/HelpEditorUtil.java (+105 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.toc;
13
14
import java.util.HashSet;
15
import java.util.Locale;
16
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.pde.core.IBaseModel;
23
import org.eclipse.pde.core.IModel;
24
import org.eclipse.pde.internal.core.itoc.ITocConstants;
25
import org.eclipse.pde.internal.ui.util.XMLRootElementMatcher;
26
27
public class HelpEditorUtil {
28
	public static final String[] pageExtensions = {"htm","shtml","html","xhtml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
29
	public static final String tocExtension = "xml"; //$NON-NLS-1$
30
	private static HashSet pageExtensionSet = new HashSet(pageExtensions.length);
31
32
	private static void populateHashSet()
33
	{	for(int i = 0; i < pageExtensions.length; ++i)
34
		{	pageExtensionSet.add(pageExtensions[i]);
35
		}
36
	}
37
	
38
	public static boolean hasValidPageExtension(IPath path)
39
	{	String fileExtension = path.getFileExtension();	
40
		if(fileExtension != null)
41
		{	fileExtension = fileExtension.toLowerCase(Locale.ENGLISH);
42
			if(pageExtensionSet.isEmpty())
43
			{	populateHashSet();
44
			}
45
			
46
			return pageExtensionSet.contains(fileExtension);
47
		}
48
49
		return false;
50
	}
51
52
	private static boolean hasValidTocExtension(IPath path)
53
	{	String fileExtension = path.getFileExtension();
54
		return fileExtension != null && fileExtension.equals(tocExtension); 
55
	}
56
57
	/**
58
	 * @param file
59
	 */
60
	public static boolean isTOCFile(IPath path) {
61
		if(!hasValidTocExtension(path))
62
			return false;
63
		
64
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
65
66
		IResource resource = root.findMember(path);
67
		if(resource != null && resource instanceof IFile)
68
		{	return XMLRootElementMatcher.fileMatchesElement((IFile)resource, ITocConstants.ELEMENT_TOC);
69
		}
70
71
		return XMLRootElementMatcher.fileMatchesElement(path.toFile(), ITocConstants.ELEMENT_TOC);
72
	}
73
74
	public static boolean isCurrentResource(IPath path, IBaseModel model)
75
	{	if(model instanceof IModel)
76
		{	IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
77
			IPath fullPath;	
78
79
			if(workspacePath.isPrefixOf(path))
80
			{	fullPath = ((IModel)model).getUnderlyingResource().getLocation();	
81
			}
82
			else
83
			{	fullPath = ((IModel)model).getUnderlyingResource().getFullPath();
84
			}
85
86
			return fullPath.equals(path);
87
		}
88
89
		return false;
90
	}
91
92
	public static String getPageExtensionList() {
93
		StringBuffer buf = new StringBuffer();
94
95
		for(int i = 0; i < pageExtensions.length; ++i)
96
		{	buf.append('.');
97
			buf.append(pageExtensions[i]);
98
			if(i != pageExtensions.length - 1)
99
			{	buf.append(", "); //$NON-NLS-1$
100
			}
101
		}
102
103
		return buf.toString();
104
	}
105
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpBlock.java (+98 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.editor.ctxhelp;
2
3
import org.eclipse.jface.viewers.ISelection;
4
import org.eclipse.jface.viewers.IStructuredSelection;
5
import org.eclipse.pde.core.IModelChangedEvent;
6
import org.eclipse.pde.core.IModelChangedListener;
7
import org.eclipse.pde.internal.core.text.ctxhelp.*;
8
import org.eclipse.pde.internal.ui.editor.*;
9
import org.eclipse.pde.internal.ui.editor.ctxhelp.details.*;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.ui.forms.*;
12
13
public class CtxHelpBlock extends PDEMasterDetailsBlock implements IModelChangedListener, IDetailsPageProvider {
14
15
	private CtxHelpTreeSection fMasterSection;
16
17
	//	private TocAbstractDetails fDetails;
18
	//	private TocAnchorDetails fAnchorDetails;
19
	//	private TocLinkDetails fLinkDetails;
20
21
	/**TODO: Comment
22
	 * @param page
23
	 */
24
	public CtxHelpBlock(PDEFormPage page) {
25
		super(page);
26
	}
27
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock#createMasterSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite)
30
	 */
31
	protected PDESection createMasterSection(IManagedForm managedForm, Composite parent) {
32
		fMasterSection = new CtxHelpTreeSection(getPage(), parent);
33
		return fMasterSection;
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart)
38
	 */
39
	protected void registerPages(DetailsPart detailsPart) {
40
		// Only static pages to be defined.  Do not cache pages
41
		detailsPart.setPageLimit(0);
42
		detailsPart.registerPage(CtxHelpContextDetails.class, new CtxHelpContextDetails(fMasterSection));
43
		detailsPart.registerPage(CtxHelpDescriptionDetails.class, new CtxHelpDescriptionDetails(fMasterSection));
44
		detailsPart.registerPage(CtxHelpTopicDetails.class, new CtxHelpTopicDetails(fMasterSection));
45
		detailsPart.registerPage(CtxHelpCommandDetails.class, new CtxHelpCommandDetails(fMasterSection));
46
		detailsPart.setPageProvider(this);
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
51
	 */
52
	public void modelChanged(IModelChangedEvent event) {
53
		if (fMasterSection != null) {
54
			fMasterSection.modelChanged(event);
55
		}
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.ui.forms.IDetailsPageProvider#getPage(java.lang.Object)
60
	 */
61
	public IDetailsPage getPage(Object key) {
62
		// No dynamic pages.  Static pages already registered
63
		return null;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.ui.forms.IDetailsPageProvider#getPageKey(java.lang.Object)
68
	 */
69
	public Object getPageKey(Object object) {
70
		ISelection selection = getSelection();
71
		if (!(selection instanceof IStructuredSelection) || ((IStructuredSelection) selection).size() > 1) {
72
			return object.getClass();
73
		}
74
75
		if (object instanceof CtxHelpContext) {
76
			return CtxHelpContextDetails.class;
77
		} else if (object instanceof CtxHelpDescription) {
78
			return CtxHelpDescriptionDetails.class;
79
		} else if (object instanceof CtxHelpTopic) {
80
			return CtxHelpTopicDetails.class;
81
		} else if (object instanceof CtxHelpCommand) {
82
			return CtxHelpCommandDetails.class;
83
		}
84
85
		return object.getClass();
86
	}
87
88
	public ISelection getSelection() {
89
		if (fMasterSection != null) {
90
			return fMasterSection.getSelection();
91
		}
92
		return null;
93
	}
94
95
	public CtxHelpTreeSection getMasterSection() {
96
		return fMasterSection;
97
	}
98
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/details/CtxHelpTopicDetails.java (+176 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp.details;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.Path;
17
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.jface.window.Window;
19
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpTopic;
20
import org.eclipse.pde.internal.ui.PDEPlugin;
21
import org.eclipse.pde.internal.ui.PDEUIMessages;
22
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
23
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpInputContext;
24
import org.eclipse.pde.internal.ui.editor.ctxhelp.CtxHelpTreeSection;
25
import org.eclipse.pde.internal.ui.editor.toc.details.HelpEditorFilter;
26
import org.eclipse.pde.internal.ui.parts.FormEntry;
27
import org.eclipse.pde.internal.ui.util.FileValidator;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
31
import org.eclipse.ui.forms.IFormPart;
32
import org.eclipse.ui.forms.events.HyperlinkEvent;
33
import org.eclipse.ui.model.WorkbenchContentProvider;
34
import org.eclipse.ui.model.WorkbenchLabelProvider;
35
36
public class CtxHelpTopicDetails extends CtxHelpAbstractDetails {
37
38
	private CtxHelpTopic fTopic;
39
	private FormEntry fLabelEntry;
40
	private FormEntry fLinkEntry;
41
42
	/**
43
	 * @param masterSection
44
	 */
45
	public CtxHelpTopicDetails(CtxHelpTreeSection masterSection) {
46
		super(masterSection, CtxHelpInputContext.CONTEXT_ID);
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite)
51
	 */
52
	public void createFields(Composite parent) {
53
		createLabel(parent, getManagedForm().getToolkit(), "Specify the display label for this topic:");
54
		fLabelEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Label:", SWT.NONE);
55
		createSpace(parent);
56
		createLabel(parent, getManagedForm().getToolkit(), "Specify the location of an HTML file containing content:");
57
		fLinkEntry = new FormEntry(parent, getManagedForm().getToolkit(), "Location:", PDEUIMessages.GeneralInfoSection_browse, isEditable());
58
	}
59
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsTitle()
62
	 */
63
	protected String getDetailsTitle() {
64
		return PDEUIMessages.TocTopicDetails_title;
65
	}
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.pde.internal.ui.editor.ctxhelp.details.CtxHelpAbstractDetails#getDetailsDescription()
69
	 */
70
	protected String getDetailsDescription() {
71
		return null;
72
	}
73
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#hookListeners()
76
	 */
77
	public void hookListeners() {
78
		fLabelEntry.setFormEntryListener(new FormEntryAdapter(this) {
79
			public void textValueChanged(FormEntry entry) {
80
				if (fTopic != null) {
81
					fTopic.setLabel(fLabelEntry.getValue());
82
				}
83
			}
84
		});
85
		fLinkEntry.setFormEntryListener(new FormEntryAdapter(this) {
86
			public void textValueChanged(FormEntry entry) { // Ensure data object is defined
87
				if (fTopic != null) {
88
					// TODO Do we need better testing for path validity?
89
					fTopic.setLocation(new Path(fLinkEntry.getValue()));
90
				}
91
			}
92
93
			public void browseButtonSelected(FormEntry entry) {
94
				handleBrowse();
95
			}
96
97
			public void linkActivated(HyperlinkEvent e) {
98
				handleOpen();
99
			}
100
		});
101
	}
102
103
	private void handleBrowse() {
104
		ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getPage().getSite().getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
105
106
		// TODO Fix browse
107
		dialog.setValidator(new FileValidator());
108
		dialog.setAllowMultiple(false);
109
		dialog.setTitle(PDEUIMessages.TocDetails_browseSelection);
110
		dialog.setMessage(PDEUIMessages.TocDetails_browseMessage);
111
		// Currently we can just use the TOC page filter (only allows html files from local projects/containers)
112
		dialog.addFilter(new HelpEditorFilter());
113
114
		dialog.setInput(PDEPlugin.getWorkspace().getRoot());
115
116
		if (dialog.open() == Window.OK) {
117
			IFile file = (IFile) dialog.getFirstResult();
118
			setPathEntry(file);
119
		}
120
	}
121
122
	/* (non-Javadoc)
123
	 * @see org.eclipse.pde.internal.ui.editor.toc.TocAbstractDetails#updateFields()
124
	 */
125
	public void updateFields() {
126
		if (fTopic != null) {
127
			fLabelEntry.setValue(fTopic.getLabel(), true);
128
			fLabelEntry.setEditable(isEditableElement());
129
			if (fTopic.getLocation() == null) {
130
				fLinkEntry.setValue("", true);
131
			} else {
132
				fLinkEntry.setValue(fTopic.getLocation().toPortableString(), true);
133
			}
134
			fLinkEntry.setEditable(isEditableElement());
135
		}
136
	}
137
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
140
	 */
141
	public void commit(boolean onSave) {
142
		super.commit(onSave);
143
		// Only required for form entries
144
		fLabelEntry.commit();
145
		fLinkEntry.commit();
146
147
	}
148
149
	/* (non-Javadoc)
150
	 * @see org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
151
	 */
152
	public void selectionChanged(IFormPart part, ISelection selection) {
153
		Object object = getFirstSelectedObject(selection);
154
		if (object instanceof CtxHelpTopic) {
155
			fTopic = (CtxHelpTopic) object;
156
			updateFields();
157
		}
158
	}
159
160
	protected void setPathEntry(IFile file) {
161
		IPath path = file.getFullPath();
162
		if (file.getProject().equals(fTopic.getModel().getUnderlyingResource().getProject())) {
163
			fLinkEntry.setValue(path.removeFirstSegments(1).toString());
164
		} else {
165
			fLinkEntry.setValue(".." + path.toString()); //$NON-NLS-1$
166
		}
167
	}
168
169
	protected void handleOpen() {
170
		IFile file = getMasterSection().openFile(fLinkEntry.getValue());
171
		if (file != null) {
172
			setPathEntry(file);
173
		}
174
	}
175
176
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpDragAdapter.java (+125 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import java.io.PrintWriter;
15
import java.io.StringWriter;
16
import java.util.ArrayList;
17
import java.util.Iterator;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
20
import org.eclipse.pde.internal.ui.editor.ModelDataTransfer;
21
import org.eclipse.swt.dnd.*;
22
23
/**
24
 * TocDragAdapter implements the drag behaviour for the TOC tree section.
25
 */
26
public class CtxHelpDragAdapter implements DragSourceListener {
27
	//The Tree Section being dragged from
28
	private CtxHelpTreeSection fSection;
29
	//The dragged items
30
	private ArrayList fDraggedItems;
31
32
	/**
33
	 * Constructs a new Drag Adapter with the specified selection
34
	 * provider and TocTreeSection
35
	 * 
36
	 * @param provider The provider of the dragged items
37
	 * @param section The section that will handle removal
38
	 */
39
	public CtxHelpDragAdapter(CtxHelpTreeSection section) {
40
		fSection = section;
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
45
	 */
46
	public void dragStart(DragSourceEvent event) {
47
		if (event.doit) { //The event should only be enabled if there is a selection to drag
48
			event.doit = !fSection.getSelection().isEmpty();
49
		}
50
	}
51
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
54
	 */
55
	public void dragSetData(DragSourceEvent event) {
56
		//Check if the drag is still enabled
57
		if (event.doit) {
58
			IStructuredSelection sel = (IStructuredSelection) fSection.getSelection();
59
60
			if (TextTransfer.getInstance().isSupportedType(event.dataType)) { //If the expected data is text, then write out the selection
61
				//into its XML representation
62
63
				StringWriter sw = new StringWriter();
64
				PrintWriter writer = new PrintWriter(sw);
65
66
				//Write the XML representation of each selected object
67
				for (Iterator iter = sel.iterator(); iter.hasNext();) {
68
					Object obj = iter.next();
69
					if (obj instanceof CtxHelpObject) {
70
						((CtxHelpObject) obj).write("", writer); //$NON-NLS-1$
71
					}
72
				}
73
74
				//Set the event's drag object to be this String
75
				event.data = sw.toString();
76
				//Set the array of dragged items to null,
77
				//since we are dragging a String
78
				fDraggedItems = null;
79
			} else if (ModelDataTransfer.getInstance().isSupportedType(event.dataType)) {
80
				//If we are dragging items from the model
81
				fDraggedItems = getSelectedObjects(sel);
82
				CtxHelpObject[] selectedObjects = (CtxHelpObject[]) fDraggedItems.toArray(new CtxHelpObject[fDraggedItems.size()]);
83
				if (selectedObjects.length == 0) { //disable the drag if there are no items selected
84
					event.doit = false;
85
				} else { //set the event's drag object to the selection
86
					event.data = selectedObjects;
87
				}
88
			}
89
		}
90
	}
91
92
	/**
93
	 * @param selection The selection to place in the ArrayList
94
	 * @return an ArrayList containing all removable TocObjects in the selection
95
	 */
96
	private ArrayList getSelectedObjects(IStructuredSelection selection) {
97
		ArrayList objects = new ArrayList();
98
		for (Iterator iter = selection.iterator(); iter.hasNext();) {
99
			Object obj = iter.next();
100
			if (obj instanceof CtxHelpObject && ((CtxHelpObject) obj).canBeRemoved()) { //If the object is a removable CtxHelpObject, add it
101
				objects.add(obj);
102
			} else { //If the object is not a removable CtxHelpObject,
103
				//we don't want to permit the drag, so return an empty list
104
				return new ArrayList();
105
			}
106
		}
107
108
		return objects;
109
	}
110
111
	/* (non-Javadoc)
112
	 * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished(org.eclipse.swt.dnd.DragSourceEvent)
113
	 */
114
	public void dragFinished(DragSourceEvent event) {
115
		if (event.detail == DND.DROP_MOVE && fDraggedItems != null) {
116
			fSection.handleDrag(fDraggedItems);
117
		}
118
119
		fDraggedItems = null;
120
	}
121
122
	public ArrayList getDraggedElements() {
123
		return fDraggedItems;
124
	}
125
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpInputContext.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import java.io.File;
15
import java.util.ArrayList;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.jface.text.IDocument;
19
import org.eclipse.pde.core.IBaseModel;
20
import org.eclipse.pde.internal.core.text.AbstractEditingModel;
21
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpModel;
22
import org.eclipse.pde.internal.ui.editor.*;
23
import org.eclipse.pde.internal.ui.editor.context.XMLInputContext;
24
import org.eclipse.ui.*;
25
26
/**
27
 * TocInputContext
28
 *
29
 */
30
public class CtxHelpInputContext extends XMLInputContext {
31
32
	public static final String CONTEXT_ID = "ctxhelp-context"; //$NON-NLS-1$	
33
34
	/**
35
	 * @param editor
36
	 * @param input
37
	 * @param primary
38
	 */
39
	public CtxHelpInputContext(PDEFormEditor editor, IEditorInput input, boolean primary) {
40
		super(editor, input, primary);
41
		create();
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.pde.internal.ui.editor.context.InputContext#createModel(org.eclipse.ui.IEditorInput)
46
	 */
47
	protected IBaseModel createModel(IEditorInput input) throws CoreException {
48
		if (input instanceof IStorageEditorInput) {
49
			boolean isReconciling = input instanceof IFileEditorInput;
50
			IDocument document = getDocumentProvider().getDocument(input);
51
52
			CtxHelpModel model = new CtxHelpModel(document, isReconciling);
53
54
			if (input instanceof IFileEditorInput) {
55
				IFile file = ((IFileEditorInput) input).getFile();
56
				model.setUnderlyingResource(file);
57
				model.setCharset(file.getCharset());
58
			} else if (input instanceof SystemFileEditorInput) {
59
				File file = (File) ((SystemFileEditorInput) input).getAdapter(File.class);
60
				model.setInstallLocation(file.getParent());
61
				model.setCharset(getDefaultCharset());
62
			} else if (input instanceof JarEntryEditorInput) {
63
				File file = (File) ((JarEntryEditorInput) input).getAdapter(File.class);
64
				model.setInstallLocation(file.toString());
65
				model.setCharset(getDefaultCharset());
66
			} else {
67
				model.setCharset(getDefaultCharset());
68
			}
69
70
			model.load();
71
72
			return model;
73
		}
74
75
		return null;
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.pde.internal.ui.editor.context.InputContext#getId()
80
	 */
81
	public String getId() {
82
		return CONTEXT_ID;
83
	}
84
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.pde.internal.ui.editor.context.XMLInputContext#reorderInsertEdits(java.util.ArrayList)
87
	 */
88
	protected void reorderInsertEdits(ArrayList ops) {
89
		// NO-OP
90
	}
91
92
	/* (non-Javadoc)
93
	 * @see org.eclipse.pde.internal.ui.editor.context.InputContext#doRevert()
94
	 */
95
	public void doRevert() {
96
		fEditOperations.clear();
97
		fOperationTable.clear();
98
		fMoveOperations.clear();
99
		AbstractEditingModel model = (AbstractEditingModel) getModel();
100
		model.reconciled(model.getDocument());
101
	}
102
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.pde.internal.ui.editor.context.InputContext#getPartitionName()
105
	 */
106
	protected String getPartitionName() {
107
		return "___ctxhelp_partition"; //$NON-NLS-1$
108
	}
109
}
(-)src/org/eclipse/pde/internal/ui/editor/ctxhelp/CtxHelpAbstractAddAction.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.pde.internal.ui.editor.ctxhelp;
13
14
import org.eclipse.jface.action.Action;
15
import org.eclipse.pde.internal.core.text.ctxhelp.CtxHelpObject;
16
17
/**
18
 * TocAddObjectAction - the abstract implementation for
19
 * adding objects to a TOC object.
20
 */
21
public abstract class CtxHelpAbstractAddAction extends Action {
22
23
	CtxHelpObject fParentObject;
24
25
	//The target object to insert after
26
	CtxHelpObject fTargetObject;
27
28
	/**
29
	 * Set the parent object that this action will add
30
	 * objects to.
31
	 * 
32
	 * @param parent The new parent object for this action
33
	 */
34
	public void setParentObject(CtxHelpObject parent) {
35
		fParentObject = parent;
36
	}
37
38
	/**
39
	 * Set the target object that this action will add
40
	 * objects after.
41
	 * 
42
	 * @param target The new target object for this action
43
	 */
44
	public void setTargetObject(CtxHelpObject target) {
45
		fTargetObject = target;
46
	}
47
48
	/**
49
	 * @return The names of the children of this TOC object
50
	 */
51
	public String[] getChildNames() {
52
		int numChildren = fParentObject.getChildren().size();
53
		CtxHelpObject[] ctxHelpObjects = (CtxHelpObject[]) fParentObject.getChildren().toArray(new CtxHelpObject[numChildren]);
54
55
		String[] ctxHelpObjectNames = new String[ctxHelpObjects.length];
56
57
		for (int i = 0; i < numChildren; ++i) {
58
			ctxHelpObjectNames[i] = ctxHelpObjects[i].getName();
59
		}
60
		return ctxHelpObjectNames;
61
	}
62
63
	/**
64
	 * Add the child to the parent object. If a target object is specified,
65
	 * add the child as a direct sibling after that object.
66
	 * 
67
	 * @param child The object to add to the parent
68
	 */
69
	protected void addChild(CtxHelpObject child) {
70
		if (fTargetObject == null) {
71
			fParentObject.addChild(child);
72
		} else {
73
			fParentObject.addChild(child, fTargetObject, false);
74
		}
75
	}
76
}

Return to bug 215091