''Open Wiki link'' and ''Create Files for Wiki link'' every new created file creates...
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / actions / mediawiki / RefreshJob.java
index bda1e0a..e3e72e8 100644 (file)
@@ -57,9 +57,30 @@ public class RefreshJob extends WorkspaceJob {
       HashMap map = new HashMap();
       String wikiTitle;
       for (int i = 0; i < files.length; i++) {
-        wikiTitle = Util.getReadableWikiName(files[i]);
+        wikiTitle = null;
+        file = files[i];
+        String srcBasePath = Util.getWikiTextsPath(file);
+        String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH);
+
+        String fileXMLName = Util.getXMLFileName(file, binBasePath, srcBasePath);
+        IPath path = new Path(fileXMLName);
+        IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+        if (xmlFile.exists()) {
+          try {
+            Page page = XStreamManager.fromXML(xmlFile.getContents());
+            if (page != null) {
+              wikiTitle = page.getTitle();
+            }
+            //                timestamp = XMLReader.getDateTimestamp(xmlFile.getContents());
+          } catch (Exception e2) {
+          }
+        }
+        if (wikiTitle==null) {
+          // if no XML file exists we create the name from the filename
+          wikiTitle = Util.getReadableWikiName(files[i]);
+        }
         buffer.append(wikiTitle);
-        map.put(wikiTitle, files[i]);
+        map.put(wikiTitle, file);
         if (i != files.length - 1) {
           buffer.append("\n");
         }