use of org.eclipse.ui.IFileEditorInput in project bndtools by bndtools.
the class PrivatePackagesPart method getJavaProject.
private IJavaProject getJavaProject() {
IFormPage page = (IFormPage) getManagedForm().getContainer();
IEditorInput input = page.getEditorInput();
if (!IFileEditorInput.class.isInstance(input)) {
return null;
}
IProject project = ((IFileEditorInput) input).getFile().getProject();
return JavaCore.create(project);
}
use of org.eclipse.ui.IFileEditorInput in project KaiZen-OpenAPI-Editor by RepreZen.
the class QuickOutline method handleMultiView.
protected void handleMultiView() {
currentScope = currentScope.next();
SwaggerFileFinder fileFinder = new SwaggerFileFinder(fileContentType);
IEditorInput input = editor.getEditorInput();
IFile currentFile = null;
if (input instanceof IFileEditorInput) {
currentFile = ((IFileEditorInput) input).getFile();
}
Iterable<IFile> files = fileFinder.collectFiles(currentScope, currentFile);
setInfoText(statusMessage());
if (currentScope == Scope.LOCAL) {
treeViewer.setAutoExpandLevel(2);
} else {
treeViewer.setAutoExpandLevel(0);
}
setInput(Model.parseYaml(files, getSchema()));
}
use of org.eclipse.ui.IFileEditorInput in project tdi-studio-se by Talend.
the class CpuDumpEditor method init.
/*
* @see MultiPageEditorPart#init(IEditorSite, IEditorInput)
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
cpuModel = new CpuModelFactory().createCpuModel();
cpuModel.addModelChangeListener(new ICpuModelChangeListener() {
@Override
public void modelChanged(CpuModelEvent event) {
if (event.state == CpuModelState.CallersCalleesTargetChanged) {
refresh();
if (cpuModel.getCallersCalleesTarget() != null) {
showCallerCalleeTab();
}
}
}
});
setPartName(input.getName());
if (input instanceof IFileEditorInput) {
String filePath = ((IFileEditorInput) input).getFile().getRawLocation().toOSString();
loadDumpFile(filePath);
} else if (input instanceof FileStoreEditorInput) {
String filePath = ((FileStoreEditorInput) input).getURI().getPath();
loadDumpFile(filePath);
}
}
use of org.eclipse.ui.IFileEditorInput in project tdi-studio-se by Talend.
the class InfoPage method doSave.
/**
* Saves the changed editor contents.
*
* @param monitor The progress monitor
*/
protected void doSave(IProgressMonitor monitor) {
IEditorInput input = editor.getEditorInput();
IFile resourceFile = null;
File file = null;
InputStream inputStream = null;
String comments = commentsText.getText();
try {
if (input instanceof IFileEditorInput) {
resourceFile = ((IFileEditorInput) input).getFile();
inputStream = new BufferedInputStream(resourceFile.getContents());
file = resourceFile.getRawLocation().toFile();
} else if (input instanceof FileStoreEditorInput) {
file = new File(((FileStoreEditorInput) input).getURI().getPath());
inputStream = new FileInputStream(file);
} else {
return;
}
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
Element root = document.getDocumentElement();
//$NON-NLS-1$
root.setAttribute("comments", comments);
DOMSource source = new DOMSource(root);
StreamResult result = new StreamResult(file);
TransformerFactory.newInstance().newTransformer().transform(source, result);
if (resourceFile != null) {
resourceFile.refreshLocal(0, monitor);
}
lastComments = comments;
editor.firePropertyChange(IEditorPart.PROP_DIRTY);
} catch (CoreException e) {
Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
} catch (SAXException e) {
Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
} catch (IOException e) {
Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
} catch (ParserConfigurationException e) {
Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
} catch (TransformerException e) {
Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// do nothing
}
}
}
}
use of org.eclipse.ui.IFileEditorInput in project bndtools by bndtools.
the class BndEditor method getFileAndProject.
static Pair<String, String> getFileAndProject(IEditorInput input) {
String path;
String projectName;
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
path = file.getProjectRelativePath().toString();
projectName = file.getProject().getName();
} else {
path = input.getName();
projectName = null;
}
return Pair.newInstance(path, projectName);
}
Aggregations