Exemplo n.º 1
0
  /** @throws WidgetNotFoundException */
  private void perform() throws Exception {
    Display display = e.display;
    SWTEclipseBot bot = new SWTEclipseBot();

    createJavaProject(bot);
    createJavaClass(bot);
    Thread.sleep(1000);
    SWTBotEclipseEditor editor = bot.editor("HelloWorld.java"); // $NON-NLS-1$

    Thread.sleep(1000);
    editor.notifyKeyboardEvent(SWT.CTRL, '.');
    editor.quickfix("Add unimplemented methods"); // $NON-NLS-1$

    editor.navigateTo(7, 0);
    editor.autoCompleteProposal(
        "sys", "sysout - print to standard out"); // $NON-NLS-1$ //$NON-NLS-2$

    editor.typeText("\"Hello World\""); // $NON-NLS-1$

    editor.navigateTo(3, 0);
    editor.autoCompleteProposal("main", "main - main method"); // $NON-NLS-1$ //$NON-NLS-2$

    editor.typeText("new Thread (new HelloWorld ());"); // $NON-NLS-1$
    if (true) return;
    editor.notifyKeyboardEvent(SWT.CTRL, '2');
    editor.notifyKeyboardEvent(SWT.NONE, 'L');
    editor.notifyKeyboardEvent(SWT.NONE, '\n');

    editor.typeText("\n"); // $NON-NLS-1$
    editor.typeText("thread.start();\n"); // $NON-NLS-1$
    editor.typeText("thread.join();"); // $NON-NLS-1$
    editor.quickfix("Add throws declaration"); // $NON-NLS-1$
    editor.notifyKeyboardEvent(SWT.NONE, (char) 27);
    editor.notifyKeyboardEvent(SWT.NONE, '\n');

    editor.notifyKeyboardEvent(SWT.CTRL, 's');

    editor.notifyKeyboardEvent(SWT.ALT | SWT.SHIFT, 'x');
    editor.notifyKeyboardEvent(SWT.NONE, 'j');

    try {
      Thread.sleep(1000);
    } catch (InterruptedException e1) {
      e1.printStackTrace();
    }
  }