package com.thingtrack.konekti.view.module.supplier.internal; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.springframework.beans.factory.annotation.Autowired; import com.thingtrack.konekti.knowledge.service.api.SupplierKnowledgeService; import com.thingtrack.konekti.service.api.AddressService; import com.thingtrack.konekti.service.api.SequenceService; import com.thingtrack.konekti.service.api.SupplierGroupService; import com.thingtrack.konekti.service.api.SupplierService; import com.thingtrack.konekti.service.api.SupplierTypeService; import com.thingtrack.konekti.view.addon.ui.AbstractViewContainer; import com.thingtrack.konekti.view.addon.ui.SliderView; import com.thingtrack.konekti.view.kernel.IModule; import com.thingtrack.konekti.view.kernel.IWorkbenchContext; import com.thingtrack.konekti.view.kernel.ui.layout.ISliderView; import com.thingtrack.konekti.view.kernel.ui.layout.IViewChangeListener; import com.thingtrack.konekti.view.kernel.ui.layout.IView; import com.vaadin.annotations.AutoGenerated; import com.vaadin.ui.VerticalLayout; @SuppressWarnings("serial") public class SupplierViewContainer extends AbstractViewContainer { @AutoGenerated private VerticalLayout mainLayout; @AutoGenerated private SliderView sliderView; /** Views **/ private SupplierView supplierView; /** Business services **/ @Autowired private SequenceService sequenceService; @Autowired private AddressService addressService; @Autowired private SupplierService supplierService; @Autowired private SupplierTypeService supplierTypeService; @Autowired private SupplierGroupService supplierGroupService; @Autowired private SupplierKnowledgeService supplierKnowledgeService; private IWorkbenchContext context; // Thread Local Bundle Business Services private static ThreadLocal<SequenceService> threadSequenceService = new ThreadLocal<SequenceService>(); private static ThreadLocal<AddressService> threadAddressService = new ThreadLocal<AddressService>(); private static ThreadLocal<SupplierService> threadSupplierService = new ThreadLocal<SupplierService>(); private static ThreadLocal<SupplierTypeService> threadSupplierTypeService = new ThreadLocal<SupplierTypeService>(); private static ThreadLocal<SupplierGroupService> threadSupplierGroupService = new ThreadLocal<SupplierGroupService>(); private static ThreadLocal<SupplierKnowledgeService> threadSupplierKnowledgeService = new ThreadLocal<SupplierKnowledgeService>(); /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ /** * The constructor should first build the main layout, set the * composition root and then do any custom initialization. * * The constructor will not be automatically regenerated by the * visual editor. */ public SupplierViewContainer(IWorkbenchContext context, IModule module) { buildMainLayout(); setCompositionRoot(mainLayout); // TODO add user code here this.context = context; this.module = module; } @SuppressWarnings("unused") @PostConstruct private void createViews() { // initialize thread local bundle services threadSequenceService.set(sequenceService); threadAddressService.set(addressService); threadSupplierService.set(supplierService); threadSupplierTypeService.set(supplierTypeService); threadSupplierGroupService.set(supplierGroupService); threadSupplierKnowledgeService.set(supplierKnowledgeService); // add all views controlled by SliderView Component supplierView = new SupplierView(context, this); sliderView.addView(supplierView); views.put(0, supplierView); } @SuppressWarnings("unused") @PreDestroy private void destroyViews() { // destroy thread local bundle services threadSequenceService.set(null); threadAddressService.set(null); threadSupplierService.set(null); threadSupplierTypeService.set(null); threadSupplierGroupService.set(null); threadSupplierKnowledgeService.set(null); } public static SequenceService getSequenceService() { return threadSequenceService.get(); } public static AddressService getAddressService() { return threadAddressService.get(); } public static SupplierService getSupplierService() { return threadSupplierService.get(); } public static SupplierTypeService getSupplierTypeService() { return threadSupplierTypeService.get(); } public static SupplierGroupService getSupplierGroupService() { return threadSupplierGroupService.get(); } public static SupplierKnowledgeService getSupplierKnowledgeService() { return threadSupplierKnowledgeService.get(); } @Override public ISliderView getSliderView() { return sliderView; } @Override public IView getSelectedView() { return sliderView.getSelectedView(); } @Override public void addListener(IViewChangeListener listener) { sliderView.addListener(listener); } @AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("100%"); mainLayout.setHeight("100%"); mainLayout.setMargin(false); // top-level component properties setWidth("100.0%"); setHeight("100.0%"); // sliderView sliderView = new SliderView(); sliderView.setImmediate(false); sliderView.setWidth("100.0%"); sliderView.setHeight("100.0%"); mainLayout.addComponent(sliderView); mainLayout.setExpandRatio(sliderView, 1.0f); return mainLayout; } }