Search in sources :

Example 21 with SWTBotEditor

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();
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 22 with SWTBotEditor

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());
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 23 with SWTBotEditor

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();
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 24 with SWTBotEditor

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);
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotStyledText(org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText)

Aggregations

SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)24 Test (org.junit.Test)11 Path (org.eclipse.core.runtime.Path)7 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)7 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)7 IEditorReference (org.eclipse.ui.IEditorReference)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 Ignore (org.junit.Ignore)5 IsEditorOpened (net.heartsome.test.swtbot.waits.IsEditorOpened)4 IFile (org.eclipse.core.resources.IFile)3 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)3 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)3 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)3 IEditorPart (org.eclipse.ui.IEditorPart)3 InputStream (java.io.InputStream)2 IResource (org.eclipse.core.resources.IResource)2 AbstractChartBuilder (org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2