Search in sources :

Example 6 with DisplayEditpart

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

the class SelectParentHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    GraphicalViewer viewer = HandlerUtil.getActivePart(event).getAdapter(GraphicalViewer.class);
    if (viewer == null)
        return null;
    ISelection currentSelection = viewer.getSelection();
    if (currentSelection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) currentSelection).getFirstElement();
        if (element instanceof AbstractBaseEditPart && !(element instanceof DisplayEditpart)) {
            if (((AbstractBaseEditPart) element).getParent().isSelectable())
                ((AbstractBaseEditPart) element).getViewer().select(((AbstractBaseEditPart) element).getParent());
            else
                ConsoleUtil.writeWarning("Parent of the selected widget is unselectable. Its grandparent may be locked.");
        }
    }
    return null;
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisplayEditpart(org.csstudio.opibuilder.editparts.DisplayEditpart)

Aggregations

AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)6 DisplayEditpart (org.csstudio.opibuilder.editparts.DisplayEditpart)6 ArrayList (java.util.ArrayList)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)3 EventObject (java.util.EventObject)1 SetBoundsCommand (org.csstudio.opibuilder.commands.SetBoundsCommand)1 AbstractContainerEditpart (org.csstudio.opibuilder.editparts.AbstractContainerEditpart)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 Command (org.eclipse.gef.commands.Command)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1