View Javadoc

1   /*
2    * $Id: SemanticWebTranslatorWizardHelper.java,v 1.6 2005/06/01 19:55:53 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8   
9   package com.bbn.swede.tools.translator;
10  
11  import java.io.File;
12  import java.io.FileOutputStream;
13  import java.io.OutputStream;
14  import java.util.ArrayList;
15  import java.util.Collections;
16  import java.util.HashSet;
17  import java.util.Iterator;
18  import java.util.List;
19  import java.util.ListIterator;
20  import java.util.Set;
21  
22  import javax.swing.tree.DefaultMutableTreeNode;
23  import javax.swing.tree.MutableTreeNode;
24  import javax.swing.tree.TreeNode;
25  
26  import org.eclipse.core.resources.IContainer;
27  import org.eclipse.core.resources.IFile;
28  import org.eclipse.core.resources.IResource;
29  import org.eclipse.core.resources.IWorkspaceRoot;
30  import org.eclipse.core.resources.ResourcesPlugin;
31  import org.eclipse.core.runtime.IPath;
32  import org.eclipse.core.runtime.IProgressMonitor;
33  import org.eclipse.core.runtime.Path;
34  import org.eclipse.core.runtime.Status;
35  import org.eclipse.jface.viewers.CheckStateChangedEvent;
36  import org.eclipse.jface.viewers.ICheckStateListener;
37  import org.eclipse.jface.viewers.ICheckable;
38  import org.eclipse.jface.viewers.ILabelProvider;
39  import org.eclipse.jface.viewers.ISelectionChangedListener;
40  import org.eclipse.jface.viewers.IStructuredSelection;
41  import org.eclipse.jface.viewers.ITreeContentProvider;
42  import org.eclipse.jface.viewers.LabelProvider;
43  import org.eclipse.jface.viewers.SelectionChangedEvent;
44  import org.eclipse.jface.viewers.StructuredSelection;
45  import org.eclipse.jface.viewers.TreeViewer;
46  import org.eclipse.jface.viewers.Viewer;
47  import org.eclipse.jface.viewers.ViewerFilter;
48  import org.eclipse.jface.wizard.ProgressMonitorPart;
49  import org.eclipse.swt.SWT;
50  import org.eclipse.swt.events.SelectionAdapter;
51  import org.eclipse.swt.events.SelectionEvent;
52  import org.eclipse.swt.events.SelectionListener;
53  import org.eclipse.swt.layout.GridData;
54  import org.eclipse.swt.layout.GridLayout;
55  import org.eclipse.swt.widgets.Button;
56  import org.eclipse.swt.widgets.Composite;
57  import org.eclipse.swt.widgets.Control;
58  import org.eclipse.swt.widgets.DirectoryDialog;
59  import org.eclipse.swt.widgets.Event;
60  import org.eclipse.swt.widgets.Group;
61  import org.eclipse.swt.widgets.Label;
62  import org.eclipse.swt.widgets.Table;
63  import org.eclipse.swt.widgets.Text;
64  import org.eclipse.swt.widgets.Tree;
65  import org.eclipse.ui.IWorkbench;
66  import org.eclipse.ui.dialogs.ContainerSelectionDialog;
67  import org.eclipse.ui.dialogs.WizardExportResourcesPage;
68  import org.eclipse.ui.internal.ide.dialogs.ResourceTreeAndListGroup;
69  import org.eclipse.ui.model.BaseWorkbenchContentProvider;
70  
71  import com.bbn.swede.core.IOWLElement;
72  import com.bbn.swede.ui.util.PixelConverter;
73  
74  /***
75   * A utility class to assist the Export and Translation wizards in selecting
76   * files and resources and translating between them. <br />
77   * <br />
78   * This class is not intended to to be subclassed or used by any code except
79   * those two wizards.
80   * 
81   * 
82   * @author aperezlo
83   */
84  final class SemanticWebTranslatorWizardHelper
85  {
86  //   /*package*/ static final int IMPORT = 1/package-summary.html">class="comment">package*/ static final int IMPORT = 1;
87  
88     /*package*/ static final int EXPORT = 2/package-summary.html">class="comment">package*/ static final int EXPORT = 2;
89  
90     /*package*/ static final int TRANSLATE = 3/package-summary.html">class="comment">package*/ static final int TRANSLATE = 3;
91  
92     private static final int OKAY = 0;
93  
94     private static final int ERROR = 2;
95  
96     private static final int WARNING = 3;
97  
98     private List _wizardPages;
99  
100    private IWorkbench _workbench;
101 
102    private IStructuredSelection _selection;
103 
104    private ListIterator _currentPage;
105 
106    private List _listHelperInputFiles;
107 
108    private IPath _pathHelperOutputPath;
109 
110    private List _listHelperTranslators;
111 
112    private ProgressMonitorPart _progressMonitor;
113 
114    private final class TranslationPageOne extends WizardExportResourcesPage
115       implements ISelectionChangedListener
116    {
117       protected TreeViewer _translatorTreeViewer;
118 
119       protected IPath _initialDestinationPath;
120 
121       protected FileExtensionTypeListenerFilter _filter;
122 
123       protected Text _destinationPathText;
124 
125       protected IPath _destinationPath;
126 
127       protected IStructuredSelection _initialSelection;
128 
129       protected Set _selectedExtensions;
130 
131       /***
132        * Creates the first page for the translation wizard.
133        * @param name The name of the page
134        * @param iss The current selection
135        */
136       public TranslationPageOne(String name, IStructuredSelection iss)
137       {
138          super(name, iss);
139          _initialSelection = iss;
140          IResource res = null;
141          if(iss.getFirstElement() instanceof IResource)
142          {
143             res = (IResource)iss.getFirstElement();
144             _filter = new FileExtensionTypeListenerFilter(true, res
145                .getFileExtension());
146             if(res instanceof IContainer)
147             {
148                _destinationPath = ((IContainer)res).getFullPath();
149             }
150             else if(res instanceof IFile)
151             {
152                _destinationPath = ((IFile)res).getFullPath()
153                   .removeLastSegments(1);
154             }
155          }
156          else if(iss.getFirstElement() instanceof IOWLElement)
157          {
158             _destinationPath = ((IOWLElement)iss.getFirstElement()).getPath();
159          }
160          _initialDestinationPath = _destinationPath;
161          _selectedExtensions = new HashSet();
162          setDescription("Choose the Semantic Web document to translate, and the desired output format.");
163          setTitle("Translation");
164       }
165 
166       private ViewerFilter computeFilter()
167       {
168          Iterator extensions = null;
169          String ext = null;
170          CombinationFilter filter = new CombinationFilter();
171 
172          extensions = _selectedExtensions.iterator();
173          while (extensions.hasNext())
174          {
175             ext = (String)extensions.next();
176             filter.addFilter(new FileExtensionTypeListenerFilter(true, ext));
177          }
178 
179          return filter;
180       }
181 
182       private boolean computeSelectedExtensions(List resources)
183       {
184          boolean toReturn = false;
185          Iterator i = resources.iterator();
186          IResource res = null;
187          Object temp = null;
188          Set newSet = new HashSet();
189 
190          while (i.hasNext())
191          {
192             temp = i.next();
193             res = (temp instanceof IResource) ? (IResource)temp : null;
194             if(res != null)
195             {
196                if(res.getFileExtension() != null)
197                {
198                   newSet.add(res.getFileExtension());
199                }
200             }
201          }
202          if(!newSet.equals(_selectedExtensions))
203          {
204             _selectedExtensions = newSet;
205             toReturn = true;
206          }
207          return toReturn;
208       }
209 
210       private void setupCheckListener(Composite parent)
211       {
212          ResourceTreeAndListGroup toReturn = null;
213          Control[] children = parent.getChildren();
214          Composite newParent = null;
215          SelectionListener sa = new SelectionAdapter()
216          {
217             public void widgetSelected(SelectionEvent e)
218             {
219                super.widgetSelected(e);
220                handleEvent(null);
221             }
222          };
223          for(int i = 0; i < children.length; i++)
224          {
225             if(children[i] instanceof Tree)
226             {
227                ((Tree)children[i]).addSelectionListener(sa);
228             }
229             else if(children[i] instanceof Table)
230             {
231                ((Table)children[i]).addSelectionListener(sa);
232             }
233             else if(children[i] instanceof Composite)
234             {
235                setupCheckListener((Composite)children[i]);
236             }
237          }
238       }
239 
240       /*
241        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
242        */
243       public void createControl(Composite parent)
244       {
245          initializeDialogUnits(parent);
246 
247          Composite composite = new Composite(parent, SWT.NULL);
248          composite.setLayout(new GridLayout());
249          composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
250             | GridData.HORIZONTAL_ALIGN_FILL));
251          composite.setFont(parent.getFont());
252 
253          //      Composite disabler = new Composite(composite, parent.getStyle() |
254          // SWT.EMBEDDED);
255          //      
256          //      
257          //      
258          //      
259          //      Group disablerGroup = new Group(disabler, parent.getStyle() |
260          // SWT.SHADOW_ETCHED_IN);
261          //        disabler.setLayout(new GridLayout());
262          //        disabler.setLayoutData(new GridData(GridData.FILL_BOTH));
263          //        disabler.setEnabled(false);
264          //        disablerGroup.setLayout(new GridLayout());
265          //        disablerGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
266          //        disablerGroup.setFont(parent.getFont());
267          //        disablerGroup.setToolTipText("Resources already selected");
268          //      disablerGroup.setText("Selected Resources:");
269          //      
270          //      
271          //      
272          //      
273          //      
274          //      
275          //      
276          //      createResourcesGroup(disablerGroup);
277 
278          final Composite listenerComposite = new Composite(composite, parent
279             .getStyle());
280          listenerComposite.setLayout(new GridLayout());
281          listenerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
282          listenerComposite.setFont(composite.getFont());
283 
284          // Disgusting hack -- so crude, but so effective...
285          createResourcesGroup(listenerComposite);
286          // ...Disgusting hack -- so crude, but so effective
287          setupCheckListener(listenerComposite);
288 
289          createSpacer(composite);
290 
291          createDestinationGroup(composite);
292          createSpacer(composite);
293          createOptionsGroup(composite);
294 
295          if(_initialSelection != null)
296          {
297             setupBasedOnInitialSelections();
298          }
299 
300          updateWidgetEnablements();
301          setPageComplete(determinePageCompletion());
302 
303          setControl(composite);
304       }
305 
306       /***
307        * Returns false.
308        * 
309        * @see org.eclipse.ui.dialogs.WizardDataTransferPage#allowNewContainerName()
310        */
311       protected boolean allowNewContainerName()
312       {
313          return false;
314       }
315 
316       /***
317        * Listens to selection events within the resources 
318        * selector and uses a FileExtensionTypeListenerFilter 
319        * instance as a delegate.
320        * @param event see interface description
321        * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
322        *      org.eclipse.jface.viewers.ISelection)
323        */
324       public void selectionChanged(SelectionChangedEvent event)
325       {
326          _filter.selectionChanged(event);
327       }
328 
329       /*
330        * (non-Javadoc)
331        * 
332        * @see org.eclipse.ui.dialogs.WizardDataTransferPage#createOptionsGroup(org.eclipse.swt.widgets.Composite)
333        */
334       protected void createOptionsGroup(Composite parent)
335       {
336          Group optionsGroup = new Group(parent, parent.getStyle());
337          Label translatorLabel = null;
338          PixelConverter pixelConverter = null;
339 
340          pixelConverter = new PixelConverter(optionsGroup);
341          GridData optionsGroupLayoutData = new GridData(
342             GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL
343                | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
344          optionsGroupLayoutData.heightHint = pixelConverter
345             .convertHeightInCharsToPixels(8);
346          optionsGroup.setLayoutData(optionsGroupLayoutData);
347          optionsGroup.setFont(parent.getFont());
348          optionsGroup.setText("Translators:");
349 
350          ITreeContentProvider contentProvider = new TranslatorTreeContentProvider();
351          ILabelProvider ilp = new TranslatorTreeLabelProvider();
352 
353          GridLayout glayout = new GridLayout();
354 
355          translatorLabel = new Label(optionsGroup, optionsGroup.getStyle());
356          translatorLabel.setText("Select a translator:");
357          translatorLabel.setFont(optionsGroup.getFont());
358 
359          _translatorTreeViewer = new TreeViewer(optionsGroup, optionsGroup
360             .getStyle()
361             | SWT.MULTI);
362          _translatorTreeViewer.setContentProvider(contentProvider);
363          _translatorTreeViewer
364             .setInput(TranslatorPlugin.getTranslatorsAsTree(TranslatorPlugin
365                .getPlugin().getTranslators()));
366          _translatorTreeViewer.setLabelProvider(ilp);
367          _translatorTreeViewer.expandAll();
368 
369          _translatorTreeViewer.getControl().setFont(optionsGroup.getFont());
370          _translatorTreeViewer.getControl().setLayoutData(
371             new GridData(GridData.VERTICAL_ALIGN_FILL
372                | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
373                | GridData.GRAB_VERTICAL));
374          _translatorTreeViewer.getControl().addListener(SWT.MouseUp, this);
375          _translatorTreeViewer.addFilter(_filter);
376 
377          optionsGroup.setLayout(new GridLayout());
378          Composite progressComposite = new Composite(parent, parent.getStyle());
379          progressComposite.setLayout(new GridLayout());
380          progressComposite.setLayoutData(new GridData(GridData.FILL_BOTH
381             | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
382          _progressMonitor = new ProgressMonitorPart(progressComposite, null);
383          _progressMonitor.setLayoutData(new GridData(GridData.FILL_BOTH
384             | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
385       }
386 
387       /*
388        * (non-Javadoc)
389        * 
390        * @see org.eclipse.ui.dialogs.WizardExportResourcesPage#createDestinationGroup(org.eclipse.swt.widgets.Composite)
391        */
392       protected void createDestinationGroup(Composite parent)
393       {
394          Group destGroup = new Group(parent, parent.getStyle());
395 
396          // Group stuff...
397          GridLayout gl = new GridLayout();
398          gl.numColumns = 2;
399          gl.makeColumnsEqualWidth = false;
400          destGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
401          destGroup.setFont(parent.getFont());
402          destGroup.setText("Destination:");
403          destGroup.setLayout(gl);
404          Label checkBoxLabel = new Label(destGroup, destGroup.getStyle());
405          checkBoxLabel.setFont(destGroup.getFont());
406          checkBoxLabel.setText("Use source location for translation results:");
407          final Button sameProjectButton = new Button(destGroup, destGroup
408             .getStyle()
409             | SWT.CHECK);
410          sameProjectButton.setSelection(true);
411          // Destination textbox / initial path setup stuff...
412          _destinationPathText = new Text(destGroup, destGroup.getStyle()
413             | SWT.BORDER | SWT.READ_ONLY);
414          _destinationPathText.setFont(destGroup.getFont());
415          _destinationPathText.setLayoutData(new GridData(
416             GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
417          _destinationPathText.setEnabled(false);
418          if(_destinationPath != null)
419          {
420             _destinationPathText.setText(_destinationPath.makeRelative()
421                .toString());
422          }
423          final Button browseButton = new Button(destGroup, destGroup.getStyle()
424             | SWT.PUSH);
425          browseButton.setEnabled(false);
426          browseButton.setFont(parent.getFont());
427          browseButton.setText("Browse");
428          browseButton.addSelectionListener(new SelectionAdapter()
429          {
430             public void widgetSelected(SelectionEvent se)
431             {
432                IWorkspaceRoot wsr = ResourcesPlugin.getWorkspace().getRoot();
433                Object[] selectedProject = null;
434                ContainerSelectionDialog csd = new ContainerSelectionDialog(
435                   getShell(), wsr, false, "Select the destination location:");
436                csd.setBlockOnOpen(true);
437                csd.showClosedProjects(false);
438                csd.open();
439                selectedProject = csd.getResult();
440                if(selectedProject != null)
441                {
442                   _destinationPath = (IPath)selectedProject[0];
443                   _destinationPathText.setText(_destinationPath.makeRelative()
444                      .toString());
445                   updatePageCompletion();
446                }
447             }
448          });
449 
450          sameProjectButton.addSelectionListener(new SelectionAdapter()
451          {
452             public void widgetSelected(SelectionEvent se)
453             {
454                if(((Button)se.getSource()).getSelection())
455                {
456                   browseButton.setEnabled(false);
457                   _destinationPathText.setEnabled(false);
458                   _destinationPathText.setText(_initialDestinationPath
459                      .toString());
460                   _destinationPath = _initialDestinationPath;
461                }
462                else
463                {
464                   browseButton.setEnabled(true);
465                   _destinationPathText.setEnabled(true);
466                }
467             }
468          });
469 
470       }
471 
472       /***
473        * Handles click events to determine page completion.
474        * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
475        */
476       public void handleEvent(Event event)
477       {
478          ViewerFilter filter = null;
479          boolean changed = computeSelectedExtensions(getSelectedResources());
480          if(changed)
481          {
482             filter = computeFilter();
483             _translatorTreeViewer.resetFilters();
484             _translatorTreeViewer.addFilter(filter);
485             _translatorTreeViewer.expandAll();
486          }
487          updatePageCompletion();
488       }
489 
490       /***
491        * All the selected resources must have the same extension.
492        * 
493        * @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateSourceGroup()
494        */
495       //      protected boolean validateSourceGroup()
496       //      {
497       //         boolean toReturn = true;
498       //         Iterator iter = getSelectedResourcesIterator();
499       //         IPath tempPath = null;
500       //         String extension = null;
501       //         if(!iter.hasNext())
502       //         {
503       //            toReturn = false;
504       //         }
505       //         else
506       //         {
507       //            while(iter.hasNext())
508       //            {
509       //               try
510       //               {
511       //                  tempPath = (IPath) ((IFile) iter.next()).getFullPath();
512       //               }
513       //               catch(ClassCastException e)
514       //               {
515       //                  toReturn = false;
516       //                  break;
517       //               }
518       //               if(extension == null)
519       //               {
520       //                  extension = tempPath.getFileExtension();
521       //               }
522       //               else
523       //               {
524       //                  if(!extension.equals(tempPath.getFileExtension()))
525       //                  {
526       //                     toReturn = false;
527       //                     break;
528       //                  }
529       //               }
530       //            }
531       //         }
532       //         return toReturn;
533       //      }
534       
535       /*
536        * @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateDestinationGroup()
537        */
538       protected boolean validateDestinationGroup()
539       {
540          boolean toReturn = false;
541          if(_destinationPath != null)
542          {
543             if(_destinationPath.isValidPath(_destinationPath.toString()))
544             {
545                toReturn = true;
546             }
547          }
548          return toReturn;
549       }
550 
551       /*
552        * (non-Javadoc)
553        * 
554        * @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateOptionsGroup()
555        */
556       protected boolean validateOptionsGroup()
557       {
558          boolean toReturn = true;
559          List selectedResources = getSelectedResources();
560          IStructuredSelection translatorSelection = (IStructuredSelection)_translatorTreeViewer
561             .getSelection();
562          Iterator transI = translatorSelection.iterator();
563          Set selectedTranslatorInputTypes = new HashSet();
564          Set selectedResourceTypes = new HashSet();
565          Iterator resourcesIterator = null;
566          IResource tempResource = null;
567          String tempExtension = null;
568          // get all the extensions for the translators
569          // and throw them into a set...
570          while (transI.hasNext())
571          {
572             try
573             {
574                // this check makes sure that we only have one translator for a
575                // particular input type - otherwise, how would we know which of
576                // the
577                // translators to use?
578                tempExtension = ((TranslatorDescriptor)((DefaultMutableTreeNode)transI
579                   .next()).getUserObject()).getInputExtension();
580                if(selectedTranslatorInputTypes.contains(tempExtension))
581                {
582                   toReturn = false;
583                   break;
584                }
585                else
586                {
587                   selectedTranslatorInputTypes.add(tempExtension);
588                }
589             }
590             catch (Exception e)
591             {
592                toReturn = false;
593             }
594          }
595          // after this loop, we know that they only have one translator for each
596          // input type. Now lets make sure that they have enough translators
597          // selected for the files they want translated...
598          if(toReturn)
599          {
600             resourcesIterator = selectedResources.iterator();
601             if(selectedResources.size() < 1)
602             {
603                toReturn = false;
604             }
605             else
606             {
607                while (resourcesIterator.hasNext())
608                {
609                   tempResource = (IResource)resourcesIterator.next();
610                   if(tempResource.getFileExtension() != null)
611                   {
612                      selectedResourceTypes.add(tempResource.getFileExtension());
613                   }
614                   else
615                   {
616                      toReturn = false;
617                      break;
618                   }
619                }
620                toReturn = selectedTranslatorInputTypes
621                   .containsAll(selectedResourceTypes);
622             }
623          }
624 
625          return toReturn;
626       }
627 
628       /*
629        * (non-Javadoc)
630        * 
631        * @see org.eclipse.ui.dialogs.WizardDataTransferPage#updatePageCompletion()
632        */
633       protected void updatePageCompletion()
634       {
635          super.updatePageCompletion();
636          IStructuredSelection selection = null;
637          Iterator translatorIterator = null;
638          _listHelperTranslators.clear();
639          if(isPageComplete())
640          {
641             _listHelperInputFiles = getSelectedResources();
642             selection = (IStructuredSelection)_translatorTreeViewer
643                .getSelection();
644             translatorIterator = selection.iterator();
645             while (translatorIterator.hasNext())
646             {
647                _listHelperTranslators
648                   .add(((TranslatorDescriptor)((DefaultMutableTreeNode)translatorIterator
649                      .next()).getUserObject()));
650             }
651             _pathHelperOutputPath = _destinationPath;
652          }
653       }
654 
655    }
656 
657    private final class ExportPageOne extends WizardExportResourcesPage
658       implements ICheckStateListener
659    {
660       protected TreeViewer _translatorTreeViewer;
661 
662       protected IStructuredSelection _initialSelection;
663 
664       protected IPath _outputDirectory;
665 
666       protected Set _selectedExtensions;
667 
668       /***
669        * Creates the first page of the export wizard.
670        * @param name The name of the page
671        * @param iss The current selection
672        */
673       public ExportPageOne(String name, StructuredSelection iss)
674       {
675          super(name, iss);
676          setMessage("Export Semantic Web Content to the filesystem");
677          setTitle("Export");
678          _selectedExtensions = new HashSet();
679          _initialSelection = iss;
680       }
681 
682       private ViewerFilter computeFilter()
683       {
684          Iterator extensions = null;
685          String ext = null;
686          CombinationFilter filter = new CombinationFilter();
687 
688          extensions = _selectedExtensions.iterator();
689          while (extensions.hasNext())
690          {
691             ext = (String)extensions.next();
692             filter.addFilter(new FileExtensionTypeListenerFilter(true, ext));
693          }
694 
695          return filter;
696       }
697 
698       private boolean computeSelectedExtensions(List resources)
699       {
700          boolean toReturn = false;
701          Iterator i = resources.iterator();
702          IResource res = null;
703          Object temp = null;
704          Set newSet = new HashSet();
705 
706          while (i.hasNext())
707          {
708             temp = i.next();
709             res = (temp instanceof IResource) ? (IResource)temp : null;
710             if(res != null)
711             {
712                if(res.getFileExtension() != null)
713                {
714                   newSet.add(res.getFileExtension());
715                }
716             }
717          }
718          if(!newSet.equals(_selectedExtensions))
719          {
720             _selectedExtensions = newSet;
721             toReturn = true;
722          }
723          return toReturn;
724       }
725 
726       private void setupCheckListener(Composite parent)
727       {
728          ResourceTreeAndListGroup toReturn = null;
729          Control[] children = parent.getChildren();
730          Composite newParent = null;
731          SelectionListener sa = new SelectionAdapter()
732          {
733             public void widgetSelected(SelectionEvent e)
734             {
735                super.widgetSelected(e);
736                handleEvent(null);
737             }
738          };
739          for(int i = 0; i < children.length; i++)
740          {
741             if(children[i] instanceof Tree)
742             {
743                ((Tree)children[i]).addSelectionListener(sa);
744             }
745             else if(children[i] instanceof Table)
746             {
747                ((Table)children[i]).addSelectionListener(sa);
748             }
749             else if(children[i] instanceof Composite)
750             {
751                setupCheckListener((Composite)children[i]);
752             }
753          }
754       }
755 
756       /*
757        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
758        */
759       public void createControl(Composite parent)
760       {
761          ICheckable target = null;
762          initializeDialogUnits(parent);
763 
764          Composite composite = new Composite(parent, SWT.NULL);
765          composite.setLayout(new GridLayout());
766          composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
767             | GridData.HORIZONTAL_ALIGN_FILL));
768          composite.setFont(parent.getFont());
769 
770          final Composite listenerComposite = new Composite(composite, parent
771             .getStyle());
772          listenerComposite.setLayout(new GridLayout());
773          listenerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
774          listenerComposite.setFont(composite.getFont());
775 
776          // Disgusting hack -- so crude, but so effective...
777          createResourcesGroup(listenerComposite);
778          // ...Disgusting hack -- so crude, but so effective
779          setupCheckListener(listenerComposite);
780 
781          createSpacer(composite);
782          createDestinationGroup(composite);
783          createSpacer(composite);
784          createOptionsGroup(composite);
785 
786          if(_initialSelection != null)
787          {
788             setupBasedOnInitialSelections();
789             computeSelectedExtensions(getSelectedResources());
790             _translatorTreeViewer.addFilter(computeFilter());
791          }
792 
793          updateWidgetEnablements();
794          setPageComplete(determinePageCompletion());
795 
796          composite.layout();
797          setControl(composite);
798       }
799 
800       protected void createDestinationGroup(Composite parent)
801       {
802          Group destinationGroup = new Group(parent, parent.getStyle());
803          GridLayout destinationGroupLayout = new GridLayout();
804          destinationGroup.setLayout(destinationGroupLayout);
805          destinationGroup.setFont(parent.getFont());
806          destinationGroup.setText("Destination:");
807          destinationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
808 
809          destinationGroupLayout.numColumns = 2;
810 
811          final Text directoryTextbox = new Text(destinationGroup,
812             destinationGroup.getStyle() | SWT.READ_ONLY | SWT.BORDER);
813          directoryTextbox.setFont(destinationGroup.getFont());
814          directoryTextbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
815          final Button browseButton = new Button(destinationGroup,
816             destinationGroup.getStyle());
817          browseButton.setFont(destinationGroup.getFont());
818          browseButton.setText("Browse");
819          browseButton.addSelectionListener(new SelectionAdapter()
820          {
821             public void widgetSelected(SelectionEvent se)
822             {
823                DirectoryDialog dd = new DirectoryDialog(getShell());
824                String directory = null;
825                dd
826                   .setMessage("Choose the location where the system should export the selected resources.");
827                dd.setText("Select export directory...");
828                directory = dd.open();
829                if(directory != null)
830                {
831                   directoryTextbox.setText(directory);
832                   _outputDirectory = new Path(directoryTextbox.getText());
833                   updatePageCompletion();
834                }
835             }
836          });
837       }
838 
839       protected void createOptionsGroup(Composite parent)
840       {
841          Group optionsGroup = new Group(parent, parent.getStyle());
842          GridLayout optionsGroupLayout = new GridLayout();
843 
844          optionsGroup.setFont(parent.getFont());
845          optionsGroup.setText("Options:");
846          optionsGroup.setLayoutData(new GridData(GridData.FILL_BOTH
847             | GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
848          optionsGroup.setLayout(optionsGroupLayout);
849 
850          optionsGroupLayout.numColumns = 2;
851 
852          Label translatorsLabel = new Label(optionsGroup, optionsGroup
853             .getStyle());
854          translatorsLabel.setFont(optionsGroup.getFont());
855          translatorsLabel.setText("Select a translator:");
856          translatorsLabel.setLayoutData(new GridData(
857             GridData.VERTICAL_ALIGN_CENTER));
858 
859          _translatorTreeViewer = new TreeViewer(optionsGroup, optionsGroup
860             .getStyle()
861             | SWT.BORDER | SWT.MULTI);
862          GridData treeViewerLayoutData = new GridData(GridData.FILL_BOTH
863             | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
864          treeViewerLayoutData.heightHint = (new PixelConverter(optionsGroup))
865             .convertHeightInCharsToPixels(8);
866 
867          _translatorTreeViewer
868             .setLabelProvider(new TranslatorTreeLabelProvider());
869          _translatorTreeViewer
870             .setContentProvider(new TranslatorTreeContentProvider());
871          _translatorTreeViewer
872             .setInput(TranslatorPlugin.getTranslatorsAsTree(TranslatorPlugin
873                .getPlugin().getTranslators()));
874          _translatorTreeViewer.expandAll();
875          _translatorTreeViewer.getControl().setLayoutData(treeViewerLayoutData);
876          _translatorTreeViewer.getControl().addListener(SWT.MouseUp, this);
877          _progressMonitor = new ProgressMonitorPart(parent, null);
878       }
879 
880       protected boolean validateDestinationGroup()
881       {
882          boolean toReturn = false;
883          if(!(_outputDirectory == null))
884          {
885             if(!_outputDirectory.isEmpty())
886             {
887                if(_outputDirectory.isValidPath(_outputDirectory.toString()))
888                {
889                   toReturn = true;
890                }
891             }
892          }
893          return toReturn;
894       }
895 
896       protected boolean validateOptionsGroup()
897       {
898          boolean toReturn = true;
899          List selectedResources = getSelectedResources();
900          IStructuredSelection translatorSelection = (IStructuredSelection)_translatorTreeViewer
901             .getSelection();
902          Iterator transI = translatorSelection.iterator();
903          Set selectedTranslatorInputTypes = new HashSet();
904          Set selectedResourceTypes = new HashSet();
905          Iterator resourcesIterator = null;
906          IResource tempResource = null;
907          String tempExtension = null;
908          // get all the extensions for the translators
909          // and throw them into a set...
910          while (transI.hasNext())
911          {
912             // it's possible the user has selected a menu
913             // heading - that will cause an exception
914             // when the String is cast to a TranslatorDescriptor,
915             // so watch out for that...
916             try
917             {
918                tempExtension = ((TranslatorDescriptor)((DefaultMutableTreeNode)transI
919                   .next()).getUserObject()).getInputExtension();
920                if(selectedTranslatorInputTypes.contains(tempExtension))
921                {
922                   toReturn = false;
923                   break;
924                }
925                else
926                {
927                   selectedTranslatorInputTypes.add(tempExtension);
928                }
929             }
930             catch (Exception e)
931             {
932                toReturn = false;
933             }
934          }
935          if(toReturn)
936          {
937             resourcesIterator = selectedResources.iterator();
938             // find all the extensions that the user wants to export from
939             while (resourcesIterator.hasNext())
940             {
941                tempResource = (IResource)resourcesIterator.next();
942                if(tempResource.getFileExtension() != null)
943                {
944                   selectedResourceTypes.add(tempResource.getFileExtension());
945                }
946                else
947                {
948                   toReturn = false;
949                   break;
950                }
951             }
952             toReturn = selectedTranslatorInputTypes
953                .containsAll(selectedResourceTypes);
954          }
955 
956          return toReturn;
957       }
958 
959       /***
960        * Checks for page completion.
961        * 
962        * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(
963        *    org.eclipse.jface.viewers.CheckStateChangedEvent)
964        */
965       public void checkStateChanged(CheckStateChangedEvent event)
966       {
967          handleEvent(null);
968       }
969 
970       protected void updatePageCompletion()
971       {
972          super.updatePageCompletion();
973          IStructuredSelection selection = null;
974          Iterator translatorIterator = null;
975          _listHelperTranslators.clear();
976          if(isPageComplete())
977          {
978             _listHelperInputFiles = getSelectedResources();
979             selection = (IStructuredSelection)_translatorTreeViewer
980                .getSelection();
981             translatorIterator = selection.iterator();
982             while (translatorIterator.hasNext())
983             {
984                _listHelperTranslators
985                   .add(((TranslatorDescriptor)((DefaultMutableTreeNode)translatorIterator
986                      .next()).getUserObject()));
987             }
988             _pathHelperOutputPath = _outputDirectory;
989          }
990       }
991 
992       /***
993        * Checks for page completion.
994        * 
995        * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
996        */
997       public void handleEvent(Event event)
998       {
999          ViewerFilter filter = null;
1000          boolean changed = computeSelectedExtensions(getSelectedResources());
1001          if(changed)
1002          {
1003             filter = computeFilter();
1004             _translatorTreeViewer.resetFilters();
1005             _translatorTreeViewer.addFilter(filter);
1006             _translatorTreeViewer.expandAll();
1007          }
1008          updatePageCompletion();
1009       }
1010    }
1011 
1012 //   private final class ImportPageOne extends WizardResourceImportPage implements
1013 //      ISelectionChangedListener
1014 //   {
1015 //      protected Text _inputDirectoryBox;
1016 //
1017 //      protected String _inputDirectoryString;
1018 //
1019 //      protected String[] _acceptableInputExtensions;
1020 //
1021 //      protected TreeViewer _translatorTreeViewer;
1022 //
1023 //      //protected List _selectedInputExtensions;
1024 //      protected Map _extensionFilterMap;
1025 //
1026 //      //protected CombinationFilter _filter;
1027 //
1028 //      protected ImportWizardSourceManager _sourceManager;
1029 //
1030 //      /***
1031 //       * Creates the first page of the import wizard.
1032 //       * @param helper A helper
1033 //       * @param name The name of the page
1034 //       * @param iss The current selection
1035 //       */
1036 //      public ImportPageOne(SemanticWebTranslatorWizardHelper helper,
1037 //         String name, StructuredSelection iss)
1038 //      {
1039 //         super(name, iss);
1040 //
1041 //         setMessage("Import Semantic Web documents into open projects");
1042 //         setTitle("Import");
1043 //
1044 //         _extensionFilterMap = new HashMap();
1045 //
1046 //         Set availableExtensions = new HashSet();
1047 //         List availableTranslators = TranslatorPlugin.getPlugin()
1048 //            .getTranslators();
1049 //         Iterator translatorIterator = null;
1050 //         Iterator extensionIterator = null;
1051 //         int iteratorIndex = 0;
1052 //         translatorIterator = availableTranslators.iterator();
1053 //         while (translatorIterator.hasNext())
1054 //         {
1055 //            availableExtensions.add(((TranslatorDescriptor)translatorIterator
1056 //               .next()).getInputExtension());
1057 //         }
1058 //         _acceptableInputExtensions = new String[availableExtensions.size()];
1059 //         extensionIterator = availableExtensions.iterator();
1060 //         while (extensionIterator.hasNext())
1061 //         {
1062 //            _acceptableInputExtensions[iteratorIndex] = (String)extensionIterator
1063 //               .next();
1064 //            iteratorIndex++;
1065 //         }
1066 //         for(int i = 0; i < _acceptableInputExtensions.length; i++)
1067 //         {
1068 //            _extensionFilterMap.put(_acceptableInputExtensions[i],
1069 //               new FileExtensionTypeListenerFilter(true,
1070 //                  _acceptableInputExtensions[i]));
1071 //         }
1072 //
1073 //         _sourceManager = new ImportWizardSourceManager(
1074 //            _acceptableInputExtensions);
1075 //      }
1076 //
1077 //      protected void createSourceGroup(Composite parent)
1078 //      {
1079 //         Group sourceGroup = new Group(parent, parent.getStyle());
1080 //         Composite directoryNamePanel = new Composite(sourceGroup, sourceGroup
1081 //            .getStyle());
1082 //
1083 //         sourceGroup.setFont(parent.getFont());
1084 //         sourceGroup.setLayout(new GridLayout());
1085 //         sourceGroup.setLayoutData(new GridData(GridData.FILL_BOTH
1086 //            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
1087 //
1088 //         GridLayout directoryNamePanelLayout = new GridLayout();
1089 //         directoryNamePanelLayout.numColumns = 3;
1090 //
1091 //         directoryNamePanel.setLayout(directoryNamePanelLayout);
1092 //         directoryNamePanel.setFont(sourceGroup.getFont());
1093 //         directoryNamePanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
1094 //            | GridData.HORIZONTAL_ALIGN_FILL));
1095 //
1096 //         Label inputDirectoryBoxLabel = new Label(directoryNamePanel,
1097 //            directoryNamePanel.getStyle());
1098 //         _inputDirectoryBox = new Text(directoryNamePanel, directoryNamePanel
1099 //            .getStyle()
1100 //            | SWT.BORDER | SWT.READ_ONLY);
1101 //         Button browseButton = new Button(directoryNamePanel,
1102 //            directoryNamePanel.getStyle() | SWT.PUSH);
1103 //
1104 //         GridData textBoxData = new GridData(GridData.GRAB_HORIZONTAL
1105 //            | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
1106 //
1107 //         _inputDirectoryBox.setLayoutData(textBoxData);
1108 //         _inputDirectoryBox.setFont(directoryNamePanel.getFont());
1109 //         inputDirectoryBoxLabel.setFont(directoryNamePanel.getFont());
1110 //         browseButton.setFont(directoryNamePanel.getFont());
1111 //
1112 //         browseButton.setText("Browse");
1113 //         inputDirectoryBoxLabel.setText("From directory:");
1114 //         browseButton.addSelectionListener(new SelectionAdapter()
1115 //         {
1116 //            public void widgetSelected(SelectionEvent e)
1117 //            {
1118 //               DirectoryDialog dd = new DirectoryDialog(getShell());
1119 //               FileSystemElement newRoot = null;
1120 //               String result = null;
1121 //               dd.setMessage("Message");
1122 //               dd.setText("Title");
1123 //               result = dd.open();
1124 //               if(result != null)
1125 //               {
1126 //                  _inputDirectoryString = result;
1127 //                  _inputDirectoryBox.setText(_inputDirectoryString);
1128 //                  _sourceManager.setRoot(_inputDirectoryString);
1129 //               }
1130 //            }
1131 //         });
1132 //         createFileSelectionGroup(sourceGroup);
1133 //         _sourceManager.setResourceTreeAndListGroup(selectionGroup);
1134 //         _sourceManager.addSelectionChangedListener(this);
1135 //      }
1136 //
1137 //      protected void createOptionsGroup(Composite parent)
1138 //      {
1139 //         Group optionsGroup = new Group(parent, parent.getStyle());
1140 //         Label translatorLabel = null;
1141 //         PixelConverter pixelConverter = null;
1142 //
1143 //         pixelConverter = new PixelConverter(optionsGroup);
1144 //         GridData optionsGroupLayoutData = new GridData(
1145 //            GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL
1146 //               | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
1147 //         optionsGroupLayoutData.heightHint = pixelConverter
1148 //            .convertHeightInCharsToPixels(8);
1149 //         optionsGroup.setLayoutData(optionsGroupLayoutData);
1150 //         optionsGroup.setFont(parent.getFont());
1151 //         optionsGroup.setText("Translators:");
1152 //
1153 //         ITreeContentProvider contentProvider = new TranslatorTreeContentProvider();
1154 //         ILabelProvider ilp = new TranslatorTreeLabelProvider();
1155 //
1156 //         GridLayout glayout = new GridLayout();
1157 //
1158 //         translatorLabel = new Label(optionsGroup, optionsGroup.getStyle());
1159 //         translatorLabel.setText("Select a translator:");
1160 //         translatorLabel.setFont(optionsGroup.getFont());
1161 //
1162 //         _translatorTreeViewer = new TreeViewer(optionsGroup);
1163 //         _translatorTreeViewer.setContentProvider(contentProvider);
1164 //         _translatorTreeViewer
1165 //            .setInput(TranslatorPlugin.getTranslatorsAsTree(TranslatorPlugin
1166 //               .getPlugin().getTranslators()));
1167 //         _translatorTreeViewer.setLabelProvider(ilp);
1168 //         _translatorTreeViewer.expandAll();
1169 //
1170 //         _translatorTreeViewer.getControl().setFont(optionsGroup.getFont());
1171 //         _translatorTreeViewer.getControl().setLayoutData(
1172 //            new GridData(GridData.VERTICAL_ALIGN_FILL
1173 //               | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
1174 //               | GridData.GRAB_VERTICAL));
1175 //         _translatorTreeViewer.getControl().addListener(SWT.MouseUp, this);
1176 //         _translatorTreeViewer.addFilter(new ViewerFilter()
1177 //         {
1178 //            public boolean select(Viewer viewer, Object parentElement,
1179 //               Object element)
1180 //            {
1181 //               return false;
1182 //            }
1183 //         });
1184 //
1185 //         optionsGroup.setLayout(new GridLayout());
1186 //         Composite progressComposite = new Composite(parent, parent.getStyle());
1187 //         progressComposite.setLayout(new GridLayout());
1188 //         progressComposite.setLayoutData(new GridData(GridData.FILL_BOTH
1189 //            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
1190 //         ProgressMonitorPart pmp = new ProgressMonitorPart(progressComposite,
1191 //            null);
1192 //         pmp.setLayoutData(new GridData(GridData.FILL_BOTH
1193 //            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
1194 //         _progressMonitor = pmp;
1195 //      }
1196 //
1197 //      protected boolean validateOptionsGroup()
1198 //      {
1199 //         boolean toReturn = true;
1200 //         Iterator i = _sourceManager.getSelectedInputExtensions().iterator();
1201 //         String temp = null;
1202 //         Set extensions = new HashSet();
1203 //         IStructuredSelection translatorSelection = (IStructuredSelection)_translatorTreeViewer
1204 //            .getSelection();
1205 //         Iterator transI = translatorSelection.iterator();
1206 //         Set selectedTranslatorInputTypes = new HashSet();
1207 //         while (i.hasNext())
1208 //         {
1209 //            extensions.add(i.next());
1210 //         }
1211 //
1212 //         while (transI.hasNext())
1213 //         {
1214 //            try
1215 //            {
1216 //               temp = ((TranslatorDescriptor)((DefaultMutableTreeNode)transI
1217 //                  .next()).getUserObject()).getInputExtension();
1218 //               if(selectedTranslatorInputTypes.contains(temp))
1219 //               {
1220 //                  toReturn = false;
1221 //                  break;
1222 //               }
1223 //               else
1224 //               {
1225 //                  selectedTranslatorInputTypes.add(temp);
1226 //               }
1227 //            }
1228 //            catch (Exception e)
1229 //            {
1230 //               // for when it's a title - then it throws a class cast exception
1231 //               // but we don't care...
1232 //            }
1233 //         }
1234 //         if(toReturn)
1235 //         {
1236 //            if(!selectedTranslatorInputTypes.containsAll(extensions))
1237 //            {
1238 //               toReturn = false;
1239 //            }
1240 //         }
1241 //
1242 //         return toReturn;
1243 //      }
1244 //
1245 //      protected void updatePageCompletion()
1246 //      {
1247 //         super.updatePageCompletion();
1248 //         IStructuredSelection selection = null;
1249 //         Iterator translatorIterator = null;
1250 //         if(isPageComplete())
1251 //         {
1252 //            _listHelperInputFiles = getSelectedResources();
1253 //            selection = (IStructuredSelection)_translatorTreeViewer
1254 //               .getSelection();
1255 //            translatorIterator = selection.iterator();
1256 //            while (translatorIterator.hasNext())
1257 //            {
1258 //               _listHelperTranslators
1259 //                  .add(((TranslatorDescriptor)((DefaultMutableTreeNode)translatorIterator
1260 //                     .next()).getUserObject()));
1261 //            }
1262 //            _pathHelperOutputPath = getContainerFullPath();
1263 //         }
1264 //      }
1265 //
1266 //      protected boolean validateSourceGroup()
1267 //      {
1268 //         boolean toReturn = true;
1269 //         if(_sourceManager == null)
1270 //         {
1271 //            toReturn = false;
1272 //         }
1273 //         else
1274 //         {
1275 //            toReturn = (_sourceManager.getSelection() != null)
1276 //               && (!_sourceManager.getSelection().isEmpty());
1277 //         }
1278 //         return toReturn;
1279 //      }
1280 //
1281 //      protected ITreeContentProvider getFileProvider()
1282 //      {
1283 //         return _sourceManager.getFileProvider(_acceptableInputExtensions);
1284 //      }
1285 //
1286 //      protected ITreeContentProvider getFolderProvider()
1287 //      {
1288 //         return _sourceManager.getFolderProvider(_acceptableInputExtensions);
1289 //      }
1290 //
1291 //      /***
1292 //       * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(
1293 //       *         org.eclipse.jface.viewers.SelectionChangedEvent)
1294 //       */
1295 //      public void selectionChanged(SelectionChangedEvent event)
1296 //      {
1297 //         _translatorTreeViewer.resetFilters();
1298 //         _translatorTreeViewer.addFilter(_sourceManager.getFilter());
1299 //         _translatorTreeViewer.expandAll();
1300 //         updatePageCompletion();
1301 //      }
1302 //
1303 //      /***
1304 //       * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
1305 //       */
1306 //      public void handleEvent(Event event)
1307 //      {
1308 //         super.handleEvent(event);
1309 //         updatePageCompletion();
1310 //      }
1311 //
1312 //      public class ImportWizardSourceManager implements ISelectionProvider,
1313 //         ICheckStateListener
1314 //      {
1315 //         private ResourceTreeAndListGroup _thingy;
1316 //
1317 //         private Composite _parent;
1318 //
1319 //         private Object _root;
1320 //
1321 //         private ITreeContentProvider _treeContent;
1322 //
1323 //         private ILabelProvider _treeLabel;
1324 //
1325 //         private ITreeContentProvider _listContent;
1326 //
1327 //         private ILabelProvider _listLabel;
1328 //
1329 //         private int _style;
1330 //
1331 //         private boolean _useHeightHint;
1332 //
1333 //         private InternalSelectionProvider _selectionProvider;
1334 //
1335 //         private Map _extensionFilterMap;
1336 //
1337 //         private CombinationFilter _filter;
1338 //
1339 //         private Map _selectedInputExtensionsToCounts;
1340 //
1341 //         private ISelection _internalSelection;
1342 //
1343 //         public ImportWizardSourceManager(String[] extensions)
1344 //         {
1345 //            _parent = null;
1346 //            _root = new FileSystemElement("No name", null, false);
1347 //            _treeContent = new InternalFolderProvider(extensions);
1348 //            _treeLabel = new InternalLabelProvider();
1349 //            _listContent = new InternalFileProvider(extensions);
1350 //            _listLabel = new InternalLabelProvider();
1351 //            _style = SWT.NONE;
1352 //            _useHeightHint = false;
1353 //
1354 //            _selectionProvider = new InternalSelectionProvider();
1355 //            _selectedInputExtensionsToCounts = new HashMap();
1356 //            _internalSelection = null;
1357 //
1358 //            /* Initialize filter stuff... */
1359 //            _extensionFilterMap = new HashMap();
1360 //            _filter = new CombinationFilter();
1361 //            for(int i = 0; i < extensions.length; i++)
1362 //            {
1363 //               _extensionFilterMap.put(extensions[i],
1364 //                  new FileExtensionTypeListenerFilter(true, extensions[i]));
1365 //            }
1366 //            /* ...Initialize filter stuff */
1367 //         }
1368 //
1369 //         public void setRoot(String newRoot)
1370 //         {
1371 //            FileSystemElement dummyElement = new FileSystemElement("", null,
1372 //               true);
1373 //            FileSystemElement newRootElement = new FileSystemElement(newRoot,
1374 //               dummyElement, true);
1375 //            newRootElement.setFileSystemObject(new File(newRoot));
1376 //            Object[] files = null;
1377 //            if(newRootElement != null)
1378 //            {
1379 //               files = _listContent.getElements(newRootElement);
1380 //               for(int i = 0; i < files.length; i++)
1381 //               {
1382 //                  newRootElement.addChild((FileSystemElement)files[i]);
1383 //               }
1384 //               files = _treeContent.getElements(newRootElement);
1385 //               for(int i = 0; i < files.length; i++)
1386 //               {
1387 //                  newRootElement.addChild((FileSystemElement)files[i]);
1388 //               }
1389 //
1390 //               //_thingy.setRoot(newRootElement);
1391 //               _thingy.setRoot(dummyElement);
1392 //               _thingy.setFocus();
1393 //
1394 //               _filter = new CombinationFilter();
1395 //               _selectedInputExtensionsToCounts = new HashMap();
1396 //               setSelection();
1397 //               _selectionProvider.fireEvent(new SelectionChangedEvent(this,
1398 //                  _internalSelection));
1399 //            }
1400 //         }
1401 //
1402 //         public List getSelectedInputExtensions()
1403 //         {
1404 //            List toReturn = new ArrayList();
1405 //            toReturn.addAll(_selectedInputExtensionsToCounts.keySet());
1406 //            return toReturn;
1407 //         }
1408 //
1409 //         public ViewerFilter getFilter()
1410 //         {
1411 //            return _filter;
1412 //         }
1413 //
1414 //         public void setResourceTreeAndListGroup(ResourceTreeAndListGroup thingy)
1415 //         {
1416 //            _thingy = thingy;
1417 //            _thingy.addCheckStateListener(this);
1418 //         }
1419 //
1420 //         public ISelection getSelection()
1421 //         {
1422 //            return _internalSelection;
1423 //         }
1424 //
1425 //         public void addSelectionChangedListener(
1426 //            ISelectionChangedListener listener)
1427 //         {
1428 //            _selectionProvider.addSelectionChangedListener(listener);
1429 //         }
1430 //
1431 //         public void removeSelectionChangedListener(
1432 //            ISelectionChangedListener listener)
1433 //         {
1434 //            _selectionProvider.removeSelectionChangedListener(listener);
1435 //         }
1436 //
1437 //         public void setSelection(ISelection selection)
1438 //         {
1439 //            _selectionProvider.setSelection(selection);
1440 //         }
1441 //
1442 //         public void checkStateChanged(CheckStateChangedEvent event)
1443 //         {
1444 //            FileSystemElement fse = null;
1445 //            boolean refreshTranslator = false;
1446 //            Integer count = new Integer(0);
1447 //            SelectionChangedEvent toFire = null;
1448 //            StructuredSelection newSelection = null;
1449 //            if(event.getElement() instanceof FileSystemElement)
1450 //            {
1451 //               fse = (FileSystemElement)event.getElement();
1452 //               if(!fse.isDirectory())
1453 //               {
1454 //                  if(event.getChecked())
1455 //                  {
1456 //                     if(_selectedInputExtensionsToCounts.get(fse
1457 //                        .getFileNameExtension()) == null)
1458 //                     {
1459 //                        _filter.addFilter((ViewerFilter)_extensionFilterMap
1460 //                           .get(fse.getFileNameExtension()));
1461 //                        count = new Integer(0);
1462 //                        refreshTranslator = true;
1463 //                     }
1464 //                     else
1465 //                     {
1466 //                        count = (Integer)_selectedInputExtensionsToCounts
1467 //                           .get(fse.getFileNameExtension());
1468 //                     }
1469 //                     count = new Integer(count.intValue() + 1);
1470 //                     _selectedInputExtensionsToCounts.put(fse
1471 //                        .getFileNameExtension(), count);
1472 //
1473 //                  }
1474 //                  else
1475 //                  {
1476 //                     count = (Integer)_selectedInputExtensionsToCounts.get(fse
1477 //                        .getFileNameExtension());
1478 //                     count = new Integer(count.intValue() - 1);
1479 //                     if(count.intValue() < 1)
1480 //                     {
1481 //                        _filter.removeFilter((ViewerFilter)_extensionFilterMap
1482 //                           .get(fse.getFileNameExtension()));
1483 //                        _selectedInputExtensionsToCounts.remove(fse
1484 //                           .getFileNameExtension());
1485 //                        refreshTranslator = true;
1486 //                     }
1487 //                     else
1488 //                     {
1489 //                        _selectedInputExtensionsToCounts.put(fse
1490 //                           .getFileNameExtension(), count);
1491 //                     }
1492 //                  }
1493 //               }
1494 //
1495 //               setSelection();
1496 //               toFire = new SelectionChangedEvent(this, _internalSelection);
1497 //               _selectionProvider.fireEvent(toFire);
1498 //            }
1499 //
1500 //         }
1501 //
1502 //         private void setSelection()
1503 //         {
1504 //            StructuredSelection newSelection = new StructuredSelection(_thingy
1505 //               .getAllCheckedListItems());
1506 //            _internalSelection = newSelection;
1507 //         }
1508 //
1509 //         public ITreeContentProvider getFileProvider(String[] exts)
1510 //         {
1511 //            return _listContent;
1512 //         }
1513 //
1514 //         public ITreeContentProvider getFolderProvider(String[] exts)
1515 //         {
1516 //            return _treeContent;
1517 //         }
1518 //
1519 //         private final class InternalLabelProvider extends LabelProvider
1520 //         {
1521 //            public String getText(Object element)
1522 //            {
1523 //               String toReturn = "";
1524 //               if(element instanceof FileSystemElement)
1525 //               {
1526 //                  toReturn = ((IWorkbenchAdapter)((FileSystemElement)element)
1527 //                     .getAdapter(IWorkbenchAdapter.class)).getLabel(element);
1528 //               }
1529 //
1530 //               return toReturn;
1531 //            }
1532 //
1533 //            public Image getImage(Object element)
1534 //            {
1535 //               Image toReturn = JFaceResources.getImage(null);
1536 //               FileSystemElement fse = null;
1537 //               if(element instanceof FileSystemElement)
1538 //               {
1539 //                  toReturn = ((IWorkbenchAdapter)((FileSystemElement)element)
1540 //                     .getAdapter(IWorkbenchAdapter.class)).getImageDescriptor(
1541 //                     element).createImage();
1542 //               }
1543 //               return toReturn;
1544 //            }
1545 //         }
1546 //
1547 //         private final class InternalFileProvider extends
1548 //            BaseWorkbenchContentProvider
1549 //         {
1550 //            private String[] _acceptableInputExtensions;
1551 //
1552 //            public InternalFileProvider(String[] strs)
1553 //            {
1554 //               _acceptableInputExtensions = strs;
1555 //               if(_acceptableInputExtensions == null)
1556 //               {
1557 //                  _acceptableInputExtensions = new String[0];
1558 //               }
1559 //            }
1560 //
1561 //            public Object[] getChildren(Object parentElement)
1562 //            {
1563 //               Object[] toReturn = null;
1564 //               FileSystemElement temp = null;
1565 //               Object[] temporaryKids = new Object[0];
1566 //               ArrayList allChildren = new ArrayList();
1567 //               List filterHelper = null;
1568 //               List okayExtensions = Arrays.asList(_acceptableInputExtensions);
1569 //               if(parentElement instanceof FileSystemElement)
1570 //               {
1571 //                  allChildren.addAll(Arrays
1572 //                     .asList(((FileSystemElement)parentElement).getFolders()
1573 //                        .getChildren()));
1574 //                  //if(allChildren.size() < 1)
1575 //                  {
1576 //                     PopulateRootOperation pro = new PopulateRootOperation(
1577 //                        ((FileSystemElement)parentElement)
1578 //                           .getFileSystemObject(),
1579 //                        FileSystemStructureProvider.INSTANCE);
1580 //                     pro.setDesiredExtensions(_acceptableInputExtensions);
1581 //                     try
1582 //                     {
1583 //                        pro.run(new NullProgressMonitor());
1584 //                     }
1585 //                     catch (Exception e)
1586 //                     {
1587 //                        //do nothing
1588 //                     }
1589 //                     if(pro.getResult() != null)
1590 //                     {
1591 //                        allChildren.addAll(Arrays.asList(pro.getResult()
1592 //                           .getFiles().getChildren()));
1593 //                     }
1594 //                     temporaryKids = allChildren.toArray();
1595 //                  }
1596 //                  filterHelper = new ArrayList();
1597 //                  for(int i = 0; i < temporaryKids.length; i++)
1598 //                  {
1599 //                     temp = (FileSystemElement)temporaryKids[i];
1600 //                     if(okayExtensions.contains(temp.getFileNameExtension()))
1601 //                     {
1602 //                        filterHelper.add(temp);
1603 //                     }
1604 //                  }
1605 //
1606 //                  toReturn = filterHelper.toArray();
1607 //               }
1608 //               return toReturn;
1609 //            }
1610 //
1611 //            public Object getParent(Object element)
1612 //            {
1613 //               FileSystemElement toReturn = null;
1614 //               if(element instanceof FileSystemElement)
1615 //               {
1616 //                  toReturn = ((FileSystemElement)element).getParent();
1617 //               }
1618 //               return toReturn;
1619 //            }
1620 //
1621 //            public boolean hasChildren(Object element)
1622 //            {
1623 //               boolean toReturn = false;
1624 //               if(element instanceof FileSystemElement)
1625 //               {
1626 //                  toReturn = ((FileSystemElement)element).getFiles()
1627 //                     .getChildren().length > 0;
1628 //               }
1629 //               return toReturn;
1630 //            }
1631 //         }
1632 //
1633 //         private final class InternalFolderProvider extends
1634 //            BaseWorkbenchContentProvider
1635 //         {
1636 //            private String[] _acceptableInputExtensions;
1637 //
1638 //            public InternalFolderProvider(String[] strs)
1639 //            {
1640 //               _acceptableInputExtensions = strs;
1641 //               if(_acceptableInputExtensions == null)
1642 //               {
1643 //                  _acceptableInputExtensions = new String[0];
1644 //               }
1645 //            }
1646 //
1647 //            public Object[] getChildren(Object parentElement)
1648 //            {
1649 //               FileSystemElement[] toReturn = null;
1650 //               Object[] temporaryKids = new Object[0];
1651 //               ArrayList allChildren = new ArrayList();
1652 //               if(parentElement instanceof FileSystemElement)
1653 //               {
1654 //                  PopulateRootOperation pro = new PopulateRootOperation(
1655 //                     ((FileSystemElement)parentElement).getFileSystemObject(),
1656 //                     FileSystemStructureProvider.INSTANCE);
1657 //                  pro.setDesiredExtensions(_acceptableInputExtensions);
1658 //                  try
1659 //                  {
1660 //                     pro.run(new NullProgressMonitor());
1661 //                  }
1662 //                  catch (Exception e)
1663 //                  {
1664 //                     //do nothing
1665 //                  }
1666 //                  if(pro.getResult() != null) // PROBLEM!
1667 //                  {
1668 //                     allChildren.addAll(Arrays.asList(pro.getResult()
1669 //                        .getFolders().getChildren()));
1670 //                  }
1671 //                  else
1672 //                  {
1673 //                     allChildren.addAll(Arrays
1674 //                        .asList(((FileSystemElement)parentElement).getFolders()
1675 //                           .getChildren()));
1676 //                  }
1677 //               }
1678 //               temporaryKids = allChildren.toArray();
1679 //               toReturn = new FileSystemElement[temporaryKids.length];
1680 //               for(int i = 0; i < temporaryKids.length; toReturn[i] = (FileSystemElement)temporaryKids[i++])
1681 //               {
1682 //                  //do nothing
1683 //               }
1684 //               return toReturn;
1685 //            }
1686 //
1687 //            public Object getParent(Object element)
1688 //            {
1689 //               FileSystemElement toReturn = null;
1690 //               if(element instanceof FileSystemElement)
1691 //               {
1692 //                  toReturn = ((FileSystemElement)element).getParent();
1693 //               }
1694 //               return toReturn;
1695 //            }
1696 //
1697 //            public boolean hasChildren(Object element)
1698 //            {
1699 //               boolean toReturn = false;
1700 //               if(element instanceof FileSystemElement)
1701 //               {
1702 //                  toReturn = ((FileSystemElement)element).getFolders()
1703 //                     .getChildren().length > 0;
1704 //               }
1705 //               return toReturn;
1706 //            }
1707 //         }
1708 //
1709 //         private final class InternalSelectionProvider implements
1710 //            ISelectionProvider
1711 //         {
1712 //            private List _listeners = new ArrayList();
1713 //
1714 //            public void addSelectionChangedListener(
1715 //               ISelectionChangedListener listener)
1716 //            {
1717 //               _listeners.add(listener);
1718 //            }
1719 //
1720 //            public ISelection getSelection()
1721 //            {
1722 //               return null;
1723 //            }
1724 //
1725 //            public void fireEvent(SelectionChangedEvent toFire)
1726 //            {
1727 //               Iterator i = _listeners.iterator();
1728 //               while (i.hasNext())
1729 //               {
1730 //                  ((ISelectionChangedListener)i.next())
1731 //                     .selectionChanged(toFire);
1732 //               }
1733 //            }
1734 //
1735 //            public void removeSelectionChangedListener(
1736 //               ISelectionChangedListener listener)
1737 //            {
1738 //               _listeners.remove(listener);
1739 //            }
1740 //
1741 //            public void setSelection(ISelection selection)
1742 //            {
1743 //            }
1744 //         }
1745 //      }
1746 //
1747 //   }
1748 //
1749 //   
1750    private final class TranslatorTreeContentProvider extends
1751       BaseWorkbenchContentProvider
1752    {
1753       /* (non-Javadoc)
1754        * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
1755        */
1756       public Object getParent(Object element)
1757       {
1758          TreeNode toReturn = null;
1759          if(element instanceof MutableTreeNode)
1760          {
1761             toReturn = ((MutableTreeNode)element).getParent();
1762          }
1763          return toReturn;
1764       }
1765 
1766       /* (non-Javadoc)
1767        * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
1768        */
1769       public Object[] getChildren(Object parentElement)
1770       {
1771          Object[] toReturn = null;
1772          if(parentElement instanceof MutableTreeNode)
1773          {
1774             toReturn = Collections.list(
1775                ((MutableTreeNode)parentElement).children()).toArray();
1776          }
1777          return toReturn;
1778       }
1779 
1780       /* (non-Javadoc)
1781        * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
1782        */
1783       public boolean hasChildren(Object element)
1784       {
1785          boolean toReturn = false;
1786          if(element instanceof MutableTreeNode)
1787          {
1788             toReturn = !((MutableTreeNode)element).isLeaf();
1789          }
1790          return toReturn;
1791       }
1792    }
1793 
1794    private final class TranslatorTreeLabelProvider extends LabelProvider
1795    {
1796       /* (non-Javadoc)
1797        * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
1798        */
1799       public String getText(Object element)
1800       {
1801          String toReturn = null;
1802          Object userObject = null;
1803          if(element instanceof DefaultMutableTreeNode)
1804          {
1805             userObject = ((DefaultMutableTreeNode)element).getUserObject();
1806             if(userObject != null)
1807             {
1808                if(userObject instanceof TranslatorDescriptor)
1809                {
1810                   TranslatorDescriptor td = (TranslatorDescriptor)userObject;
1811                   toReturn = td.getName();
1812                   if(toReturn == null)
1813                   {
1814                      toReturn = "Unknown Translator";
1815                   }
1816                }
1817                else
1818                {
1819                   toReturn = userObject.toString();
1820                }
1821             }
1822          }
1823          return toReturn;
1824       }
1825    }
1826 
1827    private final class FileExtensionTypeListenerFilter extends ViewerFilter
1828       implements ISelectionChangedListener
1829    {
1830       private String _extension;
1831 
1832       private boolean _isImportFilter;
1833 
1834       /***
1835        * Creates a viewer filter that filters based on selected 
1836        * extensions of resources in a control.
1837        * 
1838        * @param isImportFilter 
1839        * @param extension a default extension to select from the list of choices
1840        */
1841       public FileExtensionTypeListenerFilter(boolean isImportFilter,
1842          String extension)
1843       {
1844          _isImportFilter = isImportFilter;
1845          _extension = extension;
1846       }
1847 
1848       /*
1849        * (non-Javadoc)
1850        * 
1851        * @see org.eclipse.jface.viewers.ISelectionChangedListener
1852        *    #selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
1853        */
1854       public void selectionChanged(SelectionChangedEvent event)
1855       {
1856          IStructuredSelection selection = (IStructuredSelection)event
1857             .getSelection();
1858          IPath selectedPath = ((IResource)selection.getFirstElement())
1859             .getFullPath();
1860          if(selectedPath != null)
1861          {
1862             _extension = selectedPath.getFileExtension();
1863          }
1864       }
1865 
1866       /* (non-Javadoc)
1867        * @see java.lang.Object#equals(java.lang.Object)
1868        */
1869       public boolean equals(Object arg0)
1870       {
1871          boolean toReturn = super.equals(arg0);
1872          FileExtensionTypeListenerFilter other = null;
1873          if((arg0 != null) && (arg0 instanceof FileExtensionTypeListenerFilter))
1874          {
1875             toReturn = false;
1876             other = (FileExtensionTypeListenerFilter)arg0;
1877             if(((_extension == null) && (other._extension == null))
1878                || (_extension.equals(other._extension)))
1879             {
1880                if(_isImportFilter == other._isImportFilter)
1881                {
1882                   toReturn = true;
1883                }
1884             }
1885          }
1886          return toReturn;
1887       }
1888 
1889       /*
1890        * (non-Javadoc)
1891        * 
1892        * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
1893        *      java.lang.Object, java.lang.Object)
1894        */
1895       public boolean select(Viewer viewer, Object parentElement, Object element)
1896       {
1897          boolean allowToPass = true;
1898          TranslatorDescriptor td = null;
1899          if(element instanceof DefaultMutableTreeNode)
1900          {
1901             if(((DefaultMutableTreeNode)element).getUserObject() instanceof TranslatorDescriptor)
1902             {
1903                td = (TranslatorDescriptor)((DefaultMutableTreeNode)element)
1904                   .getUserObject();
1905                if(_extension != null)
1906                {
1907                   if(_isImportFilter)
1908                   {
1909                      if(!_extension.equalsIgnoreCase(td.getInputExtension()))
1910                      {
1911                         allowToPass = false;
1912                      }
1913                   }
1914                   else
1915                   {
1916                      if(!_extension.equalsIgnoreCase(td.getOutputExtension()))
1917                      {
1918                         allowToPass = false;
1919                      }
1920                   }
1921                }
1922             }
1923          }
1924          return allowToPass;
1925       }
1926    }
1927 
1928    /***
1929     * Creates a viewer filter (for a ListBox or Table or whatever)
1930     * which acts as a logical OR among a set of filters that 
1931     * you can add to and remove from the CombinationFilter.
1932     * 
1933     * The default behavior in Eclipse JFace acts as a 
1934     * logical AND, and is not applicable to all cases.
1935     * 
1936     * @author aperezlo
1937     */
1938    private final class CombinationFilter extends ViewerFilter
1939    {
1940       private List _allFilters;
1941 
1942       /***
1943        * Creates a new empty combination filter.
1944        */
1945       public CombinationFilter()
1946       {
1947          _allFilters = new ArrayList();
1948       }
1949 
1950       /***
1951        * Add Filter.
1952        * 
1953        * @param vf a viewer filter to add to this combination filter
1954        */
1955       public void addFilter(ViewerFilter vf)
1956       {
1957          _allFilters.add(vf);
1958       }
1959 
1960       /***
1961        * Remove Filter.
1962        * 
1963        * 
1964        * @param vf a viewer filter to remove from this combination filter
1965        */
1966       public void removeFilter(ViewerFilter vf)
1967       {
1968          _allFilters.remove(vf);
1969       }
1970 
1971       /***
1972        * If the object is selected by any of the filters
1973        * in the combination filter, then it is allowed to 
1974        * pass through the filter.
1975        * 
1976        * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
1977        *      java.lang.Object, java.lang.Object)
1978        */
1979       public boolean select(Viewer viewer, Object parentElement, Object element)
1980       {
1981          boolean toReturn = false;
1982          ViewerFilter vf = null;
1983          Iterator i = _allFilters.iterator();
1984          while (i.hasNext())
1985          {
1986             vf = (ViewerFilter)i.next();
1987             if(vf.select(viewer, parentElement, element))
1988             {
1989                toReturn = true;
1990                break;
1991             }
1992          }
1993          return toReturn;
1994       }
1995    }
1996 
1997    /***
1998     * Creates a new 'Helper.
1999     * 
2000     * @param mode EXPORT or TRANSLATE
2001     * @param wb reference to the active workbench
2002     * @param iss initial selection
2003     */
2004    SemanticWebTranslatorWizardHelper(int mode, IWorkbench wb,
2005       IStructuredSelection iss)
2006    {
2007       _workbench = wb;
2008       _selection = iss;
2009       _wizardPages = new ArrayList();
2010       StructuredSelection resourceSelection = null;
2011       List selected = iss.toList();
2012       List bonaFideResources = new ArrayList();
2013       _listHelperTranslators = new ArrayList();
2014       Iterator selectedIterator = null;
2015       IResource tempResource = null;
2016       Object temp = null;
2017       selectedIterator = selected.iterator();
2018       while (selectedIterator.hasNext())
2019       {
2020          temp = selectedIterator.next();
2021          if((temp instanceof IOWLElement))
2022          {
2023             tempResource = ((IOWLElement)temp).getCorrespondingResource();
2024             if(tempResource != null)
2025             {
2026                if(!(tempResource instanceof IContainer))
2027                {
2028                   if((tempResource.getFileExtension() != null)
2029                      && (TranslatorPlugin.getPlugin().getInputExtensions()
2030                         .contains(tempResource.getFileExtension())))
2031                   {
2032                      bonaFideResources.add(tempResource);
2033                   }
2034                }
2035                else
2036                {
2037                   bonaFideResources.add(tempResource);
2038                }
2039             }
2040          }
2041          else
2042          {
2043             if(temp instanceof IResource)
2044             {
2045                tempResource = (IResource)temp;
2046                if(tempResource instanceof IContainer)
2047                {
2048                   bonaFideResources.add(temp);
2049                }
2050                else
2051                {
2052                   if((tempResource.getFileExtension() != null)
2053                      && (TranslatorPlugin.getPlugin().getInputExtensions()
2054                         .contains(tempResource.getFileExtension())))
2055                   {
2056                      bonaFideResources.add(tempResource);
2057                   }
2058                }
2059             }
2060          }
2061       }
2062       resourceSelection = new StructuredSelection(bonaFideResources);
2063 
2064       switch(mode)
2065       {
2066          case TRANSLATE:
2067             _wizardPages.add(new TranslationPageOne("Translation",
2068                resourceSelection));
2069             break;
2070          case EXPORT:
2071             _wizardPages.add(new ExportPageOne("Export", resourceSelection));
2072             break;
2073 //         case IMPORT:
2074 //            _wizardPages.add(new ImportPageOne(this, "Import",
2075 //               resourceSelection));
2076 //            break;
2077          default:
2078             break;
2079       }
2080    }
2081 
2082    /***
2083     * Retrieves the progress monitor associated with this 'Helper.
2084     * @return The progress monitor
2085     */
2086    IProgressMonitor getProgressMonitor()
2087    {
2088       return _progressMonitor;
2089    }
2090 
2091    /***
2092     * Retrieves the path to which the files should be exported/translated.
2093     * @return The path
2094     */
2095    IPath getOutputPath()
2096    {
2097       return _pathHelperOutputPath;
2098    }
2099 
2100    /***
2101     * Retrieves the list of files to be exported/translated.
2102     * @return The list of files
2103     */
2104    List getInputFiles()
2105    {
2106       return _listHelperInputFiles;
2107    }
2108 
2109    /***
2110     * Retrieves the selected translators.
2111     * @return the selected translators
2112     */
2113    List getTranslatorDescriptors()
2114    {
2115       return _listHelperTranslators;
2116    }
2117 
2118    /***
2119     * Retrieves the pages suitable for a wizard of the appropriate type.
2120     * @return the appropriate pages
2121     */
2122    List getPages()
2123    {
2124       return _wizardPages;
2125    }
2126 
2127    /***
2128     * Sets the progress monitor for this 'Helper.
2129     * @param pmp The new progress monitor
2130     */
2131    void setProgressMonitor(ProgressMonitorPart pmp)
2132    {
2133       _progressMonitor = pmp;
2134    }
2135 
2136    /***
2137     * Performs a translation for a single file.
2138     * 
2139     * @param inputFile the file to be translated 
2140     * @param outputPath the directory to save the translated file/resource 
2141     * @param translatorDescriptor the translator to perform the translation
2142     * @return the object which ran the translation, so as to check for errors, etc.
2143     * @throws Exception if any error is encountered
2144     */
2145    TranslationRunner performTranslation(File inputFile, IPath outputPath,
2146       TranslatorDescriptor translatorDescriptor) throws Exception
2147    {
2148       TranslationRunner toReturn = null;
2149       ITranslator translator = translatorDescriptor.getTranslator();
2150 
2151       IContainer creator = null;
2152       IPath creationPath = null;
2153       IFile outputFile = null;
2154       IPath inputFilePath = new Path(inputFile.toString());
2155 
2156       try
2157       {
2158          creator = ResourcesPlugin.getWorkspace().getRoot().getFolder(
2159             outputPath.makeAbsolute());
2160       }
2161       catch (Exception getContainerException)
2162       {
2163          //do nothing
2164       }
2165       if(creator == null)
2166       {
2167          creator = ResourcesPlugin.getWorkspace().getRoot().getProject(
2168             outputPath.makeRelative().toString());
2169       }
2170 
2171       creationPath = inputFilePath;
2172       creationPath = creationPath.removeFirstSegments(creationPath
2173          .segmentCount());
2174       creationPath = creationPath.append(inputFilePath.lastSegment());
2175       creationPath = creationPath.removeFileExtension();
2176       creationPath = creationPath.addFileExtension(translatorDescriptor
2177          .getOutputExtension());
2178       outputFile = creator.getFile(creationPath);
2179 
2180       Status status = null;
2181       OutputStream output = null;
2182       if(creator.getLocation() == null)
2183       {
2184          output = new FileOutputStream(outputFile.getFullPath().makeAbsolute()
2185             .toOSString());
2186       }
2187       else
2188       {
2189          output = new FileOutputStream(outputFile.getLocation().toFile());
2190       }
2191       String inputFormat = translatorDescriptor.getInputExtension();
2192       String outputFormat = translatorDescriptor.getOutputExtension();
2193       toReturn = new TranslationRunner(translator);
2194       toReturn.configure(inputFile, output, inputFormat, outputFormat);
2195       toReturn.runBlocked();
2196       output.flush();
2197       output.close();
2198       if(outputFile.getLocation() != null)
2199       {
2200          outputFile.create(null, IResource.FORCE, null);
2201          outputFile.refreshLocal(0, null);
2202       }
2203       if(toReturn.getErrorString() != null)
2204       {
2205          outputFile.delete(true, null);
2206          if(outputFile.getLocation() == null)
2207          {
2208             (new File(outputFile.getFullPath().makeAbsolute().toOSString()))
2209                .delete();
2210          }
2211       }
2212 
2213       return toReturn;
2214 
2215    }
2216 
2217    /***
2218     * Performs a translation for a single file.
2219     * 
2220     * @param inputFile the file to be translated 
2221     * @param outputPath the directory to save the translated file/resource 
2222     * @param translatorDescriptor the translator to perform the translation
2223     * @return the object which ran the translation, so as to check for errors, etc.
2224     * @throws Exception if any error is encountered
2225     */
2226    TranslationRunner performTranslation(IFile inputFile, IPath outputPath,
2227       TranslatorDescriptor translatorDescriptor) throws Exception
2228    {
2229       File realFile = new File(inputFile.getFullPath().makeAbsolute()
2230          .toOSString());
2231       return performTranslation(realFile, outputPath, translatorDescriptor);
2232    }
2233 
2234 }