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

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/navigator/JavaDropAdapterAssistant.java (-1 / +30 lines)
Lines 29-36 Link Here
29
29
30
import org.eclipse.jface.viewers.ISelection;
30
import org.eclipse.jface.viewers.ISelection;
31
import org.eclipse.jface.viewers.IStructuredSelection;
31
import org.eclipse.jface.viewers.IStructuredSelection;
32
import org.eclipse.jface.window.Window;
32
33
33
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
34
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
35
import org.eclipse.ui.ide.dialogs.ImportTypeDialog;
34
import org.eclipse.ui.navigator.CommonDropAdapter;
36
import org.eclipse.ui.navigator.CommonDropAdapter;
35
import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
37
import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
36
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
38
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
Lines 91-98 Link Here
91
					return Status.CANCEL_STATUS;
93
					return Status.CANCEL_STATUS;
92
94
93
				getShell().forceActive();
95
				getShell().forceActive();
96
				CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
94
				final Object data= FileTransfer.getInstance().nativeToJava(dropAdapter.getCurrentTransfer());
97
				final Object data= FileTransfer.getInstance().nativeToJava(dropAdapter.getCurrentTransfer());
95
				new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, targetContainer);
98
				String[] names= (String[]) data;
99
				// if the target is a group and all sources are files, then
100
				// automatically create links
101
				int type;
102
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), names, targetContainer);
103
				dialog.setResource(targetContainer);
104
				if (dialog.open() == Window.OK)
105
					type = dialog.getSelection();
106
				else
107
					type = ImportTypeDialog.IMPORT_NONE;
108
				switch (type) {
109
				case ImportTypeDialog.IMPORT_COPY:
110
					operation.copyFiles(names, targetContainer);
111
					break;
112
				case ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS:
113
					if (dialog.getVariable() != null)
114
						operation.setRelativeVariable(dialog.getVariable());
115
					operation.createVirtualFoldersAndLinks(names, targetContainer);
116
					break;
117
				case ImportTypeDialog.IMPORT_LINK:
118
					if (dialog.getVariable() != null)
119
						operation.setRelativeVariable(dialog.getVariable());
120
					operation.linkFiles(names, targetContainer);
121
					break;
122
				case ImportTypeDialog.IMPORT_NONE:
123
					break;
124
				}
96
			} catch (JavaModelException e) {
125
			} catch (JavaModelException e) {
97
				String title = PackagesMessages.DropAdapter_errorTitle;
126
				String title = PackagesMessages.DropAdapter_errorTitle;
98
				String message = PackagesMessages.DropAdapter_errorMessage;
127
				String message = PackagesMessages.DropAdapter_errorMessage;
(-)ui/org/eclipse/jdt/internal/ui/packageview/FileTransferDropAdapter.java (-3 / +35 lines)
Lines 23-30 Link Here
23
23
24
import org.eclipse.jface.util.TransferDropTargetListener;
24
import org.eclipse.jface.util.TransferDropTargetListener;
25
import org.eclipse.jface.viewers.StructuredViewer;
25
import org.eclipse.jface.viewers.StructuredViewer;
26
import org.eclipse.jface.window.Window;
26
27
27
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
28
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
29
import org.eclipse.ui.ide.dialogs.ImportTypeDialog;
28
30
29
import org.eclipse.jdt.core.IJavaElement;
31
import org.eclipse.jdt.core.IJavaElement;
30
import org.eclipse.jdt.core.IJavaProject;
32
import org.eclipse.jdt.core.IJavaProject;
Lines 93-100 Link Here
93
95
94
		if (isContainer) {
96
		if (isContainer) {
95
			IContainer container= (IContainer)target;
97
			IContainer container= (IContainer)target;
96
			if (container.isAccessible() && !Resources.isReadOnly(container))
98
			if (container.isAccessible() && !Resources.isReadOnly(container)) {
99
				if (container.isVirtual())
100
					return DND.DROP_LINK;
97
				return DND.DROP_COPY;
101
				return DND.DROP_COPY;
102
			}
98
		} else {
103
		} else {
99
			IJavaElement element= (IJavaElement)target;
104
			IJavaElement element= (IJavaElement)target;
100
			if (!element.isReadOnly())
105
			if (!element.isReadOnly())
Lines 109-115 Link Here
109
	 */
114
	 */
110
	public boolean performDrop(final Object data) {
115
	public boolean performDrop(final Object data) {
111
		try {
116
		try {
112
			int operation= getCurrentOperation();
117
			final int operation= getCurrentOperation();
113
118
114
			if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY)
119
			if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY)
115
				return false;
120
				return false;
Lines 124-130 Link Here
124
			Display.getCurrent().asyncExec(new Runnable() {
129
			Display.getCurrent().asyncExec(new Runnable() {
125
				public void run() {
130
				public void run() {
126
					getShell().forceActive();
131
					getShell().forceActive();
127
					new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, target);
132
					CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell());
133
					String[] names= (String[]) data;
134
					// if the target is a group and all sources are files, then
135
					// automatically create links
136
					int type;
137
					ImportTypeDialog dialog = new ImportTypeDialog(getShell(), operation, names, target);
138
					dialog.setResource(target);
139
					if (dialog.open() == Window.OK)
140
						type = dialog.getSelection();
141
					else
142
						type = ImportTypeDialog.IMPORT_NONE;
143
					switch (type) {
144
					case ImportTypeDialog.IMPORT_COPY:
145
						copyOperation.copyFiles(names, target);
146
						break;
147
					case ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS:
148
						if (dialog.getVariable() != null)
149
							copyOperation.setRelativeVariable(dialog.getVariable());
150
						copyOperation.createVirtualFoldersAndLinks(names, target);
151
						break;
152
					case ImportTypeDialog.IMPORT_LINK:
153
						if (dialog.getVariable() != null)
154
							copyOperation.setRelativeVariable(dialog.getVariable());
155
						copyOperation.linkFiles(names, target);
156
						break;
157
					case ImportTypeDialog.IMPORT_NONE:
158
						break;
159
					}				
128
				}
160
				}
129
			});
161
			});
130
162

Return to bug 301187