java - Get selected project name every time a project is selected -


I am using Ielection to get the selected project names I Public Fixed IProject getCurrentProject () {IPOject Project = Zero; ISEXATION SERVICE SERVICESearch = Workbank.justinstance (). GetActiveWorkbenchWindow () GetSelectionService (); Selection Selection = Selection Service. Gate Selection (); If (select instance of Ist Structured selection) {Object Element = (Selecting ISert Sorted Selection)) .getFirstElement (); If (element of the IRSORS example) {project = (element (IRSOSROM)) .getProject (); } And if (element example IJavaElement) {IJavaProject jProject = (IJavaElement element)) .getJavaProject (); Project = jProject.getProject (); }} Return Project; }

The problem is that this function gives the name of the project only for the first time execution.

When I call it on a button event, I get a null pointer exception and it appears that the element is zero.

What to change to get the project name selected every time I call this function?

workspace is a internal class and you It should not be used Usage: IWorkbench to get an example PlatformUI.getWorkbench ()

ISians service Asset selection returns the selection to the active part currently, so if you call it from an editor or you get the selection when there is no selection in that package.

To get a selection in a particular part, call ISelectionService.getSelection ("part id") - but you have to work with part ID.

You can use the ISelectionService .add.postSelectionListener to change the selection of all the parts.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -