use of org.eclipse.core.resources.IWorkspace in project eclipse.platform.text by eclipse.
the class FileDocumentProvider method handleElementMoved.
/**
* Sends out the notification that the file serving as document input has been moved.
*
* @param fileEditorInput the input of an text editor
* @param path the path of the new location of the file
*/
protected void handleElementMoved(IFileEditorInput fileEditorInput, IPath path) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile newFile = workspace.getRoot().getFile(path);
fireElementMoved(fileEditorInput, new FileEditorInput(newFile));
}
use of org.eclipse.core.resources.IWorkspace in project eclipse.platform.text by eclipse.
the class FileDocumentProvider method doValidateState.
@Override
protected void doValidateState(Object element, Object computationContext) throws CoreException {
if (element instanceof IFileEditorInput) {
IFileEditorInput input = (IFileEditorInput) element;
FileInfo info = (FileInfo) getElementInfo(input);
if (info != null) {
IFile file = input.getFile();
if (file.isReadOnly()) {
// do not use cached state here
IWorkspace workspace = file.getWorkspace();
info.fStatus = workspace.validateEdit(new IFile[] { file }, computationContext);
}
if (isDerived(file)) {
IStatus status = new Status(IStatus.WARNING, EditorsUI.PLUGIN_ID, EditorsUI.DERIVED_FILE, TextEditorMessages.FileDocumentProvider_warning_fileIsDerived, null);
if (info.fStatus == null || info.fStatus.isOK())
info.fStatus = status;
else
info.fStatus = new MultiStatus(EditorsUI.PLUGIN_ID, EditorsUI.STATE_VALIDATION_FAILED, new IStatus[] { info.fStatus, status }, TextEditorMessages.FileDocumentProvider_stateValidationFailed, null);
}
}
}
super.doValidateState(element, computationContext);
}
use of org.eclipse.core.resources.IWorkspace in project eclipse.platform.text by eclipse.
the class ResourceHelper method createLinkedProject.
public static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
IProjectDescription desc = workspace.newProjectDescription(projectName);
File file = FileTool.getFileInPlugin(plugin, linkPath);
IPath projectLocation = new Path(file.getAbsolutePath());
if (Platform.getLocation().equals(projectLocation))
projectLocation = null;
desc.setLocation(projectLocation);
project.create(desc, NULL_MONITOR);
if (!project.isOpen())
project.open(NULL_MONITOR);
return project;
}
use of org.eclipse.core.resources.IWorkspace in project eclipse.platform.text by eclipse.
the class NatureLabelHoverProvider method getHoverInfo.
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
String contents = textViewer.getDocument().get();
int offset = hoverRegion.getOffset();
int endIndex = contents.indexOf("</nature>", offset);
if (endIndex == -1)
return "";
int startIndex = contents.substring(0, offset).lastIndexOf("<nature>");
if (startIndex == -1)
return "";
String selection = contents.substring(startIndex + "<nature>".length(), endIndex);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectNatureDescriptor[] natureDescriptors = workspace.getNatureDescriptors();
for (int i = 0; i < natureDescriptors.length; i++) {
if (natureDescriptors[i].getNatureId().equals(selection))
return natureDescriptors[i].getLabel();
}
return null;
}
use of org.eclipse.core.resources.IWorkspace in project eclipse.platform.text by eclipse.
the class ResourceHelper method createLinkedProject.
public static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
IProjectDescription desc = workspace.newProjectDescription(projectName);
File file = FileTool.getFileInPlugin(plugin, linkPath);
IPath projectLocation = new Path(file.getAbsolutePath());
if (Platform.getLocation().equals(projectLocation))
projectLocation = null;
desc.setLocation(projectLocation);
project.create(desc, NULL_MONITOR);
if (!project.isOpen())
project.open(NULL_MONITOR);
return project;
}
Aggregations