Search in sources :

Example 11 with IField

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

the class XSDBaseFieldEditPart method refreshVisuals.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
   */
protected void refreshVisuals() {
    IFieldFigure figure = getFieldFigure();
    IField field = (IField) getModel();
    figure.getNameLabel().setText(field.getName());
    figure.getTypeLabel().setText(field.getTypeName());
    figure.refreshVisuals(getModel());
    if (field.isReadOnly()) {
        figure.setForegroundColor(ColorConstants.darkGray);
    } else {
        if (isHighContrast) {
            figure.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
            figure.setBackgroundColor(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
        } else
            figure.setForegroundColor(ColorConstants.black);
    }
    // $NON-NLS-1$
    String occurrenceDescription = "";
    if (field instanceof IAnnotationProvider) {
        occurrenceDescription = ((IAnnotationProvider) field).getNameAnnotationString();
    }
    refreshIcon();
    figure.getNameAnnotationLabel().setText(occurrenceDescription);
    figure.recomputeLayout();
    if (getRoot() != null)
        ((GraphicalEditPart) getRoot()).getFigure().invalidateTree();
}
Also used : IAnnotationProvider(org.eclipse.wst.xsd.ui.internal.adt.design.IAnnotationProvider) IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 12 with IField

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

the class DesignViewGraphicalViewer method selectionChanged.

// this method is called when something changes in the selection manager
// (e.g. a selection occured from another view)
public void selectionChanged(SelectionChangedEvent event) {
    Object selectedObject = null;
    ISelection eventSelection = event.getSelection();
    if (eventSelection instanceof StructuredSelection) {
        selectedObject = ((StructuredSelection) eventSelection).getFirstElement();
    }
    // if (event.getSource() instanceof ADTContentOutlinePage)
    if (selectedObject != null) {
        if (event.getSource() != internalSelectionProvider) {
            if (selectedObject instanceof IStructure) {
                if (((getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || (!(getInput() instanceof IModel))) {
                    if ((selectedObject instanceof IGraphElement) && ((IGraphElement) selectedObject).isFocusAllowed()) {
                        if (!(event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)) {
                            setInputAndMarkLocation((IStructure) selectedObject);
                        }
                    }
                }
            } else if (selectedObject instanceof IGraphElement) {
                if (((IGraphElement) selectedObject).isFocusAllowed() && ((event.getSource() instanceof ADTContentOutlinePage))) {
                    setInputAndMarkLocation((IADTObject) selectedObject);
                } else if (!((IGraphElement) selectedObject).isFocusAllowed()) {
                    // We encountered an object that is not a valid input to the graph viewer
                    // Now find the top container that can be a valid input
                    IADTObject obj = ((IGraphElement) selectedObject).getTopContainer();
                    if (event.getSource() instanceof ADTContentOutlinePage) {
                        // change the inputs
                        if (// Don't change inputs if the obj is already the input
                        obj != null && getInput() != obj)
                            setInputAndMarkLocation(obj);
                    } else if (event.getSource() instanceof CommonSelectionManager) {
                        // otherwise, inputs will change unexpectedly!!
                        if (getInput() instanceof IModel) {
                            if (obj != null)
                                setInput(obj);
                        }
                    } else if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider) {
                        // of anonymous types
                        if (obj != null)
                            setInput(obj);
                    } else {
                        if (obj != null && getInput() instanceof IModel)
                            setInputAndMarkLocation(obj);
                    }
                }
                if (selectedObject instanceof IField) {
                    IField field = (IField) selectedObject;
                    if ((!field.isGlobal() && getInput() instanceof IModel) || (!field.isGlobal() && !(event.getSource() instanceof CommonSelectionManager))) {
                        IADTObject obj = ((IGraphElement) selectedObject).getTopContainer();
                        if (obj != null)
                            setInputAndMarkLocation(obj);
                    } else if (field.isGlobal() && !(getInput() instanceof IModel)) {
                        if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)
                            setInput(field);
                        else
                            setInputAndMarkLocation(field);
                    }
                }
            } else if (selectedObject instanceof IField) {
                IField field = (IField) selectedObject;
                if ((field.isGlobal() && (getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || ((field.isGlobal() && !(getInput() instanceof IModel)))) {
                    setInputAndMarkLocation(field);
                }
            } else if (selectedObject instanceof IModelProxy) {
                IModelProxy adapter = (IModelProxy) selectedObject;
                if (selectedObject instanceof RedefineCategoryAdapter) {
                    RedefineCategoryAdapter selectionAdapter = (RedefineCategoryAdapter) selectedObject;
                    XSDRedefineAdapter selectionParentAdapter = selectionAdapter.getXsdRedefineAdapter();
                    setInputAndMarkLocation(selectionParentAdapter);
                } else if (getInput() != adapter.getModel())
                    setInput(adapter.getModel());
            } else if (selectedObject instanceof IModel) {
                if (getInput() != selectedObject)
                    setInput((IModel) selectedObject);
            }
            EditPart editPart = getEditPart(getRootEditPart(), selectedObject);
            if (editPart != null) {
                setSelection(new StructuredSelection(editPart));
                setFocus(editPart);
            }
        }
    }
}
Also used : IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) IModelProxy(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IModelProxy) IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart) IHolderEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) EditPart(org.eclipse.gef.EditPart) CommonSelectionManager(org.eclipse.wst.xsd.ui.internal.adt.editor.CommonSelectionManager) IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) RedefineCategoryAdapter(org.eclipse.wst.xsd.ui.internal.adapters.RedefineCategoryAdapter) ISelection(org.eclipse.jface.viewers.ISelection) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ADTContentOutlinePage(org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage) XSDRedefineAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDRedefineAdapter)

Example 13 with IField

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

the class BaseFieldEditPart method directEditNameField.

protected void directEditNameField() {
    if (isFileReadOnly())
        return;
    Object model = getModel();
    IFieldFigure fieldFigure = getFieldFigure();
    if (model instanceof IField) {
        IField field = (IField) model;
        if (field.isReference()) {
            ElementReferenceDirectEditManager manager = new ElementReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel());
            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) LabelCellEditorLocator(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField)

Example 14 with IField

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

the class CompartmentEditPart method removeChildVisual.

protected void removeChildVisual(EditPart childEditPart) {
    Object model = childEditPart.getModel();
    IFigure child = ((GraphicalEditPart) childEditPart).getFigure();
    if (model instanceof IField) {
        getCompartmentFigure().getContentPane().remove(child);
        return;
    } else if (model instanceof Annotation) {
        getCompartmentFigure().getAnnotationPane().remove(child);
        return;
    }
    super.removeChildVisual(childEditPart);
}
Also used : IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Annotation(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation) IFigure(org.eclipse.draw2d.IFigure)

Example 15 with IField

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

the class CompartmentEditPart method addChildVisual.

protected void addChildVisual(EditPart childEditPart, int index) {
    Object model = childEditPart.getModel();
    IFigure child = ((GraphicalEditPart) childEditPart).getFigure();
    if (model instanceof IField) {
        getCompartmentFigure().getContentPane().add(child, index);
        return;
    } else if (model instanceof Annotation) {
        getCompartmentFigure().getAnnotationPane().add(child);
        return;
    }
    super.addChildVisual(childEditPart, index);
}
Also used : IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Annotation(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

IField (org.eclipse.wst.xsd.ui.internal.adt.facade.IField)16 IType (org.eclipse.wst.xsd.ui.internal.adt.facade.IType)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 IFieldFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)4 IStructure (org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure)4 ArrayList (java.util.ArrayList)3 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)3 List (java.util.List)2 IFigure (org.eclipse.draw2d.IFigure)2 EditPart (org.eclipse.gef.EditPart)2 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 ElementReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager)2 LabelCellEditorLocator (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator)2 LabelEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager)2 Annotation (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation)2 IGraphElement (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement)2 IModel (org.eclipse.wst.xsd.ui.internal.adt.facade.IModel)2 Iterator (java.util.Iterator)1 Label (org.eclipse.draw2d.Label)1 Point (org.eclipse.draw2d.geometry.Point)1