The current selection can be obtained through the selection service with a listener, similar to Eclipse 3.x. However, the ISelectionService
in Eclipse 3.x has been replaced with an almost identical ESelectionService
in Eclipse 4.x. (Other than the minor lack of JavaDoc and change of package name, the only significant difference between the two is that there is no add/removePostSelection
methods.)
Create a class called
Rainbow
in thecom.packtpub.e4.application.parts
package. Add astatic final
array of strings with colors of the rainbow.Add a
create()
method, along with a@PostConstruct
annotation, that takes aComposite
parent. Inside, create aListViewer
and set the input to the array of rainbow colors. The class will look like:public class Rainbow { private static final Object[] rainbow = { "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" }; @PostConstruct public void create(Composite parent) { ListViewer lv = new ListViewer...