PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/widgets/helpers/PackageExplorerView.java

https://github.com/szuecs/swtbot
Java | 76 lines | 44 code | 8 blank | 24 comment | 4 complexity | ba4cde1ba74c911bb0b01f9c3307eff5 MD5 | raw file
Possible License(s): EPL-1.0
  1. /*******************************************************************************
  2. * Copyright (c) 2008 Ketan Padegaonkar and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Ketan Padegaonkar - initial API and implementation
  10. *******************************************************************************/
  11. package org.eclipse.swtbot.eclipse.finder.widgets.helpers;
  12. import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
  13. import org.eclipse.core.runtime.Platform;
  14. import org.eclipse.swt.widgets.Button;
  15. import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
  16. import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
  17. import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
  18. import org.eclipse.swtbot.swt.finder.waits.Conditions;
  19. import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
  20. import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
  21. import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
  22. import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
  23. /**
  24. * Screen object that represents the operations that can be performed on the package explorer view.
  25. *
  26. * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
  27. * @version $Id$
  28. */
  29. public class PackageExplorerView {
  30. private SWTWorkbenchBot bot = new SWTWorkbenchBot();
  31. public void deleteProject(String projectName) throws Exception {
  32. SWTBotTree tree = tree();
  33. tree.setFocus();
  34. tree.select(projectName);
  35. bot.menu("Edit").menu("Delete").click();
  36. String version = (String) Platform.getBundle("org.eclipse.core.runtime").getHeaders().get("Bundle-Version");
  37. if (version.startsWith("3.3")) {
  38. SWTBotShell shell = bot.shell("Confirm Project Delete");
  39. shell.activate();
  40. Button button = bot.widget(widgetOfType(Button.class), shell.widget);
  41. new SWTBotRadio(button).click();
  42. bot.button("Yes").click();
  43. bot.waitUntil(Conditions.shellCloses(shell));
  44. }
  45. if (version.startsWith("3.4") || version.startsWith("3.5") || version.startsWith("3.6")) {
  46. SWTBotShell shell = bot.shell("Delete Resources");
  47. shell.activate();
  48. Button button = bot.widget(widgetOfType(Button.class), shell.widget);
  49. new SWTBotCheckBox(button).select();
  50. bot.button("OK").click();
  51. bot.waitUntil(Conditions.shellCloses(shell));
  52. }
  53. }
  54. /**
  55. * @return
  56. * @throws WidgetNotFoundException
  57. */
  58. private SWTBotTree tree() throws WidgetNotFoundException {
  59. return view().bot().tree();
  60. }
  61. /**
  62. * @return
  63. * @throws WidgetNotFoundException
  64. */
  65. private SWTBotView view() throws WidgetNotFoundException {
  66. return bot.viewByTitle("Package Explorer");
  67. }
  68. }