Search in sources :

Example 41 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 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("New File");
    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)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)41 Test (org.junit.Test)14 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)8 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)6 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)5 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)5 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)5 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)4 Point (org.eclipse.swt.graphics.Point)3 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)3 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)3 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)3 BeforeClass (org.junit.BeforeClass)3 DockerClient (com.spotify.docker.client.DockerClient)2 ProgressHandler (com.spotify.docker.client.ProgressHandler)2 Path (java.nio.file.Path)2 IFile (org.eclipse.core.resources.IFile)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2