private void initListening(final IInteractiveTrait trait, final Button favoredButton) { trait .getFavorization() .addFavorableChangeListener(new EnabledUpdateListener(favoredButton, trait)); List<ITraitStatusImageProvider> imageProvider = new TraitStatusImageProviderContainer().getImageProvider(); imageProvider.add(new FavoredTraitStatusImageProvider(activeImage)); IImageProvider favorizationImageProvider = new FavorizationImageProvider(trait, passiveImage, imageProvider, characterId); FavorizationModelListener listener = new FavorizationModelListener( favoredButton, trait.getFavorization(), favorizationImageProvider); trait.getFavorization().addFavoredChangeListener(listener); trait.getFavorization().addFavorableChangeListener(listener); favoredButton.addListener( SWT.MouseUp, new FavorizationButtonChangeListener(favoredButton, trait)); }
public IExtendableIntValueView create( String text, FormToolkit toolkit, final IInteractiveTrait trait) { final Button favoredButton = toolkit.createButton(parent, null, SWT.TOGGLE); initListening(trait, favoredButton); Color background = toolkit.getColors().getBackground(); createLabel(background, createGridData()).setText(text); final CanvasIntValueDisplay view = new CanvasIntValueDisplay( background, parent, passiveImage, activeImage, trait.getMaximalValue()); new TraitPresenter().initPresentation(trait, view); return view; }