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