Displaying a file in tree view [message #64188] |
Sat, 06 June 2009 10:34  |
Eclipse User |
|
|
|
Hi,
I have created a tree view. I want to add files into the parent node using
a pop-up menu. How do I add file using this menu.
private void initialize() {
// Parent initializations
}
private void makeActions() {
action1 = new Action() {
public void run() {
// some code here
// The child to the parents above should be
//added in this action
}
};
However I am not able to call the parent.addChild(child); method in
action1 as the parent is not available in he run() method.
The initialize() is function of ViewContentProvider class and makeAction
is not.
|
|
|
Re: Displaying a file in tree view [message #64373 is a reply to message #64188] |
Tue, 09 June 2009 10:49  |
Eclipse User |
|
|
|
This isn't really a PDE-build related question; you should ask SWT questions
in the eclipse.platform.swt group.
That said, what I did was add a mouse listener to the tree view, which
detects the mouse-down right-click event and stores the mouse location
somewhere that the action will be able to get it. Then in the action use
that mouse location to look up the parent. Since an action itself doesn't
know who's going to be invoking it (menu item, toolbar button, etc.) it's up
to the invoker to provide context if the action needs it.
--- WRS
"Shrijeet " <shrijeet.polke@gmail.com> wrote in message
news:9cf952713ed3cefcf5aae842e8c41427$1@www.eclipse.org...
> Hi,
> I have created a tree view. I want to add files into the parent node using
> a pop-up menu. How do I add file using this menu.
>
> private void initialize() {
>
> // Parent initializations
> }
>
> private void makeActions() {
> action1 = new Action() {
> public void run() {
> // some code here // The child to the parents above should be
> //added in this action
> }
> };
>
> However I am not able to call the parent.addChild(child); method in
> action1 as the parent is not available in he run() method.
>
> The initialize() is function of ViewContentProvider class and makeAction
> is not.
>
|
|
|
Re: Displaying a file in tree view [message #598172 is a reply to message #64188] |
Tue, 09 June 2009 10:49  |
Eclipse User |
|
|
|
This isn't really a PDE-build related question; you should ask SWT questions
in the eclipse.platform.swt group.
That said, what I did was add a mouse listener to the tree view, which
detects the mouse-down right-click event and stores the mouse location
somewhere that the action will be able to get it. Then in the action use
that mouse location to look up the parent. Since an action itself doesn't
know who's going to be invoking it (menu item, toolbar button, etc.) it's up
to the invoker to provide context if the action needs it.
--- WRS
"Shrijeet " <shrijeet.polke@gmail.com> wrote in message
news:9cf952713ed3cefcf5aae842e8c41427$1@www.eclipse.org...
> Hi,
> I have created a tree view. I want to add files into the parent node using
> a pop-up menu. How do I add file using this menu.
>
> private void initialize() {
>
> // Parent initializations
> }
>
> private void makeActions() {
> action1 = new Action() {
> public void run() {
> // some code here // The child to the parents above should be
> //added in this action
> }
> };
>
> However I am not able to call the parent.addChild(child); method in
> action1 as the parent is not available in he run() method.
>
> The initialize() is function of ViewContentProvider class and makeAction
> is not.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03036 seconds