package jetbrains.mps.editor.contextActionsTool.pluginSolution.plugin;
/*Generated by MPS */
import jetbrains.mps.plugins.tool.GeneratedTool;
import javax.swing.Icon;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowAnchor;
import jetbrains.mps.project.MPSProject;
import jetbrains.mps.ide.project.ProjectHelper;
import jetbrains.mps.nodeEditor.assist.SelectionMenuProviderByCellAndConcept;
import jetbrains.mps.editor.contextActionsTool.lang.menus.runtime.MenuLocations;
import com.intellij.openapi.wm.ex.ToolWindowEx;
import jetbrains.mps.ide.ThreadUtils;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import javax.swing.JComponent;
public class ContextActionsTool_Tool extends GeneratedTool {
private static final Icon ICON = null;
private ToolComponent myComponent;
private ToolController myController;
public ContextActionsTool_Tool(Project project) {
super(project, "Context Actions", null, ICON, ToolWindowAnchor.RIGHT, false);
}
public void init(Project project) {
super.init(project);
MPSProject mpsProject = ProjectHelper.fromIdeaProject(project);
if (mpsProject == null) {
throw new IllegalArgumentException("project must be an MPSProject");
}
ContextActionsTool_Tool.this.myComponent = new ToolComponent(ContextActionsTool_Tool.this);
ContextActionsTool_Tool.this.myController = new ToolController(mpsProject, ContextActionsTool_Tool.this.myComponent, new SelectionMenuProviderByCellAndConcept(MenuLocations.CONTEXT_ACTIONS_TOOL));
((ToolWindowEx) ContextActionsTool_Tool.this.getToolWindow()).setAdditionalGearActions(ContextActionsTool_Tool.this.createGearActionGroup());
ThreadUtils.runInUIThreadNoWait(new Runnable() {
public void run() {
ContextActionsTool_Tool.this.makeAvailableLater();
}
});
}
public void dispose() {
ContextActionsTool_Tool.this.myController.dispose();
super.dispose();
}
private DefaultActionGroup createGearActionGroup() {
DefaultActionGroup gearActionGroup = new DefaultActionGroup();
for (ViewType type : ViewType.values()) {
gearActionGroup.add(new ChangeViewAction(ContextActionsTool_Tool.this.myComponent, type));
}
return gearActionGroup;
}
public JComponent getComponent() {
return ContextActionsTool_Tool.this.myComponent;
}
}