use of org.csstudio.opibuilder.editor.OPIEditor in project yamcs-studio by yamcs.
the class CopyWidgetsAction method run.
@Override
public void run() {
DisplayModel tempModel = new DisplayModel();
List<AbstractWidgetModel> widgetModels = getSelectedWidgetModels();
for (AbstractWidgetModel widget : widgetModels) {
tempModel.addChild(widget, false);
}
String xml = XMLUtil.widgetToXMLString(tempModel, false);
((OPIEditor) getWorkbenchPart()).getClipboard().setContents(new Object[] { xml }, new Transfer[] { OPIWidgetsTransfer.getInstance() });
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
IAction pasteAction = ((ActionRegistry) ((OPIEditor) getWorkbenchPart()).getAdapter(ActionRegistry.class)).getAction(ActionFactory.PASTE.getId());
if (pasteAction != null) {
((PasteWidgetsAction) pasteAction).refreshEnable();
}
}
});
}
use of org.csstudio.opibuilder.editor.OPIEditor in project yamcs-studio by yamcs.
the class LayoutWidgetsHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart activeEditor = page.getActiveEditor();
if (activeEditor instanceof OPIEditor) {
ISelection currentSelection = ((GraphicalViewer) ((OPIEditor) activeEditor).getAdapter(GraphicalViewer.class)).getSelection();
if (currentSelection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) currentSelection).getFirstElement();
if (element instanceof AbstractLayoutEditpart) {
CommandStack commandStack = (CommandStack) ((OPIEditor) activeEditor).getAdapter(CommandStack.class);
if (commandStack != null)
LayoutWidgetsImp.run((AbstractLayoutEditpart) element, commandStack);
}
}
} else {
return null;
}
return null;
}
use of org.csstudio.opibuilder.editor.OPIEditor in project yamcs-studio by yamcs.
the class RunOPIAction method run.
@Override
public void run() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IEditorPart activeEditor = page.getActiveEditor();
if (activeEditor != null) {
// TODO: Should perform the 'save' in background, then return to UI thread when done..
if (PreferencesHelper.isAutoSaveBeforeRunning() && activeEditor.isDirty()) {
activeEditor.doSave(null);
}
}
if (runtime_page == null) {
// (Re-)create runtime window
runtime_page = createRuntimePage();
} else {
runtime_page.getWorkbenchWindow().getShell().setActive();
}
if (activeEditor instanceof OPIEditor) {
// DisplayModel displayModel = ((OPIEditor) activeEditor).getDisplayModel();
// Rectangle bounds = new Rectangle(displayModel.getLocation(), displayModel.getSize());
IEditorInput input = activeEditor.getEditorInput();
IPath path = ResourceUtil.getPathInEditor(input);
RunnerInput new_input = new RunnerInput(path, null);
// because RunModeService would only pop old content back to the front.
for (IViewReference view_ref : runtime_page.getViewReferences()) {
if (view_ref.getId().startsWith(OPIView.ID)) {
IViewPart view = view_ref.getView(true);
if (view instanceof OPIView) {
OPIView opi_view = (OPIView) view;
if (new_input.equals(opi_view.getOPIInput())) {
try {
opi_view.setOPIInput(new_input);
} catch (PartInitException ex) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, "Failed to update existing runtime for " + new_input.getName(), ex);
}
break;
}
}
}
}
RunModeService.openDisplayInView(runtime_page, new_input, DisplayMode.NEW_TAB);
}
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(page.getWorkbenchWindow().getShell(), "Cannot launch display runtime", ex);
}
}
Aggregations