use of org.csstudio.utility.singlesource.PathEditorInput in project org.csstudio.display.builder by kasemir.
the class DataBrowserEditor method doSaveAs.
/**
* {@inheritDoc}
*/
@Override
public void doSaveAs() {
final Shell shell = getSite().getShell();
final ResourceHelper resources = SingleSourcePlugin.getResourceHelper();
final IPath original = resources.getPath(getEditorInput());
// Prompt & save until success or cancel
while (true) {
final IPath file = SingleSourcePlugin.getUIHelper().openSaveDialog(shell, original, Model.FILE_EXTENSION);
if (file == null)
return;
try {
final PathEditorInput new_input = new PathEditorInput(file);
try (final OutputStream stream = resources.getOutputStream(new_input)) {
save(new NullProgressMonitor(), stream);
}
// Set that file as editor's input, so that just 'save' instead of
// 'save as' is possible from now on
final DataBrowserModelEditorInput db_input = new DataBrowserModelEditorInput(new_input, model);
setInput(db_input);
setPartName(db_input.getName());
setTitleToolTip(db_input.getToolTipText());
return;
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(getSite().getShell(), Messages.Error, ex);
}
}
}
use of org.csstudio.utility.singlesource.PathEditorInput in project org.csstudio.display.builder by kasemir.
the class OpenDisplayFile method openDisplay.
/**
* {@inheritDoc}
*/
@Override
public void openDisplay(final String path, final String data) throws Exception {
final Model model = new Model();
// Read file
final ResourceHelper resources = SingleSourcePlugin.getResourceHelper();
final IPath ipath = resources.newPath(path);
try (final InputStream stream = resources.getInputStream(ipath)) {
new XMLPersistence().load(model, stream);
}
final IEditorInput input = new DataBrowserModelEditorInput(new PathEditorInput(ipath), model);
// Create new editor
final DataBrowserEditor editor = DataBrowserEditor.createInstance(input);
if (editor == null)
throw new Exception("Cannot create Data Browser");
}
use of org.csstudio.utility.singlesource.PathEditorInput in project org.csstudio.display.builder by kasemir.
the class OpenDataBrowserAction method run.
@Override
public void run() {
IPath filename;
try {
filename = SingleSourcePlugin.getResourceHelper().newPath(widget.getExpandedFilename());
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot determine path", ex);
return;
}
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
final IEditorInput input = new PathEditorInput(filename);
final DataBrowserModelEditorInput model_input = new DataBrowserModelEditorInput(input, widget.cloneModel());
page.openEditor(model_input, DataBrowserEditor.ID, true);
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(page.getActivePart().getSite().getShell(), Messages.Error, NLS.bind(Messages.OpenDataBrowserErrorFmt, filename.toString()), ex);
}
}
use of org.csstudio.utility.singlesource.PathEditorInput in project org.csstudio.display.builder by kasemir.
the class OpenDataBrowserAction method run.
@Override
public void run() {
final DataBrowserWidgedModel model = edit_part.getWidgetModel();
IPath filename = model.getExpandedFilename();
if (!filename.isAbsolute())
filename = ResourceUtil.buildAbsolutePath(model, filename);
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
final IEditorInput input = new PathEditorInput(filename);
final DataBrowserModelEditorInput model_input = new DataBrowserModelEditorInput(input, model.createDataBrowserModel());
page.openEditor(model_input, DataBrowserEditor.ID, true);
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(page.getActivePart().getSite().getShell(), Messages.Error, NLS.bind(Messages.OpenDataBrowserErrorFmt, filename.toString()), ex);
}
}
Aggregations