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 29094 Details for
Bug 106426
Performance : need to delay class loading for DnD extension
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 for sse.ui
org.eclipse.wst.sse.ui.106426.patch (text/plain), 15.35 KB, created by
Nitin Dahyabhai
on 2005-11-01 14:47:50 EST
(
hide
)
Description:
patch for sse.ui
Filename:
MIME Type:
Creator:
Nitin Dahyabhai
Created:
2005-11-01 14:47:50 EST
Size:
15.35 KB
patch
obsolete
>Index: src/org/eclipse/wst/sse/ui/internal/ExtendedEditorDropTargetAdapter.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/ExtendedEditorDropTargetAdapter.java,v >retrieving revision 1.3 >diff -u -r1.3 ExtendedEditorDropTargetAdapter.java >--- src/org/eclipse/wst/sse/ui/internal/ExtendedEditorDropTargetAdapter.java 3 Jun 2005 20:33:54 -0000 1.3 >+++ src/org/eclipse/wst/sse/ui/internal/ExtendedEditorDropTargetAdapter.java 1 Nov 2005 10:43:52 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Caret; > import org.eclipse.ui.IEditorPart; >+import org.eclipse.wst.sse.ui.internal.TransferBuilder.TransferProxyForDelayLoading; > > /** > * ExtendedEditorDropTargetAdapter >@@ -43,22 +44,40 @@ > > private Transfer[] transfers = null; > >+ private boolean useProxy; >+ >+ /** >+ * @deprecated use ExtendedEditorDropTargetAdapter(boolean useProxy) for >+ * the performance >+ */ > public ExtendedEditorDropTargetAdapter() { >+ this(false); >+ } >+ >+ public ExtendedEditorDropTargetAdapter(boolean useProxy) { > super(); >+ this.useProxy = useProxy; > } > > protected boolean doDrop(Transfer transfer, DropTargetEvent event) { >- TransferBuilder tb = new TransferBuilder(); >+ TransferBuilder tb = new TransferBuilder(useProxy); > > IDropAction[] as = null; > if (editorIds != null && editorIds.length > 0) >- as = tb.getDropActions(editorIds, transfer.getClass().getName()); >+ as = tb.getDropActions(editorIds, transfer); > else >- as = tb.getDropActions(getTargetEditor().getClass().getName(), transfer.getClass().getName()); >+ as = tb.getDropActions(getTargetEditor().getClass().getName(), transfer); > > for (int i = 0; i < as.length; ++i) { > IDropAction da = as[i]; >- if (transfer instanceof FileTransfer) { >+ Transfer actualTransfer; >+ if (transfer instanceof TransferProxyForDelayLoading) { >+ actualTransfer = ((TransferProxyForDelayLoading) transfer).getTransferClass(); >+ } >+ else { >+ actualTransfer = transfer; >+ } >+ if (actualTransfer instanceof FileTransfer) { > if (event.data == null) { > Logger.log(Logger.ERROR, "No data in DropTargetEvent from " + event.widget); //$NON-NLS-1$ > return false; >@@ -284,7 +303,7 @@ > */ > public Transfer[] getTransfers() { > if (transfers == null) { >- TransferBuilder tb = new TransferBuilder(); >+ TransferBuilder tb = new TransferBuilder(useProxy); > if (editorIds == null || editorIds.length == 0) > transfers = tb.getDropTargetTransfers(getTargetEditor().getClass().getName()); > else >Index: src/org/eclipse/wst/sse/ui/internal/ReadOnlyAwareDropTargetAdapter.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/ReadOnlyAwareDropTargetAdapter.java,v >retrieving revision 1.3 >diff -u -r1.3 ReadOnlyAwareDropTargetAdapter.java >--- src/org/eclipse/wst/sse/ui/internal/ReadOnlyAwareDropTargetAdapter.java 18 Apr 2005 07:59:42 -0000 1.3 >+++ src/org/eclipse/wst/sse/ui/internal/ReadOnlyAwareDropTargetAdapter.java 1 Nov 2005 10:43:52 -0000 >@@ -22,7 +22,7 @@ > public class ReadOnlyAwareDropTargetAdapter extends ExtendedEditorDropTargetAdapter { > > public ReadOnlyAwareDropTargetAdapter() { >- super(); >+ super(true); > } > > public void drop(DropTargetEvent event) { >Index: src/org/eclipse/wst/sse/ui/internal/TransferBuilder.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/TransferBuilder.java,v >retrieving revision 1.2 >diff -u -r1.2 TransferBuilder.java >--- src/org/eclipse/wst/sse/ui/internal/TransferBuilder.java 28 May 2005 01:25:42 -0000 1.2 >+++ src/org/eclipse/wst/sse/ui/internal/TransferBuilder.java 1 Nov 2005 10:43:52 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.core.runtime.Platform; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.dnd.Transfer; >+import org.eclipse.swt.dnd.TransferData; > import org.eclipse.wst.sse.ui.internal.extension.DropActionProxy; > import org.eclipse.wst.sse.ui.internal.extension.RegistryReader; > import org.osgi.framework.Bundle; >@@ -61,6 +62,212 @@ > > public static final String TRUE = "true"; //$NON-NLS-1$ > >+ private boolean useProxy; >+ >+ class TransferProxyForDelayLoading extends Transfer { >+ private IConfigurationElement element; >+ private String classAttribute; >+ private Transfer proxy; >+ private Method getTypeIdsMethod, getTypeNamesMethod, javaToNativeMethod, nativeToJavaMethod; >+ >+ TransferProxyForDelayLoading() { >+ super(); >+ } >+ >+ TransferProxyForDelayLoading(IConfigurationElement elm, String clsAttr) { >+ super(); >+ this.element = elm; >+ this.classAttribute = clsAttr; >+ } >+ >+ private Transfer newInstance() { >+ if ((element != null) && (classAttribute != null)) { >+ Object o = createExtension(element, classAttribute); >+ if (o instanceof Transfer) { >+ element = null; >+ classAttribute = null; >+ return (Transfer)o; >+ } >+ } >+ return null; >+ } >+ >+ public TransferData[] getSupportedTypes() { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ if (proxy != null) { >+ return proxy.getSupportedTypes(); >+ } >+ return new TransferData[0]; >+ } >+ protected int[] getTypeIds() { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ if (proxy != null) { >+ if (getTypeIdsMethod == null) { >+ Class runtimeClass = proxy.getClass(); >+ NoSuchMethodException e = null; >+ while (runtimeClass != null) { >+ try { >+ getTypeIdsMethod = runtimeClass.getDeclaredMethod("getTypeIds", new Class[0]);//$NON-NLS-1$ >+ getTypeIdsMethod.setAccessible(true); >+ break; >+ } catch (NoSuchMethodException e1) { >+ e = e1; >+ runtimeClass = runtimeClass.getSuperclass(); >+ } catch (SecurityException e2) { >+ runtimeClass = runtimeClass.getSuperclass(); >+ } >+ } >+ if ((getTypeIdsMethod == null) && (e != null)) { >+ Logger.logException(e); >+ } >+ } >+ if (getTypeIdsMethod != null) { >+ try { >+ // changed Integer[] return type to int[] >+ int[] r = (int[])getTypeIdsMethod.invoke(proxy, new Object[0]); >+ if ((r != null) && (r.length > 0)) { >+ int[] ret = new int[r.length]; >+ for(int i = 0; i < r.length; i++) { >+ ret[i] = r[i]; >+ } >+ return ret; >+ } >+ } catch (IllegalAccessException e2) { >+ Logger.logException(e2); >+ } catch (InvocationTargetException e3) { >+ Logger.logException(e3); >+ } >+ } >+ } >+ return new int[0]; >+ } >+ protected String[] getTypeNames() { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ if (proxy != null) { >+ if (getTypeNamesMethod == null) { >+ Class runtimeClass = proxy.getClass(); >+ NoSuchMethodException e = null; >+ while (runtimeClass != null) { >+ try { >+ getTypeNamesMethod = runtimeClass.getDeclaredMethod("getTypeNames", new Class[0]);//$NON-NLS-1$ >+ getTypeNamesMethod.setAccessible(true); >+ break; >+ } catch (NoSuchMethodException e1) { >+ e = e1; >+ runtimeClass = runtimeClass.getSuperclass(); >+ } catch (SecurityException e2) { >+ runtimeClass = runtimeClass.getSuperclass(); >+ } >+ } >+ if ((getTypeNamesMethod == null) && (e != null)) { >+ Logger.logException(e); >+ } >+ } >+ if (getTypeNamesMethod != null) { >+ try { >+ return (String[])getTypeNamesMethod.invoke(proxy, new Object[0]); >+ } catch (IllegalAccessException e2) { >+ Logger.logException(e2); >+ } catch (InvocationTargetException e3) { >+ Logger.logException(e3); >+ } >+ } >+ } >+ return new String[0]; >+ } >+ public boolean isSupportedType(TransferData transferData) { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ if (proxy != null) { >+ return proxy.isSupportedType(transferData); >+ } >+ return false; >+ } >+ protected void javaToNative(Object object, TransferData transferData) { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ if (proxy != null) { >+ if (javaToNativeMethod == null) { >+ Class runtimeClass = proxy.getClass(); >+ NoSuchMethodException e = null; >+ while (runtimeClass != null) { >+ try { >+ javaToNativeMethod = runtimeClass.getDeclaredMethod("javaToNative", new Class[]{object.getClass(), transferData.getClass()});//$NON-NLS-1$ >+ javaToNativeMethod.setAccessible(true); >+ break; >+ } catch (NoSuchMethodException e1) { >+ e = e1; >+ runtimeClass = runtimeClass.getSuperclass(); >+ } catch (SecurityException e2) { >+ runtimeClass = runtimeClass.getSuperclass(); >+ } >+ } >+ if ((javaToNativeMethod == null) && (e != null)) { >+ Logger.logException(e); >+ } >+ } >+ if (javaToNativeMethod != null) { >+ try { >+ javaToNativeMethod.invoke(proxy, new Object[]{object, transferData}); >+ } catch (IllegalAccessException e2) { >+ Logger.logException(e2); >+ } catch (InvocationTargetException e3) { >+ Logger.logException(e3); >+ } >+ } >+ } >+ } >+ protected Object nativeToJava(TransferData transferData) { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ if (proxy != null) { >+ if (nativeToJavaMethod == null) { >+ Class runtimeClass = proxy.getClass(); >+ NoSuchMethodException e = null; >+ while (runtimeClass != null) { >+ try { >+ nativeToJavaMethod = runtimeClass.getDeclaredMethod("nativeToJava", new Class[]{transferData.getClass()});//$NON-NLS-1$ >+ nativeToJavaMethod.setAccessible(true); >+ break; >+ } catch (NoSuchMethodException e1) { >+ e = e1; >+ runtimeClass = runtimeClass.getSuperclass(); >+ } catch (SecurityException e2) { >+ runtimeClass = runtimeClass.getSuperclass(); >+ } >+ } >+ if ((nativeToJavaMethod == null) && (e != null)) { >+ Logger.logException(e); >+ } >+ } >+ if (nativeToJavaMethod != null) { >+ try { >+ return nativeToJavaMethod.invoke(proxy, new Object[]{transferData}); >+ } catch (IllegalAccessException e2) { >+ Logger.logException(e2); >+ } catch (InvocationTargetException e3) { >+ Logger.logException(e3); >+ } >+ } >+ } >+ return new Object(); >+ } >+ Transfer getTransferClass() { >+ if (proxy == null) { >+ proxy = newInstance(); >+ } >+ return proxy; >+ } >+ } > /** > * @param element > * @param classAttribute >@@ -209,8 +416,12 @@ > * @return Transfer > */ > protected Transfer createTransfer(IConfigurationElement element) { >- Object obj = null; >- obj = createExtension(element, ATT_CLASS); >+ Object obj = null; >+ if (useProxy == true) { >+ obj = new TransferProxyForDelayLoading(element, ATT_CLASS); >+ } else { >+ obj = createExtension(element, ATT_CLASS); >+ } > if (obj == null) > return null; > return (obj instanceof Transfer) ? (Transfer) obj : null; >@@ -282,6 +493,7 @@ > } > > /** >+ * @deprecated use getDropActions(String editorId, Transfer transfer) for the performance > * @param editorId > * @param className > * @return IDropAction[] >@@ -289,9 +501,18 @@ > public IDropAction[] getDropActions(String editorId, String transferClassName) { > return getDropActions(new String[]{editorId}, transferClassName); > } >- >+ > /** > * @param editorId >+ * @param class >+ * @return IDropAction[] >+ */ >+ public IDropAction[] getDropActions(String editorId, Transfer transfer) { >+ return getDropActions(new String[]{editorId}, transfer); >+ } >+ /** >+ * @deprecated use getDropActions(String[] editorIds, Transfer transfer) for the performance >+ * @param editorId > * @param className > * @return IDropAction[] > */ >@@ -307,6 +528,20 @@ > > /** > * @param editorId >+ * @param class >+ * @return IDropAction[] >+ */ >+ public IDropAction[] getDropActions(String[] editorIds, Transfer transfer) { >+ String transferClassName; >+ if (transfer instanceof TransferProxyForDelayLoading) { >+ transferClassName = ((TransferProxyForDelayLoading)transfer).getTransferClass().getClass().getName(); >+ } else { >+ transferClassName = transfer.getClass().getName(); >+ } >+ return getDropActions(editorIds, transferClassName); >+ } >+ /** >+ * @param editorId > * @return Transfer[] > */ > public Transfer[] getDropTargetTransfers(String editorId) { >@@ -413,4 +648,15 @@ > readElementChildren(element); > return true; > } >+ /** >+ * @deprecated - use TransferBuilder(boolean useProxy) for the performance >+ */ >+ public TransferBuilder() { >+ this(false); >+ } >+ >+ public TransferBuilder(boolean useProxy) { >+ super(); >+ this.useProxy = useProxy; >+ } > }
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 106426
: 29094 |
29095