To add the clock to the Eclipse 4 application, a new part will be added which has a ClockWidget
as its only content.
ClockWidget
in a different plug-in, the package needs to be exported. Open the MANIFEST.MF
from the com.packtpub.e4.clock.ui
project, and on the Runtime tab, click on Add to add the com.packtpub.e4.clock.ui
package to the list of Exported Packages.ClockPart
in the com.packtpub.e4.application.parts
package.create
method with a @PostConstruct
annotation that takes a Composite parent
argument.create
method, instantiate a new ClockWidget
instance with arguments parent
, SWT.NONE
, and new RGB(255,0,0)
. This will require that the com.packtpub.e4.clock.ui
package is imported into the com.packtpub.e4.application
plug-in. A quick-fix should offer this automatically, but it can be added by opening the MANIFEST.MF
, going to the Dependencies tab, and adding the com.packtpub.e4.clock.ui
package to the list of Imported Packages. At this point, the code should look like:public class ClockPart { @PostConstruct public void create(Composite parent) { new ClockWidget(parent, SWT.NONE, new RGB(255, 0, 0)); } }
Application.e4xmi
file in the model editor, and navigate inside to Application | Windows and Dialogs | Trimmed Window | Controls | Perspective Stack | Perspective | Controls | Part Sash Container | Part Stack.Clock
as the label, and click on Find next to the Class URI field to select the newly created ClockPart
class. It should fill the field with a URI reference bundleclass://com.packtpub.e4.application/com.packtpub.e4.application.parts.ClockPart
.com.packtpub.e4.clock.ui
plug-in to the product, and update the launch configuration (or delete it so that it is re-created automatically).Adding a part was covered previously in Chapter 2, Drawing a Custom View, and now the Eclipse 4 application has a Clock part with the ClockWidget
. It takes up the entire space of the application window and will be used to test setting the color of the second hand:
3.141.2.34