use of com.android.tools.idea.uibuilder.api.ViewHandler in project android by JetBrains.
the class ViewInspectorProvider method isApplicable.
@Override
public boolean isApplicable(@NotNull List<NlComponent> components, @NotNull Map<String, NlProperty> properties, @NotNull NlPropertiesManager propertiesManager) {
if (components.size() != 1) {
return false;
}
String tagName = components.get(0).getTagName();
if (TAG_EXCEPTIONS.contains(tagName)) {
return false;
}
if (myInspectors.containsKey(tagName)) {
return true;
}
ViewHandler handler = myViewHandlerManager.getHandler(tagName);
if (handler == null || handler.getInspectorProperties().isEmpty()) {
return false;
}
myInspectors.put(tagName, new ViewInspectorComponent(tagName, properties, propertiesManager, handler.getInspectorProperties()));
return true;
}
use of com.android.tools.idea.uibuilder.api.ViewHandler in project android by JetBrains.
the class NlPropertiesManager method activatePreferredEditor.
@Override
public boolean activatePreferredEditor(@NotNull DesignSurface surface, @NotNull NlComponent component) {
ViewHandler handler = component.getViewHandler();
String propertyName = handler != null ? handler.getPreferredProperty() : null;
if (propertyName == null) {
return false;
}
return myPropertiesPanel.activatePreferredEditor(propertyName, myLoading);
}
use of com.android.tools.idea.uibuilder.api.ViewHandler in project android by JetBrains.
the class NlActionManager method addViewActions.
public void addViewActions(@NotNull DefaultActionGroup group, @Nullable NlComponent component, @Nullable NlComponent parent, @NotNull List<NlComponent> newSelection, boolean toolbar) {
ScreenView screenView = mySurface.getCurrentScreenView();
if (screenView == null || (parent == null && component == null)) {
return;
}
ViewEditor editor = new ViewEditorImpl(screenView);
// TODO: Perform caching
if (component != null) {
ViewHandler handler = ViewHandlerManager.get(mySurface.getProject()).getHandler(component);
addViewActionsForHandler(group, component, newSelection, editor, handler, toolbar);
}
if (parent != null) {
ViewHandler handler = ViewHandlerManager.get(mySurface.getProject()).getHandler(parent);
List<NlComponent> selectedChildren = Lists.newArrayListWithCapacity(newSelection.size());
for (NlComponent selected : newSelection) {
if (selected.getParent() == parent) {
selectedChildren.add(selected);
}
}
addViewActionsForHandler(group, parent, selectedChildren, editor, handler, toolbar);
}
}
Aggregations