1 package net.sourceforge.phpeclipse.wiki.actions;
3 import java.util.ArrayList;
4 import java.util.HashSet;
6 import org.eclipse.core.resources.IFile;
7 import org.eclipse.core.runtime.jobs.Job;
8 import org.eclipse.jface.text.IDocument;
9 import org.eclipse.ui.IFileEditorInput;
11 public final class CreateFilesFromLinksEditorAction extends OpenWikiLinkEditorAction {
13 public void openWikiLinkOnSelection() {
14 IDocument doc = getDocument();
15 // ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
16 // int pos = selection.getOffset();
17 ArrayList startPositionList = new ArrayList();
18 char[] text = doc.get().toCharArray();
34 if (ch == ']' && startPos != (-1)) {
35 startPositionList.add(new Integer(startPos));
44 } catch (IndexOutOfBoundsException e) {
47 HashSet wikiNames = new HashSet();
48 ArrayList filesList = new ArrayList();
51 IFile currentFile = ((IFileEditorInput) editor.getEditorInput()).getFile();
52 for (int i = 0; i < startPositionList.size(); i++) {
53 posInteger = (Integer) startPositionList.get(i);
54 str = getWikiString(editor, doc, posInteger.intValue());
56 if (str != null && !str.equals("")) {
57 if (!wikiNames.contains(str)) {
58 IFile file = getWikiFile(currentFile, str);
65 if (filesList.size() > 0) {
66 IFile[] files = new IFile[filesList.size()];
67 filesList.toArray(files);
69 Job job = new CreateFilesJob(files);
70 // job.setRule(createRule(files));
77 // Iterator iter = wikiNames.iterator();
78 // while (iter.hasNext()) {
79 // openWikiFile(file, (String) iter.next(), false);
83 // public void openWikiFile(IFile cfile, String word, boolean openEditor) {
84 // if (word != null && !word.equals("")) {
85 // IFile file = getWikiFile(cfile, word);
87 // createNewFileIfNeeded(file, word);
88 // } catch (Exception e) {