use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class NlComponentUtils method getMap.
private static HashMap<String, NlComponent> getMap(NlComponent nlComponent) {
List<NlComponent> list = nlComponent.getModel().getComponents();
HashMap<String, NlComponent> map = new HashMap<String, NlComponent>();
for (NlComponent component : list) {
String id = component.getAttribute(SdkConstants.ANDROID_URI, SdkConstants.ATTR_ID);
if (id != null) {
map.put(id, component);
}
}
return map;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class NlComponentUtils method getTopMostInChain.
public static NlComponent getTopMostInChain(NlComponent component) {
HashMap<String, NlComponent> map = getMap(component);
NlComponent current = component;
NlComponent leftComponent;
do {
leftComponent = current;
current = getDir(map, leftComponent, TOP);
if (current == null) {
return leftComponent;
}
} while (getDir(map, current, BOTTOM) == leftComponent);
return leftComponent;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class ConstraintLayoutHandler method willDelete.
/**
* Update the given component if one of its constraint points to one of the component deleted
*
* @param component the component we want to check
* @param deleted the list of components that are deleted
*/
private void willDelete(NlComponent component, @NotNull List<NlComponent> deleted) {
final int count = deleted.size();
for (int i = 0; i < count; i++) {
NlComponent deletedComponent = deleted.get(i);
String id = deletedComponent.getId();
ConstraintComponentUtilities.updateOnDelete(component, id);
}
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class ConstraintLayoutHandler method deleteChildren.
/**
* Called when one or more children are about to be deleted by the user.
*
* @param parent the parent of the deleted children (which still contains
* the children since this method is called before the deletion
* is performed)
* @param deleted a nonempty list of children about to be deleted
* @return true if the children have been fully deleted by this participant; false if normal deletion should resume. Note that even though
* an implementation may return false from this method, that does not mean it did not perform any work. For example, a RelativeLayout
* handler could remove constraints pointing to now deleted components, but leave the overall deletion of the elements to the core
* designer.
*/
@Override
public boolean deleteChildren(@NotNull NlComponent parent, @NotNull List<NlComponent> deleted) {
final int count = parent.getChildCount();
for (int i = 0; i < count; i++) {
NlComponent component = parent.getChild(i);
if (deleted.contains(component)) {
continue;
}
willDelete(component, deleted);
}
return false;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class NlActionManager method showPopup.
public void showPopup(@NotNull MouseEvent event) {
NlComponent component = null;
int x = event.getX();
int y = event.getY();
ScreenView screenView = mySurface.getScreenView(x, y);
if (screenView == null) {
screenView = mySurface.getCurrentScreenView();
}
if (screenView != null) {
component = Coordinates.findComponent(screenView, x, y);
}
showPopup(event, screenView, component);
}
Aggregations