View | Details | Raw Unified | Return to bug 217759
Collapse All | Expand All

(-)plugin.xml (+8 lines)
Lines 793-797 Link Here
793
		</colorDefinition>
793
		</colorDefinition>
794
	</extension>
794
	</extension>
795
	
795
	
796
	<extension point="org.eclipse.core.runtime.adapters">		
797
		<factory 
798
            class="org.eclipse.wst.sse.ui.internal.NodeNotifierWorkbenchAdapterFactory" 
799
            adaptableType="org.eclipse.wst.sse.core.internal.provisional.INodeNotifier">
800
            <adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
801
		</factory>
802
   </extension>     	
803
	
796
</plugin>
804
</plugin>
797
805
(-)src/org/eclipse/wst/sse/ui/NodeListWorkbenchAdapter.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Chase Technology Ltd - http://www.chasetechnology.co.uk
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
 *     Doug Satchwell (Chase Technology Ltd) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui;
12
13
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.ui.model.IWorkbenchAdapter;
15
import org.w3c.dom.Node;
16
import org.w3c.dom.NodeList;
17
18
public class NodeListWorkbenchAdapter implements IWorkbenchAdapter
19
{
20
	private final NodeList nodeList;
21
22
	public NodeListWorkbenchAdapter(NodeList nodeList)
23
	{
24
		this.nodeList = nodeList;
25
	}
26
27
	public Object[] getChildren(Object o)
28
	{
29
		Node[] nodes = new Node[nodeList.getLength()];
30
		for (int i=0;i<nodes.length;i++)
31
		{
32
			nodes[i] = nodeList.item(i);
33
		}
34
		return nodes;
35
	}
36
37
	public ImageDescriptor getImageDescriptor(Object object)
38
	{
39
		return null;
40
	}
41
42
	public String getLabel(Object o)
43
	{
44
		return null;
45
	}
46
47
	public Object getParent(Object o)
48
	{
49
		return null;
50
	}
51
}
(-)src/org/eclipse/wst/sse/ui/internal/NodeNotifierWorkbenchAdapterFactory.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Chase Technology Ltd - http://www.chasetechnology.co.uk
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
 *     Doug Satchwell (Chase Technology Ltd) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal;
12
13
import org.eclipse.core.runtime.IAdapterFactory;
14
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.ui.model.IWorkbenchAdapter;
16
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
17
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
18
import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
19
20
public class NodeNotifierWorkbenchAdapterFactory implements IAdapterFactory
21
{
22
	private static final Class[] LIST = new Class[]{IWorkbenchAdapter.class};
23
	private final IWorkbenchAdapter adapter = new IWorkbenchAdapter(){
24
25
		protected IJFaceNodeAdapter getJFaceNodeAdapter(Object adaptable)
26
		{
27
			if (adaptable instanceof INodeNotifier)
28
			{
29
				INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class);
30
				if (adapter instanceof IJFaceNodeAdapter)
31
					return (IJFaceNodeAdapter) adapter;
32
			}
33
			return null;
34
		}
35
36
		public Object[] getChildren(Object o)
37
		{
38
			IJFaceNodeAdapter adapter = getJFaceNodeAdapter(o);
39
			if (adapter != null)
40
				return adapter.getChildren(o);
41
			return new Object[0];
42
		}
43
44
		public ImageDescriptor getImageDescriptor(Object object)
45
		{
46
			return ImageDescriptor.createFromImage(getJFaceNodeAdapter(object).getLabelImage(object));
47
		}
48
49
		public String getLabel(Object o)
50
		{
51
			return getJFaceNodeAdapter(o).getLabelText(o);
52
		}
53
54
		public Object getParent(Object o)
55
		{
56
			IJFaceNodeAdapter adapter = getJFaceNodeAdapter(o);
57
			if (adapter != null)
58
				return adapter.getParent(o);
59
			return null;
60
		}
61
	};
62
63
	public Object getAdapter(Object adaptableObject, Class adapterType)
64
	{
65
		return adapter;
66
	}
67
68
	public Class[] getAdapterList()
69
	{
70
		return LIST;
71
	}
72
}
(-)src/org/eclipse/wst/sse/core/internal/provisional/AbstractNotifier.java (-1 / +2 lines)
Lines 17-22 Link Here
17
import java.util.Collections;
17
import java.util.Collections;
18
18
19
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.PlatformObject;
20
import org.eclipse.wst.sse.core.internal.Logger;
21
import org.eclipse.wst.sse.core.internal.Logger;
21
import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
22
import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
22
23
Lines 29-35 Link Here
29
 * 
30
 * 
30
 * Implementers of this INodeNotifier must subclass this class.
31
 * Implementers of this INodeNotifier must subclass this class.
31
 */
32
 */
32
public abstract class AbstractNotifier implements INodeNotifier {
33
public abstract class AbstractNotifier extends PlatformObject implements INodeNotifier {
33
	private final static int growthConstant = 3;
34
	private final static int growthConstant = 3;
34
	private int adapterCount = 0;
35
	private int adapterCount = 0;
35
36

Return to bug 217759