use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class MakeAnonymousTypeGobalHandler method doExecute.
public Object doExecute(ISelection selection, XSDSchema schema) {
if (selection != null) {
Object selectedObject = ((StructuredSelection) selection).getFirstElement();
if (selectedObject instanceof XSDBaseAdapter) {
selectedObject = ((XSDBaseAdapter) selectedObject).getTarget();
}
XSDConcreteComponent concreteComp = null;
if (selectedObject instanceof Node) {
Node node = (Node) selectedObject;
concreteComp = schema.getCorrespondingComponent(node);
} else if (selectedObject instanceof XSDConcreteComponent) {
concreteComp = ((XSDConcreteComponent) selectedObject);
}
if (concreteComp != null) {
if (concreteComp instanceof XSDComplexTypeDefinition) {
isComplexType = true;
XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) concreteComp;
XSDConcreteComponent parent = typeDef.getContainer();
if (parent instanceof XSDElementDeclaration) {
parentName = ((XSDElementDeclaration) parent).getName();
run(selection, schema, typeDef);
} else if (concreteComp instanceof XSDSimpleTypeDefinition) {
isComplexType = false;
XSDSimpleTypeDefinition simpleTypeDef = (XSDSimpleTypeDefinition) concreteComp;
XSDConcreteComponent parentComp = simpleTypeDef.getContainer();
if (parentComp instanceof XSDElementDeclaration) {
parentName = ((XSDElementDeclaration) parent).getName();
} else if (parent instanceof XSDAttributeDeclaration) {
parentName = ((XSDAttributeDeclaration) parent).getName();
}
run(selection, schema, simpleTypeDef);
}
}
}
}
return null;
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class AttributeGroupDefinitionEditPart method getModelChildren.
protected List getModelChildren() {
List list = new ArrayList();
XSDAttributeGroupDefinitionAdapter adapter = (XSDAttributeGroupDefinitionAdapter) getModel();
XSDAttributeGroupDefinition attributeGroupDefinition = adapter.getXSDAttributeGroupDefinition();
Iterator i = attributeGroupDefinition.getResolvedAttributeGroupDefinition().getContents().iterator();
while (i.hasNext()) {
XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) i.next();
if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
list.add(XSDAdapterFactory.getInstance().adapt(attrGroupContent));
} else if (attrGroupContent instanceof XSDAttributeUse) {
list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) XSDAdapterFactory.getInstance().adapt(((XSDAttributeUse) attrGroupContent).getAttributeDeclaration())));
} else {
list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) getModel()));
}
}
if (list.isEmpty()) {
list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) getModel()));
}
return list;
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class TopLevelComponentEditPart method refreshVisuals.
public void refreshVisuals() {
XSDBaseAdapter adapter = (XSDBaseAdapter) getModel();
if (adapter != null) {
isReadOnly = adapter.isReadOnly();
label.setForegroundColor(computeLabelColor());
label.setText(adapter.getText());
Image image = adapter.getImage();
if (image != null) {
label.setIcon(XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent) adapter.getTarget(), image, isReadOnly));
}
if (adapter.isAbstract()) {
if (italicFont == null) {
Font font = label.getFont();
italicFont = getItalicFont(font);
}
if (italicFont != null) {
label.setFont(italicFont);
}
} else {
label.setFont(label.getParent().getFont());
}
} else {
label.setText(Messages._UI_GRAPH_UNKNOWN_OBJECT + getModel().getClass().getName());
// arrowLabel.setVisible(false);
}
if (reselect) {
getViewer().select(this);
setReselect(false);
}
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class BaseDragAndDropCommand method commonSetup.
protected void commonSetup(List siblings, GraphicalEditPart movingEditPart) {
closerSibling = ABOVE_IS_CLOSER;
int pointerYLocation = location.y;
int index;
for (index = 0; index < siblings.size(); index++) {
GraphicalEditPart sibling = (GraphicalEditPart) siblings.get(index);
if (sibling instanceof BaseFieldEditPart) {
int siblingYLocation = getZoomedBounds(sibling.getFigure().getBounds()).getCenter().y;
if (siblingYLocation > pointerYLocation) {
rightSiblingEditPart = sibling;
if (index > 0) {
leftSiblingEditPart = (GraphicalEditPart) siblings.get(index - 1);
}
if (leftSiblingEditPart != null && Math.abs(getZoomedBounds(leftSiblingEditPart.getFigure().getBounds()).getCenter().y - pointerYLocation) > Math.abs(siblingYLocation - pointerYLocation)) {
closerSibling = BELOW_IS_CLOSER;
}
break;
}
}
}
boolean isHandled = handleFirstAndLastDropTargets(index, siblings);
if (!isHandled)
handleOtherTargets(index);
calculateLeftAndRightXSDComponents();
xsdComponentToDrag = (XSDConcreteComponent) ((XSDBaseAdapter) itemToDrag.getModel()).getTarget();
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.
the class BaseDragAndDropCommand method calculateLeftAndRightXSDComponents.
protected void calculateLeftAndRightXSDComponents() {
if (leftSiblingEditPart instanceof XSDBaseFieldEditPart) {
Object leftModel = ((XSDBaseFieldEditPart) leftSiblingEditPart).getModel();
previousRefComponent = null;
if (leftModel instanceof XSDBaseAdapter) {
XSDBaseAdapter leftAdapter = (XSDBaseAdapter) leftModel;
previousRefComponent = (XSDConcreteComponent) leftAdapter.getTarget();
}
}
if (rightSiblingEditPart instanceof XSDBaseFieldEditPart) {
Object rightModel = ((XSDBaseFieldEditPart) rightSiblingEditPart).getModel();
nextRefComponent = null;
if (rightModel instanceof XSDBaseAdapter) {
XSDBaseAdapter rightAdapter = (XSDBaseAdapter) rightModel;
nextRefComponent = (XSDConcreteComponent) rightAdapter.getTarget();
}
}
}
Aggregations