use of org.eclipse.ui.ide.FileStoreEditorInput 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.ide.FileStoreEditorInput 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
}
}
}
}
Aggregations