private IWorkbenchWindow window;
- private void createFolder(IFolder folderHandle, IProgressMonitor monitor) throws CoreException {
- try {
- // Create the folder resource in the workspace
- // Recursive to create any folders which do not exist already
- if (!folderHandle.exists()) {
- IContainer parent = folderHandle.getParent();
- if (parent instanceof IFolder && (!((IFolder) parent).exists())) {
- createFolder((IFolder) parent, monitor);
- }
- folderHandle.create(false, true, monitor);
- }
- } catch (CoreException e) {
- // If the folder already existed locally, just refresh to get contents
- if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
- folderHandle.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 500));
- else
- throw e;
- }
- }
-
- /**
- * Creates a folder resource handle for the folder with the given workspace path. This method does not create the folder resource;
- * this is the responsibility of <code>createFolder</code>.
- *
- * @param folderPath
- * the path of the folder resource to create a handle for
- * @return the new folder resource handle
- * @see #createFolder
- */
- private IFolder createFolderHandle(IPath folderPath) {
- return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFolder(folderPath);
- }
-
- private void createNewFileIfNeeded(IFile file, String word) throws CoreException {
- if (!file.exists()) {
- createWikiFile(file, word);
- }
- }
-
- private void createWikiFile(IFile file, String word) throws CoreException {
- IContainer parent = file.getParent();
- if (parent instanceof IFolder && (!((IFolder) parent).exists())) {
- createFolder((IFolder) parent, null);
- }
- String newText = "<!--" + word + "-->";
- byte[] buffer = newText.getBytes();
- ByteArrayInputStream source = new ByteArrayInputStream(buffer);
- file.create(source, true, null);
- }
-
public void dispose() {
}
}
private String getWikiFile(IFile file) {
- return Util.getFileWikiName(file, WikiEditorPlugin.HTML_OUTPUT_PATH);
+ return Util.getFileWikiName(file);
}
public void init(IWorkbenchWindow window) {
}
public void openWikiLinkOnSelection() {
- IDocument doc = getDocument();
- ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
- int pos = selection.getOffset();
IFileEditorInput ei = (IFileEditorInput) fEditor.getEditorInput();
openWikiFile(ei.getFile());
}