Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 80254 Details for
Bug 203158
Need strict separation between UI and non-UI enablement plug-ins
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch refactoring out the driver property editor UI dependency from the driver template extension
BZ203158_refactor_driver_prop_editor_patch.txt (text/plain), 19.84 KB, created by
Brian Fitzpatrick
on 2007-10-12 13:44:32 EDT
(
hide
)
Description:
Patch refactoring out the driver property editor UI dependency from the driver template extension
Filename:
MIME Type:
Creator:
Brian Fitzpatrick
Created:
2007-10-12 13:44:32 EDT
Size:
19.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.datatools.connectivity.ui >Index: src/org/eclipse/datatools/connectivity/internal/ui/resources.properties >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/resources.properties,v >retrieving revision 1.21 >diff -u -r1.21 resources.properties >--- src/org/eclipse/datatools/connectivity/internal/ui/resources.properties 2 Jul 2007 16:14:16 -0000 1.21 >+++ src/org/eclipse/datatools/connectivity/internal/ui/resources.properties 12 Oct 2007 17:37:45 -0000 >@@ -139,3 +139,8 @@ > > DATATOOLS.SERVER.UI.EXPLORER.WORKOFFLINE = &Work Offline > DATATOOLS.SERVER.UI.EXPLORER.UPDATE_OFFLINE = &Save Offline >+ >+DriverPropertyEditorDescriptor.InvalidID = Driver Property Editor descriptor is missing a valid ID >+DriverPropertyEditorDescriptor.InvalidTargetTemplateID = Driver Property Editor descriptor is missing a valid target template ID >+DriverPropertyEditorDescriptor.InvalidTargetPropertyId = Driver Property Editor descriptor is missing a valid target property ID >+DriverPropertyEditorDescriptor.InvalidCustomPropertyEditorClass = Driver Property Editor descriptor is missing a valid custom property editor >Index: src/org/eclipse/datatools/connectivity/internal/ui/DriverInstancePropertySource.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.ui/src/org/eclipse/datatools/connectivity/internal/ui/DriverInstancePropertySource.java,v >retrieving revision 1.4 >diff -u -r1.4 DriverInstancePropertySource.java >--- src/org/eclipse/datatools/connectivity/internal/ui/DriverInstancePropertySource.java 12 Jul 2007 20:41:00 -0000 1.4 >+++ src/org/eclipse/datatools/connectivity/internal/ui/DriverInstancePropertySource.java 12 Oct 2007 17:37:45 -0000 >@@ -28,6 +28,7 @@ > import org.eclipse.datatools.connectivity.drivers.models.OverrideTemplateDescriptor; > import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor; > import org.eclipse.datatools.connectivity.internal.ui.dialogs.ExceptionHandler; >+import org.eclipse.datatools.connectivity.internal.ui.drivers.DriverPropertyEditorDescriptor; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.views.properties.IPropertyDescriptor; > import org.eclipse.ui.views.properties.IPropertySource; >@@ -121,6 +122,12 @@ > name = temp; > } > String ctceClass = ice.getAttribute(P_CUSTOM_PROPERTY_DESCRIPTOR); >+ DriverPropertyEditorDescriptor[] dpeds = >+ DriverPropertyEditorDescriptor.getByDriverTemplateAndProperty(descriptor.getId(), id); >+ if (dpeds != null && dpeds.length > 0) { >+ ctceClass = dpeds[0].getCustomPropertyEditor(); >+ ice = dpeds[0].getElement(); >+ } > if (otds != null && otds.length > 0) { > String temp = > otds[0].getPropertyCustomPropDescriptorFromId(id); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.ui/plugin.xml,v >retrieving revision 1.10 >diff -u -r1.10 plugin.xml >--- plugin.xml 23 Aug 2007 18:25:48 -0000 1.10 >+++ plugin.xml 12 Oct 2007 17:37:45 -0000 >@@ -1,6 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.0"?> > <plugin> >+ <extension-point id="driverPropertyEditor" name="Driver Property Editor" schema="schema/driverPropertyEditor.exsd"/> > <extension point="org.eclipse.ui.preferencePages"> > <page name="%datatools.preference.page.name" class="org.eclipse.datatools.connectivity.internal.ui.preferences.DataToolsMainPage" > id = "org.eclipse.datatools.connectivity.internal.ui.preferences.DataToolsMainPage"/> >Index: src/org/eclipse/datatools/connectivity/internal/ui/drivers/MySafeRunnable.java >=================================================================== >RCS file: src/org/eclipse/datatools/connectivity/internal/ui/drivers/MySafeRunnable.java >diff -N src/org/eclipse/datatools/connectivity/internal/ui/drivers/MySafeRunnable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/connectivity/internal/ui/drivers/MySafeRunnable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2004-2007 Sybase, Inc. >+ * >+ * All rights reserved. This program and the accompanying materials are made >+ * available under the terms of the Eclipse Public License v1.0 which >+ * accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: brianf - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.datatools.connectivity.internal.ui.drivers; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin; >+ >+/** >+ * Safe runnable to handle creating the descriptor >+ * @author brianf >+ */ >+public class MySafeRunnable implements ISafeRunnable { >+ >+ private DriverPropertyEditorDescriptor[] mInstances = null; >+ private IConfigurationElement mElement = null; >+ >+ /* >+ * Constructor >+ * @param instances >+ * @param element >+ */ >+ public MySafeRunnable ( DriverPropertyEditorDescriptor[] instances, IConfigurationElement element ) { >+ this.mInstances = instances; >+ this.mElement = element; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) >+ */ >+ public void handleException(Throwable exception) { >+ ConnectivityPlugin.getDefault().log(exception); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.ISafeRunnable#run() >+ */ >+ public void run() throws Exception { >+ if (this.mInstances != null) >+ this.mInstances[0] = new DriverPropertyEditorDescriptor(this.mElement); >+ } >+ >+} >Index: src/org/eclipse/datatools/connectivity/internal/ui/drivers/DriverPropertyEditorDescriptor.java >=================================================================== >RCS file: src/org/eclipse/datatools/connectivity/internal/ui/drivers/DriverPropertyEditorDescriptor.java >diff -N src/org/eclipse/datatools/connectivity/internal/ui/drivers/DriverPropertyEditorDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/datatools/connectivity/internal/ui/drivers/DriverPropertyEditorDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,216 @@ >+/******************************************************************************* >+ * Copyright (c) 2004-2007 Sybase, Inc. >+ * >+ * All rights reserved. This program and the accompanying materials are made >+ * available under the terms of the Eclipse Public License v1.0 which >+ * accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: brianf - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.datatools.connectivity.internal.ui.drivers; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.SafeRunner; >+import org.eclipse.datatools.connectivity.internal.ui.ConnectivityUIPlugin; >+ >+import com.ibm.icu.text.Collator; >+ >+/** >+ * Represents a way to specify a driver property descriptor which is provided by the >+ * "org.eclipse.datatools.connectivity.ui.driverPropertyEditor" extension point. >+ * >+ * @author brianf >+ */ >+public class DriverPropertyEditorDescriptor implements Comparable { >+ >+ // extension details >+ public static final String PROPERTY_EDITOR_TAG = "propertyEditor";//$NON-NLS-1$ >+ private static final String EXTENSION_POINT_NAME = "driverPropertyEditor"; //$NON-NLS-1$ >+ >+ // attributes >+ public static final String ATTR_ID = "driverTemplateID"; //$NON-NLS-1$ >+ public static final String ATTR_TEMPLATE_ID = "driverTemplateID"; //$NON-NLS-1$ >+ public static final String ATTR_PROP_ID = "driverPropertyID"; //$NON-NLS-1$ >+ public static final String ATTR_PROPERTY_EDITOR = "customPropertyDescriptor"; //$NON-NLS-1$ >+ >+ private static final DriverPropertyEditorDescriptor[] EMPTY = {}; >+ >+ // local list of driver templates >+ private static Map fgDriverPropertyEditorDescriptors; >+ >+ // local copy of configuration element >+ private IConfigurationElement fElement; >+ >+ /** >+ * Creates a new driver property editor template descriptor for the given configuration >+ * element. >+ */ >+ protected DriverPropertyEditorDescriptor(IConfigurationElement element) { >+ this.fElement = element; >+ >+ /* >+ * "An extension for extension-point >+ * org.eclipse.datatools.connectivity.driverExtension does not provide a >+ * valid ID"); >+ */ >+ Assert.isNotNull(getId(), >+ ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidID")); //$NON-NLS-1$ >+ Assert.isNotNull(getTargetTemplateId(), >+ ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidTargetTemplateID")); //$NON-NLS-1$ >+ Assert.isNotNull(getTargetPropertyId(), >+ ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidTargetPropertyId")); //$NON-NLS-1$ >+ Assert.isNotNull(getCustomPropertyEditor(), >+ ConnectivityUIPlugin.getDefault().getResourceString("DriverPropertyEditorDescriptor.InvalidCustomPropertyEditorClass")); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns any driver property editor descriptors for the template/ >+ * property ID combo. >+ * >+ * @param driverTemplateId >+ * @param driverPropertyId >+ * @return >+ */ >+ public static DriverPropertyEditorDescriptor[] getByDriverTemplateAndProperty(String driverTemplateId, String driverPropertyId) { >+ if (fgDriverPropertyEditorDescriptors == null) { >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ IConfigurationElement[] elements = registry >+ .getConfigurationElementsFor(ConnectivityUIPlugin >+ .getDefault().getBundle().getSymbolicName(), >+ EXTENSION_POINT_NAME); >+ createDriverTemplateDescriptors(elements); >+ } >+ >+ ArrayList descriptors = (ArrayList) fgDriverPropertyEditorDescriptors.get(driverTemplateId); >+ ArrayList result = new ArrayList(); >+ if (descriptors != null) { >+ Iterator iter = descriptors.iterator(); >+ while (iter.hasNext()) { >+ DriverPropertyEditorDescriptor dped = (DriverPropertyEditorDescriptor) iter.next(); >+ if (dped.getTargetPropertyId().equals(driverPropertyId)) { >+ result.add(dped); >+ } >+ } >+ } >+ >+ return result != null ? >+ (DriverPropertyEditorDescriptor[]) result.toArray(new DriverPropertyEditorDescriptor[result.size()]) : EMPTY; >+ } >+ >+ /** >+ * Returns all contributed driver property editor descriptors. >+ */ >+ public static DriverPropertyEditorDescriptor[] getDriverPropertyEditorDescriptors() { >+ if (fgDriverPropertyEditorDescriptors == null) { >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ IConfigurationElement[] elements = registry >+ .getConfigurationElementsFor(ConnectivityUIPlugin >+ .getDefault().getBundle().getSymbolicName(), >+ EXTENSION_POINT_NAME); >+ createDriverTemplateDescriptors(elements); >+ } >+ return (DriverPropertyEditorDescriptor[]) fgDriverPropertyEditorDescriptors.values().toArray(new DriverPropertyEditorDescriptor[fgDriverPropertyEditorDescriptors.size()]); >+ } >+ >+ /** >+ * Returns the property editor id. >+ */ >+ public String getId() { >+ return this.fElement.getAttribute(ATTR_ID); >+ } >+ >+ /** >+ * Returns the target property id >+ */ >+ public String getTargetPropertyId() { >+ return this.fElement.getAttribute(ATTR_PROP_ID); >+ } >+ >+ /** >+ * Returns the target template id >+ */ >+ public String getTargetTemplateId() { >+ return this.fElement.getAttribute(ATTR_TEMPLATE_ID); >+ } >+ >+ /** >+ * Returns the custom property editor class name >+ */ >+ public String getCustomPropertyEditor() { >+ return this.fElement.getAttribute(ATTR_PROPERTY_EDITOR); >+ } >+ >+ /** >+ * Returns the configuration element. >+ */ >+ public IConfigurationElement getElement() { >+ return this.fElement; >+ } >+ >+ /* >+ * Implements a method from IComparable >+ */ >+ public int compareTo(Object o) { >+ if (o instanceof DriverPropertyEditorDescriptor) >+ return Collator.getInstance().compare(getId(), >+ ((DriverPropertyEditorDescriptor) o).getId()); >+ return Integer.MIN_VALUE; >+ } >+ >+ /** >+ * Creates the property editor descriptors. >+ */ >+ private static void createDriverTemplateDescriptors( >+ IConfigurationElement[] elements) { >+ fgDriverPropertyEditorDescriptors = new HashMap(); >+ >+ for (int i = 0; i < elements.length; ++i) { >+ final IConfigurationElement element = elements[i]; >+ if (PROPERTY_EDITOR_TAG.equals(element.getName())) { >+ >+ final DriverPropertyEditorDescriptor[] desc = new DriverPropertyEditorDescriptor[1]; >+ SafeRunner >+ .run(new MySafeRunnable ( desc, element)); >+ >+ if (desc[0] != null) { >+ List descriptors = (List)fgDriverPropertyEditorDescriptors.get(desc[0].getTargetTemplateId()); >+ if (descriptors == null) { >+ descriptors = new ArrayList(1); >+ fgDriverPropertyEditorDescriptors.put(desc[0].getTargetTemplateId(), descriptors); >+ } >+ descriptors.add(desc[0]); >+ } >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (obj instanceof DriverPropertyEditorDescriptor) { >+ DriverPropertyEditorDescriptor compare = (DriverPropertyEditorDescriptor) obj; >+ return this.getId().equals(compare.getId()); >+ } >+ return super.equals(obj); >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ if (this.getId() != null) >+ return this.getId().hashCode(); >+ return super.hashCode(); >+ } >+} >Index: schema/driverPropertyEditor.exsd >=================================================================== >RCS file: schema/driverPropertyEditor.exsd >diff -N schema/driverPropertyEditor.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/driverPropertyEditor.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,137 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.datatools.connectivity.ui"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.datatools.connectivity.ui" id="driverPropertyEditor" name="Driver Property Editor"/> >+ </appInfo> >+ <documentation> >+ [Enter description of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence> >+ <element ref="propertyEditor" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="propertyEditor"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="driverTemplateID" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Required. Provides the ID of the driver template the property descriptor editor should be used for. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="driverPropertyID" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Required. Provides the ID of the driver property the editor should be used for. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="customPropertyDescriptor" type="string"> >+ <annotation> >+ <documentation> >+ 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. >+ >+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: >+ >+ private static String DRIVER_CLASS_PROP_ID = "org.eclipse.datatools.connectivity.db.driverClass"; //$NON-NLS-1$ >+ >+ public DriverClassBrowsePropertyDescriptor() { >+ super(DRIVER_CLASS_PROP_ID, >+ ConnectivityUIPlugin.getDefault().getResourceString("DriverClassBrowsePropertyDescriptor.property.label")); //$NON-NLS-1$ >+ } >+ >+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. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.ui.views.properties.PropertyDescriptor"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ [Enter the first release in which this extension point appears.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+</schema>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 203158
:
78235
|
79770
|
79771
|
79782
|
79783
|
79784
|
79840
|
80178
| 80254 |
80269
|
80612
|
80613
|
87290