Search in sources :

Example 1 with LocationRequest

use of org.eclipse.gef.requests.LocationRequest in project whole by wholeplatform.

the class E4TreeViewer method createControl.

@Override
public Control createControl(Composite parent) {
    Tree tree = (Tree) super.createControl(parent);
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent event) {
            Point point = new Point(event.x, event.y);
            EditPart editPart = findObjectAt(point);
            if (editPart != null) {
                LocationRequest request = new LocationRequest(RequestConstants.REQ_DIRECT_EDIT);
                request.setLocation(point);
                editPart.performRequest(request);
            }
        }
    });
    return tree;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) LocationRequest(org.eclipse.gef.requests.LocationRequest) MouseAdapter(org.eclipse.swt.events.MouseAdapter) EditPart(org.eclipse.gef.EditPart) Tree(org.eclipse.swt.widgets.Tree) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with LocationRequest

use of org.eclipse.gef.requests.LocationRequest in project webtools.sourceediting by eclipse.

the class XSDSimpleTypeEditPart method performRequest.

public void performRequest(Request request) {
    if (request.getType() == RequestConstants.REQ_OPEN) {
        Object model = getModel();
        if (request instanceof LocationRequest) {
            LocationRequest locationRequest = (LocationRequest) request;
            Point p = locationRequest.getLocation();
            if (getStructureFigure().hitTestHeader(p)) {
                // 
                if (model instanceof XSDSimpleTypeDefinitionAdapter) {
                    XSDSimpleTypeDefinitionAdapter adapter = (XSDSimpleTypeDefinitionAdapter) model;
                    XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) adapter.getTarget();
                    IWorkbench workbench = PlatformUI.getWorkbench();
                    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
                    IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
                    Object schema = editorPart.getAdapter(XSDSchema.class);
                    ActionRegistry registry = getEditorActionRegistry(editorPart);
                    if (registry != null) {
                        if (schema == st.getSchema()) {
                            IAction action = registry.getAction(SetInputToGraphView.ID);
                            action.run();
                        } else {
                            IAction action = registry.getAction(OpenInNewEditor.ID);
                            action.run();
                        }
                    }
                }
            }
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) XSDSimpleTypeDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDSimpleTypeDefinitionAdapter) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) LocationRequest(org.eclipse.gef.requests.LocationRequest) IAction(org.eclipse.jface.action.IAction) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Point(org.eclipse.draw2d.geometry.Point) IEditorPart(org.eclipse.ui.IEditorPart) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry)

Example 3 with LocationRequest

use of org.eclipse.gef.requests.LocationRequest in project webtools.sourceediting by eclipse.

the class TopLevelComponentEditPart method performRequest.

public void performRequest(Request request) {
    // Do not open on or set focus on direct edit type
    if (request.getType() == RequestConstants.REQ_OPEN) {
        Object model = getModel();
        if (model instanceof IGraphElement) {
            if (((IGraphElement) model).isFocusAllowed()) {
                if (request instanceof LocationRequest) {
                    LocationRequest locationRequest = (LocationRequest) request;
                    Point p = locationRequest.getLocation();
                    if (hitTest(labelHolder, p)) {
                        performDrillDownAction();
                    }
                }
            }
        } else if (model instanceof XSDSchemaDirectiveAdapter) {
            if (request instanceof LocationRequest) {
                LocationRequest locationRequest = (LocationRequest) request;
                Point p = locationRequest.getLocation();
                if (hitTest(labelHolder, p)) {
                    XSDSchemaDirective dir = (XSDSchemaDirective) ((XSDSchemaDirectiveAdapter) model).getTarget();
                    String schemaLocation = "";
                    // force load of imported schema
                    if (dir instanceof XSDImportImpl) {
                        ((XSDImportImpl) dir).importSchema();
                    }
                    if (dir.getResolvedSchema() != null) {
                        schemaLocation = URIHelper.removePlatformResourceProtocol(dir.getResolvedSchema().getSchemaLocation());
                        if (schemaLocation != null) {
                            OpenOnSelectionHelper.openXSDEditor(dir.getResolvedSchema());
                        }
                    }
                }
            }
        }
    }
}
Also used : XSDSchemaDirectiveAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter) XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) XSDImportImpl(org.eclipse.xsd.impl.XSDImportImpl) IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) LocationRequest(org.eclipse.gef.requests.LocationRequest) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with LocationRequest

use of org.eclipse.gef.requests.LocationRequest in project archi by archimatetool.

the class SelectionTool method createHoverRequest.

/**
 * Creates the hover request (a {@link LocationRequest}) and sets its type
 * to {@link RequestConstants#REQ_SELECTION_HOVER}.
 */
protected void createHoverRequest() {
    hoverRequest = new LocationRequest();
    hoverRequest.setType(RequestConstants.REQ_SELECTION_HOVER);
}
Also used : LocationRequest(org.eclipse.gef.requests.LocationRequest)

Example 5 with LocationRequest

use of org.eclipse.gef.requests.LocationRequest in project webtools.sourceediting by eclipse.

the class BaseFieldEditPart method performRequest.

public void performRequest(Request request) {
    if (((IADTObject) getModel()).isReadOnly() || isFileReadOnly()) {
        return;
    }
    if (request.getType() == RequestConstants.REQ_DIRECT_EDIT || request.getType() == RequestConstants.REQ_OPEN) {
        IFieldFigure fieldFigure = getFieldFigure();
        Object model = getModel();
        if (request instanceof LocationRequest) {
            LocationRequest locationRequest = (LocationRequest) request;
            Point p = locationRequest.getLocation();
            if (hitTest(fieldFigure.getTypeLabel(), p)) {
                TypeReferenceDirectEditManager manager = new TypeReferenceDirectEditManager((IField) model, this, fieldFigure.getTypeLabel());
                TypeUpdateCommand typeUpdateCommand = new TypeUpdateCommand();
                typeUpdateCommand.setDelegate(manager);
                adtDirectEditPolicy.setUpdateCommand(typeUpdateCommand);
                manager.show();
            } else if (hitTest(fieldFigure.getNameLabel(), p)) {
                directEditNameField();
            }
        } else {
            directEditNameField();
        }
    }
}
Also used : TypeReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.TypeReferenceDirectEditManager) LocationRequest(org.eclipse.gef.requests.LocationRequest) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) Point(org.eclipse.draw2d.geometry.Point) IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)

Aggregations

LocationRequest (org.eclipse.gef.requests.LocationRequest)6 Point (org.eclipse.draw2d.geometry.Point)4 EditPart (org.eclipse.gef.EditPart)1 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)1 IAction (org.eclipse.jface.action.IAction)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Tree (org.eclipse.swt.widgets.Tree)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 XSDSchemaDirectiveAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter)1 XSDSimpleTypeDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDSimpleTypeDefinitionAdapter)1 TypeReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.TypeReferenceDirectEditManager)1 IGraphElement (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement)1 IFieldFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)1 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)1 XSDSchemaDirective (org.eclipse.xsd.XSDSchemaDirective)1 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)1 XSDImportImpl (org.eclipse.xsd.impl.XSDImportImpl)1