Lines 22-27
Link Here
|
22 |
import org.eclipse.jface.window.Window; |
22 |
import org.eclipse.jface.window.Window; |
23 |
import org.eclipse.swt.SWT; |
23 |
import org.eclipse.swt.SWT; |
24 |
import org.eclipse.swt.dnd.DND; |
24 |
import org.eclipse.swt.dnd.DND; |
|
|
25 |
import org.eclipse.swt.events.SelectionAdapter; |
25 |
import org.eclipse.swt.events.SelectionEvent; |
26 |
import org.eclipse.swt.events.SelectionEvent; |
26 |
import org.eclipse.swt.events.SelectionListener; |
27 |
import org.eclipse.swt.events.SelectionListener; |
27 |
import org.eclipse.swt.graphics.Image; |
28 |
import org.eclipse.swt.graphics.Image; |
Lines 32-44
Link Here
|
32 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.Control; |
34 |
import org.eclipse.swt.widgets.Control; |
34 |
import org.eclipse.swt.widgets.Label; |
35 |
import org.eclipse.swt.widgets.Label; |
|
|
36 |
import org.eclipse.swt.widgets.Link; |
35 |
import org.eclipse.swt.widgets.Shell; |
37 |
import org.eclipse.swt.widgets.Shell; |
36 |
import org.eclipse.ui.ISharedImages; |
38 |
import org.eclipse.ui.ISharedImages; |
37 |
import org.eclipse.ui.PlatformUI; |
39 |
import org.eclipse.ui.PlatformUI; |
|
|
40 |
import org.eclipse.ui.dialogs.PreferencesUtil; |
38 |
import org.eclipse.ui.internal.ide.IDEInternalPreferences; |
41 |
import org.eclipse.ui.internal.ide.IDEInternalPreferences; |
39 |
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; |
42 |
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; |
40 |
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; |
43 |
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; |
41 |
import org.eclipse.ui.internal.ide.IIDEHelpContextIds; |
44 |
import org.eclipse.ui.internal.ide.IIDEHelpContextIds; |
|
|
45 |
import org.eclipse.ui.internal.ide.dialogs.LinkedResourcesPreferencePage; |
42 |
import org.eclipse.ui.internal.ide.dialogs.RelativePathVariableGroup; |
46 |
import org.eclipse.ui.internal.ide.dialogs.RelativePathVariableGroup; |
43 |
import org.eclipse.ui.internal.ide.misc.OverlayIcon; |
47 |
import org.eclipse.ui.internal.ide.misc.OverlayIcon; |
44 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
48 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
Lines 80-87
Link Here
|
80 |
*/ |
84 |
*/ |
81 |
public final static int IMPORT_VIRTUAL_FOLDERS_AND_LINKS = 2; |
85 |
public final static int IMPORT_VIRTUAL_FOLDERS_AND_LINKS = 2; |
82 |
|
86 |
|
83 |
private Button alwaysPerformThisOperation = null; |
87 |
private final static int IMPORT_WITHOUT_PROMPT = 32; |
84 |
|
|
|
85 |
|
88 |
|
86 |
private Button copyButton = null; |
89 |
private Button copyButton = null; |
87 |
|
90 |
|
Lines 237-258
Link Here
|
237 |
|
240 |
|
238 |
String mode = store.getString(targetIsVirtual? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE:IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE); |
241 |
String mode = store.getString(targetIsVirtual? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE:IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE); |
239 |
|
242 |
|
|
|
243 |
if ((operationMask & IMPORT_WITHOUT_PROMPT) != 0) { |
244 |
if (hasFlag(IMPORT_COPY)) |
245 |
currentSelection = IMPORT_COPY; |
246 |
if (hasFlag(IMPORT_LINK)) |
247 |
currentSelection = IMPORT_LINK; |
248 |
if (hasFlag(IMPORT_MOVE)) |
249 |
currentSelection = IMPORT_MOVE; |
250 |
return Window.OK; |
251 |
} |
240 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) |
252 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) |
241 |
return super.open(); |
253 |
return super.open(); |
242 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY) && hasFlag(IMPORT_COPY)) { |
254 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY) && hasFlag(IMPORT_COPY)) { |
243 |
this.currentSelection = IMPORT_COPY; |
255 |
currentSelection = IMPORT_COPY; |
244 |
return Window.OK; |
256 |
return Window.OK; |
245 |
} |
257 |
} |
246 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY) && hasFlag(IMPORT_MOVE)) { |
258 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY) && hasFlag(IMPORT_MOVE)) { |
247 |
this.currentSelection = IMPORT_MOVE; |
259 |
currentSelection = IMPORT_MOVE; |
248 |
return Window.OK; |
260 |
return Window.OK; |
249 |
} |
261 |
} |
250 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK) && hasFlag(IMPORT_LINK)) { |
262 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK) && hasFlag(IMPORT_LINK)) { |
251 |
this.currentSelection = IMPORT_LINK; |
263 |
currentSelection = IMPORT_LINK; |
252 |
return Window.OK; |
264 |
return Window.OK; |
253 |
} |
265 |
} |
254 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER) && hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS)) { |
266 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER) && hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS)) { |
255 |
this.currentSelection = IMPORT_VIRTUAL_FOLDERS_AND_LINKS; |
267 |
currentSelection = IMPORT_VIRTUAL_FOLDERS_AND_LINKS; |
256 |
return Window.OK; |
268 |
return Window.OK; |
257 |
} |
269 |
} |
258 |
|
270 |
|
Lines 331-352
Link Here
|
331 |
|
343 |
|
332 |
IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); |
344 |
IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); |
333 |
store.putValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE, Boolean.toString(variable != null)); |
345 |
store.putValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE, Boolean.toString(variable != null)); |
334 |
if (alwaysPerformThisOperation.getSelection()) { |
|
|
335 |
String mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT; |
336 |
switch(currentSelection) { |
337 |
case IMPORT_COPY: |
338 |
case IMPORT_MOVE: |
339 |
mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY; |
340 |
break; |
341 |
case IMPORT_LINK: |
342 |
mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK; |
343 |
break; |
344 |
case IMPORT_VIRTUAL_FOLDERS_AND_LINKS: |
345 |
mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER; |
346 |
break; |
347 |
} |
348 |
store.putValue(targetIsVirtual? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE:IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE, mode); |
349 |
} |
350 |
} |
346 |
} |
351 |
super.buttonPressed(buttonId); |
347 |
super.buttonPressed(buttonId); |
352 |
} |
348 |
} |
Lines 466-481
Link Here
|
466 |
currentSelection = IMPORT_LINK; |
462 |
currentSelection = IMPORT_LINK; |
467 |
parent.getShell().setText(IDEWorkbenchMessages.ImportTypeDialog_titleFilesLinking); |
463 |
parent.getShell().setText(IDEWorkbenchMessages.ImportTypeDialog_titleFilesLinking); |
468 |
} |
464 |
} |
469 |
alwaysPerformThisOperation = new Button(parent, SWT.CHECK); |
465 |
createLinkControl(parent); |
470 |
alwaysPerformThisOperation.setText(linkIsOnlyChoice? IDEWorkbenchMessages.ImportTypeDialog_alwaysUseLocationWhenLinkingFiles: IDEWorkbenchMessages.ImportTypeDialog_alwaysPerformThisOperation); |
|
|
471 |
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); |
472 |
gridData.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); |
473 |
alwaysPerformThisOperation.setLayoutData(gridData); |
474 |
|
475 |
refreshSelection(); |
466 |
refreshSelection(); |
476 |
return composite; |
467 |
return composite; |
477 |
} |
468 |
} |
478 |
|
469 |
|
|
|
470 |
private Control createLinkControl(Composite composite) { |
471 |
Link link= new Link(composite, SWT.WRAP | SWT.RIGHT); |
472 |
link.setText(IDEWorkbenchMessages.ImportTypeDialog_configureSettings); |
473 |
link.addSelectionListener(new SelectionAdapter() { |
474 |
public void widgetSelected(SelectionEvent e) { |
475 |
openSettingsPage(); |
476 |
} |
477 |
}); |
478 |
GridData gridData= new GridData(GridData.FILL, GridData.CENTER, true, false); |
479 |
gridData.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); |
480 |
link.setLayoutData(gridData); |
481 |
link.setFont(composite.getFont()); |
482 |
|
483 |
return link; |
484 |
} |
485 |
|
486 |
protected void openSettingsPage() { |
487 |
String prefID = LinkedResourcesPreferencePage.PREF_ID; |
488 |
PreferencesUtil.createPreferenceDialogOn(getShell(), prefID, new String[] {prefID}, null).open(); |
489 |
} |
490 |
|
479 |
protected Control createMessageArea(Composite parent) { |
491 |
protected Control createMessageArea(Composite parent) { |
480 |
Composite composite = new Composite(parent, 0); |
492 |
Composite composite = new Composite(parent, 0); |
481 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
493 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
Lines 540-549
Link Here
|
540 |
* @return the appropriate import mask given the files dropped on the target |
552 |
* @return the appropriate import mask given the files dropped on the target |
541 |
*/ |
553 |
*/ |
542 |
private static int selectAppropriateMask(int dropOperation, IResource[] resources, IContainer target) { |
554 |
private static int selectAppropriateMask(int dropOperation, IResource[] resources, IContainer target) { |
543 |
int mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK; |
555 |
boolean onlyFiles = areOnlyFiles(resources); |
544 |
if (!target.isVirtual() && (dropOperation != DND.DROP_LINK)) |
556 |
int mask = selectAppropriateMask(dropOperation, target, onlyFiles); |
545 |
mask |= ImportTypeDialog.IMPORT_COPY; |
557 |
return mask; |
546 |
if (areOnlyFiles(resources)) |
558 |
} |
|
|
559 |
|
560 |
/** |
561 |
* @param dropOperation |
562 |
* @param target |
563 |
* @param onlyFiles |
564 |
* @return the appropriate import mask given the objects dropped on the target |
565 |
*/ |
566 |
private static int selectAppropriateMask(int dropOperation, |
567 |
IContainer target, boolean onlyFiles) { |
568 |
int mask; |
569 |
switch (dropOperation) { |
570 |
case DND.DROP_LINK: |
571 |
mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK; |
572 |
break; |
573 |
case DND.DROP_COPY: |
574 |
if (!target.isVirtual()) { |
575 |
mask = ImportTypeDialog.IMPORT_COPY | ImportTypeDialog.IMPORT_WITHOUT_PROMPT; |
576 |
break; |
577 |
} // otherwise, fall to default |
578 |
case DND.DROP_MOVE: // always for prompt |
579 |
default: |
580 |
mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK; |
581 |
if (!target.isVirtual()) |
582 |
mask |= ImportTypeDialog.IMPORT_COPY; |
583 |
} |
584 |
if (onlyFiles) |
547 |
mask |= ImportTypeDialog.IMPORT_FILES_ONLY; |
585 |
mask |= ImportTypeDialog.IMPORT_FILES_ONLY; |
548 |
return mask; |
586 |
return mask; |
549 |
} |
587 |
} |
Lines 560-570
Link Here
|
560 |
* @return the appropriate import mask given the files dropped on the target |
598 |
* @return the appropriate import mask given the files dropped on the target |
561 |
*/ |
599 |
*/ |
562 |
private static int selectAppropriateMask(int dropOperation, String[] names, IContainer target) { |
600 |
private static int selectAppropriateMask(int dropOperation, String[] names, IContainer target) { |
563 |
int mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK; |
601 |
boolean onlyFiles = areOnlyFiles(names); |
564 |
if (!target.isVirtual() && (dropOperation != DND.DROP_LINK)) |
602 |
int mask = selectAppropriateMask(dropOperation, target, onlyFiles); |
565 |
mask |= ImportTypeDialog.IMPORT_COPY; |
|
|
566 |
if (areOnlyFiles(names)) |
567 |
mask |= ImportTypeDialog.IMPORT_FILES_ONLY; |
568 |
return mask; |
603 |
return mask; |
569 |
} |
604 |
} |
570 |
|
605 |
|
Lines 594-597
Link Here
|
594 |
} |
629 |
} |
595 |
|
630 |
|
596 |
} |
631 |
} |
|
|
632 |
|
633 |
/** Get the default drop operation based on the user preferences. |
634 |
* @param target The container |
635 |
* @return either DND.DROP_DEFAULT for 'prompt', DND.DROP_COPY for 'copy' |
636 |
*/ |
637 |
public static int getDefaultDropMask(IContainer target) { |
638 |
if (target.isVirtual()) |
639 |
return DND.DROP_LINK; |
640 |
IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); |
641 |
|
642 |
String mode = store.getString(target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE:IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE); |
643 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY)) |
644 |
return DND.DROP_COPY; |
645 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK)) |
646 |
return DND.DROP_LINK; |
647 |
if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER)) |
648 |
return DND.DROP_LINK; |
649 |
return DND.DROP_MOVE; // move is always for prompt |
650 |
} |
597 |
} |
651 |
} |