use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project eclipse-pmd by acanda.
the class JavaProjectClient method createFileInProject.
/**
* Creates a text file in a project.
*
* @param projectName The name of the existing project.
* @param relativePath The path of the file including the file name, relative to the project.
* @param content The content of the file.
*/
public static void createFileInProject(final String projectName, final Path relativePath, final String content) {
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
bot.menu("File").menu("New").menu("File").click();
final SWTBotShell dialog = bot.shell(ResourceMessages.FileResource_shellTitle);
if (relativePath.getParent() != null) {
dialog.bot().text(0).setText(projectName + "/" + relativePath.getParent().toString());
} else {
dialog.bot().text(0).setText(projectName);
}
dialog.bot().text(1).setText(relativePath.getFileName().toString());
dialog.bot().button("Finish").click();
final SWTBotEditor editor = bot.editorByTitle(relativePath.getFileName().toString());
editor.toTextEditor().setText(content);
editor.saveAndClose();
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project egit by eclipse.
the class StashesMenuTest method stashAndApplyChanges.
@Test
public void stashAndApplyChanges() throws Exception {
String originalContent = getTestFileContent();
String modifiedContent = "changes to stash";
touch(modifiedContent);
assertEquals(modifiedContent, getTestFileContent());
ContextMenuHelper.clickContextMenu(selectProject(), "Team", STASHES, UIText.StashesMenu_StashChangesActionText);
SWTBotShell createDialog = bot.shell(UIText.StashCreateCommand_titleEnterCommitMessage);
SWTBotText enterMessageText = createDialog.bot().text(0);
String stashMessage = "stash message";
enterMessageText.setText(stashMessage);
createDialog.bot().button(IDialogConstants.OK_LABEL).click();
assertEquals(originalContent, getTestFileContent());
ContextMenuHelper.clickContextMenu(selectProject(), "Team", STASHES, MessageFormat.format(UIText.StashesMenu_StashItemText, Integer.valueOf(0), stashMessage));
SWTBotEditor stashEditor = bot.activeEditor();
// Check if text with message is there
stashEditor.bot().styledText(stashMessage);
stashEditor.bot().toolbarButtonWithTooltip(util.getPluginLocalizedValue("StashApplyCommand.label")).click();
assertEquals(modifiedContent, getTestFileContent());
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project egit by eclipse.
the class AbstractSynchronizeViewTest method changeFilesInProject.
protected void changeFilesInProject() throws Exception {
SWTBot packageExlBot = bot.viewById(JavaUI.ID_PACKAGES).bot();
SWTBotTreeItem coreTreeItem = selectProject(PROJ1, packageExlBot.tree());
SWTBotTreeItem rootNode = TestUtil.expandAndWait(coreTreeItem);
rootNode = TestUtil.expandAndWait(rootNode.getNode(0)).select();
rootNode.getNode(0).select().doubleClick();
SWTBotEditor corePomEditor = bot.editorByTitle(FILE1);
corePomEditor.toTextEditor().insertText("<!-- EGit jUnit test case -->");
corePomEditor.saveAndClose();
rootNode.getNode(1).select().doubleClick();
SWTBotEditor uiPomEditor = bot.editorByTitle(FILE2);
uiPomEditor.toTextEditor().insertText("<!-- EGit jUnit test case -->");
uiPomEditor.saveAndClose();
coreTreeItem.collapse();
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project egit by eclipse.
the class CompareEditorTester method forTitleContaining.
public static CompareEditorTester forTitleContaining(String title) {
SWTWorkbenchBot bot = new SWTWorkbenchBot();
SWTBotEditor editor = bot.editor(new CompareEditorTitleMatcher(title));
// Ensure that both StyledText widgets are enabled
SWTBotStyledText styledText = editor.toTextEditor().getStyledText();
bot.waitUntil(Conditions.widgetIsEnabled(styledText));
return new CompareEditorTester(editor);
}
Aggregations