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 203158 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/datatools/connectivity/internal/ui/resources.properties (+5 lines)
Lines 139-141 Link Here
139
139
140
DATATOOLS.SERVER.UI.EXPLORER.WORKOFFLINE = &Work Offline
140
DATATOOLS.SERVER.UI.EXPLORER.WORKOFFLINE = &Work Offline
141
DATATOOLS.SERVER.UI.EXPLORER.UPDATE_OFFLINE = &Save Offline
141
DATATOOLS.SERVER.UI.EXPLORER.UPDATE_OFFLINE = &Save Offline
142
143
DriverPropertyEditorDescriptor.InvalidID = Driver Property Editor descriptor is missing a valid ID
144
DriverPropertyEditorDescriptor.InvalidTargetTemplateID = Driver Property Editor descriptor is missing a valid target template ID
145
DriverPropertyEditorDescriptor.InvalidTargetPropertyId = Driver Property Editor descriptor is missing a valid target property ID
146
DriverPropertyEditorDescriptor.InvalidCustomPropertyEditorClass = Driver Property Editor descriptor is missing a valid custom property editor
(-)src/org/eclipse/datatools/connectivity/internal/ui/DriverInstancePropertySource.java (+7 lines)
Lines 28-33 Link Here
28
import org.eclipse.datatools.connectivity.drivers.models.OverrideTemplateDescriptor;
28
import org.eclipse.datatools.connectivity.drivers.models.OverrideTemplateDescriptor;
29
import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
29
import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
30
import org.eclipse.datatools.connectivity.internal.ui.dialogs.ExceptionHandler;
30
import org.eclipse.datatools.connectivity.internal.ui.dialogs.ExceptionHandler;
31
import org.eclipse.datatools.connectivity.internal.ui.drivers.DriverPropertyEditorDescriptor;
31
import org.eclipse.swt.widgets.Shell;
32
import org.eclipse.swt.widgets.Shell;
32
import org.eclipse.ui.views.properties.IPropertyDescriptor;
33
import org.eclipse.ui.views.properties.IPropertyDescriptor;
33
import org.eclipse.ui.views.properties.IPropertySource;
34
import org.eclipse.ui.views.properties.IPropertySource;
Lines 121-126 Link Here
121
							name = temp;
122
							name = temp;
122
					}
123
					}
123
					String ctceClass = ice.getAttribute(P_CUSTOM_PROPERTY_DESCRIPTOR);
124
					String ctceClass = ice.getAttribute(P_CUSTOM_PROPERTY_DESCRIPTOR);
125
					DriverPropertyEditorDescriptor[] dpeds =
126
						DriverPropertyEditorDescriptor.getByDriverTemplateAndProperty(descriptor.getId(), id);
127
					if (dpeds != null && dpeds.length > 0) {
128
						ctceClass = dpeds[0].getCustomPropertyEditor();
129
						ice = dpeds[0].getElement();
130
					}
124
					if (otds != null && otds.length > 0) {
131
					if (otds != null && otds.length > 0) {
125
						String temp =
132
						String temp =
126
							otds[0].getPropertyCustomPropDescriptorFromId(id);
133
							otds[0].getPropertyCustomPropDescriptorFromId(id);
(-)plugin.xml (+1 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
2
<?eclipse version="3.0"?>
3
<plugin>
3
<plugin>
4
   <extension-point id="driverPropertyEditor" name="Driver Property Editor" schema="schema/driverPropertyEditor.exsd"/>
4
   <extension point="org.eclipse.ui.preferencePages">
5
   <extension point="org.eclipse.ui.preferencePages">
5
   	<page name="%datatools.preference.page.name" class="org.eclipse.datatools.connectivity.internal.ui.preferences.DataToolsMainPage"
6
   	<page name="%datatools.preference.page.name" class="org.eclipse.datatools.connectivity.internal.ui.preferences.DataToolsMainPage"
6
   	id = "org.eclipse.datatools.connectivity.internal.ui.preferences.DataToolsMainPage"/>
7
   	id = "org.eclipse.datatools.connectivity.internal.ui.preferences.DataToolsMainPage"/>
(-)src/org/eclipse/datatools/connectivity/internal/ui/drivers/MySafeRunnable.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004-2007 Sybase, Inc.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: brianf - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.datatools.connectivity.internal.ui.drivers;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
import org.eclipse.core.runtime.ISafeRunnable;
15
import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin;
16
17
/**
18
 * Safe runnable to handle creating the descriptor
19
 * @author brianf
20
 */
21
public class MySafeRunnable implements ISafeRunnable {
22
23
	private DriverPropertyEditorDescriptor[] mInstances = null;
24
	private IConfigurationElement mElement = null;
25
	
26
	/*
27
	 * Constructor
28
	 * @param instances
29
	 * @param element
30
	 */
31
	public MySafeRunnable ( DriverPropertyEditorDescriptor[] instances, IConfigurationElement element ) {
32
		this.mInstances = instances;
33
		this.mElement = element;
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
38
	 */
39
	public void handleException(Throwable exception) {
40
		ConnectivityPlugin.getDefault().log(exception);
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.core.runtime.ISafeRunnable#run()
45
	 */
46
	public void run() throws Exception {
47
		if (this.mInstances != null)
48
			this.mInstances[0] = new DriverPropertyEditorDescriptor(this.mElement);
49
	}
50
51
}
(-)src/org/eclipse/datatools/connectivity/internal/ui/drivers/DriverPropertyEditorDescriptor.java (+216 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004-2007 Sybase, Inc.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: brianf - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.datatools.connectivity.internal.ui.drivers;
12
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.eclipse.core.runtime.Assert;
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.IExtensionRegistry;
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.SafeRunner;
24
import org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin;
25
26
import com.ibm.icu.text.Collator;
27
28
/**
29
 * Represents a way to specify a driver property descriptor which is provided by the
30
 * "org.eclipse.datatools.connectivity.ui.driverPropertyEditor" extension point.
31
 * 
32
 * @author brianf
33
 */
34
public class DriverPropertyEditorDescriptor implements Comparable {
35
36
	// extension details
37
	public static final String PROPERTY_EDITOR_TAG = "propertyEditor";//$NON-NLS-1$
38
	private static final String EXTENSION_POINT_NAME = "driverPropertyEditor"; //$NON-NLS-1$
39
40
	// attributes
41
	public static final String ATTR_ID = "driverTemplateID"; //$NON-NLS-1$
42
	public static final String ATTR_TEMPLATE_ID = "driverTemplateID"; //$NON-NLS-1$
43
	public static final String ATTR_PROP_ID = "driverPropertyID"; //$NON-NLS-1$
44
	public static final String ATTR_PROPERTY_EDITOR = "customPropertyDescriptor"; //$NON-NLS-1$
45
46
	private static final DriverPropertyEditorDescriptor[] EMPTY = {};
47
48
	// local list of driver templates
49
	private static Map fgDriverPropertyEditorDescriptors;
50
51
	// local copy of configuration element
52
	private IConfigurationElement fElement;
53
	
54
	/**
55
	 * Creates a new driver property editor template descriptor for the given configuration
56
	 * element.
57
	 */
58
	protected DriverPropertyEditorDescriptor(IConfigurationElement element) {
59
		this.fElement = element;
60
61
		/*
62
		 * "An extension for extension-point
63
		 * org.eclipse.datatools.connectivity.driverExtension does not provide a
64
		 * valid ID");
65
		 */
66
		Assert.isNotNull(getId(), 
67
				ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidID")); //$NON-NLS-1$
68
		Assert.isNotNull(getTargetTemplateId(), 
69
				ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidTargetTemplateID")); //$NON-NLS-1$
70
		Assert.isNotNull(getTargetPropertyId(), 
71
				ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidTargetPropertyId")); //$NON-NLS-1$
72
		Assert.isNotNull(getCustomPropertyEditor(), 
73
				ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidCustomPropertyEditorClass")); //$NON-NLS-1$
74
	}
75
76
	/**
77
	 * Returns any driver property editor descriptors for the template/
78
	 * property ID combo.
79
	 * 
80
	 * @param driverTemplateId
81
	 * @param driverPropertyId
82
	 * @return
83
	 */
84
	public static DriverPropertyEditorDescriptor[] getByDriverTemplateAndProperty(String driverTemplateId, String driverPropertyId) {
85
		if (fgDriverPropertyEditorDescriptors == null) {
86
			IExtensionRegistry registry = Platform.getExtensionRegistry();
87
			IConfigurationElement[] elements = registry
88
					.getConfigurationElementsFor(ConnectivityUIPlugin
89
							.getDefault().getBundle().getSymbolicName(),
90
							EXTENSION_POINT_NAME);
91
			createDriverTemplateDescriptors(elements);
92
		}
93
94
		ArrayList descriptors = (ArrayList) fgDriverPropertyEditorDescriptors.get(driverTemplateId);
95
		ArrayList result = new ArrayList();
96
		if (descriptors != null) {
97
			Iterator iter = descriptors.iterator();
98
			while (iter.hasNext()) {
99
				DriverPropertyEditorDescriptor dped = (DriverPropertyEditorDescriptor) iter.next();
100
				if (dped.getTargetPropertyId().equals(driverPropertyId)) {
101
					result.add(dped);
102
				}
103
			}
104
		}
105
		
106
		return result != null ?
107
				(DriverPropertyEditorDescriptor[]) result.toArray(new DriverPropertyEditorDescriptor[result.size()]) : EMPTY;
108
	}
109
110
	/**
111
	 * Returns all contributed driver property editor descriptors.
112
	 */
113
	public static DriverPropertyEditorDescriptor[] getDriverPropertyEditorDescriptors() {
114
		if (fgDriverPropertyEditorDescriptors == null) {
115
			IExtensionRegistry registry = Platform.getExtensionRegistry();
116
			IConfigurationElement[] elements = registry
117
					.getConfigurationElementsFor(ConnectivityUIPlugin
118
							.getDefault().getBundle().getSymbolicName(),
119
							EXTENSION_POINT_NAME);
120
			createDriverTemplateDescriptors(elements);
121
		}
122
		return (DriverPropertyEditorDescriptor[]) fgDriverPropertyEditorDescriptors.values().toArray(new DriverPropertyEditorDescriptor[fgDriverPropertyEditorDescriptors.size()]);
123
	}
124
125
	/**
126
	 * Returns the property editor id.
127
	 */
128
	public String getId() {
129
		return this.fElement.getAttribute(ATTR_ID);
130
	}
131
132
	/**
133
	 * Returns the target property id
134
	 */
135
	public String getTargetPropertyId() {
136
		return this.fElement.getAttribute(ATTR_PROP_ID);
137
	}
138
139
	/**
140
	 * Returns the target template id
141
	 */
142
	public String getTargetTemplateId() {
143
		return this.fElement.getAttribute(ATTR_TEMPLATE_ID);
144
	}
145
146
	/**
147
	 * Returns the custom property editor class name
148
	 */
149
	public String getCustomPropertyEditor() {
150
		return this.fElement.getAttribute(ATTR_PROPERTY_EDITOR);
151
	}
152
	
153
	/**
154
	 * Returns the configuration element.
155
	 */
156
	public IConfigurationElement getElement() {
157
		return this.fElement;
158
	}
159
160
	/*
161
	 * Implements a method from IComparable
162
	 */
163
	public int compareTo(Object o) {
164
		if (o instanceof DriverPropertyEditorDescriptor)
165
			return Collator.getInstance().compare(getId(),
166
					((DriverPropertyEditorDescriptor) o).getId());
167
		return Integer.MIN_VALUE;
168
	}
169
170
	/**
171
	 * Creates the property editor descriptors.
172
	 */
173
	private static void createDriverTemplateDescriptors(
174
			IConfigurationElement[] elements) {
175
		fgDriverPropertyEditorDescriptors = new HashMap();
176
		
177
		for (int i = 0; i < elements.length; ++i) {
178
			final IConfigurationElement element = elements[i];
179
			if (PROPERTY_EDITOR_TAG.equals(element.getName())) {
180
181
				final DriverPropertyEditorDescriptor[] desc = new DriverPropertyEditorDescriptor[1];
182
				SafeRunner
183
						.run(new MySafeRunnable ( desc, element));
184
185
				if (desc[0] != null) {
186
					List descriptors = (List)fgDriverPropertyEditorDescriptors.get(desc[0].getTargetTemplateId());
187
					if (descriptors == null) {
188
						descriptors = new ArrayList(1);
189
						fgDriverPropertyEditorDescriptors.put(desc[0].getTargetTemplateId(), descriptors);
190
					}
191
					descriptors.add(desc[0]);
192
				}
193
			}
194
		}
195
	}
196
	
197
	/* (non-Javadoc)
198
	 * @see java.lang.Object#equals(java.lang.Object)
199
	 */
200
	public boolean equals(Object obj) {
201
		if (obj instanceof DriverPropertyEditorDescriptor) {
202
			DriverPropertyEditorDescriptor compare = (DriverPropertyEditorDescriptor) obj;
203
			return this.getId().equals(compare.getId());
204
		}
205
		return super.equals(obj);
206
	}
207
208
	/* (non-Javadoc)
209
	 * @see java.lang.Object#hashCode()
210
	 */
211
	public int hashCode() {
212
		if (this.getId() != null)
213
			return this.getId().hashCode();
214
		return super.hashCode();
215
	}
216
}
(-)schema/driverPropertyEditor.exsd (+137 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.datatools.connectivity.ui">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.datatools.connectivity.ui" id="driverPropertyEditor" name="Driver Property Editor"/>
7
      </appInfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="propertyEditor" minOccurs="1" maxOccurs="unbounded"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="propertyEditor">
46
      <complexType>
47
         <attribute name="id" type="string" use="required">
48
            <annotation>
49
               <documentation>
50
                  
51
               </documentation>
52
            </annotation>
53
         </attribute>
54
         <attribute name="driverTemplateID" type="string" use="required">
55
            <annotation>
56
               <documentation>
57
                  Required. Provides the ID of the driver template the property descriptor editor should be used for.
58
               </documentation>
59
            </annotation>
60
         </attribute>
61
         <attribute name="driverPropertyID" type="string" use="required">
62
            <annotation>
63
               <documentation>
64
                  Required. Provides the ID of the driver property the editor should be used for.
65
               </documentation>
66
            </annotation>
67
         </attribute>
68
         <attribute name="customPropertyDescriptor" type="string">
69
            <annotation>
70
               <documentation>
71
                  Required. Provides a custom property descriptor that extends the class org.eclipse.ui.views.properties.PropertyDescriptor. An example of this is the class org.eclipse.datatools.connectivity.ui.PasswordTextPropertyDescriptor, which provides a property editor that masks the characters for a password property. Anything you can implement as a property descriptor for the Properties Viewer, you can use here. Or if you want to make the property values read-only, you can use org.eclipse.ui.views.properties.PropertyDescriptor directly.
72
73
Note that your property descriptor must implement a zero-argument constructor in order to be created correctly. This zero-argument constructor should provide the id and display name of the property you are editing. For example:
74
75
 private static String DRIVER_CLASS_PROP_ID = &quot;org.eclipse.datatools.connectivity.db.driverClass&quot;; //$NON-NLS-1$
76
 
77
 public DriverClassBrowsePropertyDescriptor() {
78
  super(DRIVER_CLASS_PROP_ID, 
79
    ConnectivityUIPlugin.getDefault().getResourceString(&quot;DriverClassBrowsePropertyDescriptor.property.label&quot;)); //$NON-NLS-1$
80
 }
81
 
82
Also note that there is a new interface that your Property Descriptor can extend called org.eclipse.datatools.connectivity.drivers.IDriverInstancePropertyDescriptor. This interface allows you to pass the Driver Instance to your descriptor when it is instantiated in the Edit Driver Definition dialog.
83
               </documentation>
84
               <appInfo>
85
                  <meta.attribute kind="java" basedOn="org.eclipse.ui.views.properties.PropertyDescriptor"/>
86
               </appInfo>
87
            </annotation>
88
         </attribute>
89
      </complexType>
90
   </element>
91
92
   <annotation>
93
      <appInfo>
94
         <meta.section type="since"/>
95
      </appInfo>
96
      <documentation>
97
         [Enter the first release in which this extension point appears.]
98
      </documentation>
99
   </annotation>
100
101
   <annotation>
102
      <appInfo>
103
         <meta.section type="examples"/>
104
      </appInfo>
105
      <documentation>
106
         [Enter extension point usage example here.]
107
      </documentation>
108
   </annotation>
109
110
   <annotation>
111
      <appInfo>
112
         <meta.section type="apiInfo"/>
113
      </appInfo>
114
      <documentation>
115
         [Enter API information here.]
116
      </documentation>
117
   </annotation>
118
119
   <annotation>
120
      <appInfo>
121
         <meta.section type="implementation"/>
122
      </appInfo>
123
      <documentation>
124
         [Enter information about supplied implementation of this extension point.]
125
      </documentation>
126
   </annotation>
127
128
   <annotation>
129
      <appInfo>
130
         <meta.section type="copyright"/>
131
      </appInfo>
132
      <documentation>
133
         
134
      </documentation>
135
   </annotation>
136
137
</schema>

Return to bug 203158