package jetbrains.mps.lang.editor.menus.contextAssistant.testExtendingLanguage.editor;

/*Generated by MPS */

import jetbrains.mps.nodeEditor.menus.transformation.TransformationMenuBase;
import java.util.Set;
import jetbrains.mps.internal.collections.runtime.SetSequence;
import java.util.HashSet;
import jetbrains.mps.editor.contextActionsTool.lang.menus.runtime.MenuLocations;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import jetbrains.mps.openapi.editor.menus.transformation.TransformationMenuItem;
import jetbrains.mps.openapi.editor.menus.transformation.TransformationMenuContext;
import jetbrains.mps.lang.editor.menus.EditorMenuDescriptorBase;
import jetbrains.mps.smodel.SNodePointer;
import jetbrains.mps.lang.editor.menus.MenuPart;
import java.util.ArrayList;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.lang.editor.menus.extras.runtime.RefactoringMenuPartBase;
import jetbrains.mps.refactoring.framework.IRefactoring;
import jetbrains.mps.lang.editor.menus.extras.runtime.RefactoringMenuItemBase;
import jetbrains.mps.editor.contextActionsTool.lang.menus.runtime.SidebarActionItem;
import jetbrains.mps.smodel.runtime.IconResource;
import jetbrains.mps.lang.editor.menus.extras.runtime.PluginActionMenuPartBase;
import com.intellij.openapi.actionSystem.AnAction;
import jetbrains.mps.lang.editor.menus.extras.runtime.PluginActionMenuItemBase;
import jetbrains.mps.lang.editor.menus.extras.runtime.AbstractIntentionMenuPart;
import jetbrains.mps.openapi.intentions.IntentionExecutable;
import jetbrains.mps.openapi.editor.menus.EditorMenuTraceInfo;

public class Extras extends TransformationMenuBase {
  public Extras() {
    super(true);
  }
  private final Set<String> myLocations = SetSequence.fromSetAndArray(new HashSet<String>(), MenuLocations.CONTEXT_ACTIONS_TOOL);
  @Override
  public boolean isApplicableToLocation(@NotNull String location) {
    return SetSequence.fromSet(myLocations).contains(location);
  }

  @NotNull
  @Override
  public List<TransformationMenuItem> createMenuItems(@NotNull TransformationMenuContext context) {
    context.getEditorMenuTrace().pushTraceInfo();
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase("contribution to the " + "default transformation menu for " + "Child", new SNodePointer("r:1ed8add9-1a05-4a2d-a8ee-1a24e378c5f6(jetbrains.mps.lang.editor.menus.contextAssistant.testExtendingLanguage.editor)", "2468431357009903065")));
    try {
      return super.createMenuItems(context);
    } finally {
      context.getEditorMenuTrace().popTraceInfo();
    }
  }

  @Override
  @NotNull
  protected List<MenuPart<TransformationMenuItem, TransformationMenuContext>> getParts(TransformationMenuContext _context) {
    List<MenuPart<TransformationMenuItem, TransformationMenuContext>> result = new ArrayList<MenuPart<TransformationMenuItem, TransformationMenuContext>>();
    if (ListSequence.fromListAndArray(new ArrayList<String>(), MenuLocations.CONTEXT_ACTIONS_TOOL).contains(_context.getMenuLocation())) {
      result.add(new TMP_Refactoring_ha3uwx_a0());
      result.add(new TMP_PluginAction_ha3uwx_b0());
      result.add(new TMP_Intention_ha3uwx_c0());
    }
    return result;
  }

  public class TMP_Refactoring_ha3uwx_a0 extends RefactoringMenuPartBase {
    public TMP_Refactoring_ha3uwx_a0() {
      super("jetbrains.mps.lang.editor.menus.contextAssistant.testLanguage.refactorings.AppendOneToName");
    }

    @Override
    protected TransformationMenuItem createItem(@NotNull TransformationMenuContext context, @NotNull IRefactoring refactoring) {
      return new Item(context, refactoring);
    }

    private class Item extends RefactoringMenuItemBase implements SidebarActionItem {
      private Item(TransformationMenuContext context, IRefactoring refactoring) {
        super(context, refactoring);
      }

      @Override
      public IconResource getIcon() {
        return IconContainer.RESOURCE_a0a2e8;
      }
      @Override
      public String getTooltipText() {
        return "A refactoring";
      }
    }
  }
  public class TMP_PluginAction_ha3uwx_b0 extends PluginActionMenuPartBase {
    public TMP_PluginAction_ha3uwx_b0() {
      super("jetbrains.mps.ide.actions.ShowBookmarksDialog_Action");
    }

    @Override
    protected TransformationMenuItem createItem(@NotNull TransformationMenuContext context, @NotNull AnAction action) {
      return new Item(context, action);
    }

    private class Item extends PluginActionMenuItemBase implements SidebarActionItem {
      private Item(TransformationMenuContext context, AnAction action) {
        super(context, action);
      }

      @Override
      public IconResource getIcon() {
        return IconContainer.RESOURCE_a0a2e9;
      }
      @Override
      public String getTooltipText() {
        return "An action";
      }
    }
  }
  public class TMP_Intention_ha3uwx_c0 extends AbstractIntentionMenuPart {
    public TMP_Intention_ha3uwx_c0() {
      super("jetbrains.mps.lang.editor.menus.contextAssistant.testLanguage.intentions.AddLetterToName_Intention");
    }

    @Override
    protected TransformationMenuItem createItem(@NotNull TransformationMenuContext context, @NotNull IntentionExecutable executable) {
      context.getEditorMenuTrace().pushTraceInfo();
      context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase("intention transformation menu part: " + "AddLetterToName", new SNodePointer("r:1ed8add9-1a05-4a2d-a8ee-1a24e378c5f6(jetbrains.mps.lang.editor.menus.contextAssistant.testExtendingLanguage.editor)", "2468431357009934542")));
      try {
        return new Item(context, executable);
      } finally {
        context.getEditorMenuTrace().popTraceInfo();
      }
    }

    private class Item extends AbstractIntentionMenuPart.ItemBase implements SidebarActionItem {
      private EditorMenuTraceInfo myTraceInfo;
      private Item(TransformationMenuContext context, IntentionExecutable executable) {
        super(context, executable);
        this.myTraceInfo = context.getEditorMenuTrace().getTraceInfo();
      }

      @Override
      public EditorMenuTraceInfo getTraceInfo() {
        return myTraceInfo;
      }
      @Override
      public IconResource getIcon() {
        return null;
      }
      @Override
      public String getTooltipText() {
        return myExecutable.getDescriptor().getPresentation();
      }
    }
  }
}
