Search in sources :

Example 1 with IComplexType

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType in project webtools.sourceediting by eclipse.

the class ComplexTypeEditPart method refreshVisuals.

protected void refreshVisuals() {
    super.refreshVisuals();
    Label label = getNameLabelFigure();
    IComplexType complexType = (IComplexType) getModel();
    if (complexType.isAbstract()) {
        if (italicFont == null) {
            Font font = label.getFont();
            italicFont = getItalicFont(font);
        }
        if (italicFont != null) {
            label.setFont(italicFont);
        }
    } else {
        label.setFont(label.getParent().getFont());
    }
}
Also used : Label(org.eclipse.draw2d.Label) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType) Font(org.eclipse.swt.graphics.Font)

Example 2 with IComplexType

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType in project webtools.sourceediting by eclipse.

the class ComplexTypeEditPart method createConnectionFigure.

public TypeReferenceConnection createConnectionFigure() {
    connectionFigure = null;
    IComplexType complexType = (IComplexType) getModel();
    IType type = complexType.getSuperType();
    if (type != null) {
        AbstractGraphicalEditPart referenceTypePart = (AbstractGraphicalEditPart) getTargetEditPart(type);
        if (referenceTypePart != null) {
            connectionFigure = new TypeReferenceConnection(true);
            // draw a line out from the top
            connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.TOP, 1));
            // TODO (cs) need to draw the target anchor to look like a UML inheritance relationship
            // adding a label to the connection would help to
            connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(referenceTypePart.getFigure(), CenteredConnectionAnchor.BOTTOM, 0, 0));
            connectionFigure.setConnectionRouter(new ManhattanConnectionRouter());
            ((CenteredConnectionAnchor) connectionFigure.getSourceAnchor()).setOther((CenteredConnectionAnchor) connectionFigure.getTargetAnchor());
            connectionFigure.setHighlight(false);
        }
    }
    return connectionFigure;
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType) IType(org.eclipse.wst.xsd.ui.internal.adt.facade.IType)

Example 3 with IComplexType

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType in project webtools.sourceediting by eclipse.

the class AddFieldAction method run.

public void run() {
    if (getSelectedObjects().size() > 0) {
        Object o = getSelectedObjects().get(0);
        IComplexType type = null;
        if (o instanceof IComplexType) {
            type = (IComplexType) o;
        } else if (o instanceof IField) {
            IField field = (IField) o;
            type = field.getContainerType();
        }
        if (type != null) {
            // $NON-NLS-1$
            Command command = type.getAddNewFieldCommand("");
            if (command != null) {
                getCommandStack().execute(command);
                Adapter adapter = XSDAdapterFactory.getInstance().adapt(((BaseCommand) command).getAddedComponent());
                selectAddedComponent(adapter);
            } else {
            // TODO ... pop up a command not implemented message
            }
        }
    }
}
Also used : BaseCommand(org.eclipse.wst.xsd.ui.internal.common.commands.BaseCommand) Command(org.eclipse.gef.commands.Command) Adapter(org.eclipse.emf.common.notify.Adapter) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)

Example 4 with IComplexType

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType in project webtools.sourceediting by eclipse.

the class XSDGroupsForAnnotationEditPart method getModelChildren.

protected List getModelChildren() {
    List xsdModelGroupList = new ArrayList();
    List adapterList = new ArrayList();
    IStructure structure = ((Annotation) getModel()).getOwner();
    if (structure instanceof IComplexType) {
        complexType = (IComplexType) structure;
        if (complexType instanceof XSDComplexTypeDefinitionAdapter) {
            XSDComplexTypeDefinitionAdapter adapter = (XSDComplexTypeDefinitionAdapter) complexType;
            xsdModelGroupList = adapter.getModelGroups();
        }
        for (Iterator i = xsdModelGroupList.iterator(); i.hasNext(); ) {
            Object obj = i.next();
            if (obj instanceof XSDModelGroup) {
                adapterList.add(XSDAdapterFactory.getInstance().adapt((XSDModelGroup) obj));
            } else if (obj instanceof XSDModelGroupDefinition) {
                adapterList.add(XSDAdapterFactory.getInstance().adapt((XSDModelGroupDefinition) obj));
            }
        }
    } else if (structure instanceof XSDModelGroupDefinitionAdapter) {
        XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) structure;
        XSDModelGroup group = adapter.getXSDModelGroupDefinition().getModelGroup();
        if (group != null) {
            adapterList.add(XSDAdapterFactory.getInstance().adapt(group));
        }
    }
    return adapterList;
}
Also used : XSDComplexTypeDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDModelGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) Annotation(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)

Example 5 with IComplexType

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType in project webtools.sourceediting by eclipse.

the class XSDBaseAdapter method getContainerType.

/**
 * Implements IField getContainerType.  Get parent Complex Type containing the field
 * @return IComplexType
 */
public IComplexType getContainerType() {
    XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) target;
    XSDConcreteComponent parent = null;
    XSDComplexTypeDefinition ct = null;
    for (parent = xsdConcreteComponent.getContainer(); parent != null; ) {
        if (parent instanceof XSDComplexTypeDefinition) {
            ct = (XSDComplexTypeDefinition) parent;
            break;
        }
        parent = parent.getContainer();
    }
    if (ct != null) {
        return (IComplexType) XSDAdapterFactory.getInstance().adapt(ct);
    }
    return null;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)

Aggregations

IComplexType (org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Iterator (java.util.Iterator)1 Label (org.eclipse.draw2d.Label)1 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 Command (org.eclipse.gef.commands.Command)1 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)1 Font (org.eclipse.swt.graphics.Font)1 XSDComplexTypeDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter)1 XSDModelGroupDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter)1 Annotation (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation)1 IField (org.eclipse.wst.xsd.ui.internal.adt.facade.IField)1 IModel (org.eclipse.wst.xsd.ui.internal.adt.facade.IModel)1 IStructure (org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure)1 IType (org.eclipse.wst.xsd.ui.internal.adt.facade.IType)1 BaseCommand (org.eclipse.wst.xsd.ui.internal.common.commands.BaseCommand)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1