Search in sources :

Example 11 with ViewHandler

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;
}
Also used : ViewHandler(com.android.tools.idea.uibuilder.api.ViewHandler)

Example 12 with ViewHandler

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);
}
Also used : ViewHandler(com.android.tools.idea.uibuilder.api.ViewHandler)

Example 13 with ViewHandler

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);
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) ViewHandler(com.android.tools.idea.uibuilder.api.ViewHandler) ViewEditor(com.android.tools.idea.uibuilder.api.ViewEditor) ViewEditorImpl(com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)

Aggregations

ViewHandler (com.android.tools.idea.uibuilder.api.ViewHandler)13 ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)6 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)4 ViewHandlerManager (com.android.tools.idea.uibuilder.handlers.ViewHandlerManager)3 AdViewHandler (com.android.tools.idea.uibuilder.handlers.google.AdViewHandler)2 MapViewHandler (com.android.tools.idea.uibuilder.handlers.google.MapViewHandler)2 Nullable (org.jetbrains.annotations.Nullable)2 ViewInfo (com.android.ide.common.rendering.api.ViewInfo)1 ResourceValueMap (com.android.ide.common.resources.ResourceValueMap)1 InsertType (com.android.tools.idea.uibuilder.api.InsertType)1 ViewEditor (com.android.tools.idea.uibuilder.api.ViewEditor)1 TextViewHandler (com.android.tools.idea.uibuilder.handlers.TextViewHandler)1 ViewEditorImpl (com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)1 ConstraintLayoutHandler (com.android.tools.idea.uibuilder.handlers.constraint.ConstraintLayoutHandler)1 ConstraintLayoutDecorator (com.android.tools.idea.uibuilder.scene.decorator.ConstraintLayoutDecorator)1 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)1 Project (com.intellij.openapi.project.Project)1 FontRenderContext (java.awt.font.FontRenderContext)1 Rectangle2D (java.awt.geom.Rectangle2D)1 NotNull (org.jetbrains.annotations.NotNull)1