use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class XSDElementDragAndDropCommand method setup.
protected void setup() {
canExecute = false;
// Drop target is model group
if (target instanceof ModelGroupEditPart) {
parentEditPart = (ModelGroupEditPart) target;
if (((GenericGroupFigure) parentEditPart.getFigure()).getIconFigure().getBounds().contains(location)) {
xsdComponentToDrag = (XSDConcreteComponent) ((XSDElementDeclarationAdapter) itemToDrag.getModel()).getTarget();
action = new MoveXSDElementAction(((ModelGroupEditPart) target).getXSDModelGroup(), 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();
calculateModelGroupList();
doDrop(targetEditPartSiblings, itemToDrag);
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class BaseDragAndDropCommand method calculateFieldEditParts.
protected List calculateFieldEditParts() {
List list = target.getParent().getChildren();
List listOfFields = new ArrayList();
for (Iterator i = list.iterator(); i.hasNext(); ) {
Object o = i.next();
if (o instanceof BaseFieldEditPart) {
listOfFields.add(o);
}
}
return listOfFields;
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class XSDBaseAction method doEdit.
protected void doEdit(Object obj, IWorkbenchPart part) {
if (obj instanceof TopLevelComponentEditPart) {
TopLevelComponentEditPart editPart = (TopLevelComponentEditPart) obj;
if (addedComponent == ((XSDBaseAdapter) editPart.getModel()).getTarget()) {
editPart.setScroll(true);
editPart.addFeedback();
editPart.doEditName(!(part instanceof ContentOutline));
}
} else if (obj instanceof BaseFieldEditPart) {
BaseFieldEditPart editPart = (BaseFieldEditPart) obj;
editPart.doEditName(!(part instanceof ContentOutline));
} else if (obj instanceof IAutoDirectEdit) {
((IAutoDirectEdit) obj).doEditName(!(part instanceof ContentOutline));
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class LabelCellEditorLocator method relocate.
public void relocate(CellEditor celleditor) {
Text text = (Text) celleditor.getControl();
Label label = namedEditPart.getNameLabelFigure();
if (text.getBounds().x <= 0) {
int widthToRemove = 0;
// HACK
if (namedEditPart instanceof BaseFieldEditPart) {
BaseFieldEditPart field = (BaseFieldEditPart) namedEditPart;
IFieldFigure fieldFigure = field.getFieldFigure();
widthToRemove = fieldFigure.getTypeLabel().getBounds().width;
// TODO: !! perhaps the IFieldFigure should just have a method to compute this?
// Label typeAnnotationLabel = ((FieldFigure) field.getFigure()).getTypeAnnotationLabel();
// Label nameAnnotationLabel = ((FieldFigure) field.getFigure()).getNameAnnotationLabel();
// widthToRemove = typeLabel.getBounds().width + typeAnnotationLabel.getBounds().width + nameAnnotationLabel.getBounds().width;
}
Rectangle boundingRect = label.getTextBounds();
// Reduce the width by the amount we shifted along the x-axis
int delta = Math.abs(boundingRect.x - label.getParent().getBounds().x);
label.getParent().translateToAbsolute(boundingRect);
org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
boundingRect.translate(trim.x, trim.y);
boundingRect.height = boundingRect.height - trim.y;
boundingRect.width = label.getParent().getBounds().width - delta - widthToRemove;
text.setBounds(boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height);
// Translate point
if (cursorLocation != null) {
Point translatedPoint = new Point(cursorLocation.x - boundingRect.x, cursorLocation.y - boundingRect.y);
// Calculate text offset corresponding to the translated point
text.setSelection(0, 0);
int xCaret = text.getCaretLocation().x;
int offset = text.getCaretPosition();
while (xCaret < translatedPoint.x) {
text.setSelection(offset + 1, offset + 1);
xCaret = text.getCaretLocation().x;
int newOffset = text.getCaretPosition();
if (newOffset == offset) {
break;
}
offset++;
}
text.setSelection(offset, offset);
}
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class AddFieldAction method doEdit.
protected void doEdit(Object obj, IWorkbenchPart part) {
if (obj instanceof BaseFieldEditPart) {
BaseFieldEditPart editPart = (BaseFieldEditPart) obj;
editPart.doEditName(!(part instanceof ContentOutline));
}
}
Aggregations