You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Rahul Khandelwal <ra...@gmail.com> on 2021/05/22 09:45:59 UTC

Help Needed: How to get project instance in AbstractAction implementation for LocalTerminalAction.

Hi All,

This is related to terminal improvement.
Whenever we select *Window -> IDE Tools -> Terminal*, we most likely want
to do one of the following -
1. Run a maven command OR
2. Run a gradle command OR
3. Run an ant command OR
4. Any other action which is more often than not involved with the project
directory.

So looking at above use cases, it makes sense that Terminal should by
default open in the project directory of the opened file.

This will require *LocalTerminalAction *to be aware of either context or
opened file object so that it can lookup for project.
*LocalTerminalAction *extends from *TerminalAction *which in turn extends
from *AbstractAction*.

Here I am struggling with injecting lookup context or fileobject
in LocalTerminalAction class.
I have tried the following ways, but it is not working -
1. I implemented *ContextAwareAction *action in LocalTerminalAction and
tried to lookup for project in createContextAwareInstance method.
2. I added the constructor argument *FileObject opendFile* in
LocalTerminalAction's constructor. From the fileobject, I then tried to
lookup for the project.

But none of the above methods are working.

Can someone help me solve this problem?

Regards,
Rahul Khandelwal

Re: Help Needed: How to get project instance in AbstractAction implementation for LocalTerminalAction.

Posted by Jaroslav Tulach <ja...@gmail.com>.
Have you tried to generate New/Action/Conditinally Enabled action using the 
action wizard? Does that work? It should. Then it'd be just about finding the 
difference between newly generated class and the TerminalAction (there are 
going to be many - TerminalAction seems old fashioned).
-jt

Dne sobota 22. května 2021 11:45:59 CEST, Rahul Khandelwal napsal(a):
> Hi All,
> 
> This is related to terminal improvement.
> Whenever we select *Window -> IDE Tools -> Terminal*, we most likely want
> to do one of the following -
> 1. Run a maven command OR
> 2. Run a gradle command OR
> 3. Run an ant command OR
> 4. Any other action which is more often than not involved with the project
> directory.
> 
> So looking at above use cases, it makes sense that Terminal should by
> default open in the project directory of the opened file.
> 
> This will require *LocalTerminalAction *to be aware of either context or
> opened file object so that it can lookup for project.
> *LocalTerminalAction *extends from *TerminalAction *which in turn extends
> from *AbstractAction*.
> 
> Here I am struggling with injecting lookup context or fileobject
> in LocalTerminalAction class.
> I have tried the following ways, but it is not working -
> 1. I implemented *ContextAwareAction *action in LocalTerminalAction and
> tried to lookup for project in createContextAwareInstance method.
> 2. I added the constructor argument *FileObject opendFile* in
> LocalTerminalAction's constructor. From the fileobject, I then tried to
> lookup for the project.
> 
> But none of the above methods are working.
> 
> Can someone help me solve this problem?
> 
> Regards,
> Rahul Khandelwal





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists