Search in sources :

Example 6 with ViewEditorImpl

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

ViewEditorImpl (com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)6 ViewEditor (com.android.tools.idea.uibuilder.api.ViewEditor)3 ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)2 ViewHandlerManager (com.android.tools.idea.uibuilder.handlers.ViewHandlerManager)2 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)2 ScrollHandler (com.android.tools.idea.uibuilder.api.ScrollHandler)1 ViewHandler (com.android.tools.idea.uibuilder.api.ViewHandler)1 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)1 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 Project (com.intellij.openapi.project.Project)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1