/** * Returns the first {@link SWTBotLabel} with the given text, or {@code null} if none was found. * * @param text * the label text * @return the first {@link SWTBotLabel} with the given text, or {@code null} if none was found */ public SWTBotLabel getLabel(final String text) { List<Label> labels = finder.findControls(new BaseMatcher<Label>() { @Override public boolean matches(final Object item) { return item instanceof Label && ((Label) item).getText().equals(text); } @Override public void describeTo(final Description description) {} }); if (labels.isEmpty()) { return null; } else { return new SWTBotLabel(labels.get(0)); } }
/** * Checks the default appearance for */ @Test public void checkDefaults() { // Create a basic, default dialog. dialog = new ComboDialog(getShell(), false); // Open the dialog and get an SWTBot for it. openDialog(); // Get the widgets. SWTBotLabel label = getInfoLabel(); SWTBotCombo combo = getCombo(); SWTBotButton okButton = getOKButton(); SWTBotButton cancelButton = getCancelButton(); // Check the default appearance. assertEquals("", getBot().activeShell().getText()); // Check the title. assertEquals("Please select a value.", label.getText()); assertEnabled(combo); assertEquals("", getCombo().getText()); assertEquals(0, getCombo().itemCount()); assertNotEnabled(okButton); assertEnabled(cancelButton); // Check the default value. assertNull(dialog.getValue()); // Close the dialog. closeDialog(); return; }
/** * @return 文字标签:正在导入 TYPE_TMX/TYPE_TBX 文件; */ public SWTBotLabel msgImporting() { if (importType.equals(TMX)) { return dialogBot.label(TsUIConstants.getString("lblImportingTMX")); } else { return dialogBot.label(TsUIConstants.getString("lblImportingTBX")); } }
public boolean hasValidFilename () { SWTBotLabel sl = bot.label(filename); return sl!=null; }
public boolean hasValidPath ( ) { String label = "/"+project+"/"+folder+"/"+ pkg +"/"+filename; SWTBotLabel sl = bot.label(label); return sl!=null; }
/** * @return 文字标签:文件名非法; */ public SWTBotLabel msgFileNameInvalid() { return dialogBot.label(file + TsUIConstants.getString("msgFileNameInvalid")); }
/** * @return 文字标签:文件未找到; */ public SWTBotLabel msgFileNotFound() { String msg = TsUIConstants.getString("msgFileNotFound"); return dialogBot.label(MessageFormat.format(msg, file)); }
/** * @return 文字标签:信息内容; */ public SWTBotLabel lblMessage() { return dialogBot.label(msg); }
/** * @return 文字标签:确认是否删除项目; */ public SWTBotLabel msgConfirmDeleteProject() { assertTrue("参数错误,项目名称为 null。", prjName != null); return dialogBot.label(MessageFormat.format(TsUIConstants.getString("msgConfirmDeleteProject"), prjName)); }
/** * @return 第 1 页:项目信息; */ public SWTBotLabel lblProjectInfo() { return dialogBot.label(TsUIConstants.getString("lblProjectInfo")); }
/** * @return 第 2 页:语言对设置; */ public SWTBotLabel lblLangSetting() { return dialogBot.label(TsUIConstants.getString("lblLangSetting")); }
/** * @return 第 3 页:记忆库设置; */ public SWTBotLabel lblTmSetting() { return dialogBot.label(TsUIConstants.getString("lblTmSetting")); }
/** * @return ; */ public SWTBotLabel lblTbSetting() { return dialogBot.label(TsUIConstants.getString("lblTbSetting")); }
/** * @return 第 5 页:添加源文件; */ public SWTBotLabel lblAddSrcFile() { return dialogBot.label(TsUIConstants.getString("lblAddSrcFile")); }
/** * Checks if there is a label with the given text, and if it is visible. * * @param text * the label text * @return {@code true} if a label with the given text exists and is visible, {@code false} otherwise */ public boolean hasLabel(final String text) { SWTBotLabel label = getLabel(text); return label != null && label.isVisible(); }
/** * Gets the dialog's info label. * * @return The associated widget wrapped by SWTBot. */ private SWTBotLabel getInfoLabel() { return getBot().label(); }
/** * @param msgKey 信息内容在资源文件中的 Key,请使用本类常量 * @return 文字标签:进度信息内容; */ public SWTBotLabel lblMsg(String msgKey) { return dlgBot.label(TsUIConstants.getString(msgKey)); }
/** * @param name * 文件名,在信息中包含 * @return 文字标签:out of sync 信息的内容 */ public SWTBotLabel lblOutOfSync(String name) { // FIXME: 新的 Out Of Sync 信息控件可能不是 Label 了。 return dialogBot.label(MessageFormat.format(TsUIConstants.getString("lblOutOfSync"), name)); }
/** * @param name * 含非法字符的项目名 * @param invalidChar * 名称中的非法字符 * @return 文字标签:项目名称非法的信息内容; */ public SWTBotLabel lblInvalidChar(String name, String invalidChar) { return dialogBot.label(MessageFormat.format(TsUIConstants.getString("lblInvalidChar"), invalidChar, name)); }
/** * @param oldName * 旧文件名,在信息中包含 * @return 文字标签:out of sync 信息的内容 */ public SWTBotLabel lblOutOfSync(String oldName) { return dialogBot.label(MessageFormat.format(TsUIConstants.getString("lblOutOfSync"), oldName)); }
/** * @param name 项目名称 * @return 文字标签:项目已存在的提示、并询问是否需要覆盖信息; */ public SWTBotLabel lblProjectExists(String name) { return dialogBot.label(MessageFormat.format(TsUIConstants.getString("lblProjectExists"), name, name)); }