I am developing a plugin in eclipse using the eclipse ViewPart class. Inside the viewpart i have the styledtext. Consider i have 2 views view_1 and view_2 and both have styledText_1 and styledText_2. For some search function, i need to get the focused styled text content. I tried with below code, but was not successful.
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IWorkBenchPart activePart = page.getActivePart(); // will give the foucsed view part
Both the views are created by same class and has the static styledtext variable say "text".
I tried with
System.out.println(((StyledText)page.getActivePart().getClass().getDeclaredField("text").get(null)).getText());
But this prints the last opened view's text content how can i get the styled text of focused content.