Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » opening project properties hack
opening project properties hack [message #32890] Tue, 21 April 2009 23:33 Go to next message
David Crawshaw is currently offline David CrawshawFriend
Messages: 3
Registered: July 2009
Junior Member
Hello,

I am writing a generic function openProjectProperties(String name). The
obvious technique is to open the Project Explorer, select the project from
the tree, and right click.

This works very well, unless there is another tree visible on the
workbench. Then all too often, that other tree is what is returned by
bot.tree(). This happens even if I call view("Project Explorer").show(),
or setFocus(), or use an ICondition to waitUntil() the view isActive().

The workaround is a terrible hack, it involves enumerating the visible
trees. This doesn't sound too hackish, until you realise that there is no
getAllTrees() function. Instead I need to call bot.tree(int) with indexes
until an exception is thrown. Then even when I get a tree, there is no way
to extract its id (if I knew the id of the project explorer tree, I would
just call treeWithId(), but I've tried to guess and had no luck).

What would be really nice is if I could go view("Project
Explorer").tree(), but that function doesn't exist.

Any thoughts on how I can do this more intelligently?

d.
Re: opening project properties hack [message #32926 is a reply to message #32890] Wed, 22 April 2009 08:40 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
See the tree() method in PackageExplorerView[1] for how this is achieved.

The next nightly build of SWTBot in will let you say instead of the
funny statements in [1].

packageExplorerBot = bot.view("Package Explorer").bot();
packageExplorerBot.tree();


[1] -
http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbo t.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/ widgets/helpers/PackageExplorerView.java#L67

-- Ketan

David Crawshaw wrote:
> Hello,
>
> I am writing a generic function openProjectProperties(String name). The
> obvious technique is to open the Project Explorer, select the project
> from the tree, and right click.
>
> This works very well, unless there is another tree visible on the
> workbench. Then all too often, that other tree is what is returned by
> bot.tree(). This happens even if I call view("Project Explorer").show(),
> or setFocus(), or use an ICondition to waitUntil() the view isActive().
>
> The workaround is a terrible hack, it involves enumerating the visible
> trees. This doesn't sound too hackish, until you realise that there is
> no getAllTrees() function. Instead I need to call bot.tree(int) with
> indexes until an exception is thrown. Then even when I get a tree, there
> is no way to extract its id (if I knew the id of the project explorer
> tree, I would just call treeWithId(), but I've tried to guess and had no
> luck).
>
> What would be really nice is if I could go view("Project
> Explorer").tree(), but that function doesn't exist.
>
> Any thoughts on how I can do this more intelligently?
>
> d.
>
Re: opening project properties hack [message #33105 is a reply to message #32926] Wed, 22 April 2009 22:48 Go to previous messageGo to next message
David Crawshaw is currently offline David CrawshawFriend
Messages: 3
Registered: July 2009
Junior Member
Ketan Padegaonkar wrote:
> See the tree() method in PackageExplorerView[1] for how this is achieved.

Ah, I have not explored the helpers properly.

> The next nightly build of SWTBot in will let you say instead of the
> funny statements in [1].
>
> packageExplorerBot = bot.view("Package Explorer").bot();
> packageExplorerBot.tree();

Brilliant. Extracting a bot straight from the view function will make my
code so much simpler. Thank you.

A question about the semantics of view(): if the view is closed, will it
open it? What happens, for example, if "Package Explorer" is open in one
shell, but another shell (say, Progress Information) is active? Will
calling view("Package Explorer") switch shells, or fail?

d.
Re: opening project properties hack [message #33209 is a reply to message #33105] Thu, 23 April 2009 06:37 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
David Crawshaw wrote:
> A question about the semantics of view(): if the view is closed, will it
> open it? What happens, for example, if "Package Explorer" is open in one
> shell, but another shell (say, Progress Information) is active? Will
> calling view("Package Explorer") switch shells, or fail?

SWTBot looks for the view in the active workbench window(and throws
exception in case it's not). I'm not sure what the active workbench
window is when another shell is open, I guess there's only one way to
find the answer to this question :)

-- Ketan
Previous Topic:Problem with opening File Menu
Next Topic:why waitUntilWidgetAppears()?
Goto Forum:
  


Current Time: Fri Mar 29 10:21:38 GMT 2024

Powered by FUDForum. Page generated in 0.03510 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top