|
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-117
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) && (operation != DND.DROP_LINK)) |
| 115 |
return false; |
120 |
return false; |
| 116 |
|
121 |
|
| 117 |
final IContainer target= getActualTarget(getCurrentTarget()); |
122 |
final IContainer target= getActualTarget(getCurrentTarget()); |
|
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 |
|