fix #774 infinite loop in net.sourceforge.phpeclipse.builder.IdentifierIndexManager...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / obfuscator / export / ObfuscatorExportOperation.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.obfuscator.export;
12
13 import java.io.File;
14 import java.io.IOException;
15 import java.util.ArrayList;
16 import java.util.HashMap;
17 import java.util.Iterator;
18 import java.util.List;
19
20 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
21 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
22 import net.sourceforge.phpeclipse.obfuscator.ObfuscatorIgnores;
23 import net.sourceforge.phpeclipse.obfuscator.ObfuscatorPass1Exporter;
24 import net.sourceforge.phpeclipse.obfuscator.ObfuscatorPass2Exporter;
25
26 import org.eclipse.core.resources.IContainer;
27 import org.eclipse.core.resources.IFile;
28 import org.eclipse.core.resources.IProject;
29 import org.eclipse.core.resources.IResource;
30 import org.eclipse.core.runtime.CoreException;
31 import org.eclipse.core.runtime.IPath;
32 import org.eclipse.core.runtime.IProgressMonitor;
33 import org.eclipse.core.runtime.IStatus;
34 import org.eclipse.core.runtime.MultiStatus;
35 import org.eclipse.core.runtime.Path;
36 import org.eclipse.core.runtime.Status;
37 import org.eclipse.jface.operation.IRunnableWithProgress;
38 import org.eclipse.jface.operation.ModalContext;
39 import org.eclipse.jface.preference.IPreferenceStore;
40 import org.eclipse.ui.PlatformUI;
41 import org.eclipse.ui.dialogs.IOverwriteQuery;
42
43 /**
44  * Operation for exporting the contents of a resource to the local file system.
45  */
46 /* package */
47 class ObfuscatorExportOperation implements IRunnableWithProgress {
48         private IPath fPath;
49
50         private IProgressMonitor fMonitor;
51
52         private ObfuscatorPass1Exporter fExporter1 = null;
53
54         private ObfuscatorPass2Exporter fExporter2 = null;
55
56         private HashMap fCurrentIdentifierMap = null;
57
58         private HashMap fProjectMap = null;
59
60         private String fCurrentProjectName = "";
61
62         private List fResourcesToExport;
63
64         private IOverwriteQuery fOverwriteCallback;
65
66         private IResource fResource;
67
68         private List errorTable = new ArrayList(1);
69
70         // The constants for the overwrite 3 state
71         private static final int OVERWRITE_NOT_SET = 0;
72
73         private static final int OVERWRITE_NONE = 1;
74
75         private static final int OVERWRITE_ALL = 2;
76
77         private int overwriteState = OVERWRITE_NOT_SET;
78
79         // private boolean createLeadupStructure = true;
80         private boolean createContainerDirectories = true;
81
82         /**
83          * Create an instance of this class. Use this constructor if you wish to
84          * export specific resources without a common parent resource
85          */
86         // public ObfuscatorExportOperation(List resources, String destinationPath,
87         // IOverwriteQuery overwriteImplementor) {
88         // super();
89         //
90         // exporter1 = new ObfuscatorPass1Exporter(new Scanner(false, false),
91         // identifierMap);
92         // exporter2 = new ObfuscatorPass2Exporter(new Scanner(true, true),
93         // identifierMap);
94         // identifierMap = null;
95         //              
96         // // Eliminate redundancies in list of resources being exported
97         // Iterator elementsEnum = resources.iterator();
98         // while (elementsEnum.hasNext()) {
99         // IResource currentResource = (IResource) elementsEnum.next();
100         // if (isDescendent(resources, currentResource))
101         // elementsEnum.remove(); //Remove currentResource
102         // }
103         //
104         // resourcesToExport = resources;
105         // path = new Path(destinationPath);
106         // overwriteCallback = overwriteImplementor;
107         // }
108         /**
109          * Create an instance of this class. Use this constructor if you wish to
110          * recursively export a single resource
111          */
112         public ObfuscatorExportOperation(IResource res, String destinationPath,
113                         IOverwriteQuery overwriteImplementor) {
114                 super();
115
116                 fResource = res;
117                 fPath = new Path(destinationPath);
118                 fOverwriteCallback = overwriteImplementor;
119         }
120
121         /**
122          * Create an instance of this class. Use this constructor if you wish to
123          * export specific resources with a common parent resource (affects
124          * container directory creation)
125          */
126         public ObfuscatorExportOperation(IResource res, List resources,
127                         String destinationPath, IOverwriteQuery overwriteImplementor) {
128                 this(res, destinationPath, overwriteImplementor);
129                 fResourcesToExport = resources;
130         }
131
132         /**
133          * Add a new entry to the error table with the passed information
134          */
135         protected void addError(String message, Throwable e) {
136                 errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
137                                 message, e));
138         }
139
140         /**
141          * Answer the total number of file resources that exist at or below self in
142          * the resources hierarchy.
143          * 
144          * @return int
145          * @param resource
146          *            org.eclipse.core.resources.IResource
147          */
148         protected int countChildrenOf(IResource resource) throws CoreException {
149                 if (resource.getType() == IResource.FILE)
150                         return 1;
151
152                 int count = 0;
153                 if (resource.isAccessible()) {
154                         IResource[] children = ((IContainer) resource).members();
155                         for (int i = 0; i < children.length; i++)
156                                 count += countChildrenOf(children[i]);
157                 }
158
159                 return count;
160         }
161
162         /**
163          * Answer a boolean indicating the number of file resources that were
164          * specified for export
165          * 
166          * @return int
167          */
168         protected int countSelectedResources() throws CoreException {
169                 int result = 0;
170                 Iterator resources = fResourcesToExport.iterator();
171
172                 while (resources.hasNext())
173                         result += countChildrenOf((IResource) resources.next());
174
175                 return result;
176         }
177
178         /**
179          * Create the directories required for exporting the passed resource, based
180          * upon its container hierarchy
181          * 
182          * @param resource
183          *            org.eclipse.core.resources.IResource
184          */
185         protected void createLeadupDirectoriesFor(IResource resource) {
186                 IPath resourcePath = resource.getFullPath().removeLastSegments(1);
187
188                 for (int i = 0; i < resourcePath.segmentCount(); i++) {
189                         fPath = fPath.append(resourcePath.segment(i));
190                         fExporter2.createFolder(fPath);
191                 }
192         }
193
194         /**
195          * Recursively export the previously-specified resource
196          */
197         protected void exportAllResources1() throws InterruptedException {
198                 if (fResource.getType() == IResource.FILE) {
199                         exportFile1((IFile) fResource, fPath);
200                 } else {
201                         try {
202                                 setExporters(fResource);
203                                 exportChildren1(((IContainer) fResource).members(), fPath);
204                         } catch (CoreException e) {
205                                 // not safe to show a dialog
206                                 // should never happen because the file system export wizard
207                                 // ensures that the
208                                 // single resource chosen for export is both existent and
209                                 // accessible
210                                 errorTable.add(e);
211                         }
212                 }
213         }
214
215         /**
216          * Recursively export the previously-specified resource
217          */
218         protected void exportAllResources2() throws InterruptedException {
219                 if (fResource.getType() == IResource.FILE) {
220                         exportFile2((IFile) fResource, fPath);
221                 } else {
222                         try {
223                                 setExporters(fResource);
224                                 exportChildren2(((IContainer) fResource).members(), fPath);
225                         } catch (CoreException e) {
226                                 // not safe to show a dialog
227                                 // should never happen because the file system export wizard
228                                 // ensures that the
229                                 // single resource chosen for export is both existent and
230                                 // accessible
231                                 errorTable.add(e);
232                         }
233                 }
234         }
235
236         /**
237          * Export all of the resources contained in the passed collection
238          * 
239          * @param children
240          *            java.util.Enumeration
241          * @param currentPath
242          *            IPath
243          */
244         protected void exportChildren1(IResource[] children, IPath currentPath)
245                         throws InterruptedException {
246                 for (int i = 0; i < children.length; i++) {
247                         IResource child = children[i];
248                         if (!child.isAccessible())
249                                 continue;
250
251                         if (child.getType() == IResource.FILE)
252                                 exportFile1((IFile) child, currentPath);
253                         else {
254                                 IPath destination = currentPath.append(child.getName());
255                                 fExporter1.createFolder(destination);
256                                 try {
257                                         exportChildren1(((IContainer) child).members(), destination);
258                                 } catch (CoreException e) {
259                                         // not safe to show a dialog
260                                         // should never happen because:
261                                         // i. this method is called recursively iterating over the
262                                         // result of #members,
263                                         // which only answers existing children
264                                         // ii. there is an #isAccessible check done before #members
265                                         // is invoked
266                                         errorTable.add(e.getStatus());
267                                 }
268                         }
269                 }
270         }
271
272         /**
273          * Export all of the resources contained in the passed collection
274          * 
275          * @param children
276          *            java.util.Enumeration
277          * @param currentPath
278          *            IPath
279          */
280         protected void exportChildren2(IResource[] children, IPath currentPath)
281                         throws InterruptedException {
282                 for (int i = 0; i < children.length; i++) {
283                         IResource child = children[i];
284                         if (!child.isAccessible())
285                                 continue;
286
287                         if (child.getType() == IResource.FILE)
288                                 exportFile2((IFile) child, currentPath);
289                         else {
290                                 IPath destination = currentPath.append(child.getName());
291                                 fExporter2.createFolder(destination);
292                                 try {
293                                         exportChildren2(((IContainer) child).members(), destination);
294                                 } catch (CoreException e) {
295                                         // not safe to show a dialog
296                                         // should never happen because:
297                                         // i. this method is called recursively iterating over the
298                                         // result of #members,
299                                         // which only answers existing children
300                                         // ii. there is an #isAccessible check done before #members
301                                         // is invoked
302                                         errorTable.add(e.getStatus());
303                                 }
304                         }
305                 }
306         }
307
308         protected void exportFile1(IFile file, IPath location)
309                         throws InterruptedException {
310                 IPath fullPath = location.append(file.getName());
311                 fMonitor.subTask(file.getFullPath().toString());
312                 String properPathString = fullPath.toOSString();
313                 File targetFile = new File(properPathString);
314
315                 // if (targetFile.exists()) {
316                 // if (!targetFile.canWrite()) {
317                 // errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
318                 // ObfuscatorExportMessages.format("ObfuscatorTransfer.cannotOverwrite",
319                 // //$NON-NLS-1$
320                 // new Object[] { targetFile.getAbsolutePath()}), null));
321                 // monitor.worked(1);
322                 // return;
323                 // }
324                 //
325                 // if (overwriteState == OVERWRITE_NONE)
326                 // return;
327                 //
328                 // if (overwriteState != OVERWRITE_ALL) {
329                 // String overwriteAnswer =
330                 // overwriteCallback.queryOverwrite(properPathString);
331                 //
332                 // if (overwriteAnswer.equals(IOverwriteQuery.CANCEL))
333                 // throw new InterruptedException();
334                 //
335                 // if (overwriteAnswer.equals(IOverwriteQuery.NO)) {
336                 // monitor.worked(1);
337                 // return;
338                 // }
339                 //
340                 // if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) {
341                 // monitor.worked(1);
342                 // overwriteState = OVERWRITE_NONE;
343                 // return;
344                 // }
345                 //
346                 // if (overwriteAnswer.equals(IOverwriteQuery.ALL))
347                 // overwriteState = OVERWRITE_ALL;
348                 // }
349                 // }
350
351                 try {
352                         setExporters(file);
353                         fExporter1.write(file, fullPath);
354                 } catch (IOException e) {
355                         errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
356                                         ObfuscatorExportMessages.format(
357                                                         "ObfuscatorTransfer.errorExporting", //$NON-NLS-1$
358                                                         new Object[] { fullPath, e.getMessage() }), e));
359                 } catch (CoreException e) {
360                         errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
361                                         ObfuscatorExportMessages.format(
362                                                         "ObfuscatorTransfer.errorExporting", //$NON-NLS-1$
363                                                         new Object[] { fullPath, e.getMessage() }), e));
364                 }
365
366                 fMonitor.worked(1);
367                 ModalContext.checkCanceled(fMonitor);
368         }
369
370         /**
371          * Export the passed file to the specified location
372          * 
373          * @param file
374          *            org.eclipse.core.resources.IFile
375          * @param location
376          *            org.eclipse.core.runtime.IPath
377          */
378         protected void exportFile2(IFile file, IPath location)
379                         throws InterruptedException {
380                 IPath fullPath = location.append(file.getName());
381                 fMonitor.subTask(file.getFullPath().toString());
382                 String properPathString = fullPath.toOSString();
383                 File targetFile = new File(properPathString);
384
385                 if (targetFile.exists()) {
386                         if (!targetFile.canWrite()) {
387                                 errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID,
388                                                 0, ObfuscatorExportMessages.format(
389                                                                 "ObfuscatorTransfer.cannotOverwrite", //$NON-NLS-1$
390                                                                 new Object[] { targetFile.getAbsolutePath() }),
391                                                 null));
392                                 fMonitor.worked(1);
393                                 return;
394                         }
395
396                         if (overwriteState == OVERWRITE_NONE)
397                                 return;
398
399                         if (overwriteState != OVERWRITE_ALL) {
400                                 String overwriteAnswer = fOverwriteCallback
401                                                 .queryOverwrite(properPathString);
402
403                                 if (overwriteAnswer.equals(IOverwriteQuery.CANCEL))
404                                         throw new InterruptedException();
405
406                                 if (overwriteAnswer.equals(IOverwriteQuery.NO)) {
407                                         fMonitor.worked(1);
408                                         return;
409                                 }
410
411                                 if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) {
412                                         fMonitor.worked(1);
413                                         overwriteState = OVERWRITE_NONE;
414                                         return;
415                                 }
416
417                                 if (overwriteAnswer.equals(IOverwriteQuery.ALL))
418                                         overwriteState = OVERWRITE_ALL;
419                         }
420                 }
421
422                 try {
423                         setExporters(file);
424                         fExporter2.write(file, fullPath);
425                 } catch (IOException e) {
426                         errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
427                                         ObfuscatorExportMessages.format(
428                                                         "ObfuscatorTransfer.errorExporting", //$NON-NLS-1$
429                                                         new Object[] { fullPath, e.getMessage() }), e));
430                 } catch (CoreException e) {
431                         errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
432                                         ObfuscatorExportMessages.format(
433                                                         "ObfuscatorTransfer.errorExporting", //$NON-NLS-1$
434                                                         new Object[] { fullPath, e.getMessage() }), e));
435                 }
436
437                 fMonitor.worked(1);
438                 ModalContext.checkCanceled(fMonitor);
439         }
440
441         protected void exportSpecifiedResources1() throws InterruptedException {
442                 Iterator resources = fResourcesToExport.iterator();
443                 IPath initPath = (IPath) fPath.clone();
444
445                 while (resources.hasNext()) {
446                         IResource currentResource = (IResource) resources.next();
447                         if (!currentResource.isAccessible())
448                                 continue;
449                         setExporters(currentResource);
450                         fPath = initPath;
451
452                         if (fResource == null) {
453                                 // No root resource specified and creation of containment
454                                 // directories
455                                 // is required. Create containers from depth 2 onwards (ie.-
456                                 // project's
457                                 // child inclusive) for each resource being exported.
458                                 // if (createLeadupStructure)
459                                 // createLeadupDirectoriesFor(currentResource);
460
461                         } else {
462                                 // Root resource specified. Must create containment directories
463                                 // from this point onwards for each resource being exported
464                                 IPath containersToCreate = currentResource.getFullPath()
465                                                 .removeFirstSegments(
466                                                                 fResource.getFullPath().segmentCount())
467                                                 .removeLastSegments(1);
468
469                                 for (int i = 0; i < containersToCreate.segmentCount(); i++) {
470                                         fPath = fPath.append(containersToCreate.segment(i));
471                                         fExporter1.createFolder(fPath);
472                                 }
473                         }
474
475                         if (currentResource.getType() == IResource.FILE)
476                                 exportFile1((IFile) currentResource, fPath);
477                         else {
478                                 if (createContainerDirectories) {
479                                         fPath = fPath.append(currentResource.getName());
480                                         fExporter1.createFolder(fPath);
481                                 }
482
483                                 try {
484                                         exportChildren1(((IContainer) currentResource).members(),
485                                                         fPath);
486                                 } catch (CoreException e) {
487                                         // should never happen because #isAccessible is called
488                                         // before #members is invoked,
489                                         // which implicitly does an existence check
490                                         errorTable.add(e.getStatus());
491                                 }
492                         }
493                 }
494         }
495
496         /**
497          * Export the resources contained in the previously-defined
498          * resourcesToExport collection
499          */
500         protected void exportSpecifiedResources2() throws InterruptedException {
501                 Iterator resources = fResourcesToExport.iterator();
502                 IPath initPath = (IPath) fPath.clone();
503
504                 while (resources.hasNext()) {
505                         IResource currentResource = (IResource) resources.next();
506                         if (!currentResource.isAccessible())
507                                 continue;
508                         setExporters(currentResource);
509
510                         fPath = initPath;
511
512                         if (fResource == null) {
513                                 // No root resource specified and creation of containment
514                                 // directories
515                                 // is required. Create containers from depth 2 onwards (ie.-
516                                 // project's
517                                 // child inclusive) for each resource being exported.
518                                 // if (createLeadupStructure)
519                                 // createLeadupDirectoriesFor(currentResource);
520
521                         } else {
522                                 // Root resource specified. Must create containment directories
523                                 // from this point onwards for each resource being exported
524                                 IPath containersToCreate = currentResource.getFullPath()
525                                                 .removeFirstSegments(
526                                                                 fResource.getFullPath().segmentCount())
527                                                 .removeLastSegments(1);
528
529                                 for (int i = 0; i < containersToCreate.segmentCount(); i++) {
530                                         fPath = fPath.append(containersToCreate.segment(i));
531                                         fExporter2.createFolder(fPath);
532                                 }
533                         }
534
535                         if (currentResource.getType() == IResource.FILE)
536                                 exportFile2((IFile) currentResource, fPath);
537                         else {
538                                 if (createContainerDirectories) {
539                                         fPath = fPath.append(currentResource.getName());
540                                         fExporter2.createFolder(fPath);
541                                 }
542
543                                 try {
544                                         exportChildren2(((IContainer) currentResource).members(),
545                                                         fPath);
546                                 } catch (CoreException e) {
547                                         // should never happen because #isAccessible is called
548                                         // before #members is invoked,
549                                         // which implicitly does an existence check
550                                         errorTable.add(e.getStatus());
551                                 }
552                         }
553                 }
554         }
555
556         /**
557          * Returns the status of the export operation. If there were any errors, the
558          * result is a status object containing individual status objects for each
559          * error. If there were no errors, the result is a status object with error
560          * code <code>OK</code>.
561          * 
562          * @return the status
563          */
564         public IStatus getStatus() {
565                 IStatus[] errors = new IStatus[errorTable.size()];
566                 errorTable.toArray(errors);
567                 return new MultiStatus(
568                                 PlatformUI.PLUGIN_ID,
569                                 IStatus.OK,
570                                 errors,
571                                 ObfuscatorExportMessages
572                                                 .getString("ObfuscatorExportOperation.problemsExporting"), //$NON-NLS-1$
573                                 null);
574         }
575
576         /**
577          * Answer a boolean indicating whether the passed child is a descendent of
578          * one or more members of the passed resources collection
579          * 
580          * @return boolean
581          * @param resources
582          *            java.util.List
583          * @param child
584          *            org.eclipse.core.resources.IResource
585          */
586         protected boolean isDescendent(List resources, IResource child) {
587                 if (child.getType() == IResource.PROJECT)
588                         return false;
589
590                 IResource parent = child.getParent();
591                 if (resources.contains(parent))
592                         return true;
593
594                 return isDescendent(resources, parent);
595         }
596
597         private void setExporters(IResource resource) {
598                 if (fCurrentIdentifierMap == null) {
599                         if (fProjectMap == null) {
600                                 fProjectMap = new HashMap();
601                         }
602                         createExporters(resource);
603                 } else {
604                         IProject project = resource.getProject();
605                         if (!fCurrentProjectName.equals(project.getName())) {
606                                 HashMap temp = (HashMap) fProjectMap.get(project.getName());
607                                 if (temp != null) {
608                                         fCurrentProjectName = project.getName();
609                                         fCurrentIdentifierMap = temp;
610                                         fExporter1 = new ObfuscatorPass1Exporter(new Scanner(false,
611                                                         false), fCurrentIdentifierMap);
612                                         fExporter2 = new ObfuscatorPass2Exporter(new Scanner(true,
613                                                         true), fCurrentIdentifierMap);
614                                         return;
615                                 }
616                                 createExporters(resource);
617                         }
618                 }
619         }
620
621         private void createExporters(IResource resource) {
622                 IProject project = resource.getProject();
623                 IPreferenceStore store = PHPeclipsePlugin.getDefault()
624                                 .getPreferenceStore();
625                 ObfuscatorIgnores ignore = new ObfuscatorIgnores(project);
626                 fCurrentIdentifierMap = ignore.getIdentifierMap();
627                 fCurrentProjectName = project.getName();
628                 fProjectMap.put(fCurrentProjectName, fCurrentIdentifierMap);
629                 fExporter1 = new ObfuscatorPass1Exporter(new Scanner(false, false),
630                                 fCurrentIdentifierMap);
631                 fExporter2 = new ObfuscatorPass2Exporter(new Scanner(true, true),
632                                 fCurrentIdentifierMap);
633         }
634
635         /**
636          * Export the resources that were previously specified for export (or if a
637          * single resource was specified then export it recursively)
638          */
639         public void run(IProgressMonitor monitor) throws InterruptedException {
640                 this.fMonitor = monitor;
641                 final IPath tempPath = (IPath) fPath.clone();
642                 if (fResource != null) {
643                         setExporters(fResource);
644                         // if (createLeadupStructure)
645                         // createLeadupDirectoriesFor(resource);
646
647                         if (createContainerDirectories
648                                         && fResource.getType() != IResource.FILE) {
649                                 // ensure it's a container
650                                 fPath = fPath.append(fResource.getName());
651                                 fExporter2.createFolder(fPath);
652                         }
653                 }
654
655                 try {
656                         // reset variables for this run:
657                         fCurrentIdentifierMap = null;
658                         fProjectMap = null;
659                         fCurrentProjectName = "";
660
661                         // count number of files
662                         int totalWork = IProgressMonitor.UNKNOWN;
663                         try {
664                                 if (fResourcesToExport == null) {
665                                         totalWork = countChildrenOf(fResource);
666                                 } else {
667                                         totalWork = countSelectedResources();
668                                 }
669                         } catch (CoreException e) {
670                                 // Should not happen
671                                 errorTable.add(e.getStatus());
672                         }
673                         monitor
674                                         .beginTask(
675                                                         ObfuscatorExportMessages
676                                                                         .getString("ObfuscatorTransfer.exportingTitle1"), totalWork); //$NON-NLS-1$
677                         if (fResourcesToExport == null) {
678                                 exportAllResources1();
679                         } else {
680                                 exportSpecifiedResources1();
681                         }
682
683                         // try {
684                         // if (resourcesToExport == null)
685                         // totalWork = countChildrenOf(resource);
686                         // else
687                         // totalWork = countSelectedResources();
688                         // } catch (CoreException e) {
689                         // // Should not happen
690                         // errorTable.add(e.getStatus());
691                         // }
692
693                         // reset path:
694                         fPath = tempPath;
695                         monitor
696                                         .beginTask(
697                                                         ObfuscatorExportMessages
698                                                                         .getString("ObfuscatorTransfer.exportingTitle2"), totalWork); //$NON-NLS-1$
699                         if (fResourcesToExport == null) {
700                                 exportAllResources2();
701                         } else {
702                                 exportSpecifiedResources2();
703                         }
704                 } finally {
705                         monitor.done();
706                 }
707         }
708
709         /**
710          * Set this boolean indicating whether a directory should be created for
711          * Folder resources that are explicitly passed for export
712          * 
713          * @param value
714          *            boolean
715          */
716         // public void setCreateContainerDirectories(boolean value) {
717         // createContainerDirectories = value;
718         // }
719         /**
720          * Set this boolean indicating whether each exported resource's complete
721          * path should include containment hierarchies as dictated by its parents
722          * 
723          * @param value
724          *            boolean
725          */
726         // public void setCreateLeadupStructure(boolean value) {
727         // createLeadupStructure = value;
728         // }
729         /**
730          * Set this boolean indicating whether exported resources should
731          * automatically overwrite existing files when a conflict occurs. If not
732          * query the user.
733          * 
734          * @param value
735          *            boolean
736          */
737         public void setOverwriteFiles(boolean value) {
738                 if (value)
739                         overwriteState = OVERWRITE_ALL;
740         }
741 }