use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart in project webtools.sourceediting by eclipse.
the class DesignViewGraphicalViewer method getEditPart.
protected EditPart getEditPart(EditPart parent, Object object) {
EditPart result = null;
for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) {
EditPart editPart = (EditPart) i.next();
if (editPart.getModel() == object && !(editPart instanceof IHolderEditPart) && !(editPart instanceof RootContentEditPart)) {
result = editPart;
break;
}
}
if (result == null) {
for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) {
EditPart editPart = getEditPart((EditPart) i.next(), object);
if (editPart != null) {
// First check to see if there is a selection
ISelection currentSelection = getSelection();
// direct edit mode
if (currentSelection != null) {
if (currentSelection instanceof StructuredSelection) {
EditPart targetStructureEditPart = (EditPart) ((StructuredSelection) currentSelection).getFirstElement();
if (targetStructureEditPart != null) {
while (targetStructureEditPart != null) {
if (targetStructureEditPart instanceof StructureEditPart) {
break;
}
targetStructureEditPart = targetStructureEditPart.getParent();
}
}
EditPart potentialEditPartToSelect = editPart;
while (potentialEditPartToSelect != null) {
if (potentialEditPartToSelect instanceof StructureEditPart) {
break;
}
potentialEditPartToSelect = potentialEditPartToSelect.getParent();
}
// the edit part we found
if (potentialEditPartToSelect == targetStructureEditPart || potentialEditPartToSelect == null || targetStructureEditPart == null) {
result = editPart;
break;
}
}
} else // Otherwise just find the first one and return
{
result = editPart;
break;
}
}
}
}
return result;
}
Aggregations