14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 package com.nokia.carbide.cpp.internal.project.ui.importWizards; |
17 package com.nokia.carbide.cpp.internal.project.ui.importWizards; |
18 |
18 |
19 import com.nokia.carbide.cdt.builder.EpocEngineHelper; |
19 import java.io.File; |
20 import com.nokia.carbide.cpp.internal.project.ui.ProjectUIHelpIds; |
20 import java.lang.reflect.InvocationTargetException; |
21 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; |
21 import java.util.List; |
22 |
22 |
23 import org.eclipse.core.resources.*; |
23 import org.eclipse.core.resources.IContainer; |
24 import org.eclipse.core.runtime.*; |
24 import org.eclipse.core.resources.IProject; |
|
25 import org.eclipse.core.resources.IResource; |
|
26 import org.eclipse.core.resources.ResourcesPlugin; |
|
27 import org.eclipse.core.runtime.IPath; |
|
28 import org.eclipse.core.runtime.IProgressMonitor; |
|
29 import org.eclipse.core.runtime.IStatus; |
|
30 import org.eclipse.core.runtime.Path; |
25 import org.eclipse.jface.operation.IRunnableWithProgress; |
31 import org.eclipse.jface.operation.IRunnableWithProgress; |
26 import org.eclipse.jface.wizard.WizardPage; |
32 import org.eclipse.jface.wizard.WizardPage; |
27 import org.eclipse.swt.SWT; |
33 import org.eclipse.swt.SWT; |
28 import org.eclipse.swt.graphics.Font; |
34 import org.eclipse.swt.graphics.Font; |
29 import org.eclipse.swt.layout.GridData; |
35 import org.eclipse.swt.layout.GridData; |
30 import org.eclipse.swt.layout.GridLayout; |
36 import org.eclipse.swt.layout.GridLayout; |
31 import org.eclipse.swt.widgets.*; |
37 import org.eclipse.swt.widgets.Button; |
|
38 import org.eclipse.swt.widgets.Composite; |
|
39 import org.eclipse.swt.widgets.DirectoryDialog; |
|
40 import org.eclipse.swt.widgets.Event; |
|
41 import org.eclipse.swt.widgets.Label; |
|
42 import org.eclipse.swt.widgets.Listener; |
|
43 import org.eclipse.swt.widgets.Text; |
32 import org.eclipse.ui.PlatformUI; |
44 import org.eclipse.ui.PlatformUI; |
33 |
45 |
34 import java.lang.reflect.InvocationTargetException; |
46 import com.nokia.carbide.cdt.builder.EpocEngineHelper; |
35 import java.util.List; |
47 import com.nokia.carbide.cpp.internal.project.ui.ProjectUIHelpIds; |
|
48 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; |
36 |
49 |
37 public class ProjectPropertiesPage extends WizardPage implements Listener { |
50 public class ProjectPropertiesPage extends WizardPage implements Listener { |
38 |
51 |
39 private Text projectName; |
52 private Text projectName; |
40 private Text rootDirectory; |
53 private Text rootDirectory; |
41 private Button browseButton; |
54 private Button browseButton; |
|
55 private long MAX_FILE_COUNT_UNDER_ROOT = 20000; |
42 |
56 |
43 String projectNameText = ""; //$NON-NLS-1$ |
57 String projectNameText = ""; //$NON-NLS-1$ |
44 IPath rootDirectoryPath = null; |
58 IPath rootDirectoryPath = null; |
45 IPath rootPathContainingAllProjectFiles = null; |
59 IPath rootPathContainingAllProjectFiles = null; |
46 IPath rootPathContainingAllProjectAndSourceFiles = null; |
60 IPath rootPathContainingAllProjectAndSourceFiles = null; |
238 |
252 |
239 // still legal |
253 // still legal |
240 return true; |
254 return true; |
241 } |
255 } |
242 |
256 |
|
257 if (rootDirectoryPath.isRoot()){ |
|
258 long resCount = countFilesRecursivelyWithMax(rootDirectoryPath.toFile(), 0); |
|
259 // Don't show warning, if by chance there's few sources under the root |
|
260 if (resCount >= MAX_FILE_COUNT_UNDER_ROOT){ |
|
261 setMessage(Messages.ProjectPropertiesPage_directoryIsRoot, IStatus.WARNING); |
|
262 } |
|
263 return true; |
|
264 } |
|
265 |
243 return true; |
266 return true; |
244 } |
267 } |
|
268 |
|
269 /** |
|
270 * Recursively count the # of files under a given directory. Stops counting when count >= MAX_FILE_COUNT_UNDER_ROOT |
|
271 * @param directory - Start directory |
|
272 * @param start count, current count |
|
273 * @return |
|
274 */ |
|
275 private long countFilesRecursivelyWithMax(File directory, long inCount) { |
|
276 if (inCount >= MAX_FILE_COUNT_UNDER_ROOT) |
|
277 return MAX_FILE_COUNT_UNDER_ROOT; |
|
278 if (directory.isDirectory()) { |
|
279 String[] children = directory.list(); |
|
280 inCount = children.length + inCount; // increment the file count for this directory |
|
281 for (int i=0; i<children.length; i++) { |
|
282 inCount = countFilesRecursivelyWithMax(new File(directory, children[i]), inCount); |
|
283 } |
|
284 |
|
285 return inCount; // return current file count |
|
286 } |
|
287 return inCount; // return current file count |
|
288 |
|
289 } |
245 |
290 |
246 public String getProjectName() { |
291 public String getProjectName() { |
247 return projectNameText; |
292 return projectNameText; |
248 } |
293 } |
249 |
294 |