Search in sources :

Example 6 with ViewEditor

use of com.android.tools.idea.uibuilder.api.ViewEditor in project android by JetBrains.

the class PreferenceCategoryDragHandlerTest method newPreferenceCategoryDragHandler.

@NotNull
private static PreferenceGroupDragHandler newPreferenceCategoryDragHandler(@NotNull NlComponent category) {
    ViewEditor editor = PreferenceScreenTestFactory.mockEditor();
    List<NlComponent> preferences = Collections.singletonList(Mockito.mock(NlComponent.class));
    return new PreferenceCategoryDragHandler(editor, new ViewGroupHandler(), category, preferences, DragType.MOVE);
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) ViewEditor(com.android.tools.idea.uibuilder.api.ViewEditor) ViewGroupHandler(com.android.tools.idea.uibuilder.api.ViewGroupHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ViewEditor

use of com.android.tools.idea.uibuilder.api.ViewEditor 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

ViewEditor (com.android.tools.idea.uibuilder.api.ViewEditor)7 ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)5 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)5 ViewEditorImpl (com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)3 NotNull (org.jetbrains.annotations.NotNull)3 ListView (android.widget.ListView)1 ViewInfo (com.android.ide.common.rendering.api.ViewInfo)1 ScrollHandler (com.android.tools.idea.uibuilder.api.ScrollHandler)1 ViewHandler (com.android.tools.idea.uibuilder.api.ViewHandler)1 ComponentDescriptor (com.android.tools.idea.uibuilder.fixtures.ComponentDescriptor)1 NlModel (com.android.tools.idea.uibuilder.model.NlModel)1 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)1 Nullable (org.jetbrains.annotations.Nullable)1