List of usage examples for com.intellij.openapi.wm IdeFocusManager getGlobalInstance
@NotNull public static IdeFocusManager getGlobalInstance()
From source file:automation.commands.ActionCommand.java
License:Apache License
@Override public void process(Queue<Command> script) throws Exception { String actionId = myParameters.getTextField(); AnAction action = ActionManager.getInstance().getAction(actionId); final InputEvent inputEvent = getInputEvent(actionId); ActionManager.getInstance().tryToExecute(action, inputEvent, IdeFocusManager.getGlobalInstance().getFocusOwner(), null, true); startNext(script);//from ww w . j ava2s . c o m }
From source file:automation.commands.ChangeFocusCommand.java
License:Apache License
@Override public void process(final Queue<Command> script) throws Exception { myParameters.log();//from ww w. j av a 2 s.co m ActionCallback callback = IdeFocusManager.getGlobalInstance().requestFocus(myParameters.getComponent(), true); callback.doWhenDone(new Runnable() { @Override public void run() { try { startNext(script); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:automation.commands.CheckProjectViewModelCommand.java
License:Apache License
@Override public void process(final Queue<Command> script) throws Exception { final Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); final ProjectViewTree projectViewTree = getProjectViewTree(focusOwner); final AbstractTreeBuilder treeBuilder = ProjectTreeBuilder.getBuilderFor(projectViewTree); assert treeBuilder != null; final AbstractTreeStructure treeStructure = treeBuilder.getTreeStructure(); final Object rootElement = treeStructure.getRootElement(); final Object[] childElements = treeStructure.getChildElements(rootElement); AbstractTreeNode prj = (AbstractTreeNode) childElements[0]; final AbstractTreeNode nodeFromPath = getNodeFromPath(path, prj); final TreePath path = projectViewTree.getPath(nodeFromPath); treeBuilder.expand(nodeFromPath, new Runnable() { @Override//from w ww .j av a2s. c o m public void run() { projectViewTree.scrollPathToVisible(path); try { startNext(script); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:automation.commands.navigateAndClick.NavigateAndClickCommand.java
License:Apache License
@Override public void process(final Queue<Command> script) throws Exception { myParameters.log();/* www . ja v a2s.c o m*/ final Component componentByText = GuiUtil.findComponentByText(myParameters.getTextField(), IdeFocusManager.getGlobalInstance().getFocusOwner()); RobotControlManager.getInstance().getRobotControl().navigateAndClick(componentByText, runNext(script)); }
From source file:automation.commands.navigateAndClick.NavigateAndClickMenuCommand.java
License:Apache License
private void getNSMenuItem(String menuName) throws Exception { Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); JRootPane rootPane = SwingUtilities.getRootPane(focusOwner); final JMenuBar jMenuBar = rootPane.getJMenuBar(); Window mainWindow = SwingUtilities.getWindowAncestor(jMenuBar); if (mainWindow instanceof IdeFrameImpl) { final ID sharedApplication = invoke("NSApplication", "sharedApplication"); final ID mainMenu = invoke(sharedApplication, "mainMenu"); final int itemCount = invoke(mainMenu, "numberOfItems").intValue(); ID resultMenuItem = null;/*from w w w . j a v a2 s . c o m*/ for (int i = 0; i < itemCount; i++) { ID menuItem = invoke(mainMenu, "itemAtIndex:", i); ID mt = invoke(menuItem, "title"); String menuItemName = Foundation.toStringViaUTF8(mt); if (menuItemName.equals(menuName)) { resultMenuItem = menuItem; break; } } if (resultMenuItem == null) throw new Exception("Unable to find Mac main menu: " + menuName); int index = invoke(mainMenu, "indexOfItem:", resultMenuItem).intValue(); } }
From source file:automation.commands.navigateAndClick.NavigateAndClickMenuCommand.java
License:Apache License
public Component getMainMenuComponent(String menuName) throws Exception { Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); JMenuBar jMenuBar = SwingUtilities.getRootPane(focusOwner).getJMenuBar(); int n = jMenuBar.getComponentCount(); for (int i = 0; i < n; i++) { ActionMenu actionMenu = (ActionMenu) jMenuBar.getComponent(i); if (actionMenu.getText().equals(menuName)) { return actionMenu.getComponent(); }// w w w .j a v a 2 s . co m } throw new Exception("Unable to find \"" + menuName + "\" in main menu"); }
From source file:automation.commands.navigateAndClick.NavigateAndClickMenuCommand.java
License:Apache License
public int getMainMenuIndex(String menuName) throws Exception { Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); JMenuBar jMenuBar = SwingUtilities.getRootPane(focusOwner).getJMenuBar(); int n = jMenuBar.getComponentCount(); for (int i = 0; i < n; i++) { ActionMenu actionMenu = (ActionMenu) jMenuBar.getComponent(i); if (actionMenu.getText().equals(menuName)) { return i; }//from ww w .j av a2 s . c o m } throw new Exception("Unable to find \"" + menuName + "\" in main menu"); }
From source file:automation.commands.navigateAndClick.NavigateAndClickMenuCommand.java
License:Apache License
private Rectangle getMonitorBounds() throws Exception { Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); JMenuBar jMenuBar = SwingUtilities.getRootPane(focusOwner).getJMenuBar(); Window window = WindowUtils.findWindow(jMenuBar); if (window == null) throw new Exception("Unable to find window"); GraphicsConfiguration config = window.getGraphicsConfiguration(); GraphicsDevice myScreen = config.getDevice(); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] allScreens = env.getScreenDevices(); int myScreenIndex = -1; for (int i = 0; i < allScreens.length; i++) { if (allScreens[i].equals(myScreen)) { myScreenIndex = i;/*from w w w .j a v a2 s.c o m*/ break; } } return allScreens[myScreenIndex].getDefaultConfiguration().getBounds(); }
From source file:automation.commands.ProjectViewCommand.java
License:Apache License
@Override public void process(final Queue<Command> script) throws Exception { //Project View item name final Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); final Component componentByText = GuiUtil.findComponentByTextAndType(elementText, HierarchyTree.ProjectViewElement.class, focusOwner); final RobotControl rc = RobotControlManager.getInstance().getRobotControl(); switch (action) { case ACTION_LEFT_CLICK: rc.navigateAndClick(componentByText, runNext(script)); break;//from ww w . j a v a 2 s. co m case ACTION_DOUBLE_CLICK: rc.navigateAndDoubleClick(componentByText, runNext(script)); break; case ACTION_RIGHT_CLICK: rc.navigateAndRightClick(componentByText, runNext(script)); break; case ACTION_EXPAND_ALL: } }
From source file:automation.GuiUtil.java
License:Apache License
public TreeModel getFocusedTree() { return getTree(IdeFocusManager.getGlobalInstance().getFocusOwner()); }