private boolean verifierChamp() { if (dObs.getValue() == null) { MessageDialog.openError( Display.getCurrent().getActiveShell(), "Champs obligatoire manquant", "Date de l'observation"); return false; } if (comboType.getSelection().isEmpty()) { MessageDialog.openError( Display.getCurrent().getActiveShell(), "Champs obligatoire manquant", "Type de non conformité"); return false; } return true; }
@Override protected Control createDialogArea(Composite parent) { Personne p = null; container = (Composite) super.createDialogArea(parent); container.setLayout(new GridLayout(1, false)); Group gIdent = new Group(container, SWT.BORDER); gIdent.setText("Identité"); gIdent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); gIdent.setLayout(new GridLayout(4, false)); Label lblNom = new Label(gIdent, SWT.NONE); lblNom.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNom.setText("Nom :"); Text tNom = new Text(gIdent, SWT.BORDER); GridData gd_tNom = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); tNom.setLayoutData(gd_tNom); Label lblPreNom = new Label(gIdent, SWT.NONE); lblPreNom.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblPreNom.setText("Prénom :"); Text tPreNom = new Text(gIdent, SWT.BORDER); GridData gd_tPreNom = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); tPreNom.setLayoutData(gd_tPreNom); if (nonConf.getPersonne() != null) { p = PersonneServiceImpl.getInstance().getPersonneById(nonConf.getPersonne().getIdPersonne()); tNom.setText(p.getNom()); tPreNom.setText(p.getPrenom()); } tNom.setEnabled(false); tPreNom.setEnabled(false); final Group gDescription = new Group(container, SWT.BORDER); gDescription.setText("Description"); gDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); gDescription.setLayout(new GridLayout(6, false)); Label lblType = new Label(gDescription, SWT.NONE); lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblType.setText("Type :"); comboType = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY); comboType.setContentProvider(ArrayContentProvider.getInstance()); comboType.setLabelProvider(new TypeNonConformiteLabelProvider()); comboType.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); comboType.setInput(ReferentielServiceImpl.getInstance().getTypeNonConformite()); comboType.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { TypeNonConformite typeNonConformite = null; ISelection selectiontypeNonConformite = comboType.getSelection(); if (!selectiontypeNonConformite.isEmpty()) { IStructuredSelection structuredSelection = (IStructuredSelection) selectiontypeNonConformite; typeNonConformite = (TypeNonConformite) structuredSelection.getFirstElement(); comboCat.setInput( ReferentielServiceImpl.getInstance() .getCategorieNonConfByIdTypeNonConformite( typeNonConformite.getIdTypeNonConformite())); comboSousCat.setInput(null); } else { comboCat.setInput(null); comboSousCat.setInput(null); } gDescription.pack(); } }); Label lblCat = new Label(gDescription, SWT.NONE); lblCat.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblCat.setText("Catégorie :"); comboCat = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY); comboCat.setContentProvider(ArrayContentProvider.getInstance()); comboCat.setLabelProvider(new CategorieNonConformiteLabelProvider()); comboCat.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); if (nonConf.getCategorie() != null) { comboCat.setInput( ReferentielServiceImpl.getInstance() .getCategorieNonConfByIdTypeNonConformite( nonConf.getCategorie().getIdCategorieNonConformite())); } else { comboCat.setInput(null); } comboCat.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { CategorieNonConformite catNonConformite = null; ISelection selectioncatNonConformite = comboCat.getSelection(); if (!selectioncatNonConformite.isEmpty()) { IStructuredSelection structuredSelection = (IStructuredSelection) selectioncatNonConformite; catNonConformite = (CategorieNonConformite) structuredSelection.getFirstElement(); comboSousCat.setInput( ReferentielServiceImpl.getInstance() .getSousCategorieNonConfByIdCategorieNonConformite( catNonConformite.getIdCategorieNonConformite())); } else { comboSousCat.setInput(null); } gDescription.pack(); } }); Label lblSouCat = new Label(gDescription, SWT.NONE); lblSouCat.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblSouCat.setText("Sous-catégorie :"); comboSousCat = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY); comboSousCat.setContentProvider(ArrayContentProvider.getInstance()); comboSousCat.setLabelProvider(new SousCategorieNonConformiteLabelProvider()); comboSousCat.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); if (nonConf.getSousCategorie() != null) { comboSousCat.setInput( ReferentielServiceImpl.getInstance() .getSousCategorieNonConfByIdCategorieNonConformite( nonConf.getSousCategorie().getIdSousCategorieNonConformite())); } else { comboSousCat.setInput(null); } Label lblAcc = new Label(gDescription, SWT.NONE); lblAcc.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblAcc.setText("Acceptation :"); comboAcceptation = new Combo(gDescription, SWT.READ_ONLY); comboAcceptation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1)); comboAcceptation.setItems(ApplicationContexte.acceptations); Label lblComm = new Label(gDescription, SWT.NONE); lblComm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblComm.setText("Commentaire :"); Text tCommentaire = new Text(gDescription, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); GridData gd_tCommentaire = new GridData(SWT.FILL, SWT.CENTER, false, false, 5, 1); gd_tCommentaire.widthHint = 250; gd_tCommentaire.heightHint = 96; tCommentaire.setLayoutData(gd_tCommentaire); if (nonConf.getCommentaire() != null) { tCommentaire.setText(nonConf.getCommentaire()); } Label lblDateDeLa = new Label(gDescription, SWT.NONE); lblDateDeLa.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblDateDeLa.setText("Date obs :"); dObs = new FormattedText(gDescription, SWT.BORDER); dObs.setFormatter(new DateFormatter("dd/MM/yyyy")); GridData gridData_ddObs = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gridData_ddObs.widthHint = 75; dObs.getControl().setLayoutData(gridData_ddObs); if (nonConf.getDateObservation() != null) { dObs.setValue(nonConf.getDateObservation()); } Label lblListPrelev = new Label(gDescription, SWT.NONE); lblListPrelev.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblListPrelev.setText("Associé au prélèvement :"); listPrelevement = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY); listPrelevement.setContentProvider(ArrayContentProvider.getInstance()); listPrelevement.setLabelProvider(new PrelevementLabelProvider()); listPrelevement .getCombo() .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); if (p != null) { java.util.List<Prelevement> prelevements = PrelevementServiceImpl.getInstance().findAllByidPersonne(p.getIdPersonne()); listPrelevement.setInput(prelevements); } else { listPrelevement.setInput(null); } listPrelevement.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Prelevement prelevement = null; ISelection selectionPrelevement = listPrelevement.getSelection(); if (!selectionPrelevement.isEmpty()) { IStructuredSelection structuredSelection = (IStructuredSelection) selectionPrelevement; prelevement = (Prelevement) structuredSelection.getFirstElement(); List<Analyse> ana = AnalyseServiceImpl.getInstance() .findAllByidPrelevement(prelevement.getIdPrelevement()); ana.add(new Analyse()); listAnalyse.setInput(ana); } else { listAnalyse.setInput(null); } gDescription.pack(); } }); Label lblListAnalyse = new Label(gDescription, SWT.NONE); lblListAnalyse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblListAnalyse.setText("pour l'analyse :"); listAnalyse = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY); listAnalyse.setContentProvider(ArrayContentProvider.getInstance()); listAnalyse.setLabelProvider(new AnalyseLabelProvider()); listAnalyse.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); return container; }