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());
}
}
}
}
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.
}
}
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());
}
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();
}
}
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();
}
}
Aggregations