opening project properties hack [message #32890] |
Tue, 21 April 2009 19:33  |
Eclipse User |
|
|
|
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 04:40   |
Eclipse User |
|
|
|
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 #33209 is a reply to message #33105] |
Thu, 23 April 2009 02:37  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03175 seconds