Search in sources :

Example 1 with XSDAttributeDeclarationAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter in project webtools.sourceediting by eclipse.

the class XSDBaseFieldEditPart method directEditNameField.

protected void directEditNameField() {
    Object model = getModel();
    IFieldFigure fieldFigure = getFieldFigure();
    if (model instanceof IField) {
        IField field = (IField) model;
        if (field.isReference()) {
            ReferenceDirectEditManager manager = null;
            if (field instanceof XSDElementDeclarationAdapter) {
                manager = new ElementReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel());
            } else if (field instanceof XSDAttributeDeclarationAdapter) {
                manager = new AttributeReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel());
            }
            if (manager != null) {
                ReferenceUpdateCommand elementUpdateCommand = new ReferenceUpdateCommand();
                elementUpdateCommand.setDelegate(manager);
                adtDirectEditPolicy.setUpdateCommand(elementUpdateCommand);
                manager.show();
            }
        } else {
            LabelEditManager manager = new LabelEditManager(this, new LabelCellEditorLocator(this, null));
            NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper();
            adtDirectEditPolicy.setUpdateCommand(wrapper);
            manager.show();
        }
    }
}
Also used : ElementReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager) LabelEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager) XSDAttributeDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter) LabelCellEditorLocator(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator) IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) AttributeReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.AttributeReferenceDirectEditManager) XSDElementDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter) AttributeReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.AttributeReferenceDirectEditManager) ReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ReferenceDirectEditManager) ElementReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager)

Example 2 with XSDAttributeDeclarationAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter in project webtools.sourceediting by eclipse.

the class KeyboardDragImpl method performKeyboardDrag.

public void performKeyboardDrag(GraphicalEditPart movingElement, int direction) {
    KeyBoardAccessibilityEditPolicy policy = (KeyBoardAccessibilityEditPolicy) movingElement.getEditPolicy(KeyBoardAccessibilityEditPolicy.KEY);
    EditPart rightElement = policy.getRelativeEditPart(movingElement, direction);
    policy = (KeyBoardAccessibilityEditPolicy) rightElement.getEditPolicy(KeyBoardAccessibilityEditPolicy.KEY);
    EditPart leftElement = (policy != null) ? policy.getRelativeEditPart(rightElement, direction) : null;
    // TODO: add support for extenders
    if (!(movingElement instanceof XSDBaseFieldEditPart))
        return;
    XSDBaseFieldEditPart movingField = (XSDBaseFieldEditPart) movingElement;
    XSDBaseFieldEditPart leftField = (XSDBaseFieldEditPart) leftElement;
    XSDBaseFieldEditPart rightField = (XSDBaseFieldEditPart) rightElement;
    Object movingObject = movingField.getModel();
    BaseDragAndDropCommand command = null;
    if (movingObject instanceof XSDElementDeclarationAdapter || movingObject instanceof XSDWildcard) {
        command = new XSDElementDragAndDropCommand(movingField, leftField, rightField, direction);
    } else if (movingObject instanceof XSDAttributeDeclarationAdapter) {
        command = new XSDAttributeDragAndDropCommand(movingField, leftField, rightField, direction);
    }
    if (command != null && command.canExecute()) {
        command.execute();
        // This is to reselect the moved item
        try {
            IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
            if (editor != null && editor.getAdapter(ISelectionProvider.class) != null) {
                ISelectionProvider provider = (ISelectionProvider) editor.getAdapter(ISelectionProvider.class);
                if (provider != null) {
                    provider.setSelection(new StructuredSelection(movingElement.getModel()));
                }
            }
        } catch (Exception e) {
        }
    }
}
Also used : KeyBoardAccessibilityEditPolicy(org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) XSDAttributeDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) XSDWildcard(org.eclipse.xsd.XSDWildcard) IEditorPart(org.eclipse.ui.IEditorPart) XSDAttributeDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.XSDAttributeDragAndDropCommand) XSDElementDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter) XSDElementDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.XSDElementDragAndDropCommand) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) BaseDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand)

Example 3 with XSDAttributeDeclarationAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter in project webtools.sourceediting by eclipse.

the class XSDAttributeDragAndDropCommand method setup.

protected void setup() {
    canExecute = false;
    // Drop target is attribute group ref
    if (target instanceof AttributeGroupDefinitionEditPart) {
        parentEditPart = (AttributeGroupDefinitionEditPart) target;
        if (((GenericGroupFigure) parentEditPart.getFigure()).getIconFigure().getBounds().contains(location)) {
            xsdComponentToDrag = (XSDConcreteComponent) ((XSDAttributeDeclarationAdapter) itemToDrag.getModel()).getTarget();
            action = new MoveXSDAttributeAction(((AttributeGroupDefinitionEditPart) parentEditPart).getXSDAttributeGroupDefinition(), xsdComponentToDrag, null, null);
            canExecute = action.canMove();
        }
    } else if (target instanceof BaseFieldEditPart) {
        targetSpacesList = new ArrayList();
        // Calculate the list of all sibling field edit parts;
        List targetEditPartSiblings = calculateFieldEditParts();
        calculateAttributeGroupList();
        // Get 'left' and 'right' siblings
        doDrop(targetEditPartSiblings, itemToDrag);
    }
}
Also used : MoveXSDAttributeAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction) GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) XSDAttributeDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter) AttributeGroupDefinitionEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 4 with XSDAttributeDeclarationAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter in project webtools.sourceediting by eclipse.

the class XSDAttributeDragAndDropCommand method getElement.

/*
   * (non-Javadoc)
   * @see org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand#getElement()
   */
protected Element getElement() {
    XSDAttributeDeclarationAdapter adapter = (XSDAttributeDeclarationAdapter) itemToDrag.getModel();
    XSDAttributeDeclaration target = (XSDAttributeDeclaration) adapter.getTarget();
    XSDConcreteComponent parent = (XSDConcreteComponent) target.eContainer();
    return parent.getElement();
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDAttributeDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Aggregations

XSDAttributeDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter)4 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)2 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IEditorPart (org.eclipse.ui.IEditorPart)1 MoveXSDAttributeAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction)1 AttributeReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.AttributeReferenceDirectEditManager)1 ElementReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager)1 LabelCellEditorLocator (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator)1 LabelEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager)1 ReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ReferenceDirectEditManager)1 BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)1 KeyBoardAccessibilityEditPolicy (org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy)1 IFieldFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)1 IField (org.eclipse.wst.xsd.ui.internal.adt.facade.IField)1