import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.texteditor.AbstractTextEditor;
-public final class OpenWikiLinkEditorAction implements IEditorActionDelegate {
+public class OpenWikiLinkEditorAction implements IEditorActionDelegate {
- private IWorkbenchWindow window;
+ protected IWorkbenchWindow window;
- private AbstractTextEditor editor;
+ protected AbstractTextEditor editor;
public void dispose() {
}
String textRegion = getWikiString(editor, doc, pos);
IFileEditorInput ei = (IFileEditorInput) editor.getEditorInput();
- openWikiFile(ei.getFile(), textRegion);
+ openWikiFile(ei.getFile(), textRegion, true);
}
- public static void openWikiUrl(IProject project, String word) {
+ public void openWikiUrl(IProject project, String word) {
if (word != null && !word.equals("")) {
IFile cfile = project.getFile("dummy.wp");
IFile file = getWikiFile(cfile, word);
}
}
- public static void openWikiFile(IFile cfile, String word) {
+ protected void openWikiFile(IFile cfile, String word, boolean openEditor) {
if (word != null && !word.equals("")) {
IFile file = getWikiFile(cfile, word);
try {
}
}
- private static void createNewFileIfNeeded(IFile file, String word) throws CoreException {
+ protected void createNewFileIfNeeded(IFile file, String word) throws CoreException {
if (!file.exists()) {
- createWikiFile(file, word);
+ createWikiFile(file);
}
}
- private static IFile getWikiFile(IFile file, String word) {
+ protected IFile getWikiFile(IFile file, String word) {
String wikiFileName = Util.getWikiFileName(word, file, WikiEditorPlugin.HTML_OUTPUT_PATH);
IPath path = new Path(wikiFileName);
return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
}
}
- private static void createWikiFile(IFile file, String word) throws CoreException {
+ private void createWikiFile(IFile file) throws CoreException {
IContainer parent = file.getParent();
if (parent instanceof IFolder && (!((IFolder) parent).exists())) {
createFolder((IFolder) parent, null);
}
- String newText = "<!--" + word + "-->";
+ String newText = WikiEditorPlugin.AUTOMATICALLY_CREATED;
byte[] buffer = newText.getBytes();
ByteArrayInputStream source = new ByteArrayInputStream(buffer);
file.create(source, true, null);