View | Details | Raw Unified | Return to bug 259348 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java (-1 / +10 lines)
Lines 10-28 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model;
11
package org.eclipse.pde.internal.runtime.registry.model;
12
12
13
import java.util.Collections;
14
import java.util.Map;
15
13
public class ServiceRegistration extends ModelObject {
16
public class ServiceRegistration extends ModelObject {
14
17
15
	private Long id;
18
	private Long id;
16
	private String bundle;
19
	private String bundle;
17
	private Long[] usingBundles;
20
	private Long[] usingBundles;
18
	private String[] classes;
21
	private String[] classes;
22
	private Map properties;
19
23
20
	public ServiceRegistration(RegistryModel model, Long id, String bundle, Long[] usingBundles, String[] classes) {
24
	public ServiceRegistration(RegistryModel model, Long id, String bundle, Long[] usingBundles, String[] classes, Map properties) {
21
		super(model);
25
		super(model);
22
		this.id = id;
26
		this.id = id;
23
		this.bundle = bundle;
27
		this.bundle = bundle;
24
		this.usingBundles = usingBundles;
28
		this.usingBundles = usingBundles;
25
		this.classes = classes;
29
		this.classes = classes;
30
		this.properties = Collections.unmodifiableMap(properties);
26
	}
31
	}
27
32
28
	public Long getId() {
33
	public Long getId() {
Lines 41-46 Link Here
41
		return usingBundles;
46
		return usingBundles;
42
	}
47
	}
43
48
49
	public Map getProperties() {
50
		return properties;
51
	}
52
44
	public boolean equals(Object obj) {
53
	public boolean equals(Object obj) {
45
		return (obj instanceof ServiceRegistration) && (id.equals(((ServiceRegistration) obj).id));
54
		return (obj instanceof ServiceRegistration) && (id.equals(((ServiceRegistration) obj).id));
46
	}
55
	}
(-)src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java (-1 / +10 lines)
Lines 207-213 Link Here
207
			}
207
			}
208
		}
208
		}
209
		String[] classes = (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
209
		String[] classes = (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
210
		return new ServiceRegistration(model, id, bundle, usingBundlesIds, classes);
210
		Map properties = new HashMap();
211
		String[] propertyKeys = ref.getPropertyKeys();
212
		if (propertyKeys != null) {
213
			for (int p = 0; p < propertyKeys.length; p++) {
214
				String key = propertyKeys[p];
215
				Object value = ref.getProperty(key);
216
				properties.put(key, value);
217
			}
218
		}
219
		return new ServiceRegistration(model, id, bundle, usingBundlesIds, classes, properties);
211
	}
220
	}
212
221
213
	private static boolean getIsEnabled(org.osgi.framework.Bundle bundle) {
222
	private static boolean getIsEnabled(org.osgi.framework.Bundle bundle) {
(-)plugin.xml (+10 lines)
Lines 62-66 Link Here
62
            commandId="org.eclipse.pde.runtime.spy.commands.spyCommand">
62
            commandId="org.eclipse.pde.runtime.spy.commands.spyCommand">
63
      </handler>
63
      </handler>
64
   </extension>
64
   </extension>
65
   <extension
66
         point="org.eclipse.core.runtime.adapters">
67
      <factory
68
            adaptableType="org.eclipse.pde.internal.runtime.registry.model.ServiceRegistration"
69
            class="org.eclipse.pde.internal.runtime.registry.ServiceRegistrationAdapterFactory">
70
         <adapter
71
               type="org.eclipse.ui.views.properties.IPropertySource">
72
         </adapter>
73
      </factory>
74
   </extension>
65
75
66
</plugin>
76
</plugin>
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 13-19 Link Here
13
 org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
13
 org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
14
 org.eclipse.jdt.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
14
 org.eclipse.jdt.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
15
 org.eclipse.pde.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
15
 org.eclipse.pde.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
16
 org.eclipse.help;bundle-version="[3.3.0,4.0.0)";resolution:=optional
16
 org.eclipse.help;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
17
 org.eclipse.ui.views;bundle-version="[3.3.0,4.0.0)";resolution:=optional
17
Eclipse-LazyStart: true
18
Eclipse-LazyStart: true
18
Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true,
19
Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true,
19
 org.eclipse.pde.internal.runtime.registry;x-internal:=true,
20
 org.eclipse.pde.internal.runtime.registry;x-internal:=true,
(-)src/org/eclipse/pde/internal/runtime/registry/ServiceRegistrationAdapterFactory.java (+40 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.runtime.registry;
13
14
import org.eclipse.core.runtime.IAdapterFactory;
15
import org.eclipse.pde.internal.runtime.registry.model.ServiceRegistration;
16
import org.eclipse.ui.views.properties.IPropertySource;
17
18
public class ServiceRegistrationAdapterFactory implements IAdapterFactory {
19
20
	public Object getAdapter(Object adaptableObject, Class adapterType) {
21
		Object adapter = null;
22
23
		if (adaptableObject instanceof ServiceRegistration) {
24
			ServiceRegistration serviceRegistration = (ServiceRegistration) adaptableObject;
25
			if (adapterType == IPropertySource.class) {
26
				adapter = new ServiceRegistrationPropertySource(serviceRegistration);
27
			}
28
		}
29
30
		return adapter;
31
	}
32
33
	/* (non-Javadoc)
34
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
35
	 */
36
	public Class[] getAdapterList() {
37
		return new Class[] {IPropertySource.class,};
38
	}
39
40
}
(-)src/org/eclipse/pde/internal/runtime/registry/ServiceRegistrationPropertySource.java (+91 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.runtime.registry;
13
14
import java.util.Iterator;
15
import java.util.Map;
16
import org.eclipse.pde.internal.runtime.registry.model.ServiceRegistration;
17
import org.eclipse.ui.views.properties.*;
18
19
public class ServiceRegistrationPropertySource implements IPropertySource {
20
	private final ServiceRegistration serviceRegistration;
21
22
	public ServiceRegistrationPropertySource(ServiceRegistration serviceRegistration) {
23
		this.serviceRegistration = serviceRegistration;
24
	}
25
26
	public Object getEditableValue() {
27
		return serviceRegistration;
28
	}
29
30
	public IPropertyDescriptor[] getPropertyDescriptors() {
31
		Map properties = serviceRegistration.getProperties();
32
		IPropertyDescriptor[] descriptors = new IPropertyDescriptor[properties.size()];
33
		Iterator it = properties.keySet().iterator();
34
		for (int p = 0; it.hasNext(); p++) {
35
			String name = (String) it.next();
36
			descriptors[p] = new PropertyDescriptor(name, name);
37
		}
38
		return descriptors;
39
	}
40
41
	public Object getPropertyValue(Object id) {
42
		return toString(serviceRegistration.getProperties().get(id));
43
	}
44
45
	protected String toString(Object value) {
46
		if (value == null) {
47
			return ""; //$NON-NLS-1$
48
		} else if (value instanceof CharSequence) {
49
			CharSequence charSequence = (CharSequence) value;
50
			return charSequence.toString();
51
		} else if (value instanceof Object[]) {
52
			StringBuffer buff = new StringBuffer();
53
			appendString(buff, value);
54
55
			return buff.toString();
56
		} else {
57
			return value.toString();
58
		}
59
	}
60
61
	protected void appendString(StringBuffer buff, Object value) {
62
63
		if (value == null) {
64
			// ignore
65
		} else if (value instanceof Object[]) {
66
			Object[] objects = (Object[]) value;
67
			buff.append("["); //$NON-NLS-1$
68
			for (int o = 0; o < objects.length; o++) {
69
				Object object = objects[o];
70
				if (o > 0)
71
					buff.append(", "); //$NON-NLS-1$
72
				appendString(buff, object);
73
			}
74
			buff.append("]"); //$NON-NLS-1$
75
		} else {
76
			buff.append(value.toString());
77
		}
78
	}
79
80
	public boolean isPropertySet(Object id) {
81
		return serviceRegistration.getProperties().containsKey(id);
82
	}
83
84
	public void resetPropertyValue(Object id) {
85
		// ignore
86
	}
87
88
	public void setPropertyValue(Object id, Object value) {
89
		// ignore
90
	}
91
}

Return to bug 259348