Search in sources :

Example 21 with ScreenView

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

the class LintNotificationAction method actionPerformed.

/** Shows list of warnings/errors */
@Override
public void actionPerformed(AnActionEvent e) {
    NlUsageTrackerManager.getInstance(mySurface).logAction(LayoutEditorEvent.LayoutEditorEventType.SHOW_LINT_MESSAGES);
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView != null) {
        LintAnnotationsModel lintModel = screenView.getModel().getLintAnnotationsModel();
        if (lintModel != null && lintModel.getIssueCount() > 0) {
            LintNotificationPanel notificationPanel = new LintNotificationPanel(screenView, lintModel);
            Object source = e.getInputEvent().getSource();
            if (source instanceof JComponent) {
                notificationPanel.showInBestPositionFor(e.getProject(), (JComponent) source);
            } else {
                notificationPanel.showInBestPositionFor(e.getProject(), e.getDataContext());
            }
        }
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) LintNotificationPanel(com.android.tools.idea.uibuilder.lint.LintNotificationPanel) LintAnnotationsModel(com.android.tools.idea.uibuilder.lint.LintAnnotationsModel)

Example 22 with ScreenView

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

the class LintNotificationAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    ScreenView screenView = mySurface.getCurrentScreenView();
    int markerCount = 0;
    if (screenView != null) {
        LintAnnotationsModel lintModel = screenView.getModel().getLintAnnotationsModel();
        if (lintModel != null) {
            markerCount = lintModel.getIssueCount();
        }
    }
    if (markerCount != myCount) {
        myCount = markerCount;
        Icon icon;
        switch(markerCount) {
            case 0:
                icon = AndroidIcons.LintNotification.Lint0;
                break;
            case 1:
                icon = AndroidIcons.LintNotification.Lint1;
                break;
            case 2:
                icon = AndroidIcons.LintNotification.Lint2;
                break;
            case 3:
                icon = AndroidIcons.LintNotification.Lint3;
                break;
            case 4:
                icon = AndroidIcons.LintNotification.Lint4;
                break;
            case 5:
                icon = AndroidIcons.LintNotification.Lint5;
                break;
            case 6:
                icon = AndroidIcons.LintNotification.Lint6;
                break;
            case 7:
                icon = AndroidIcons.LintNotification.Lint7;
                break;
            case 8:
                icon = AndroidIcons.LintNotification.Lint8;
                break;
            case 9:
                icon = AndroidIcons.LintNotification.Lint9;
                break;
            default:
                icon = AndroidIcons.LintNotification.Lint9plus;
                break;
        }
        presentation.setIcon(icon);
        presentation.setText(markerCount == 0 ? "No Warnings" : "Show Warnings and Errors");
    // Leaving action enabled, since the disabled icon currently doesn't look right.
    // Instead we check in the action performed method and do nothing if the error count
    // is 0.
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) LintAnnotationsModel(com.android.tools.idea.uibuilder.lint.LintAnnotationsModel) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 23 with ScreenView

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

the class DeleteAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView == null) {
        return;
    }
    SelectionModel selectionModel = screenView.getSelectionModel();
    NlModel model = screenView.getModel();
    model.delete(selectionModel.getSelection());
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) SelectionModel(com.android.tools.idea.uibuilder.model.SelectionModel) NlModel(com.android.tools.idea.uibuilder.model.NlModel)

Example 24 with ScreenView

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

the class SelectAllAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView != null) {
        SelectionModel selectionModel = screenView.getSelectionModel();
        selectionModel.selectAll(screenView.getModel());
        mySurface.repaint();
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) SelectionModel(com.android.tools.idea.uibuilder.model.SelectionModel)

Example 25 with ScreenView

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

the class SelectParentAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ScreenView screenView = mySurface.getCurrentScreenView();
    if (screenView != null) {
        SelectionModel selectionModel = screenView.getSelectionModel();
        List<NlComponent> selection = selectionModel.getSelection();
        if (selection.size() == 1) {
            NlComponent first = selection.get(0);
            NlComponent parent = first.getParent();
            if (parent != null) {
                selectionModel.setSelection(Collections.singletonList(parent));
            }
        }
        mySurface.repaint();
    }
}
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)

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