Search in sources :

Example 6 with IFieldFigure

use of org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure 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 7 with IFieldFigure

use of org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure 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 8 with IFieldFigure

use of org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure in project webtools.sourceediting by eclipse.

the class BaseFieldEditPart method createFigure.

protected IFigure createFigure() {
    IFieldFigure figure = getFigureFactory().createFieldFigure(getModel());
    figure.setForegroundColor(ColorConstants.black);
    return figure;
}
Also used : IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)

Example 9 with IFieldFigure

use of org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure in project webtools.sourceediting by eclipse.

the class BaseFieldEditPart method performRequest.

public void performRequest(Request request) {
    if (((IADTObject) getModel()).isReadOnly() || isFileReadOnly()) {
        return;
    }
    if (request.getType() == RequestConstants.REQ_DIRECT_EDIT || request.getType() == RequestConstants.REQ_OPEN) {
        IFieldFigure fieldFigure = getFieldFigure();
        Object model = getModel();
        if (request instanceof LocationRequest) {
            LocationRequest locationRequest = (LocationRequest) request;
            Point p = locationRequest.getLocation();
            if (hitTest(fieldFigure.getTypeLabel(), p)) {
                TypeReferenceDirectEditManager manager = new TypeReferenceDirectEditManager((IField) model, this, fieldFigure.getTypeLabel());
                TypeUpdateCommand typeUpdateCommand = new TypeUpdateCommand();
                typeUpdateCommand.setDelegate(manager);
                adtDirectEditPolicy.setUpdateCommand(typeUpdateCommand);
                manager.show();
            } else if (hitTest(fieldFigure.getNameLabel(), p)) {
                directEditNameField();
            }
        } else {
            directEditNameField();
        }
    }
}
Also used : TypeReferenceDirectEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.TypeReferenceDirectEditManager) LocationRequest(org.eclipse.gef.requests.LocationRequest) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) Point(org.eclipse.draw2d.geometry.Point) IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)

Aggregations

IFieldFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)9 IField (org.eclipse.wst.xsd.ui.internal.adt.facade.IField)4 Point (org.eclipse.draw2d.geometry.Point)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 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)2 Label (org.eclipse.draw2d.Label)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 LocationRequest (org.eclipse.gef.requests.LocationRequest)1 Image (org.eclipse.swt.graphics.Image)1 Text (org.eclipse.swt.widgets.Text)1 XSDAttributeDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)1 IAnnotationProvider (org.eclipse.wst.xsd.ui.internal.adt.design.IAnnotationProvider)1 AttributeReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.AttributeReferenceDirectEditManager)1 ReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ReferenceDirectEditManager)1 TypeReferenceDirectEditManager (org.eclipse.wst.xsd.ui.internal.adt.design.directedit.TypeReferenceDirectEditManager)1