import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
import net.sourceforge.phpeclipse.wiki.preferences.Util;
+import net.sourceforge.phpeclipse.wiki.xml.Page;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
public class CreateFilesJob extends WorkspaceJob {
IFile[] files;
+ String[] wikiTitles;
- public CreateFilesJob(IFile[] files) {
+ public CreateFilesJob(IFile[] files, String[] wikiTitles) {
super("Create Wiki Files Job");
this.files = files;
+ this.wikiTitles = wikiTitles;
}
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
monitor.beginTask("Create Wiki Files", 100);
IFile file;
+ String wikiTitle;
int partOfWork = 100 / files.length;
int work = 0;
String newText = WikiEditorPlugin.AUTOMATICALLY_CREATED;
byte[] buffer = newText.getBytes();
ByteArrayInputStream source = new ByteArrayInputStream(buffer);
ProblemConsole console = new ProblemConsole();
+ boolean showConsole = WikiEditorPlugin.getDefault().getPreferenceStore().getBoolean(WikiEditorPlugin.CONSOLE_OUTPUT);
+
for (int i = 0; i < files.length; i++) {
file = files[i];
+ wikiTitle = wikiTitles[i];
IContainer parent = file.getParent();
if (parent instanceof IFolder && (!((IFolder) parent).exists())) {
}
try {
if (!file.exists()) {
+ monitor.subTask("Create File: "+file.getLocation().toString());
file.create(source, true, monitor);
+ Page page = new Page("", wikiTitle, "");
+ page.createXMLFile(file, false);
+ if (showConsole) {
+ console.println("Title: "+wikiTitle+" =>File: " + file.getLocation().toString() + "created\n");
+ }
} else {
- console.println("File: " + file.getLocation().toString() + "\n==>file already exists!");
+ String message = "File: " + file.getLocation().toString() + "\n==>file already exists!";
+ monitor.subTask(message);
+ console.println(message);
}
} catch (CoreException e) {
if (file != null) {
if (isModal(this)) {
// The progress dialog is still open show the message
- console.reportError();
} else {
setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
// setProperty(IProgressConstants.ACTION_PROPERTY, getWikisCompletedAction());