Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.smartera3s.nasec.screens;
- import com.smartera3s.nasec.listeners.PatientHeaderListener;
- import com.smartera3s.nasec.model.entities.PatientEntity;
- import com.vaadin.data.fieldgroup.BeanFieldGroup;
- import com.vaadin.data.fieldgroup.PropertyId;
- import com.vaadin.data.util.ObjectProperty;
- import com.vaadin.event.ShortcutAction;
- import com.vaadin.server.FileResource;
- import com.vaadin.server.Resource;
- import com.vaadin.ui.*;
- import com.vaadin.ui.themes.ValoTheme;
- import java.io.File;
- import java.util.Date;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTSEARCH;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTLOAD;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTADD;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTVISITID;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTVISITDATE;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTNAME;
- import static com.smartera3s.nasec.controllers.PatientHeaderController.PATIENTAGE;
- import static com.smartera3s.utils.InternationalizationFileBundle.CAPTIONS;
- import static com.smartera3s.utils.InternationalizationFileBundle.getBundleValue;
- /**
- * Created by aelabasery on 21/08/16.
- */
- public class PatientHeaderScreen extends CustomComponent {
- public static final String PATIENTBASICINFOSTYLE = "Patient-Basic-Infos-tyle";
- private Image myLocalImage;
- //Labels
- @PropertyId("fullName")
- private TextField Patientname;
- @PropertyId("age")
- private TextField patientage;
- private Label Visitid;
- private Label Visitdate;
- //windowLayouts
- private Layout loadwindowLayout;
- private Layout addwindowLayout;
- private Layout searchwindowLayout;
- //Layouts
- private Layout pateintimageLayout;
- private Layout pateintNameLayout;
- private Layout pateintAgeLayout;
- private Layout visitIDLayout;
- private Layout visitDateLayout;
- //Object Property to fill Labels
- private ObjectProperty<String> NameLabel;
- private ObjectProperty<String> ageLabel;
- private ObjectProperty<String> VisitLabel;
- private ObjectProperty<Date> DateLabel;
- private Button addPatient;
- private Button loadPatient;
- private Button searchPatient;
- private Layout mainLayout;
- private Layout controlersLayout;
- private Layout patinetInfoLayout;
- private BeanFieldGroup<PatientEntity> fieldGroup;
- private PatientEntity patientEntity;
- private PatientHeaderListener eventsListener;
- public PatientHeaderScreen(PatientHeaderListener patientHeaderListener) {
- this.eventsListener = patientHeaderListener;
- NameLabel = new ObjectProperty<String>("");
- ageLabel = new ObjectProperty<String>("");
- VisitLabel = new ObjectProperty<String>("");
- DateLabel = new ObjectProperty<Date>(new Date());
- patientEntity = new PatientEntity();
- addLayout();
- fillLayout(mainLayout);
- addControls(controlersLayout);
- initFiledGroup();
- }
- public void addLayout() {
- mainLayout = new VerticalLayout();
- mainLayout.setSizeFull();
- mainLayout.setStyleName(PATIENTBASICINFOSTYLE);
- loadwindowLayout = new VerticalLayout();
- loadwindowLayout.setSizeUndefined();
- addwindowLayout = new VerticalLayout();
- addwindowLayout.setSizeUndefined();
- searchwindowLayout = new VerticalLayout();
- searchwindowLayout.setSizeUndefined();
- controlersLayout = new HorizontalLayout();
- controlersLayout.setSizeUndefined();
- // ((AbstractOrderedLayout) layoutControls).setSpacing(true);
- controlersLayout.addStyleName("visit-toolbar");
- pateintimageLayout = new HorizontalLayout();
- pateintimageLayout.setSizeUndefined();
- pateintimageLayout.setStyleName("spark");
- pateintNameLayout = new VerticalLayout();
- pateintNameLayout.setSizeUndefined();
- pateintNameLayout.setStyleName("spark");
- pateintAgeLayout = new VerticalLayout();
- pateintAgeLayout.setSizeUndefined();
- pateintAgeLayout.setStyleName("spark");
- visitIDLayout = new VerticalLayout();
- visitIDLayout.setSizeUndefined();
- visitIDLayout.setStyleName("spark");
- visitDateLayout = new VerticalLayout();
- visitDateLayout.setSizeUndefined();
- visitDateLayout.setStyleName("spark");
- patinetInfoLayout = new CssLayout();
- patinetInfoLayout.setSizeUndefined();
- patinetInfoLayout.setStyleName("patient-info");
- setCompositionRoot(mainLayout);
- }
- public void fillLayout(Layout mainLayout) {
- myLocalImage = createImage();
- patientage = createPatientAge();
- Patientname = createPatientName();
- Visitdate = createVisitDate();
- Visitid = createVisitID();
- pateintimageLayout.addComponent(myLocalImage);
- pateintNameLayout.addComponent(Patientname);
- pateintAgeLayout.addComponent(patientage);
- visitIDLayout.addComponent(Visitid);
- visitDateLayout.addComponent(Visitdate);
- patinetInfoLayout.addComponent(pateintimageLayout);
- patinetInfoLayout.addComponent(pateintNameLayout);
- patinetInfoLayout.addComponent(pateintAgeLayout);
- patinetInfoLayout.addComponent(visitIDLayout);
- patinetInfoLayout.addComponent(visitDateLayout);
- mainLayout.addComponent(buildHeader());
- mainLayout.addComponent(patinetInfoLayout);
- }
- /////Header Buttons Controlers .
- private Component buildHeader() {
- HorizontalLayout header = new HorizontalLayout();
- header.addStyleName("Visit-header");
- header.setSpacing(true);
- /// This is the Layout That have the Buttons
- header.addComponent(controlersLayout);
- return header;
- }
- private void addControls(Layout layout) {
- loadPatient = createLoadButton();
- addPatient = createAddButton();
- searchPatient = createVisitSearch();
- // fill related layout
- layout.addComponent(loadPatient);
- layout.addComponent(addPatient);
- layout.addComponent(searchPatient);
- }
- private Button createVisitSearch() {
- Button search = new Button(getBundleValue(CAPTIONS, PATIENTSEARCH));
- search.setStyleName(ValoTheme.BUTTON_PRIMARY);
- search.setClickShortcut(ShortcutAction.KeyCode.ENTER);
- search.setId(PATIENTSEARCH);
- // assign the listener class that handles events
- search.addClickListener(eventsListener);
- return search;
- }
- private Button createLoadButton() {
- Button load = new Button(getBundleValue(CAPTIONS, PATIENTLOAD));
- load.setStyleName(ValoTheme.BUTTON_PRIMARY);
- load.setClickShortcut(ShortcutAction.KeyCode.ENTER);
- load.setId(PATIENTLOAD);
- // assign the listener class that handles events
- load.addClickListener(eventsListener);
- return load;
- }
- private Button createAddButton() {
- Button add = new Button(getBundleValue(CAPTIONS, PATIENTADD));
- add.setStyleName(ValoTheme.BUTTON_PRIMARY);
- add.setClickShortcut(ShortcutAction.KeyCode.ENTER);
- add.setId(PATIENTADD);
- // assign the listener class that handles events
- add.addClickListener(eventsListener);
- return add;
- }
- private Image createImage() {
- myLocalImage = new Image();
- myLocalImage.setWidth("40px");
- myLocalImage.setHeight("40px");
- myLocalImage.setStyleName("user-menu");
- return myLocalImage;
- }
- private TextField createPatientName() {
- Patientname = new TextField();
- Patientname.setId(PATIENTNAME);
- Patientname.setCaption(getBundleValue(CAPTIONS, PATIENTNAME));
- Patientname.setStyleName(ValoTheme.LABEL_NO_MARGIN);
- // Patientname.setPropertyDataSource(NameLabel);
- Patientname.setNullRepresentation("");
- Patientname.setReadOnly(true);
- Patientname.setSizeFull();
- return Patientname;
- }
- private TextField createPatientAge() {
- patientage = new TextField();
- patientage.setId(PATIENTAGE);
- patientage.setStyleName(ValoTheme.LABEL_NO_MARGIN);
- patientage.setCaption(getBundleValue(CAPTIONS, PATIENTAGE));
- // patientage.setPropertyDataSource(ageLabel);
- patientage.setReadOnly(true);
- patientage.setSizeFull();
- return patientage;
- }
- private Label createVisitID() {
- Visitid = new Label("");
- Visitid.setId(PATIENTVISITID);
- Visitid.setCaption(getBundleValue(CAPTIONS, PATIENTVISITID));
- Visitid.setStyleName(ValoTheme.LABEL_NO_MARGIN);
- Visitid.setPropertyDataSource(VisitLabel);
- return Visitid;
- }
- private Label createVisitDate() {
- Visitdate = new Label("");
- Visitdate.setId(PATIENTVISITDATE);
- Visitdate.setCaption(getBundleValue(CAPTIONS, PATIENTVISITDATE));
- Visitdate.setStyleName(ValoTheme.LABEL_NO_MARGIN);
- Visitdate.setPropertyDataSource(DateLabel);
- return Visitdate;
- }
- public Image getMyLocalImage() {
- return myLocalImage;
- }
- public void setMyLocalImage(Image myLocalImage) {
- this.myLocalImage = myLocalImage;
- }
- public TextField getPatientname() {
- return Patientname;
- }
- public void setPatientname(TextField patientname) {
- Patientname = patientname;
- }
- public TextField getPatientage() {
- return patientage;
- }
- public void setPatientage(TextField patientage) {
- this.patientage = patientage;
- }
- public Label getVisitid() {
- return Visitid;
- }
- public void setVisitid(Label visitid) {
- Visitid = visitid;
- }
- public Label getVisitdate() {
- return Visitdate;
- }
- public void setVisitdate(Label visitdate) {
- Visitdate = visitdate;
- }
- public Layout getPateintimageLayout() {
- return pateintimageLayout;
- }
- public void setPateintimageLayout(Layout pateintimageLayout) {
- this.pateintimageLayout = pateintimageLayout;
- }
- public Layout getPateintNameLayout() {
- return pateintNameLayout;
- }
- public void setPateintNameLayout(Layout pateintNameLayout) {
- this.pateintNameLayout = pateintNameLayout;
- }
- public Layout getPateintAgeLayout() {
- return pateintAgeLayout;
- }
- public void setPateintAgeLayout(Layout pateintAgeLayout) {
- this.pateintAgeLayout = pateintAgeLayout;
- }
- public Layout getVisitIDLayout() {
- return visitIDLayout;
- }
- public void setVisitIDLayout(Layout visitIDLayout) {
- this.visitIDLayout = visitIDLayout;
- }
- public Layout getVisitDateLayout() {
- return visitDateLayout;
- }
- public void setVisitDateLayout(Layout visitDateLayout) {
- this.visitDateLayout = visitDateLayout;
- }
- public ObjectProperty<String> getNameLabel() {
- return NameLabel;
- }
- public void setNameLabel(ObjectProperty<String> nameLabel) {
- NameLabel = nameLabel;
- }
- public ObjectProperty<String> getAgeLabel() {
- return ageLabel;
- }
- public void setAgeLabel(ObjectProperty<String> ageLabel) {
- this.ageLabel = ageLabel;
- }
- public ObjectProperty<String> getVisitLabel() {
- return VisitLabel;
- }
- public void setVisitLabel(ObjectProperty<String> visitLabel) {
- VisitLabel = visitLabel;
- }
- public ObjectProperty<Date> getDateLabel() {
- return DateLabel;
- }
- public void setDateLabel(ObjectProperty<Date> dateLabel) {
- DateLabel = dateLabel;
- }
- public Button getAddPatient() {
- return addPatient;
- }
- public void setAddPatient(Button addPatient) {
- this.addPatient = addPatient;
- }
- public Button getLoadPatient() {
- return loadPatient;
- }
- public void setLoadPatient(Button loadPatient) {
- this.loadPatient = loadPatient;
- }
- public Button getSearchPatient() {
- return searchPatient;
- }
- public void setSearchPatient(Button searchPatient) {
- this.searchPatient = searchPatient;
- }
- public Layout getMainLayout() {
- return mainLayout;
- }
- public void setMainLayout(Layout mainLayout) {
- this.mainLayout = mainLayout;
- }
- public Layout getControlersLayout() {
- return controlersLayout;
- }
- public void setControlersLayout(Layout controlersLayout) {
- this.controlersLayout = controlersLayout;
- }
- public Layout getPatinetInfoLayout() {
- return patinetInfoLayout;
- }
- public void setPatinetInfoLayout(Layout patinetInfoLayout) {
- this.patinetInfoLayout = patinetInfoLayout;
- }
- public Layout getLoadwindowLayout() {
- return loadwindowLayout;
- }
- public void setLoadwindowLayout(Layout loadwindowLayout) {
- this.loadwindowLayout = loadwindowLayout;
- }
- public Layout getAddwindowLayout() {
- return addwindowLayout;
- }
- public void setAddwindowLayout(Layout addwindowLayout) {
- this.addwindowLayout = addwindowLayout;
- }
- public Layout getSearchwindowLayout() {
- return searchwindowLayout;
- }
- public void setSearchwindowLayout(Layout searchwindowLayout) {
- this.searchwindowLayout = searchwindowLayout;
- }
- public BeanFieldGroup<PatientEntity> getFieldGroup() {
- return fieldGroup;
- }
- public void initFiledGroup() {
- fieldGroup = new BeanFieldGroup<>(PatientEntity.class);
- fieldGroup.setBuffered(false);
- fieldGroup.bindMemberFields(this);
- }
- public void updateFiledGroup(PatientEntity selectedPatient) {
- this.fieldGroup.setItemDataSource(selectedPatient);
- this.setReadOnlyProberty();
- }
- private void setReadOnlyProberty() {
- patientage.setReadOnly(true);
- Patientname.setReadOnly(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement