public static void openPerspective(SWTWorkbenchBot bot, String perspectiveLabel) { SwtBotUtils.print("Opening Perspective: " + perspectiveLabel); SWTBotShell shell = null; try { menu(bot, "Window").menu("Open Perspective").menu("Other...").click(); shell = bot.shell("Open Perspective"); bot.waitUntil(ActiveWidgetCondition.widgetMakeActive(shell)); shell.bot().table().select(perspectiveLabel); shell.bot().button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); } catch (Exception e) { if (shell != null && shell.isOpen()) shell.close(); SwtBotUtils.printError("Couldn't open perspective '" + perspectiveLabel + "'\n" + "trying to activate already open perspective instead"); // maybe somehow the perspective is already opened (by another test before us) SWTBotPerspective perspective = bot.perspectiveByLabel(perspectiveLabel); perspective.activate(); } SwtBotUtils.print("Opened Perspective: " + perspectiveLabel); }
public void resetToJavPerspective() { final SWTBotPerspective javaPerspective = bot.perspectiveById(JavaUI.ID_PERSPECTIVE); javaPerspective.activate(); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { return javaPerspective.isActive(); } @Override public String getFailureMessage() { return JavaUI.ID_PERSPECTIVE + " has not become active in time"; } }); }
/** * @return 透视图:默认布局; */ public SWTBotPerspective psptvBtnDefault() { return bot.perspectiveByLabel(TsUIConstants .getString("psptvBtnDefault")); }