java - Get selected project name every time a project is selected -
I am using Ielection to get the selected project names I 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? To get a selection in a particular part, call You can use the 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; }
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.
ISelectionService.getSelection ("part id") - but you have to work with part ID.
ISelectionService .add.postSelectionListener to change the selection of all the parts.
Comments
Post a Comment