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();
}
}
}
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) {
}
}
}
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);
}
}
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();
}
Aggregations