Lines 20-25
Link Here
|
20 |
import java.util.Map; |
20 |
import java.util.Map; |
21 |
|
21 |
|
22 |
import org.eclipse.core.resources.IContainer; |
22 |
import org.eclipse.core.resources.IContainer; |
|
|
23 |
import org.eclipse.core.resources.IProject; |
24 |
import org.eclipse.core.resources.IResource; |
25 |
import org.eclipse.core.resources.IResourceChangeEvent; |
26 |
import org.eclipse.core.resources.IResourceChangeListener; |
27 |
import org.eclipse.core.resources.IResourceDelta; |
28 |
import org.eclipse.core.resources.ResourcesPlugin; |
23 |
import org.eclipse.core.runtime.IPath; |
29 |
import org.eclipse.core.runtime.IPath; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
30 |
import org.eclipse.core.runtime.IProgressMonitor; |
25 |
import org.eclipse.core.runtime.IStatus; |
31 |
import org.eclipse.core.runtime.IStatus; |
Lines 54-61
Link Here
|
54 |
import org.eclipse.swt.widgets.Shell; |
60 |
import org.eclipse.swt.widgets.Shell; |
55 |
import org.eclipse.ui.IWorkbench; |
61 |
import org.eclipse.ui.IWorkbench; |
56 |
import org.eclipse.ui.PlatformUI; |
62 |
import org.eclipse.ui.PlatformUI; |
|
|
63 |
import org.eclipse.ui.actions.NewProjectAction; |
57 |
import org.eclipse.ui.dialogs.FileSystemElement; |
64 |
import org.eclipse.ui.dialogs.FileSystemElement; |
58 |
import org.eclipse.ui.dialogs.WizardResourceImportPage; |
65 |
import org.eclipse.ui.dialogs.WizardResourceImportPage; |
|
|
66 |
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; |
67 |
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; |
59 |
import org.eclipse.ui.internal.ide.dialogs.IElementFilter; |
68 |
import org.eclipse.ui.internal.ide.dialogs.IElementFilter; |
60 |
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog; |
69 |
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog; |
61 |
import org.eclipse.ui.model.WorkbenchContentProvider; |
70 |
import org.eclipse.ui.model.WorkbenchContentProvider; |
Lines 73-78
Link Here
|
73 |
|
82 |
|
74 |
protected Button overwriteExistingResourcesCheckbox; |
83 |
protected Button overwriteExistingResourcesCheckbox; |
75 |
|
84 |
|
|
|
85 |
protected Button importAsConfiguredProjectCheckbox; |
86 |
|
76 |
protected Button createContainerStructureButton; |
87 |
protected Button createContainerStructureButton; |
77 |
|
88 |
|
78 |
protected Button createOnlySelectedButton; |
89 |
protected Button createOnlySelectedButton; |
Lines 93-98
Link Here
|
93 |
|
104 |
|
94 |
private final static String STORE_OVERWRITE_EXISTING_RESOURCES_ID = "WizardFileSystemResourceImportPage1.STORE_OVERWRITE_EXISTING_RESOURCES_ID";//$NON-NLS-1$ |
105 |
private final static String STORE_OVERWRITE_EXISTING_RESOURCES_ID = "WizardFileSystemResourceImportPage1.STORE_OVERWRITE_EXISTING_RESOURCES_ID";//$NON-NLS-1$ |
95 |
|
106 |
|
|
|
107 |
private final static String STORE_IMPORT_CONFIGURED_PROJECT = "WizardFileSystemResourceImportPage1.STORE_IMPORT_CONFIGURED_PROJECT"; //$NON-NLS-1$ |
108 |
|
96 |
private final static String STORE_CREATE_CONTAINER_STRUCTURE_ID = "WizardFileSystemResourceImportPage1.STORE_CREATE_CONTAINER_STRUCTURE_ID";//$NON-NLS-1$ |
109 |
private final static String STORE_CREATE_CONTAINER_STRUCTURE_ID = "WizardFileSystemResourceImportPage1.STORE_CREATE_CONTAINER_STRUCTURE_ID";//$NON-NLS-1$ |
97 |
|
110 |
|
98 |
private static final String SELECT_TYPES_TITLE = DataTransferMessages.DataTransfer_selectTypes; |
111 |
private static final String SELECT_TYPES_TITLE = DataTransferMessages.DataTransfer_selectTypes; |
Lines 106-112
Link Here
|
106 |
private static final String SELECT_SOURCE_MESSAGE = DataTransferMessages.FileImport_selectSource; |
119 |
private static final String SELECT_SOURCE_MESSAGE = DataTransferMessages.FileImport_selectSource; |
107 |
|
120 |
|
108 |
protected static final String SOURCE_EMPTY_MESSAGE = DataTransferMessages.FileImport_sourceEmpty; |
121 |
protected static final String SOURCE_EMPTY_MESSAGE = DataTransferMessages.FileImport_sourceEmpty; |
109 |
|
122 |
|
|
|
123 |
/** |
124 |
* This is copied from {@link org.eclipse.team.internal.ccvs.ui.wizards.CheckoutAsWizard} |
125 |
*/ |
126 |
class NewProjectListener implements IResourceChangeListener { |
127 |
private IProject newProject = null; |
128 |
/** |
129 |
* @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) |
130 |
*/ |
131 |
public void resourceChanged(IResourceChangeEvent event) { |
132 |
IResourceDelta root = event.getDelta(); |
133 |
IResourceDelta[] projectDeltas = root.getAffectedChildren(); |
134 |
for (int i = 0; i < projectDeltas.length; i++) { |
135 |
IResourceDelta delta = projectDeltas[i]; |
136 |
IResource resource = delta.getResource(); |
137 |
if (delta.getKind() == IResourceDelta.ADDED) { |
138 |
newProject = (IProject)resource; |
139 |
} |
140 |
} |
141 |
} |
142 |
/** |
143 |
* Gets the newProject. |
144 |
* @return Returns a IProject |
145 |
*/ |
146 |
public IProject getNewProject() { |
147 |
return newProject; |
148 |
} |
149 |
} |
150 |
|
110 |
/** |
151 |
/** |
111 |
* Creates an instance of this class |
152 |
* Creates an instance of this class |
112 |
*/ |
153 |
*/ |
Lines 239-253
Link Here
|
239 |
} |
280 |
} |
240 |
|
281 |
|
241 |
/** |
282 |
/** |
242 |
* Create the import options specification widgets. |
283 |
* Create the options specification widgets. There is only one |
|
|
284 |
* in this case so create no group. |
285 |
* |
286 |
* @param parent org.eclipse.swt.widgets.Composite |
243 |
*/ |
287 |
*/ |
244 |
protected void createOptionsGroupButtons(Group optionsGroup) { |
288 |
protected void createBaseOptionsGroup(Composite parent) { |
|
|
289 |
|
290 |
// create import as configured project checkbox |
291 |
importAsConfiguredProjectCheckbox = new Button(parent, SWT.CHECK); |
292 |
importAsConfiguredProjectCheckbox.setText(DataTransferMessages.FileImport_configuredProject); |
293 |
importAsConfiguredProjectCheckbox.setFont(parent.getFont()); |
294 |
importAsConfiguredProjectCheckbox.addSelectionListener(new SelectionAdapter() { |
295 |
public void widgetSelected(SelectionEvent e) |
296 |
{ // if the configured project checkbox is checked the name field and browse button should be disabled, and vice-versa |
297 |
boolean newState = importAsConfiguredProjectCheckbox.getSelection(); |
298 |
containerNameField.setEnabled(!newState); |
299 |
containerBrowseButton.setEnabled(!newState); |
300 |
updateWidgetEnablements(); |
301 |
} |
302 |
}); |
245 |
|
303 |
|
246 |
// overwrite... checkbox |
304 |
// overwrite... checkbox |
247 |
overwriteExistingResourcesCheckbox = new Button(optionsGroup, SWT.CHECK); |
305 |
overwriteExistingResourcesCheckbox = new Button(parent, SWT.CHECK); |
248 |
overwriteExistingResourcesCheckbox.setFont(optionsGroup.getFont()); |
|
|
249 |
overwriteExistingResourcesCheckbox.setText(DataTransferMessages.FileImport_overwriteExisting); |
306 |
overwriteExistingResourcesCheckbox.setText(DataTransferMessages.FileImport_overwriteExisting); |
|
|
307 |
overwriteExistingResourcesCheckbox.setFont(parent.getFont()); |
308 |
} |
309 |
|
310 |
/** |
311 |
* Create the import options specification widgets. |
312 |
*/ |
313 |
protected void createOptionsGroupButtons(Group optionsGroup) { |
250 |
|
314 |
|
|
|
315 |
createBaseOptionsGroup(optionsGroup); |
316 |
|
251 |
// create containers radio |
317 |
// create containers radio |
252 |
createContainerStructureButton = new Button(optionsGroup, SWT.RADIO); |
318 |
createContainerStructureButton = new Button(optionsGroup, SWT.RADIO); |
253 |
createContainerStructureButton.setFont(optionsGroup.getFont()); |
319 |
createContainerStructureButton.setFont(optionsGroup.getFont()); |
Lines 434-439
Link Here
|
434 |
return true; |
500 |
return true; |
435 |
} |
501 |
} |
436 |
|
502 |
|
|
|
503 |
/* |
504 |
* @see WizardDataTransferPage.determinePageCompletion. |
505 |
*/ |
506 |
protected boolean determinePageCompletion() { |
507 |
//Check for valid projects before making the user do anything |
508 |
if (noOpenProjects() && !importAsConfiguredProjectCheckbox.getSelection()) { |
509 |
setErrorMessage(IDEWorkbenchMessages.WizardImportPage_noOpenProjects); |
510 |
return false; |
511 |
} |
512 |
return super.determinePageCompletion(); |
513 |
} |
514 |
|
515 |
/** |
516 |
* Returns whether or not the passed workspace has any |
517 |
* open projects |
518 |
* @return boolean |
519 |
*/ |
520 |
protected boolean noOpenProjects() { |
521 |
IProject[] projects = IDEWorkbenchPlugin.getPluginWorkspace().getRoot() |
522 |
.getProjects(); |
523 |
for (int i = 0; i < projects.length; i++) { |
524 |
if (projects[i].isOpen()) |
525 |
return false; |
526 |
} |
527 |
return true; |
528 |
} |
529 |
|
437 |
/** |
530 |
/** |
438 |
* The Finish button was pressed. Try to do the required work now and answer |
531 |
* The Finish button was pressed. Try to do the required work now and answer |
439 |
* a boolean indicating success. If false is returned then the wizard will |
532 |
* a boolean indicating success. If false is returned then the wizard will |
Lines 634-640
Link Here
|
634 |
* Import the resources with extensions as specified by the user |
727 |
* Import the resources with extensions as specified by the user |
635 |
*/ |
728 |
*/ |
636 |
protected boolean importResources(List fileSystemObjects) { |
729 |
protected boolean importResources(List fileSystemObjects) { |
637 |
ImportOperation operation = new ImportOperation(getContainerFullPath(), |
730 |
IPath containerPath; |
|
|
731 |
if (importAsConfiguredProjectCheckbox.getSelection()) |
732 |
{ // Create a new configured project than import into there |
733 |
IProject newProject = getNewProject(); |
734 |
if (newProject == null) return false; |
735 |
containerPath = newProject.getFullPath(); |
736 |
} |
737 |
else |
738 |
{ |
739 |
containerPath = getContainerFullPath(); |
740 |
} |
741 |
ImportOperation operation = new ImportOperation(containerPath, |
638 |
getSourceDirectory(), FileSystemStructureProvider.INSTANCE, |
742 |
getSourceDirectory(), FileSystemStructureProvider.INSTANCE, |
639 |
this, fileSystemObjects); |
743 |
this, fileSystemObjects); |
640 |
|
744 |
|
Lines 643-648
Link Here
|
643 |
} |
747 |
} |
644 |
|
748 |
|
645 |
/** |
749 |
/** |
|
|
750 |
* Get a new project that is configured by the new project wizard. |
751 |
* This is currently the only way to do this. |
752 |
*/ |
753 |
protected IProject getNewProject() { |
754 |
NewProjectListener listener = new NewProjectListener(); |
755 |
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); |
756 |
(new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow())).run(); |
757 |
ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener); |
758 |
IProject project = listener.getNewProject(); |
759 |
return project; |
760 |
} |
761 |
|
762 |
|
763 |
/** |
646 |
* Initializes the specified operation appropriately. |
764 |
* Initializes the specified operation appropriately. |
647 |
*/ |
765 |
*/ |
648 |
protected void initializeOperation(ImportOperation op) { |
766 |
protected void initializeOperation(ImportOperation op) { |
Lines 701-707
Link Here
|
701 |
// radio buttons and checkboxes |
819 |
// radio buttons and checkboxes |
702 |
overwriteExistingResourcesCheckbox.setSelection(settings |
820 |
overwriteExistingResourcesCheckbox.setSelection(settings |
703 |
.getBoolean(STORE_OVERWRITE_EXISTING_RESOURCES_ID)); |
821 |
.getBoolean(STORE_OVERWRITE_EXISTING_RESOURCES_ID)); |
704 |
|
822 |
boolean configureSelection = settings.getBoolean(STORE_IMPORT_CONFIGURED_PROJECT); |
|
|
823 |
importAsConfiguredProjectCheckbox.setSelection(configureSelection); |
824 |
containerBrowseButton.setEnabled(!configureSelection); |
825 |
containerNameField.setEnabled(!configureSelection); |
826 |
|
827 |
|
705 |
boolean createStructure = settings |
828 |
boolean createStructure = settings |
706 |
.getBoolean(STORE_CREATE_CONTAINER_STRUCTURE_ID); |
829 |
.getBoolean(STORE_CREATE_CONTAINER_STRUCTURE_ID); |
707 |
createContainerStructureButton.setSelection(createStructure); |
830 |
createContainerStructureButton.setSelection(createStructure); |
Lines 726-731
Link Here
|
726 |
settings.put(STORE_SOURCE_NAMES_ID, sourceNames); |
849 |
settings.put(STORE_SOURCE_NAMES_ID, sourceNames); |
727 |
|
850 |
|
728 |
// radio buttons and checkboxes |
851 |
// radio buttons and checkboxes |
|
|
852 |
settings.put(STORE_IMPORT_CONFIGURED_PROJECT, |
853 |
importAsConfiguredProjectCheckbox.getSelection()); |
854 |
|
729 |
settings.put(STORE_OVERWRITE_EXISTING_RESOURCES_ID, |
855 |
settings.put(STORE_OVERWRITE_EXISTING_RESOURCES_ID, |
730 |
overwriteExistingResourcesCheckbox.getSelection()); |
856 |
overwriteExistingResourcesCheckbox.getSelection()); |
731 |
|
857 |
|
Lines 934-939
Link Here
|
934 |
return true; |
1060 |
return true; |
935 |
} |
1061 |
} |
936 |
|
1062 |
|
|
|
1063 |
protected boolean validateDestinationGroup() { |
1064 |
if (importAsConfiguredProjectCheckbox.getSelection()) |
1065 |
return true; |
1066 |
return super.validateDestinationGroup(); |
1067 |
} |
1068 |
|
937 |
/** |
1069 |
/** |
938 |
* Returns whether the source location conflicts |
1070 |
* Returns whether the source location conflicts |
939 |
* with the destination resource. This will occur if |
1071 |
* with the destination resource. This will occur if |