Search in sources :

Example 1 with AbstractLayoutEditpart

use of org.csstudio.opibuilder.editparts.AbstractLayoutEditpart 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;
}
Also used : OPIEditor(org.csstudio.opibuilder.editor.OPIEditor) CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AbstractLayoutEditpart(org.csstudio.opibuilder.editparts.AbstractLayoutEditpart)

Example 2 with AbstractLayoutEditpart

use of org.csstudio.opibuilder.editparts.AbstractLayoutEditpart in project yamcs-studio by yamcs.

the class LinkingContainerEditpart method layout.

@Override
public void layout() {
    AbstractLayoutEditpart layoutter = getLayoutWidget();
    if (layoutter != null && layoutter.getWidgetModel().isEnabled()) {
        List<AbstractWidgetModel> modelChildren = new ArrayList<AbstractWidgetModel>();
        for (Object child : getChildren()) {
            if (child instanceof AbstractBaseEditPart && !(child instanceof AbstractLayoutEditpart)) {
                modelChildren.add(((AbstractBaseEditPart) child).getWidgetModel());
            }
        }
        layoutter.layout(modelChildren, getFigure().getClientArea());
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) ArrayList(java.util.ArrayList) AbstractLayoutEditpart(org.csstudio.opibuilder.editparts.AbstractLayoutEditpart)

Example 3 with AbstractLayoutEditpart

use of org.csstudio.opibuilder.editparts.AbstractLayoutEditpart in project yamcs-studio by yamcs.

the class LayoutWidgetsAction method run.

@Override
public void run(IAction action) {
    AbstractLayoutEditpart layoutWidget = getLayoutWidget();
    LayoutWidgetsImp.run(layoutWidget, getCommandStack());
}
Also used : AbstractLayoutEditpart(org.csstudio.opibuilder.editparts.AbstractLayoutEditpart)

Aggregations

AbstractLayoutEditpart (org.csstudio.opibuilder.editparts.AbstractLayoutEditpart)3 ArrayList (java.util.ArrayList)1 OPIEditor (org.csstudio.opibuilder.editor.OPIEditor)1 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1