get category
authoraxelcl <axelcl>
Sun, 20 Feb 2005 17:36:58 +0000 (17:36 +0000)
committeraxelcl <axelcl>
Sun, 20 Feb 2005 17:36:58 +0000 (17:36 +0000)
archive/net.sourceforge.phpeclipse.wiki/plugin.xml
archive/net.sourceforge.phpeclipse.wiki/prefs/default_linux.properties
archive/net.sourceforge.phpeclipse.wiki/prefs/default_macosx.properties
archive/net.sourceforge.phpeclipse.wiki/prefs/default_win32.properties
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/category/CreateFilesFromCategoryEditorAction.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/RefreshJob.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/MediaWikiConnector.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/export/pdf/WikiPDFExportWizardPage.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/export/pdf/WikiPDFExporter.java

index 7090dd3..1e053db 100644 (file)
       <viewerContribution
             targetID="#EditorContext"
             id="net.sourceforge.phpeclipse.wiki.texteditor.viewercontribution">
+            <action
+               label="Create files from Category"
+               class="net.sourceforge.phpeclipse.wiki.actions.category.CreateFilesFromCategoryEditorAction"
+               menubarPath="additions"
+               id="net.sourceforge.phpeclipse.wiki.actions.category.CreateFilesFromCategoryEditorAction">
+         </action>
          <action
                label="Create files for Wiki links"
                class="net.sourceforge.phpeclipse.wiki.actions.CreateFilesFromLinksEditorAction"
                menubarPath="additions"
                id="net.sourceforge.phpeclipse.wiki.actions.CreateFilesFromLinksEditorAction">
          </action>
-         <action
+         <action 
                label="Open Wiki link"
                class="net.sourceforge.phpeclipse.wiki.actions.OpenWikiLinkEditorAction"
                menubarPath="additions"
          point="org.eclipse.ui.exportWizards">
       <wizard 
             name="Wikipedia to HTML"
+            icon="icons/step.gif"
             class="net.sourceforge.phpeclipse.wiki.export.html.WikiHTMLExportWizard"
             id="WikiHTMLWizard">
       </wizard>
       <wizard 
             name="Wikipedia to PDF"
+            icon="icons/step.gif"
             class="net.sourceforge.phpeclipse.wiki.export.pdf.WikiPDFExportWizard"
             id="WikiPDFWizard">
       </wizard>
index e1ba50a..3a7f0c9 100644 (file)
@@ -1,6 +1,9 @@
 editor.wrap.words=false
+http.get.throttle=1
+http.put.throttle=5
 http.timeout=30
 http.proxyHost=
 http.proxyPort=
 http.proxyUserName=
-http.proxyPassword=
\ No newline at end of file
+http.proxyPassword=
+
index e1ba50a..97c7b24 100644 (file)
@@ -1,6 +1,8 @@
 editor.wrap.words=false
+http.get.throttle=1
+http.put.throttle=5
 http.timeout=30
 http.proxyHost=
 http.proxyPort=
 http.proxyUserName=
-http.proxyPassword=
\ No newline at end of file
+http.proxyPassword=
index e1ba50a..97c7b24 100644 (file)
@@ -1,6 +1,8 @@
 editor.wrap.words=false
+http.get.throttle=1
+http.put.throttle=5
 http.timeout=30
 http.proxyHost=
 http.proxyPort=
 http.proxyUserName=
-http.proxyPassword=
\ No newline at end of file
+http.proxyPassword=
index fccc4e7..7c56834 100644 (file)
@@ -1,14 +1,24 @@
 package net.sourceforge.phpeclipse.wiki.actions.category;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 
 import net.sourceforge.phpeclipse.wiki.actions.CreateFilesJob;
 import net.sourceforge.phpeclipse.wiki.actions.OpenWikiLinkEditorAction;
+import net.sourceforge.phpeclipse.wiki.actions.ProblemConsole;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.Loaded;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.MediaWikiConnector;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.MethodException;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.PageNotEditableException;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.UnexpectedAnswerException;
 import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
+import net.sourceforge.phpeclipse.wiki.internal.Configuration;
+import net.sourceforge.phpeclipse.wiki.internal.ConfigurationManager;
+import net.sourceforge.phpeclipse.wiki.internal.IConfiguration;
 import net.sourceforge.phpeclipse.wiki.preferences.Util;
 
 import org.eclipse.core.resources.IFile;
@@ -41,15 +51,53 @@ public final class CreateFilesFromCategoryEditorAction extends OpenWikiLinkEdito
     public String toString() {
       return wikiTitle + " - " + file.getProjectRelativePath().toString();
     }
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
     public int compareTo(Object o) {
-      return wikiTitle.compareTo(((WikiFile)o).wikiTitle);
+      return wikiTitle.compareTo(((WikiFile) o).wikiTitle);
+    }
+  }
+
+  protected Configuration getConfigurationPrefix(String prefix) {
+    List allConfigsList = ConfigurationManager.getInstance().getConfigurations();
+    ArrayList configsList = new ArrayList();
+    for (int i = 0; i < allConfigsList.size(); i++) {
+      IConfiguration temp = (IConfiguration) allConfigsList.get(i);
+      if (temp.getType().startsWith(prefix)) {
+        configsList.add(temp);
+      }
+    }
+    if (configsList.size() == 1) {
+      return (Configuration) configsList.get(0);
+    }
+    Collections.sort(configsList);
+    Configuration configuration = null;
+    ListSelectionDialog listSelectionDialog = new ListSelectionDialog(WikiEditorPlugin.getDefault().getWorkbench()
+        .getActiveWorkbenchWindow().getShell(), configsList, new ListContentProvider(), new LabelProvider(),
+        "Select the refresh URL.");
+    listSelectionDialog.setTitle("Multiple active configuration found");
+    if (listSelectionDialog.open() == Window.OK) {
+      Object[] locations = listSelectionDialog.getResult();
+      if (locations != null) {
+        for (int i = 0; i < locations.length; i++) {
+          configuration = (Configuration) locations[i];
+          break;
+        }
+      }
     }
+    return configuration;
+  }
+
+  protected Configuration getConfiguration() {
+    return getConfigurationPrefix(WikiEditorPlugin.PREFIX_LOAD);
   }
 
   public void openWikiLinkOnSelection() {
+    ProblemConsole console = new ProblemConsole();
     IDocument doc = getDocument();
     Shell shell = Util.findShell();
     if (shell == null) {
@@ -58,15 +106,40 @@ public final class CreateFilesFromCategoryEditorAction extends OpenWikiLinkEdito
     CategoryDialog dialog = new CategoryDialog(shell);//$NON-NLS-1$
     dialog.open();
     String category = dialog.getCategory();
-    
-    // TODO: this doesn#t work at the moment:
-    MediaWikiConnector connector = new MediaWikiConnector();
-      Loaded page = null;
-//        connector.loadCategory(actionUrl, wikipedia.getCharSet(), "plog4u.org bot");
-      
+    if (category == null || category.length() == 0) {
+      return;
+    }
+    category = category.replaceAll(" ", "_");
+    Configuration configuration = getConfiguration();
+    String wikiLocale = configuration.getType().substring(WikiEditorPlugin.PREFIX_LOAD.length());
+    String htmlContent = null;
+    try {
+      IWikipedia wikipediaProperties = WikiEditorPlugin.getWikiInstance(wikiLocale);
+
+      MediaWikiConnector connector = new MediaWikiConnector();
+      String actionUrl = wikipediaProperties.getActionUrl() + "/Category:" + category;
+      htmlContent = connector.loadHTMLPage(actionUrl, wikipediaProperties.getCharSet());
+    } catch (UnexpectedAnswerException e) {
+      console.println("UnexpectedAnswerException: " + e.getMessage());
+    } catch (MethodException e) {
+      console.println("HTTP-MethodException: " + e.getMessage());
+    } catch (PageNotEditableException e) {
+      console.println("PageNotEditableException: " + e.getMessage());
+    } catch (NoSuchMethodException e) {
+      console.println("NoSuchMethodException: " + e.getMessage());
+    } catch (IllegalAccessException e) {
+      console.println("IllegalAccessException: " + e.getMessage());
+    } catch (ClassNotFoundException e) {
+      console.println("ClassNotFoundException: " + e.getMessage());
+    } catch (InvocationTargetException e) {
+      console.println("InvocationTargetException: " + e.getMessage());
+    }
+    if (htmlContent == null) {
+      return;
+    }
     ParseCategory pc = new ParseCategory();
-    pc.parseCategory(page.getContent().getBody());
-    
+    pc.parseCategory(htmlContent);
+
     ArrayList startPositionList = pc.getTitleList();
 
     HashSet wikiNames = new HashSet();
@@ -105,7 +178,7 @@ public final class CreateFilesFromCategoryEditorAction extends OpenWikiLinkEdito
             files[i] = ((WikiFile) locations[i]).file;
             wikiTitles[i] = ((WikiFile) locations[i]).wikiTitle;
           }
-          
+
           Job job = new CreateFilesJob(files, wikiTitles);
           //        job.setRule(createRule(files));
           job.setRule(null);
index 9563651..cc38239 100644 (file)
@@ -49,13 +49,18 @@ public class RefreshJob extends WorkspaceJob {
     IFile file = null;
 
     try {
-      monitor.beginTask("Download Wiki Articles: ", 100);
+      int totalWork = files.length;
+      if (totalWork <= 0) {
+        totalWork = 100;
+      }
+      monitor.beginTask("Download Wiki Articles: ", totalWork);
       //      ArrayList wikiTitles = new ArrayList();
       //      for (int i = 0; i < files.length; i++) {
       //        wikiTitles.add( Util.getReadableWikiName(files[i]) );
       //      }
       StringBuffer buffer = new StringBuffer();
       HashMap map = new HashMap();
+      MediaWikiConnector mwConnector = new MediaWikiConnector();
       String wikiTitle;
       int titleCounter = 0;
       for (int i = 0; i < files.length; i++) {
@@ -67,9 +72,9 @@ public class RefreshJob extends WorkspaceJob {
         if (i != files.length - 1) {
           buffer.append("\n");
         }
-        if (i % 10 == 0) {
-          // read only 10 files at a time
-          IStatus status = readWikisFromBuffer(buffer, map, monitor, console);
+        if (i % 5 == 0) {
+          // read only 5 files at a time
+          IStatus status = readWikisFromBuffer(mwConnector, buffer, map, monitor, console);
           if (status.equals(Status.CANCEL_STATUS)) {
             return Status.CANCEL_STATUS;
           }
@@ -78,7 +83,7 @@ public class RefreshJob extends WorkspaceJob {
         }
       }
       if (titleCounter > 0) {
-        IStatus status = readWikisFromBuffer(buffer, map, monitor, console);
+        IStatus status = readWikisFromBuffer(mwConnector, buffer, map, monitor, console);
         if (status.equals(Status.CANCEL_STATUS)) {
           return Status.CANCEL_STATUS;
         }
@@ -132,11 +137,11 @@ public class RefreshJob extends WorkspaceJob {
    * @throws UnexpectedAnswerException
    * @throws MethodException
    */
-  private IStatus readWikisFromBuffer(StringBuffer buffer, HashMap map, IProgressMonitor monitor, ProblemConsole console)
-      throws UnexpectedAnswerException, InterruptedException, MethodException {
+  private IStatus readWikisFromBuffer(MediaWikiConnector mwConnector, StringBuffer buffer, HashMap map, IProgressMonitor monitor,
+      ProblemConsole console) throws UnexpectedAnswerException, InterruptedException, MethodException {
     String wikiTitle;
     boolean showConsole = WikiEditorPlugin.getDefault().getPreferenceStore().getBoolean(WikiEditorPlugin.CONSOLE_OUTPUT);
-    MediaWikiConnector mwConnector = new MediaWikiConnector();
+
     String url = actionURL;
     if (url == null) {
       url = configuration.getActionUrl() + "/" + configuration.getSpecialNs() + ":Export";
@@ -167,6 +172,7 @@ public class RefreshJob extends WorkspaceJob {
           }
         }
       }
+      monitor.worked(1);
       if (monitor.isCanceled()) {
         return Status.CANCEL_STATUS;
       }
index ca80eec..efc1fc9 100644 (file)
@@ -69,7 +69,12 @@ public class MediaWikiConnector {
   /**
    * Delay a new store to 1 second
    */
-  private Throttle storeThrottle = new Throttle(1000);
+  private Throttle loadThrottle = new Throttle(WikiEditorPlugin.HTTP_GET_THROTTLE);
+
+  /**
+   * Delay a new store to 1 second
+   */
+  private Throttle storeThrottle = new Throttle(WikiEditorPlugin.HTTP_PUT_THROTTLE);
 
   class Throttle {
     private long nextTime = 0;
@@ -80,6 +85,12 @@ public class MediaWikiConnector {
       this.minimumDelay = minimumDelay;
     }
 
+    public Throttle(String key) {
+      Preferences prefs = WikiEditorPlugin.getDefault().getPluginPreferences();
+      String minimumDelay = prefs.getString(key);
+      this.minimumDelay = Integer.parseInt(minimumDelay);
+    }
+
     /** this is called from the client */
     public synchronized void delay() throws InterruptedException {
       long delay = nextTime - System.currentTimeMillis();
@@ -311,24 +322,25 @@ public class MediaWikiConnector {
     return result;
   }
 
-  public Loaded loadCategory(String actionURL, String charSet, String title) throws UnexpectedAnswerException, MethodException,
+  public String loadHTMLPage(String actionURL, String charSet) throws UnexpectedAnswerException, MethodException,
       PageNotEditableException {
     GetMethod method = new GetMethod(actionURL);
-    method.setFollowRedirects(false);
+    method.setFollowRedirects(true);
     method.addRequestHeader("User-Agent", userAgent);
-    NameValuePair[] params = new NameValuePair[] { new NameValuePair("title", title) };
-    method.setQueryString(EncodingUtil.formUrlEncode(params, charSet));
+//    NameValuePair[] params = new NameValuePair[] { new NameValuePair("title", title) };
+//    method.setQueryString(EncodingUtil.formUrlEncode(params, charSet));
 
-    Loaded result;
+    String result = "";
     try {
       int responseCode = client.executeMethod(method);
       String responseBody = method.getResponseBodyAsString();
       //                       log(method);
 
       if (responseCode == 200) {
-        Parsed parsed = parseBody(charSet, responseBody);
-        Content content = new Content(parsed.timestamp, parsed.body);
-        result = new Loaded(actionURL, charSet, parsed.title, content);
+        result = responseBody;
+//        Parsed parsed = parseBody(charSet, responseBody);
+//        Content content = new Content(parsed.timestamp, parsed.body);
+//        result = new Loaded(actionURL, charSet, parsed.title, content);
       } else {
         throw new UnexpectedAnswerException("load not successful: expected 200 OK, got " + method.getStatusLine());
       }
@@ -344,7 +356,7 @@ public class MediaWikiConnector {
 
   public ArrayList loadXML(IWikipedia config, String actionURL, String pages) throws UnexpectedAnswerException, MethodException,
       InterruptedException {
-    storeThrottle.delay();
+    loadThrottle.delay();
     PostMethod method = new PostMethod(actionURL);
     method.setFollowRedirects(false);
     method.addRequestHeader("User-Agent", userAgent);
index 67f3451..d36277a 100644 (file)
@@ -146,6 +146,10 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
 
   public final static String CONSOLE_OUTPUT = "__console_output";
 
+  public final static String HTTP_GET_THROTTLE = "http.get.throttle";
+
+  public final static String HTTP_PUT_THROTTLE = "http.put.throttle";
+
   public final static String HTTP_TIMEOUT = "http.timeout";
 
   public final static String HTTP_PROXYHOST = "http.proxyHost";
@@ -379,7 +383,7 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
       try {
         String wordWrap = resourceBundle.getString(key);
         Boolean b = Boolean.valueOf(wordWrap);
-        if (b.booleanValue()) { 
+        if (b.booleanValue()) {
           store.setDefault(key, "true");
         } else {
           store.setDefault(key, "false");
@@ -388,6 +392,34 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
         store.setDefault(key, "false");
       }
 
+      key = HTTP_GET_THROTTLE;
+      try {
+        String timeout = resourceBundle.getString(key);
+        int val = Integer.parseInt(timeout);
+        if (val > 0) {
+          val *= 1000;
+        } else {
+          val = 1000;
+        }
+        store.setDefault(key, Integer.toString(val));
+      } catch (Exception e) {
+        store.setDefault(key, "1000"); // 1 second
+      }
+
+      key = HTTP_PUT_THROTTLE;
+      try {
+        String timeout = resourceBundle.getString(key);
+        int val = Integer.parseInt(timeout);
+        if (val > 0) {
+          val *= 1000;
+        } else {
+          val = 5000;
+        }
+        store.setDefault(key, Integer.toString(val));
+      } catch (Exception e) {
+        store.setDefault(key, "5000"); // 5 seconds
+      }
+
       key = HTTP_TIMEOUT;
       try {
         String timeout = resourceBundle.getString(key);
index a71bcf6..5407958 100644 (file)
@@ -44,29 +44,31 @@ import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
 public final class WikiPDFExportWizardPage extends WizardExportResourcesPage implements IPropertyChangeListener, SelectionListener {
 //  private StringFieldEditor folderText;
 
-  private static final String[] PDF_EXTENSION = { "pdf" };
+  private static final String[] PDF_EXTENSION = { "*.pdf" };
 
   //dialog store id constants
-  private static final String STORE_DESTINATION_NAMES_ID = "WikiPDFExportWizardPage.STORE_DESTINATION_NAMES_ID"; //$NON-NLS-1$
+  private static final String PAGE_NAME = "WikiPDFExportWizardPage"; //$NON-NLS-1$
+  
+  private static final String STORE_DESTINATION_NAMES = PAGE_NAME+".STORE_DESTINATION_NAMES"; //$NON-NLS-1$
 
-  private static final String STORE_OVERWRITE_EXISTING_FILES_ID = "WikiPDFExportWizardPage.STORE_OVERWRITE_EXISTING_FILES_ID"; //$NON-NLS-1$
+  private static final String STORE_OVERWRITE_EXISTING_FILES_ID = PAGE_NAME+".STORE_OVERWRITE_EXISTING_FILES_ID"; //$NON-NLS-1$
 
 //  private StringFieldEditor exportFileText;
 
-  private Combo destinationNameField;
+  private Combo fDestinationNamesCombo;
 
   private Button destinationBrowseButton;
 
   protected Button overwriteExistingFilesCheckbox;
 
-  private ISelection selection;
+  private ISelection fInitialSelection;
   private IDialogSettings fSettings = null;
 
   public WikiPDFExportWizardPage(IStructuredSelection selection) {
-    super(WikiEditorPlugin.getResourceString("Export.wizardTitle"), selection);
+    super(PAGE_NAME, selection);
     setTitle(WikiEditorPlugin.getResourceString("Export.wizardTitle"));
     setDescription(WikiEditorPlugin.getResourceString("Export.wizardDescription"));
-    this.selection = selection;
+    this.fInitialSelection = selection;
   }
 
   /**
@@ -91,13 +93,13 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
     destinationLabel.setFont(font);
 
     // destination name entry field
-    destinationNameField = new Combo(destinationSelectionGroup, SWT.SINGLE | SWT.BORDER);
-    destinationNameField.addListener(SWT.Modify, this);
-    destinationNameField.addListener(SWT.Selection, this);
+    fDestinationNamesCombo = new Combo(destinationSelectionGroup, SWT.SINGLE | SWT.BORDER);
+    fDestinationNamesCombo.addListener(SWT.Modify, this);
+    fDestinationNamesCombo.addListener(SWT.Selection, this);
     GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
     data.widthHint = SIZING_TEXT_FIELD_WIDTH;
-    destinationNameField.setLayoutData(data);
-    destinationNameField.setFont(font);
+    fDestinationNamesCombo.setLayoutData(data);
+    fDestinationNamesCombo.setFont(font);
 
     // destination browse button
     destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
@@ -173,7 +175,7 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
    */
   protected void handleDestinationBrowseButtonPressed() {
     FileDialog dialog = new FileDialog(getContainer().getShell(), SWT.SAVE);
-    dialog.setFilterExtensions(PDF_EXTENSION);
+    dialog.setFilterExtensions(PDF_EXTENSION); 
     dialog.setText("Select pdf file");
     dialog.setFilterPath(getDestinationValue());
     String selectedFileName = dialog.open();
@@ -184,54 +186,84 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
     }
   }
 
+//  /**
+//   * Answer the contents of self's destination specification widget
+//   * 
+//   * @return java.lang.String
+//   */
+//  protected String getDestinationValue() {
+//    
+//    return fDestinationNamesCombo.getText().trim();
+//  }
   /**
-   * Answer the contents of self's destination specification widget
-   * 
-   * @return java.lang.String
-   */
-  protected String getDestinationValue() {
-    return destinationNameField.getText().trim();
-  }
+        *      Answer the contents of the destination specification widget. If this
+        *      value does not have the required suffix then add it first.
+        *
+        *      @return java.lang.String
+        */
+       protected String getDestinationValue() {
+               String destinationText= fDestinationNamesCombo.getText().trim();
+               if (destinationText.indexOf('.') < 0)
+                       destinationText += getOutputSuffix();
+               return destinationText;
+       }
+       
+       /**
+        *      Answer the suffix that files exported from this wizard must have.
+        *      If this suffix is a file extension (which is typically the case)
+        *      then it must include the leading period character.
+        *
+        *      @return java.lang.String
+        */
+       protected String getOutputSuffix() {
+               return ".pdf"; //$NON-NLS-1$
+       }
 
   /**
    * Set the contents of the receivers destination specification widget to the passed value
    *  
    */
   protected void setDestinationValue(String value) {
-    destinationNameField.setText(value);
+    fDestinationNamesCombo.setText(value);
   }
 
   /**
    * Hook method for saving widget values for restoration by the next instance of this class.
    */
   protected void internalSaveWidgetValues() {
-    // update directory names history
-    IDialogSettings settings = getDialogSettings();
-    if (settings != null) {
-      String[] fileNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
-      if (fileNames == null)
-        fileNames = new String[0];
-
-      fileNames = addToHistory(fileNames, getDestinationValue());
-      settings.put(STORE_DESTINATION_NAMES_ID, fileNames);
-
-      // options
-      settings.put(STORE_OVERWRITE_EXISTING_FILES_ID, overwriteExistingFilesCheckbox.getSelection());
-
-      //                       settings.put(
-      //                               STORE_CREATE_STRUCTURE_ID,
-      //                               createDirectoryStructureButton.getSelection());
-
-    }
+    
   }
 
   /**
+        * Persists resource specification control setting that are to be restored
+        * in the next instance of this page. Subclasses wishing to persist
+        * settings for their controls should extend the hook method 
+        * <code>internalSaveWidgetValues</code>.
+        */
+       public final void saveWidgetValues() {
+               // update directory names history
+               IDialogSettings settings= getDialogSettings();
+               if (settings != null) {
+                       String[] directoryNames= settings.getArray(STORE_DESTINATION_NAMES);
+                       if (directoryNames == null)
+                               directoryNames= new String[0];
+                       directoryNames= addToHistory(directoryNames, getDestinationValue());
+                       settings.put(STORE_DESTINATION_NAMES, directoryNames);
+
+                       // options
+                       settings.put(STORE_OVERWRITE_EXISTING_FILES_ID, overwriteExistingFilesCheckbox.getSelection());
+               }
+               // Allow subclasses to save values
+               internalSaveWidgetValues();
+       }
+
+  /**
    * Hook method for restoring widget values to the values that they held last time this wizard was used to completion.
    */
   protected void restoreWidgetValues() {
     IDialogSettings settings = getDialogSettings();
     if (settings != null) {
-      String[] fileNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
+      String[] fileNames = settings.getArray(STORE_DESTINATION_NAMES);
       if (fileNames == null)
         return; // ie.- no settings stored
 
@@ -257,7 +289,7 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
    *          java.lang.String
    */
   protected void addDestinationItem(String value) {
-    destinationNameField.add(value);
+    fDestinationNamesCombo.add(value);
   }
 
   /**
@@ -265,6 +297,7 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
    */
   public void createControl(Composite parent) {
     super.createControl(parent);
+//    update();
     giveFocusToDestination();
     //         WorkbenchHelp.setHelp(
     //                 getControl(),
@@ -275,7 +308,7 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
    * Set the current input focus to self's destination entry field
    */
   protected void giveFocusToDestination() {
-    destinationNameField.setFocus();
+    fDestinationNamesCombo.setFocus();
   }
 
   //  private Composite createControlsContainer(Composite parent) {
@@ -346,11 +379,11 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
   //  }
 
 //  private void initialize() throws CoreException {
-//    if (selection == null || selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
+//    if (fInitialSelection == null || fInitialSelection.isEmpty() || !(fInitialSelection instanceof IStructuredSelection)) {
 //      return;
 //    }
 //
-//    IStructuredSelection ssel = (IStructuredSelection) selection;
+//    IStructuredSelection ssel = (IStructuredSelection) fInitialSelection;
 //    if (ssel.size() == 1) {
 //      initialiseFromSelectedObject(ssel.getFirstElement());
 //    }
@@ -497,20 +530,27 @@ public final class WikiPDFExportWizardPage extends WizardExportResourcesPage imp
 
     return false;
   }
-  /* (non-Javadoc)
-   * @see org.eclipse.jface.wizard.WizardPage#getDialogSettings()
-   */
-//  protected IDialogSettings getDialogSettings() {
-//    IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY);
-//     if (dialogBounds == null) {
-//             dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY);
-//             fSettings.addSection(dialogBounds);
+  
+  /**
+        * Returns a boolean indicating whether the passed File handle is
+        * is valid and available for use.
+        *
+        * @return boolean
+        */
+//     protected boolean ensureTargetFileIsValid(File targetFile) {
+//             if (targetFile.exists() && targetFile.isDirectory() && fDestinationNamesCombo.getText().length() > 0) {
+//                     setErrorMessage(JarPackagerMessages.getString("JarPackageWizardPage.error.exportDestinationMustNotBeDirectory")); //$NON-NLS-1$
+//                     fDestinationNamesCombo.setFocus();
+//                     return false;
+//             }
+//             if (targetFile.exists()) {
+//                     if (!targetFile.canWrite()) {
+//                             setErrorMessage(JarPackagerMessages.getString("JarPackageWizardPage.error.jarFileExistsAndNotWritable")); //$NON-NLS-1$
+//                             fDestinationNamesCombo.setFocus();
+//                             return false;
+//                     }
+//             }
+//             return true;
 //     }
-//     dialogBounds.put(X, bounds.x);
-//     dialogBounds.put(Y, bounds.y);
-//     dialogBounds.put(WIDTH, bounds.width);
-//     dialogBounds.put(HEIGHT, bounds.height);
-//    // TODO Auto-generated method stub
-//    return super.getDialogSettings();
-//  }
+
 }
\ No newline at end of file
index e97dd4d..4ba33df 100644 (file)
@@ -198,7 +198,7 @@ public final class WikiPDFExporter implements IRunnableWithProgress {
 
     List list = visitor.getList();
     Collections.sort(list, new IFileComparator());
-    IFile file;
+    IFile file = null;
 
     FileOutputStream os = null;
     String pdffilename = fPath.toString();
@@ -243,11 +243,16 @@ public final class WikiPDFExporter implements IRunnableWithProgress {
             monitor.worked(1);
           }
         } catch (Exception e) {
-          addError("PDF export exception", e);
+          String error = "PDF export exception: "+e.getMessage();
+          if (file!=null) {
+            error = file.getLocation().toString()+" - "+e.getMessage();
+          }
+          addError(error, e);
         }
       }
     } catch (Exception e) {
-      addError("PDF export exception", e);
+      String error = "PDF export exception: "+e.getMessage();
+      addError(error, e);
     } finally {
       document.close();
       if (pdfWriter != null) {