use of org.eclipse.ui.part.FileEditorInput in project linuxtools by eclipse.
the class ChangeLogAction method getDocumentLocation.
protected String getDocumentLocation(IEditorPart currentEditor, boolean appendRoot) {
IFile loc = getDocumentIFile(currentEditor);
IEditorInput cc = null;
String WorkspaceRoot;
IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
if (currentEditor instanceof MultiPageEditorPart) {
Object ed = ((MultiPageEditorPart) currentEditor).getSelectedPage();
if (ed instanceof IEditorPart)
cc = ((IEditorPart) ed).getEditorInput();
if (cc instanceof FileEditorInput)
return (appendRoot) ? WorkspaceRoot + ((FileEditorInput) cc).getFile().getFullPath().toOSString() : ((FileEditorInput) cc).getFile().getFullPath().toOSString();
}
cc = currentEditor.getEditorInput();
if (cc == null)
return "";
if ((cc instanceof SyncInfoCompareInput) || (cc instanceof CompareEditorInput)) {
CompareEditorInput test = (CompareEditorInput) cc;
if (test.getCompareResult() == null) {
return "";
} else if (test.getCompareResult() instanceof ICompareInput) {
ITypedElement leftCompare = ((ICompareInput) test.getCompareResult()).getLeft();
if (leftCompare instanceof IResourceProvider) {
String localPath = ((IResourceProvider) leftCompare).getResource().getFullPath().toString();
if (appendRoot) {
return WorkspaceRoot + localPath;
}
return localPath;
}
} else {
if (appendRoot)
return WorkspaceRoot + test.getCompareResult().toString();
return test.getCompareResult().toString();
}
} else if (cc instanceof FileStoreEditorInput) {
return ((FileStoreEditorInput) cc).getName();
}
if (appendRoot) {
return WorkspaceRoot + loc.getFullPath().toOSString();
} else if (loc != null) {
return loc.getFullPath().toOSString();
} else {
return "";
}
}
use of org.eclipse.ui.part.FileEditorInput in project linuxtools by eclipse.
the class FileTestCase method newFile.
protected void newFile(String contents) {
try {
testFile.setContents(new ByteArrayInputStream(contents.getBytes()), false, false, null);
} catch (CoreException e) {
fail(e.getMessage());
}
testDocument = new Document(contents);
fei = new FileEditorInput(testFile);
try {
SpecfileEditor.getSpecfileDocumentProvider().disconnect(fei);
SpecfileEditor.getSpecfileDocumentProvider().connect(fei);
} catch (CoreException e) {
// let failures occur
}
errorHandler = new SpecfileErrorHandler(fei, testDocument);
parser.setErrorHandler(errorHandler);
specfile = parser.parse(testDocument);
}
use of org.eclipse.ui.part.FileEditorInput in project linuxtools by eclipse.
the class STLink2SourceSupport method findFileInCommonSourceLookup.
private static IEditorInput findFileInCommonSourceLookup(IPath path) {
try {
AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
ISourceContainer[] c = director.getSourceContainers();
for (ISourceContainer sourceContainer : c) {
Object[] o = sourceContainer.findSourceElements(path.toOSString());
for (Object object : o) {
if (object instanceof IFile) {
return new FileEditorInput((IFile) object);
} else if (object instanceof LocalFileStorage) {
LocalFileStorage storage = (LocalFileStorage) object;
IFileStore ifs = EFS.getStore(storage.getFile().toURI());
return new FileStoreEditorInput(ifs);
}
}
}
} catch (CoreException e) {
// do nothing
}
return null;
}
use of org.eclipse.ui.part.FileEditorInput in project knime-core by knime.
the class MoveModelProvider method validateChange.
/**
* Checks if a KNIIME workflow project is intended to be renamed. The reason
* is, that at the moment the KNIME core saves an absolute path for storage
* reasons. If renamed save actions would fail.
*
* @see org.eclipse.core.resources.mapping.ModelProvider#
* validateChange(org.eclipse.core.resources.IResourceDelta,
* org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public IStatus validateChange(final IResourceDelta delta, final IProgressMonitor monitor) {
try {
// check whether this is a knime project
IProject project = null;
IFile workflowFile = null;
for (IResourceDelta affectedChild : delta.getAffectedChildren()) {
project = affectedChild.getResource().getProject();
workflowFile = project.getFile(WorkflowPersistor.WORKFLOW_FILE);
// break if we found the project with a knime workflow
if (workflowFile.exists()) {
break;
}
}
// check whether this is a move delta
IResourceDelta[] deltas = delta.getAffectedChildren();
boolean moveAction = false;
for (IResourceDelta curDelta : deltas) {
if ((curDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
moveAction = true;
break;
}
}
if (workflowFile.exists() && moveAction) {
// check if an editor is opened on this resource
boolean editorOpen = false;
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
IEditorPart editorPart = page.findEditor(new FileEditorInput(workflowFile));
if (editorPart != null) {
editorOpen = true;
break;
}
}
}
if (editorOpen) {
return new ModelStatus(IStatus.WARNING, ResourcesPlugin.PI_RESOURCES, getModelProviderId(), "Renaming " + project.getName() + " may have undesirable side effects " + "since this workflow is currently open." + " You may loose some or all of your " + "data if you continue (although the " + "settings will" + " not be affected). Consider closing the " + "workflow before renaming it.");
}
}
} catch (Exception e) {
// do nothing
}
// else performe the default behavior
return super.validateChange(delta, monitor);
}
use of org.eclipse.ui.part.FileEditorInput in project yamcs-studio by yamcs.
the class OPIEditor method doSaveAs.
/**
* {@inheritDoc}
*/
@Override
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getEditorSite().getShell());
if (getEditorInput() instanceof FileEditorInput)
saveAsDialog.setOriginalFile(((FileEditorInput) getEditorInput()).getFile());
else if (getEditorInput() instanceof FileStoreEditorInput)
saveAsDialog.setOriginalName(((FileStoreEditorInput) getEditorInput()).getName());
int ret = saveAsDialog.open();
try {
if (ret == Window.OK) {
IPath targetPath = saveAsDialog.getResult();
IFile targetFile = ResourcesPlugin.getWorkspace().getRoot().getFile(targetPath);
if (!targetFile.exists()) {
targetFile.create(null, true, null);
}
FileEditorInput editorInput = new FileEditorInput(targetFile);
setInput(editorInput);
setPartName(targetFile.getName());
performSave();
}
} catch (CoreException e) {
MessageDialog.openError(getSite().getShell(), "IO Error", e.getMessage());
// $NON-NLS-1$
OPIBuilderPlugin.getLogger().log(Level.WARNING, "File save error", e);
}
}
Aggregations