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 74687 Details for
Bug 101993
[dnd] get rid of dnd classes which are now offered by JFace
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]
improved fix
fix_101993.txt (text/plain), 11.04 KB, created by
Benno Baumgartner
on 2007-07-26 09:55:11 EDT
(
hide
)
Description:
improved fix
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2007-07-26 09:55:11 EDT
Size:
11.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java,v >retrieving revision 1.30 >diff -u -r1.30 FileTransferDropAdapter.java >--- ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java 26 Jul 2007 13:01:56 -0000 1.30 >+++ ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java 26 Jul 2007 13:55:47 -0000 >@@ -74,7 +74,14 @@ > /** > * {@inheritDoc} > */ >- public int validateDrop(Object target, int operation, TransferData transferType) { >+ public boolean validateDrop(Object target, int operation, TransferData transferType) { >+ return getDefaultDropOperation(target, operation, transferType) != DND.DROP_NONE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected int getDefaultDropOperation(Object target, int operation, TransferData transferType) { > > boolean isPackageFragment= target instanceof IPackageFragment; > boolean isJavaProject= target instanceof IJavaProject; >@@ -100,16 +107,16 @@ > /** > * {@inheritDoc} > */ >- public int performDrop(final Object data) { >+ public boolean performDrop(final Object data) { > try { > int operation= getCurrentOperation(); > > if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY) >- return DND.DROP_NONE; >+ return false; > > final IContainer target= getActualTarget(getCurrentTarget()); > if (target == null) >- return DND.DROP_NONE; >+ return false; > > // Run the import operation asynchronously. > // Otherwise the drag source (e.g., Windows Explorer) will be blocked >@@ -121,14 +128,14 @@ > } > }); > >- return DND.DROP_COPY; >+ return false; > } catch (JavaModelException e) { > String title= PackagesMessages.DropAdapter_errorTitle; > String message= PackagesMessages.DropAdapter_errorMessage; > ExceptionHandler.handle(e, getShell(), title, message); > } > >- return DND.DROP_NONE; >+ return true; > } > > private IContainer getActualTarget(Object dropTarget) throws JavaModelException{ >Index: ui/org/eclipse/jdt/internal/ui/packageview/SelectionTransferDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/SelectionTransferDropAdapter.java,v >retrieving revision 1.62 >diff -u -r1.62 SelectionTransferDropAdapter.java >--- ui/org/eclipse/jdt/internal/ui/packageview/SelectionTransferDropAdapter.java 26 Jul 2007 13:01:56 -0000 1.62 >+++ ui/org/eclipse/jdt/internal/ui/packageview/SelectionTransferDropAdapter.java 26 Jul 2007 13:55:47 -0000 >@@ -106,11 +106,18 @@ > fCopyProcessor= null; > fCanCopyElements= 0; > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean validateDrop(Object target, int operation, TransferData transferType) { >+ return getDefaultDropOperation(target, operation, transferType) != DND.DROP_NONE; >+ } > > /** > * {@inheritDoc} > */ >- public int validateDrop(Object target, int operation, TransferData transferType) { >+ protected int getDefaultDropOperation(Object target, int operation, TransferData transferType) { > > initializeSelection(); > >@@ -162,7 +169,7 @@ > /** > * {@inheritDoc} > */ >- public int performDrop(Object data) { >+ public boolean performDrop(Object data) { > try{ > switch(getCurrentOperation()) { > case DND.DROP_MOVE: handleDropMove(getCurrentTarget()); break; >@@ -178,7 +185,7 @@ > // The drag source listener must not perform any operation > // since this drop adapter did the remove of the source even > // if we moved something. >- return DND.DROP_NONE; >+ return false; > > } > >Index: ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetDropAdapter.java,v >retrieving revision 1.8 >diff -u -r1.8 WorkingSetDropAdapter.java >--- ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetDropAdapter.java 26 Jul 2007 13:01:56 -0000 1.8 >+++ ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetDropAdapter.java 26 Jul 2007 13:55:47 -0000 >@@ -55,10 +55,14 @@ > private Set fCurrentElements; > private IWorkingSet fWorkingSet; > >+ private int fLocation; >+ > public WorkingSetDropAdapter(PackageExplorerPart part) { > super(part.getTreeViewer()); > fPackageExplorer= part; > >+ fLocation= -1; >+ > setScrollEnabled(true); > setExpandEnabled(true); > setFeedbackEnabled(false); >@@ -96,7 +100,14 @@ > /** > * {@inheritDoc} > */ >- public int validateDrop(Object target, int operation, TransferData transferType) { >+ public boolean validateDrop(Object target, int operation, TransferData transferType) { >+ return getDefaultDropOperation(target, operation, transferType) != DND.DROP_NONE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected int getDefaultDropOperation(Object target, int operation, TransferData transferType) { > switch(operation) { > case DND.DROP_DEFAULT: > case DND.DROP_COPY: >@@ -200,14 +211,14 @@ > /** > * {@inheritDoc} > */ >- public int performDrop(Object data) { >+ public boolean performDrop(Object data) { > if (isWorkingSetSelection()) { > performWorkingSetReordering(); > } else { > performElementRearrange(getCurrentOperation()); > } > // drag adapter has nothing to do, even on move. >- return DND.DROP_NONE; >+ return false; > } > > private void performWorkingSetReordering() { >@@ -285,6 +296,16 @@ > } > > public void internalTestSetLocation(int location) { >- setCurrentLocation(location); >+ fLocation= location; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected int getCurrentLocation() { >+ if (fLocation == -1) >+ return super.getCurrentLocation(); >+ >+ return fLocation; > } > } >Index: ui/org/eclipse/jdt/internal/ui/dnd/ViewerInputDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/ViewerInputDropAdapter.java,v >retrieving revision 1.1 >diff -u -r1.1 ViewerInputDropAdapter.java >--- ui/org/eclipse/jdt/internal/ui/dnd/ViewerInputDropAdapter.java 26 Jul 2007 13:01:56 -0000 1.1 >+++ ui/org/eclipse/jdt/internal/ui/dnd/ViewerInputDropAdapter.java 26 Jul 2007 13:55:47 -0000 >@@ -40,7 +40,7 @@ > /** > * {@inheritDoc} > */ >- public int validateDrop(Object target, int operation, TransferData transferType) { >+ protected int getDefaultDropOperation(Object target, int operation, TransferData transferType) { > > setSelectionFeedbackEnabled(true); > setExpandEnabled(true); >@@ -48,7 +48,7 @@ > initializeSelection(); > > if (target != null) { >- return super.validateDrop(target, operation, transferType); >+ return super.getDefaultDropOperation(target, operation, transferType); > } else if (getInputElement(getSelection()) != null) { > setSelectionFeedbackEnabled(false); > setExpandEnabled(false); >@@ -61,7 +61,7 @@ > /** > * {@inheritDoc} > */ >- public int performDrop(Object data) { >+ public boolean performDrop(Object data) { > setSelectionFeedbackEnabled(true); > setExpandEnabled(true); > >@@ -73,7 +73,7 @@ > if (input != null) > doInputView(input); > >- return DND.DROP_NONE; >+ return false; > } > > /** >Index: ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java,v >retrieving revision 1.17 >diff -u -r1.17 JdtViewerDropAdapter.java >--- ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java 26 Jul 2007 13:01:56 -0000 1.17 >+++ ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java 26 Jul 2007 13:55:47 -0000 >@@ -181,7 +181,7 @@ > * that it is still enabled. > */ > private void doDropValidation(DropTargetEvent event) { >- currentOperation= validateDrop(currentTarget, lastValidOperation, event.currentDataType); >+ currentOperation= getDefaultDropOperation(currentTarget, lastValidOperation, event.currentDataType); > event.detail = currentOperation; > } > >@@ -237,8 +237,10 @@ > currentLocation = determineLocation(event); > > //perform the drop behavior >- currentOperation= performDrop(event.data); >- event.detail= currentOperation; >+ if (!performDrop(event.data)) { >+ event.detail = DND.DROP_NONE; >+ } >+ currentOperation = event.detail; > } > > /* (non-Javadoc) >@@ -246,7 +248,7 @@ > * Last chance for the action to disable itself > */ > public void dropAccept(DropTargetEvent event) { >- event.detail= validateDrop(currentTarget, event.detail, event.currentDataType); >+ event.detail= getDefaultDropOperation(currentTarget, event.detail, event.currentDataType); > } > > /** >@@ -367,7 +369,7 @@ > * @return <code>true</code> if the drop was successful, and > * <code>false</code> otherwise > */ >- public abstract int performDrop(Object data); >+ public abstract boolean performDrop(Object data); > > /* (non-Javadoc) > * Method declared on DropTargetAdapter. >@@ -479,14 +481,37 @@ > * @return <code>true</code> if the drop is valid, and <code>false</code> > * otherwise > */ >- public abstract int validateDrop(Object target, int operation, >+ public abstract boolean validateDrop(Object target, int operation, > TransferData transferType); > > /** >- * For testing only. The location should not be set otherwise. >- * @param location the location to assume >- */ >- protected void setCurrentLocation(int location) { >- currentLocation= location; >- } >+ * Get the default drop operation on the given object. This method is called whenever some >+ * aspect of the drop operation changes. >+ * <p> >+ * The default operation is the one used when no modifier key is pressed by the user. >+ * </p> >+ * <p> >+ * Subclasses can overwrite this method to define which operation does make >+ * sense on the drop target. >+ * </p> >+ * >+ * @param target the object that the mouse is currently hovering over, or >+ * <code>null</code> if the mouse is hovering over empty space >+ * @param operation the current drag operation (copy, move, etc.) >+ * @param transferType the current transfer type >+ * @return the operation which will be executed if no modifier key is pressed >+ * by the user >+ * >+ * @see DND#DROP_NONE >+ * @see DND#DROP_MOVE >+ * @see DND#DROP_COPY >+ * @see DND#DROP_LINK >+ */ >+ protected int getDefaultDropOperation(Object target, int operation, TransferData transferType) { >+ if (!validateDrop(target, operation, transferType)) { >+ return DND.DROP_NONE; >+ } >+ >+ return operation; >+ } > }
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 101993
:
74682
| 74687