package jetbrains.mps.ide.editor.suppresserrors;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.editor.runtime.AbstractLeftEditorHighlighterMessage;
import jetbrains.mps.nodeEditor.EditorMessageIconRenderer;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.openapi.editor.message.EditorMessageOwner;
import javax.swing.Icon;
import jetbrains.mps.icons.MPSIcons;
import com.intellij.openapi.actionSystem.AnAction;
import jetbrains.mps.workbench.action.BaseAction;
import com.intellij.openapi.actionSystem.ActionManager;
import jetbrains.mps.nodeEditor.cells.EditorCell;
import jetbrains.mps.nodeEditor.EditorComponent;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.openapi.editor.cells.EditorCell_Collection;
import jetbrains.mps.nodeEditor.cells.CellFinderUtil;
import jetbrains.mps.openapi.editor.cells.EditorCell_Label;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import org.jetbrains.mps.openapi.language.SConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;

@GeneratedClass(node = "r:ae9ec0c8-644a-4abb-bd37-ca2f4eb2d3d9(jetbrains.mps.ide.editor.suppresserrors)/7348309840067517756", model = "r:ae9ec0c8-644a-4abb-bd37-ca2f4eb2d3d9(jetbrains.mps.ide.editor.suppresserrors)")
public class SuppressErrorsMessage extends AbstractLeftEditorHighlighterMessage {
  private static final EditorMessageIconRenderer.IconRendererType TYPE = new EditorMessageIconRenderer.IconRendererType(1);
  public SuppressErrorsMessage(SNode node, EditorMessageOwner owner, String tooltip) {
    super(node, owner, tooltip);
  }
  @Override
  public Icon getIcon() {
    return MPSIcons.Actions.SuppressedError;
  }
  @Override
  public EditorMessageIconRenderer.IconRendererType getType() {
    return TYPE;
  }

  @Override
  public AnAction getClickAction() {
    return ((BaseAction) ActionManager.getInstance().getAction("jetbrains.mps.ide.editor.actions.ShowSuppressedErrors_Action"));
  }

  public static EditorCell getOwnCell(EditorComponent editor, SNode sa) {
    return editor.findCellWithId(sa, "suppressedInfo");
  }

  @Nullable
  @Override
  public jetbrains.mps.openapi.editor.cells.EditorCell getAnchorCell(jetbrains.mps.openapi.editor.EditorComponent editorComponent) {
    jetbrains.mps.openapi.editor.cells.EditorCell cell = getNodeCell(editorComponent);
    if (cell instanceof EditorCell_Collection) {
      EditorCell_Collection collection = (EditorCell_Collection) cell;
      return CellFinderUtil.findChildByClass(collection, EditorCell_Label.class, true);
    }
    return cell;
  }

  @Override
  public jetbrains.mps.openapi.editor.cells.EditorCell getCell(EditorComponent editor) {
    SNode node = getNode();
    if (SNodeOperations.isInstanceOf(node, CONCEPTS.SuppressErrorsAnnotation$D1)) {
      EditorCell result = getOwnCell(editor, SNodeOperations.cast(node, CONCEPTS.SuppressErrorsAnnotation$D1));
      if (result != null) {
        return result;
      }
    }
    return super.getCell(editor);
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept SuppressErrorsAnnotation$D1 = MetaAdapterFactory.getConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x3a98b0957fe8e5d2L, "jetbrains.mps.lang.core.structure.SuppressErrorsAnnotation");
  }
}
