Search in sources :

Example 26 with ScreenView

use of com.android.tools.idea.uibuilder.surface.ScreenView in project android by JetBrains.

the class NlActionsToolbar method updateViewActions.

private void updateViewActions(@NotNull List<NlComponent> newSelection) {
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView == null) {
        return;
    }
    myActionToolbar.getComponent().setVisible(mySurface.getLayoutType().isSupportedByDesigner());
    // TODO: Perform caching
    myDynamicGroup.removeAll();
    NlComponent parent = findSharedParent(newSelection);
    if (parent != null) {
        mySurface.getActionManager().addViewActions(myDynamicGroup, null, parent, newSelection, true);
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent)

Example 27 with ScreenView

use of com.android.tools.idea.uibuilder.surface.ScreenView in project android by JetBrains.

the class NlPreviewForm method setActiveModel.

public void setActiveModel(@Nullable NlModel model) {
    myPendingFile = null;
    ScreenView currentScreenView = mySurface.getCurrentScreenView();
    if (currentScreenView != null) {
        currentScreenView.getModel().deactivate();
        Disposer.dispose(currentScreenView.getModel());
    }
    if (model == null) {
        setEditor(null);
        myWorkBench.setToolContext(null);
    } else {
        myFile = model.getFile();
        mySurface.setModel(model);
        if (!mySurface.isCanvasResizing() && mySurface.isZoomFitted()) {
            // If we are resizing, keep the zoom level constant
            // only if the zoom was previously set to FIT
            mySurface.zoomToFit();
        } else {
            mySurface.updateScrolledAreaSize();
        }
        setEditor(myManager.getActiveLayoutXmlEditor());
        model.activate();
        myWorkBench.setToolContext(mySurface);
        myWorkBench.setFileEditor(myEditor);
        myActionsToolbar.setModel(model);
        if (!model.getType().isSupportedByDesigner()) {
            myScreenMode = mySurface.getScreenMode();
            mySurface.setScreenMode(DesignSurface.ScreenMode.SCREEN_ONLY, false);
            myWorkBench.setMinimizePanelsVisible(false);
        } else if (myScreenMode != null && mySurface.getScreenMode() == DesignSurface.ScreenMode.SCREEN_ONLY) {
            mySurface.setScreenMode(myScreenMode, false);
            myWorkBench.setMinimizePanelsVisible(true);
        }
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView)

Example 28 with ScreenView

use of com.android.tools.idea.uibuilder.surface.ScreenView in project android by JetBrains.

the class NlPreviewForm method updateCaret.

private void updateCaret() {
    if (myCaretModel != null && !myIgnoreListener && myUseInteractiveSelector) {
        ScreenView screenView = mySurface.getCurrentScreenView();
        if (screenView != null) {
            int offset = myCaretModel.getOffset();
            if (offset != -1) {
                List<NlComponent> views = screenView.getModel().findByOffset(offset);
                if (views == null || views.isEmpty()) {
                    views = screenView.getModel().getComponents();
                }
                try {
                    myIgnoreListener = true;
                    SelectionModel selectionModel = screenView.getSelectionModel();
                    selectionModel.setSelection(views);
                    myRenderingQueue.queue(new Update("Preview update") {

                        @Override
                        public void run() {
                            mySurface.repaint();
                        }

                        @Override
                        public boolean canEat(Update update) {
                            return true;
                        }
                    });
                } finally {
                    myIgnoreListener = false;
                }
            }
        }
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) SelectionModel(com.android.tools.idea.uibuilder.model.SelectionModel) Update(com.intellij.util.ui.update.Update)

Example 29 with ScreenView

use of com.android.tools.idea.uibuilder.surface.ScreenView in project android by JetBrains.

the class NlLintHighlightingPass method applyInformationToEditor.

@Override
public void applyInformationToEditor() {
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView == null) {
        return;
    }
    screenView.getModel().setLintAnnotationsModel(myLintAnnotationsModel);
    // Ensure that the layers are repainted to reflect the latest model
    // (updating the lint annotations associated with a model doesn't actually rev the model
    // version.)
    screenView.getSurface().repaint();
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView)

Example 30 with ScreenView

use of com.android.tools.idea.uibuilder.surface.ScreenView in project android by JetBrains.

the class NlLintHighlightingPass method collectInformation.

@Override
public void collectInformation(@NotNull ProgressIndicator progress) {
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView == null) {
        return;
    }
    myLintAnnotationsModel = getAnnotations(screenView.getModel(), progress);
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView)

Aggregations

ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)42 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)16 NlModel (com.android.tools.idea.uibuilder.model.NlModel)6 SelectionModel (com.android.tools.idea.uibuilder.model.SelectionModel)6 DesignSurface (com.android.tools.idea.uibuilder.surface.DesignSurface)6 Nullable (org.jetbrains.annotations.Nullable)5 NotNull (org.jetbrains.annotations.NotNull)4 Configuration (com.android.tools.idea.configurations.Configuration)3 LintAnnotationsModel (com.android.tools.idea.uibuilder.lint.LintAnnotationsModel)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 BufferedImage (java.awt.image.BufferedImage)2 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)1 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)1 GradleDependencyManager (com.android.tools.idea.gradle.dependencies.GradleDependencyManager)1 RenderResult (com.android.tools.idea.rendering.RenderResult)1 InsertType (com.android.tools.idea.uibuilder.api.InsertType)1 ViewEditor (com.android.tools.idea.uibuilder.api.ViewEditor)1 ViewHandler (com.android.tools.idea.uibuilder.api.ViewHandler)1 ViewEditorImpl (com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)1 LintNotificationPanel (com.android.tools.idea.uibuilder.lint.LintNotificationPanel)1