IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaFX Discussion :

Menu Item dans une boite de Dialog


Sujet :

JavaFX

  1. #1
    Membre averti
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2012
    Messages
    42
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2012
    Messages : 42
    Par défaut Menu Item dans une boite de Dialog
    Bonjour a tous!!!!
    (J'utilise JavaFx Builder pour mes UI)
    Dans mon application, le Main principe dispose d'un MenuBar contenant les Items suivants: Open, New, Save, Save As et Exit.
    l'apel de ces item au niveau du Main principal fonction parfaitement.
    mon souci se situe au niveau de la boite de dialog lorsque j'essaie d'adapter le Menu bar dans celle ci.

    je vous presente ci-dessous les differentes partie de mon API

    - MainApp(principal) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    package ch.makery.address;
     
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.prefs.Preferences;
     
    import javafx.application.Application;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Scene;
    import javafx.scene.control.Dialogs;
    import javafx.scene.image.Image;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import ch.makery.address.AbscenceOverviewController;
    import ch.makery.address.model.Person;
    import ch.makery.address.util.FileUtil;
    import ch.makery.address.AbscenceEditDialogController;
     
    import com.thoughtworks.xstream.XStream;
     
    public class MainApp extends Application {
     
    	private Stage primaryStage;
    	private BorderPane rootLayout;
     
    	/**
             * The data as an observable list of Persons.
             */
    	private ObservableList<Person> personData = FXCollections.observableArrayList();
    	private AbscenceOverviewController abscenceOverviewController;
     
    	/**
             * Constructor
             */
    	public MainApp() {
    		// Add some sample data
    		personData.add(new Person("Hans", "Muster"));
    		personData.add(new Person("Ruth", "Mueller"));
    		personData.add(new Person("Heinz", "Kurz"));
    		personData.add(new Person("Cornelia", "Meier"));
    		personData.add(new Person("Werner", "Meyer"));
    		personData.add(new Person("Lydia", "Kunz"));
    		personData.add(new Person("Anna", "Best"));
    		personData.add(new Person("Stefan", "Meier"));
    		personData.add(new Person("Martin", "Mueller"));
     
     
    	}
     
    	@Override
    	public void start(Stage primaryStage) {
    		this.primaryStage = primaryStage;
    		this.primaryStage.setTitle("GRH-ALDIS");
    		this.primaryStage.getIcons().add(new Image("file:resources/images/address_book_32.png"));
     
    		try {
    			// Load the root layout from the fxml file
    			FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/RootLayout.fxml"));
    			rootLayout = (BorderPane) loader.load();
    			Scene scene = new Scene(rootLayout);
    			primaryStage.setScene(scene);
     
    			// Give the controller access to the main app
    			RootLayoutController controller = loader.getController();
    			controller.setMainApp(this);
     
    			primaryStage.show();
    		} catch (IOException e) {
    			// Exception gets thrown if the fxml file could not be loaded
    			e.printStackTrace();
    		}
     
    		showPersonOverview();
     
    		// Try to load last opened person file
    		File filePerson = getPersonFilePath();
    		if (filePerson != null) {
    			loadPersonDataFromFile(filePerson);
    		}
     
     
    	}
     
    	/**
             * Returns the data as an observable list of Persons. 
             * @return
             */
    	public ObservableList<Person> getPersonData() {
    		return personData;
    	}
     
    	/**
             * Returns the main stage.
             * @return
             */
    	public Stage getPrimaryStage() {
    		return primaryStage;
    	}
     
     
    	/**
             * Shows the person overview page in the center of the root layout.
             */
     
    	public void showPersonOverview() {
    		try {
    			// Load the fxml file and set into the center of the main layout
    			FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/PersonOverview.fxml"));
    			AnchorPane overviewPage = (AnchorPane) loader.load();
    			rootLayout.setCenter(overviewPage);
     
    			// Give the controller access to the main app
    			PersonOverviewController controller = loader.getController();
    			controller.setMainApp(this);
     
    		} catch (IOException e) {
    			// Exception gets thrown if the fxml file could not be loaded
    			e.printStackTrace();
    		}
    	}
     
    	public  void showListePerson(){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(MainApp.class.getResource("view/ListePerson.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStage = new Stage();
    		dialogStage.setTitle("Liste du Personnel");
    		dialogStage.initModality(Modality.APPLICATION_MODAL);
    		dialogStage.initOwner(dialogStage);
    		Scene scene = new Scene(page);
    		dialogStage.setScene(scene);
    		dialogStage.show();
     
    		// Set the permission formulaire into the controller
    	    ListePerson controller = loader2.getController();
    	    controller.setMainApp(this);
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
     
    		}
     
    	}
     
     
    	public void showAbscenceListe(){
     
    				try {
    				FXMLLoader loader = new FXMLLoader(AbscenceOverviewController.class.getResource("view/RootLayoutAbsc.fxml"));
    				BorderPane borderPane = (BorderPane) loader.load();	
    				Stage dialogStageAbscL = new Stage();
    				dialogStageAbscL.setTitle("Liste des Abscences");
    				dialogStageAbscL.initModality(Modality.APPLICATION_MODAL);
    				dialogStageAbscL.getIcons().add(new Image("file:resources/images/aldhis_list.png"));
    				dialogStageAbscL.initOwner(primaryStage);
    				Scene scene = new Scene(borderPane);
    				dialogStageAbscL.setScene(scene);
     
    				dialogStageAbscL.show();
     
    				FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceOverview.fxml"));
    				AnchorPane overviewPage = (AnchorPane) loader2.load();
    				borderPane.setCenter(overviewPage);
     
    				// Give the controller access to the main app
    			    AbscenceOverviewController controller = loader2.getController();
    			    controller.setAbscenceListController(abscenceOverviewController);
     
    				}
    				catch (IOException e) {
    				// TODO Bloc catch généré automatiquement
    				e.printStackTrace();
    			 	}
     
    	}
     
     
    	public  boolean showNouvelleAbscence(){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceEdit.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStageAbscN = new Stage();
    		dialogStageAbscN.setTitle("Formulaire Abscence");
    		dialogStageAbscN.initModality(Modality.APPLICATION_MODAL);
    		dialogStageAbscN.initOwner(dialogStageAbscN);
    		Scene scene = new Scene(page);
    		dialogStageAbscN.setScene(scene);
    		dialogStageAbscN.show();
     
    		// Set the permission formulaire into the controller
    	   AbscenceEditDialogController controller = loader2.getController();
    	    controller.setDialogStage(dialogStageAbscN);
     
    		return controller.isValideClicked();
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
    			return false;
    		}
     
    	}
     
     
    	/**
             * Opens a dialog to edit details for the specified person. If the user
             * clicks OK, the changes are saved into the provided person object and
             * true is returned.
             * 
             * @param person the person object to be edited
             * @return true if the user clicked OK, false otherwise.
             */
    	public boolean showPersonEditDialog(Person person) {
    		try {
    			// Load the fxml file and create a new stage for the popup
    			FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/PersonEditDialog.fxml"));
    			AnchorPane page = (AnchorPane) loader.load();
    			Stage dialogStage = new Stage();
    			dialogStage.setTitle("Edit Person");
    			dialogStage.initModality(Modality.WINDOW_MODAL);
    			dialogStage.getIcons().add(new Image("file:resources/images/edit.png"));
    			dialogStage.initOwner(primaryStage);
    			Scene scene = new Scene(page);
    			dialogStage.setScene(scene);
     
    			// Set the person into the controller
    			PersonEditDialogController controller = loader.getController();
    			controller.setDialogStage(dialogStage);
    			controller.setPerson(person);
     
    			// Show the dialog and wait until the user closes it
    			dialogStage.showAndWait();
     
    			return controller.isOkClicked();
     
    		} catch (IOException e) {
    			// Exception gets thrown if the fxml file could not be loaded
    			e.printStackTrace();
    			return false;
    		}
    	}
     
     
     
    	/**
             * Returns the person file preference, i.e. the file that was last opened.
             * The preference is read from the OS specific registry. If no such
             * preference can be found, null is returned.
             * 
             * @return
             */
    	public File getPersonFilePath() {
    		Preferences prefs = Preferences.userNodeForPackage(MainApp.class);
    		String filePath = prefs.get("filePath", null);
    		if (filePath != null) {
    			return new File(filePath);
    		} else {
    			return null;
    		}
    	}
     
     
    	/**
             * Sets the file path of the currently loaded file.
             * The path is persisted in the OS specific registry.
             * 
             * @param file the file or null to remove the path
             */
    	public void setPersonFilePath(File filePerson) {
    		Preferences prefs = Preferences.userNodeForPackage(MainApp.class);
    		if (filePerson != null) {
    			prefs.put("filePath", filePerson.getPath());
     
    			// Update the stage title
    			primaryStage.setTitle("Base de Données ALDIS - " + filePerson.getName());
    		} else {
    			prefs.remove("filePath");
     
    			// Update the stage title
    			primaryStage.setTitle("Base de Données ALDIS");
    		}
    	}
     
    	/**
             * Loads person data from the specified file. The current person data will
             * be replaced.
             * 
             * @param file
             */
    	@SuppressWarnings("unchecked")
    	public void loadPersonDataFromFile(File filePerson) {
    		XStream xstreamPerson = new XStream();
    		xstreamPerson.alias("person", Person.class);
     
    		try {
    			String xml = FileUtil.readFile(filePerson);
     
    			ArrayList<Person> personList = (ArrayList<Person>) xstreamPerson.fromXML(xml);
     
    			personData.clear();
    			personData.addAll(personList);
     
    			setPersonFilePath(filePerson);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(primaryStage,
    					"Could not load data from file:\n" + filePerson.getPath(),
    					"Could not load data", "Error", e);
    		}
    	}
     
     
    	/**
             * Saves the current person data to the specified file.
             * 
             * @param file
             */
    	public void savePersonDataToFile(File filePerson) {
    		XStream xstreamPerson = new XStream();
    		xstreamPerson.alias("person", Person.class);
     
    		// Convert ObservableList to a normal ArrayList
    		ArrayList<Person> personList = new ArrayList<>(personData);
     
    		String xml = xstreamPerson.toXML(personList);
    		try {
    			FileUtil.saveFile(xml, filePerson);
     
    			setPersonFilePath(filePerson);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(primaryStage,
    					"Could not save data to file:\n" + filePerson.getPath(),
    					"Could not save data", "Error", e);
    		}
    	}
     
    	/**
             * Opens a dialog to show birthday statistics. 
             */
    	public void showBirthdayStatistics() {
    	  try {
    	    // Load the fxml file and create a new stage for the popup
    	    FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/BirthdayStatistics.fxml"));
    	    AnchorPane page = (AnchorPane) loader.load();
    	    Stage dialogStage = new Stage();
    	    dialogStage.setTitle("Birthday Statistics");
    	    dialogStage.initModality(Modality.WINDOW_MODAL);
    	    dialogStage.initOwner(primaryStage);
    	    Scene scene = new Scene(page);
    	    dialogStage.setScene(scene);
     
    	    // Set the persons into the controller
    	    BirthdayStatisticsController controller = loader.getController();
    	    controller.setPersonData(personData);
     
    	    dialogStage.show();
     
    	  } catch (IOException e) {
    	    // Exception gets thrown if the fxml file could not be loaded
    	    e.printStackTrace();
    	  }
    	}
     
     
     
     
    	public static void main(String[] args) {
    		launch(args);
    	}
    }
    **********************************************************
    - RootLayoutController
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    package ch.makery.address;
     
    import java.io.File;
     
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.stage.FileChooser;
     
    /**
     * The controller for the root layout. The root layout provides the basic
     * application layout containing a menu bar and space where other JavaFX
     * elements can be placed.
     * 
     * @author Marco Jakob
     */
    public class RootLayoutController {
     
      // Reference to the main application
      private MainApp mainApp;
      /**
      * Is called by the main application to give a reference back to itself.
      * 
      * @param mainApp
      */
      public void setMainApp(MainApp mainApp) {
          this.mainApp = mainApp;
      }
     
      /**
      * Creates an empty address book.
      */
      @FXML
      protected void handleNew() {
          mainApp.getPersonData().clear();
          mainApp.setPersonFilePath(null);
      }
     
      /**
      * Opens a FileChooser to let the user select an address book to load.
      */
      @FXML
      protected void handleOpen() {
          FileChooser fileChooser = new FileChooser();
     
          // Set extension filter
          FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
          fileChooser.getExtensionFilters().add(extFilter);
     
          // Show save file dialog
          File file = fileChooser.showOpenDialog(mainApp.getPrimaryStage());
     
          if (file != null) {
              mainApp.loadPersonDataFromFile(file);
          }
      }
     
      /**
      * Saves the file to the person file that is currently open. If there is no
      * open file, the "save as" dialog is shown.
      */
      @FXML
      protected void handleSave() {
          File personFile = mainApp.getPersonFilePath();
          if (personFile != null) {
              mainApp.savePersonDataToFile(personFile);
          } else {
              handleSaveAs();
          }
      }
     
      /**
      * Opens a FileChooser to let the user select a file to save to.
      */
      @FXML
      protected void handleSaveAs() {
        FileChooser fileChooser = new FileChooser();
     
        // Set extension filter
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
        fileChooser.getExtensionFilters().add(extFilter);
     
        // Show save file dialog
        File file = fileChooser.showSaveDialog(mainApp.getPrimaryStage());
     
        if (file != null) {
          // Make sure it has the correct extension
          if (!file.getPath().endsWith(".xml")) {
            file = new File(file.getPath() + ".xml");
          }
          mainApp.savePersonDataToFile(file);
        }
      }
     
      /**
      * Opens an about dialog.
      */
      @FXML
      protected void handleAbout() {
          Dialogs.showInformationDialog(mainApp.getPrimaryStage(), "Author: Marco Jakob\nWebsite: http://edu.makery.ch", "AddressApp", "About");
      }
     
      /**
      * Closes the application.
      */
      @FXML
      protected void handleExit() {
          System.exit(0);
      }
     
      /**
      * Opens the birthday statistics.
      */
     @FXML
     protected void handleShowBirthdayStatistics() {
       mainApp.showBirthdayStatistics();
     }
     
     @FXML
     protected void handleNouvellePermission(){
    	// mainApp.showNouvellePermission();
     }
     
     
     @FXML
     protected void handleNouvelleAbscence(){
    	 mainApp.showNouvelleAbscence();
     }
     
     @FXML
     protected void handleAbscenceListe(){
    	 mainApp.showAbscenceListe();
     }
     
     @FXML
     protected void handleListePerson(){
    	 mainApp.showListePerson();
     }
    }
    - PersonOverviewController
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    package ch.makery.address;
     
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.image.ImageView;
    import ch.makery.address.model.Person;
    import ch.makery.address.util.CalendarUtil;
     
    /**
     * The controller for the overview with address table and details view.
     * 
     * @author Marco Jakob
     */
    public class PersonOverviewController {
    	@FXML
    	private TableView<Person> personTable;
    	@FXML
    	private TableColumn<Person, String> nomColumn;
    	@FXML
    	private TableColumn<Person, String> prenomColumn;
     
    	@FXML
    	private Label nomLabel;
    	@FXML
    	private Label prenomLabel;
    	@FXML
    	private Label sexeLabel;
    	@FXML
    	private Label dateNaissLabel;
    	@FXML
    	private Label lieuNaissLabel;
    	@FXML
    	private Label matrimonialeLabel;
    	@FXML
    	private Label enfMinLabel;
    	@FXML
    	private Label enfMajLabel;
    	@FXML
    	private Label totalEnfLabel;
    	@FXML
    	private Label adresseLabel;
    	@FXML
    	private Label tel1Label;
    	@FXML
    	private Label tel2Label;
    	@FXML
    	private Label mail1Label;
    	@FXML
    	private Label mail2Label;
    	@FXML
    	private Label fonctionLabel;
    	@FXML
    	private Label categorieLabel;
    	@FXML
    	private Label contratLabel;
    	@FXML
    	private Label dateEmbLabel;
    	@FXML
    	private Label diplomeLabel;
    	@FXML
    	private Label ancienLabel;
    	@FXML
    	private Label salaireDebutLabel;
    	@FXML
    	private Label salaireActuelLabel;
    	@FXML
    	private ImageView imageView;
     
    	// Reference to the main application
    	private MainApp mainApp;
     
    	/**
             * The constructor. The constructor is called before the initialize()
             * method.
             */
    	public PersonOverviewController() {
    	}
     
    	@FXML
    	private void initialize() {
    		// Initialize the person table
    		nomColumn.setCellValueFactory(new PropertyValueFactory<Person, String>("nom"));
    		prenomColumn.setCellValueFactory(new PropertyValueFactory<Person, String>("prenom"));
     
    		// Auto resize columns
    		personTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
     
    		// clear person
    		showPersonDetails(null);
     
    		// Listen for selection changes
    		personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
     
    			@Override
    			public void changed(ObservableValue<? extends Person> observable,
    					Person oldValue, Person newValue) {
    				showPersonDetails(newValue);
    			}
    		});
    	}
     
    	/**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setMainApp(MainApp mainApp) {
    		this.mainApp = mainApp;
     
    		// Add observable list data to the table
    		personTable.setItems(mainApp.getPersonData());
    	}
     
    	/**
             * Fills all text fields to show details about the person.
             * If the specified person is null, all text fields are cleared.
             * 
             * @param person the person or null
             */
    	private void showPersonDetails(Person person) {
    		if (person != null) {
    			nomLabel.setText(person.getNom());
    			prenomLabel.setText(person.getPrenom());
    			sexeLabel.setText(person.getSexe());
    			dateNaissLabel.setText(CalendarUtil.format(person.getDateNaiss()));
    			//dLabel.setText(Integer.toString(person.getPostalCode()));
    			lieuNaissLabel.setText(person.getLieuNaiss());
    			matrimonialeLabel.setText(person.getMatrimoniale());
    			enfMinLabel.setText(Integer.toString(person.getEnfMin()));
    			enfMajLabel.setText(Integer.toString(person.getEnfMaj()));
    			totalEnfLabel.setText(Integer.toString(person.getTotalEnf()));
    			adresseLabel.setText(person.getAdresse());
    			tel1Label.setText(person.getTel1());
    			tel2Label.setText(person.getTel2());
    			mail1Label.setText(person.getMail1());
    			mail2Label.setText(person.getMail2());
    			fonctionLabel.setText(person.getFonction());
    			categorieLabel.setText(person.getCategorie());
    			contratLabel.setText(person.getContrat());
    			dateEmbLabel.setText(CalendarUtil.format(person.getDateEmb()));
    			diplomeLabel.setText(person.getDiplome());
    			ancienLabel.setText(Integer.toString(person.getAncien()));
    			salaireDebutLabel.setText(Integer.toString(person.getSalaireDebut()));
    			salaireActuelLabel.setText(Integer.toString(person.getSalaireActuel()));
    			imageView.setImage(person.getImagePers());
     
    		} else {
    			nomLabel.setText("");
    			prenomLabel.setText("");
    			sexeLabel.setText("");
    			dateNaissLabel.setText("");
    			lieuNaissLabel.setText("");
    			matrimonialeLabel.setText("");
    			enfMinLabel.setText("");
    			enfMajLabel.setText("");
    			totalEnfLabel.setText("");
    			adresseLabel.setText("");
    			tel1Label.setText("");
    			tel2Label.setText("");
    			mail1Label.setText("");
    			mail2Label.setText("");
    			fonctionLabel.setText("");
    			categorieLabel.setText("");
    			contratLabel.setText("");
    			dateEmbLabel.setText("");
    			diplomeLabel.setText("");
    			ancienLabel.setText("");
    			salaireDebutLabel.setText("");
    			salaireActuelLabel.setText("");
    			imageView.setImage(null);
    		}
    	}
     
    	/**
             * Called when the user clicks on the delete button.
             */
    	@FXML
    	private void handleSupprimerPerson() {
    		int selectedIndex = personTable.getSelectionModel().getSelectedIndex();
    		if (selectedIndex >= 0) {
    			personTable.getItems().remove(selectedIndex);
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(mainApp.getPrimaryStage(),
    					"Please select a person in the table.",
    					"No Person Selected", "No Selection");
    		}
    	}
     
    	/**
             * Called when the user clicks the new button.
             * Opens a dialog to edit details for a new person.
             */
    	@FXML
    	private void handleNouveauPerson() {
    		Person tempPerson = new Person();
    		boolean okClicked = mainApp.showPersonEditDialog(tempPerson);
    		if (okClicked) {
    			mainApp.getPersonData().add(tempPerson);
    		}
    	}
     
    	/**
             * Called when the user clicks the edit button.
             * Opens a dialog to edit details for the selected person.
             */
    	@FXML
    	private void handleModifierPerson() {
    		Person selectedPerson = personTable.getSelectionModel().getSelectedItem();
    		if (selectedPerson != null) {
    			boolean okClicked = mainApp.showPersonEditDialog(selectedPerson);
    			if (okClicked) {
    				refreshPersonTable();
    				showPersonDetails(selectedPerson);
    			}
     
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(mainApp.getPrimaryStage(),
    					"Please select a person in the table.",
    					"No Person Selected", "No Selection");
    		}
    	}
     
    	/**
             * Refreshes the table. This is only necessary if an item that is already in
             * the table is changed. New and deleted items are refreshed automatically.
             * 
             * This is a workaround because otherwise we would need to use property
             * bindings in the model class and add a *property() method for each
             * property. Maybe this will not be necessary in future versions of JavaFX
             * (see <a href="http://javafx-jira.kenai.com/browse/RT-22599" target="_blank">http://javafx-jira.kenai.com/browse/RT-22599</a>)
             */
    	private void refreshPersonTable() {
    		int selectedIndex = personTable.getSelectionModel().getSelectedIndex();
    		personTable.setItems(null);
    		personTable.layout();
    		personTable.setItems(mainApp.getPersonData());
    		// Must set the selected index again (see <a href="http://javafx-jira.kenai.com/browse/RT-26291" target="_blank">http://javafx-jira.kenai.com/browse/RT-26291</a>)
    		personTable.getSelectionModel().select(selectedIndex);
    	}
    }
    Affichage de la boite de dialogue

    - RootLayoutAbscController
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    package ch.makery.address;
     
    import java.io.File;
     
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.stage.FileChooser;
    import ch.makery.address.model.Abscence;
     
    public class RootLayoutAbscController {
     
     
    	private AbscenceOverviewController abscenceOverviewController;
     
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController){
    		this.abscenceOverviewController = abscenceOverviewController;
     
    	}
     
     
    	//*****************************************************************************************
    	@FXML
    	  private void handleNouveau() {
    		  abscenceOverviewController.getAbscenceData().clear();
    		  abscenceOverviewController.setAbscenceFilePath(null);
    	  }
     
    	/**
              * Opens a FileChooser to let the user select an address book to load.
             */
     
    	  @FXML
    	  private void handleOuvrir() {
     
    		FileChooser fileChooser = new FileChooser();
     
    		// Set extension filter
    		FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
    		fileChooser.getExtensionFilters().add(extFilter);
     
    		// Show save file dialog
    		File abscenceFile = fileChooser.showOpenDialog(null);
     
    			if (abscenceFile != null) {
    			   abscenceOverviewController.loadAbscenceDataFromFile(abscenceFile);
    			   }
    	}
     
    	  /**
              * Saves the file to the abscence file that is currently open. If there is no
              * open file, the "save as" dialog is shown.
              */
     
    	  @FXML
    	  private void handleEnregistrer() {
    		File abscenceFile = abscenceOverviewController.getAbscenceFilePath();
    		if (abscenceFile != null) {
    			abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		} else{
    			handleEnregistrerSous();
    			}   
    	  }
     
    	  /**
              * Opens a FileChooser to let the user select a file to save to.
              *
               */
    	  @FXML
    	  private void handleEnregistrerSous() {
     
    		FileChooser fileChooser = new FileChooser();
     
    		// Set extension filter
    		FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
    		fileChooser.getExtensionFilters().add(extFilter);
     
    		// Show save file dialog
    		File abscenceFile = fileChooser.showSaveDialog(null);
     
    		if (abscenceFile != null) {
     
    		// Make sure it has the correct extension
    			if (!abscenceFile.getPath().endsWith(".xml")) {
    				abscenceFile = new File(abscenceFile.getPath() + ".xml");
    			  }
    			  abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		}
    	  }
     
    	  @FXML
    	  protected void handleQuitter() {
    	      System.exit(0);
    	  }
     
     
    	/*
    	 * 
    	 * 
     
    	  @FXML
    	  private void handleExit(ActionEvent event) {
    	        System.exit(0);
    	      }
    	  */
     
    	  @FXML
    		private void handleModifierAbscence() {
    			Abscence selectedAbscence = abscenceOverviewController.abscenceTable.getSelectionModel().getSelectedItem();
    			if (selectedAbscence != null) {
    				boolean okClicked = abscenceOverviewController.showAbscenceEditDialog(selectedAbscence);
    				if (okClicked) {
    					abscenceOverviewController.refreshAbscenceTable();
    					abscenceOverviewController.showAbscenceDetails(selectedAbscence);
    				}
     
    			} else {
    				// Nothing selected
    				Dialogs.showWarningDialog(null,
    						"Veillez sélectionnez une personne dans la Table.",
    						"Pas de Personne Sélectionnée", "Pas de Sélection");
    			}
    		}
     
    		/**
                     * Called when the user clicks on the delete button.
                     */
    		@FXML
    		private void handleSupprimerAbscence() {
    			int selectedIndex = abscenceOverviewController.abscenceTable.getSelectionModel().getSelectedIndex();
    			if (selectedIndex >= 0) {
    				abscenceOverviewController.abscenceTable.getItems().remove(selectedIndex);
    			} else {
    				// Nothing selected
    				Dialogs.showErrorDialog( null,
    						"Please select a person in the table.",
    						"No Person Selected", "No Selection");
    			}
    		}
     
     
     
    }
    - AbscenceOverviewController
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    package ch.makery.address;
     
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.prefs.Preferences;
     
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXML;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.Dialogs;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.AnchorPane;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import ch.makery.address.model.Abscence;
    import ch.makery.address.util.CalendarUtil;
    import ch.makery.address.util.FileUtil;
     
    import com.thoughtworks.xstream.XStream;
     
    /**
     * 
     * @author Anohjp
     *
     */
     
    public class AbscenceOverviewController{
     
    	@FXML
    	protected TextField filterField;
    	@FXML 
    	protected TableView<Abscence> abscenceTable;
    	@FXML
    	private TableColumn<Abscence, String> nomPersColumn;
    	@FXML
    	private TableColumn<Abscence, String> prenomPersColumn;
     
    	@FXML
    	private Label nomPersLabel;
    	@FXML
    	private Label prenomPersLabel;
    	@FXML
    	private Label fonctionLabel;
    	@FXML
    	private Label dateDebutLabel;
    	@FXML
    	private Label dateFinLabel;
    	@FXML
    	private Label dureeLabel;
    	@FXML
    	private Label motifLabel;
    	@FXML
    	ComboBox<String> trimestreComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<String> moisComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<String> semestreComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<Integer> anneeComboBox = new ComboBox<Integer>();
     
    	//private String mois[] = new String[]{};
    	//final ComboBox comboBox = new ComboBox();
     
    	private ObservableList<Abscence> abscenceData = FXCollections.observableArrayList();
    	//private ObservableList<Abscence> filteredData = FXCollections.observableArrayList();
    	//private ObservableList<Abscence> comboBoxData = FXCollections.observableArrayList();
     
    	private Stage dialogStageAbscL;
     
     
    	// Creation d constructeur
    	public AbscenceOverviewController(){
     
    		abscenceData.add(new Abscence("Jean", "Ezan"));
    		abscenceData.add(new Abscence("Paul", "Anoh"));
    		abscenceData.add(new Abscence("Germain", "Ezan"));
    		abscenceData.add(new Abscence("Jean", "Anoh"));
    		abscenceData.add(new Abscence("Paul", "Ezan"));
    		abscenceData.add(new Abscence("Germain", "Anoh"));
    		abscenceData.add(new Abscence("Hans", "Muster"));
    		abscenceData.add(new Abscence("Ruth", "Mueller"));
    		abscenceData.add(new Abscence("Heinz", "Kurz"));
    		abscenceData.add(new Abscence("Cornelia", "Meier"));
    		abscenceData.add(new Abscence("Werner", "Meyer"));
    	}
     
    	@FXML
    	private void initialize() {
     
    		// Initialise la table permission
    		nomPersColumn.setCellValueFactory(new PropertyValueFactory<Abscence, String>("nomPers"));
    		prenomPersColumn.setCellValueFactory(new PropertyValueFactory<Abscence, String>("prenomPers"));		
     
    		// Auto resize columns
    		abscenceTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
     
    		// effacer Abscence
    		showAbscenceDetails(null);
     
    		// Listen for selection changes/ Ecouteur de changement de selection
    		abscenceTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Abscence>() {
     
    			@Override
    			public void changed(ObservableValue<? extends Abscence> observable,
    				Abscence oldValue, Abscence newValue) {
    					showAbscenceDetails(newValue);
    				}
    			});
     
    	}//Fin de private void initialize()
     
    //****************************************************************************************************	   
     
    	public ObservableList<Abscence> getAbscenceData() {
    		return abscenceData;
    	}
     
    	/**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController) {
    		// Add observable list data to the table
    		abscenceTable.setItems(getAbscenceData());	
    	}
     
     
    	/**
             * Fills all text fields to show details about the permission.
             * If the specified permission is null, all text fields are cleared.
             * 
             * @param Abscence the abscence or null
             */
    	protected void showAbscenceDetails(Abscence abscence) {
    		if (abscence != null) {
    			nomPersLabel.setText(abscence.getNomPers());
    			prenomPersLabel.setText(abscence.getPrenomPers());
    			fonctionLabel.setText(abscence.getFonction());
    			dateDebutLabel.setText(CalendarUtil.format(abscence.getDateDebut()));
    			dateFinLabel.setText(CalendarUtil.format(abscence.getDateFin()));
    			dureeLabel.setText(Integer.toString(abscence.getDureeAbsc()));
    			motifLabel.setText(abscence.getMotif());
     
     
    		} else {
    			nomPersLabel.setText("");
    			prenomPersLabel.setText("");
    			fonctionLabel.setText("");
    			dateDebutLabel.setText("");
    			dateFinLabel.setText("");
    			dureeLabel.setText("");
    			motifLabel.setText("");
     
    		}
    	}
     
    	/***
             * 
             * @param abscence, montre le formulaire d'abscence
             * @return
             */
     
    	public  boolean showAbscenceEditDialog(Abscence abscence){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceEditDialog.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStageAbscE = new Stage();
    		dialogStageAbscE.setTitle("Formulaire Abscence");
    		dialogStageAbscE.initModality(Modality.WINDOW_MODAL);
    		dialogStageAbscE.initOwner(dialogStageAbscE);
    		Scene scene = new Scene(page);
    		dialogStageAbscE.setScene(scene);
    		dialogStageAbscE.show();
     
    		// Set the permission formulaire into the controller
    		AbscenceEditDialogController controller = loader2.getController();
    	    controller.setDialogStageAbscE(dialogStageAbscE);
    	    controller.setAbscence(abscence);
     
    		return controller.isValideClicked();
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
    			return false;
    		}
     
    	}
     
     
    	/**
             * Called when the user clicks the new button.
             * Opens a dialog to edit details for a new person.
            */
    	@FXML
    	private void handleNouvelleAbscence() {
    		Abscence tempAbscence = new Abscence();
    		boolean nouveauClicked = showAbscenceEditDialog(tempAbscence);
    		if (nouveauClicked) {
    			getAbscenceData().add(tempAbscence);
    		}
    	} 
     
    	/***
             * Param du bouton Modifier
             */
    	@FXML
    	private void handleModifierAbscence() {
    		Abscence selectedAbscence = abscenceTable.getSelectionModel().getSelectedItem();
    		if (selectedAbscence != null) {
    			boolean okClicked = showAbscenceEditDialog(selectedAbscence);
    			if (okClicked) {
    				refreshAbscenceTable();
    				showAbscenceDetails(selectedAbscence);
    			}
     
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(null,
    					"Veillez sélectionnez une Abscence dans la Table.",
    					"Pas d'Abscence Sélectionnée", "Pas de Sélection");
    		}
    	}
     
    	/**
             * Called when the user clicks on the delete button.
             */
    	@FXML
    	private void handleSupprimerAbscence() {
    		int selectedIndex = abscenceTable.getSelectionModel().getSelectedIndex();
    		if (selectedIndex >= 0) {
    			abscenceTable.getItems().remove(selectedIndex);
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(null,
    					"Veillez sélectionner une Abscence dans la table",
    					"Pas d'Abscence Sélectionnée", "Pas de Sélection");
    		}
    	}
     
     
    	/**
             * Returns the data as an observable list of Abscence
             * @return
             */
     
     
    	public File getAbscenceFilePath() {
    		Preferences prefsAbs = Preferences.systemNodeForPackage(AbscenceOverviewController.class);
    		String filePathAbsc = prefsAbs.get("filePathAbsc", null);
    		if (filePathAbsc != null) {
    			return new File(filePathAbsc);
    		} 
    		else {
    			return null;
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, setAbscenceFilePath
             */
     
    	public void setAbscenceFilePath(File abscenceFile) {
    		Preferences prefsAbs = Preferences.userNodeForPackage(AbscenceOverviewController.class);
    		if (abscenceFile != null) {
    			prefsAbs.put("filePath", abscenceFile.getPath());
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence - " + abscenceFile.getName());
    		} 
    		else {
    			prefsAbs.remove("filePathAbsc");
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence");
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, loadAbscenceDataFromFile
             */
    	@SuppressWarnings("unchecked")
    	public void loadAbscenceDataFromFile(File abscenceFile) {
    		XStream xstreamAbscence = new XStream();
    		xstreamAbscence.alias("abscence", Abscence.class);
     
    		try {
    			String xml = FileUtil.readFile(abscenceFile);
     
    			ArrayList<Abscence> abscenceList = (ArrayList<Abscence>) xstreamAbscence.fromXML(xml);
     
    			abscenceData.clear();
    			abscenceData.addAll(abscenceList);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    					"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    					"Impossible de charger les données", "Error", e);
    		}
    	}
     
    	/****
             * 
             * @param file, saveAbscenceDataToFile
             */
    	public void saveAbscenceDataToFile(File abscenceFile) {
    		XStream xstream = new XStream();
    		xstream.alias("abscence", Abscence.class);
     
    		// Convert ObservableList to a normal ArrayList
    		ArrayList<Abscence> abscenceList = new ArrayList<>(abscenceData);		
    		String xml = xstream.toXML(abscenceList);
     
    		try {
    			FileUtil.saveFile(xml, abscenceFile);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    				"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    				"Impossible de charger les données", "Error", e);
    		}
    	}
     
     
     
    	/**
             * Refreshes the table. This is only necessary if an item that is already in
             * the table is changed. New and deleted items are refreshed automatically.
             * 
             * This is a workaround because otherwise we would need to use property
             * bindings in the model class and add a *property() method for each
             * property. Maybe this will not be necessary in future versions of JavaFX
             * (see <a href="http://javafx-jira.kenai.com/browse/RT-22599" target="_blank">http://javafx-jira.kenai.com/browse/RT-22599</a>)
             */
     
    	protected void refreshAbscenceTable() {
    		int selectedIndex = abscenceTable.getSelectionModel().getSelectedIndex();
    		abscenceTable.setItems(null);
    		abscenceTable.layout();
    		abscenceTable.setItems(getAbscenceData());
    		// Must set the selected index again (see <a href="http://javafx-jira.kenai.com/browse/RT-26291" target="_blank">http://javafx-jira.kenai.com/browse/RT-26291</a>)
    		abscenceTable.getSelectionModel().select(selectedIndex);
    	}
     
    	@Override
    	public void start(Stage arg0) throws Exception {
    		// TODO Stub de la méthode généré automatiquement
     
    	}
     
     
     
    }// Fin de la classe PermissionListController

  2. #2
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    Citation Envoyé par Anohjp
    mon souci se situe au niveau de la boite de dialog lorsque j'essaie d'adapter le Menu bar dans celle ci.
    Un soucis ? Mais lequel ?

    Est-ce qu'on pourrait avoir qq captures d’écran de ce qui ne va pas et éventuellement un montage de de ce que ça devrait être quand ca fonctionne vu que sans les FXML appropriés, c'est assez difficile de tester en l’état ?
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  3. #3
    Membre averti
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2012
    Messages
    42
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2012
    Messages : 42
    Par défaut
    Ok, merci pour votre reponse!!

    Tout d'abord je tiens a preciser que le probleme se situe au niveau des MenuItems(New, Open, Save, Save As) de ma boite de dialogue.

    Voici la capture de mon UI principal
    Dans ce UI principal les MenuItems(New, Open, Save, Save As) marchent parfaitement.

    Codes permettant son affichache:

    -MainApp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
     package ch.makery.address;
     
     
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.prefs.Preferences;
     
    import javafx.application.Application;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Scene;
    import javafx.scene.control.Dialogs;
    import javafx.scene.image.Image;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import ch.makery.address.AbscenceOverviewController;
    import ch.makery.address.model.Person;
    import ch.makery.address.util.FileUtil;
    import ch.makery.address.AbscenceEditDialogController;
     
    import com.thoughtworks.xstream.XStream;
     
    public class MainApp extends Application {
     
    	private Stage primaryStage;
    	private BorderPane rootLayout;
     
    	/**
             * The data as an observable list of Persons.
             */
    	private ObservableList<Person> personData = FXCollections.observableArrayList();
    	private AbscenceOverviewController abscenceOverviewController;
     
    	/**
             * Constructor
             */
    	public MainApp() {
    		// Add some sample data
    		personData.add(new Person("Hans", "Muster"));
    		personData.add(new Person("Ruth", "Mueller"));
    		personData.add(new Person("Heinz", "Kurz"));
    		personData.add(new Person("Cornelia", "Meier"));
    		personData.add(new Person("Werner", "Meyer"));
    		personData.add(new Person("Lydia", "Kunz"));
    		personData.add(new Person("Anna", "Best"));
    		personData.add(new Person("Stefan", "Meier"));
    		personData.add(new Person("Martin", "Mueller"));
     
     
    	}
     
    	@Override
    	public void start(Stage primaryStage) {
    		this.primaryStage = primaryStage;
    		this.primaryStage.setTitle("GRH-ALDIS");
    		this.primaryStage.getIcons().add(new Image("file:resources/images/address_book_32.png"));
     
    		try {
    			// Load the root layout from the fxml file
    			FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/RootLayout.fxml"));
    			rootLayout = (BorderPane) loader.load();
    			Scene scene = new Scene(rootLayout);
    			primaryStage.setScene(scene);
     
    			// Give the controller access to the main app
    			RootLayoutController controller = loader.getController();
    			controller.setMainApp(this);
     
    			primaryStage.show();
    		} catch (IOException e) {
    			// Exception gets thrown if the fxml file could not be loaded
    			e.printStackTrace();
    		}
     
    		showPersonOverview();
     
    		// Try to load last opened person file
    		File filePerson = getPersonFilePath();
    		if (filePerson != null) {
    			loadPersonDataFromFile(filePerson);
    		}
     
     
    	}
     
    	/**
             * Returns the data as an observable list of Persons. 
             * @return
             */
    	public ObservableList<Person> getPersonData() {
    		return personData;
    	}
     
    	//***************************************************
     
    	/**
             * Returns the main stage.
             * @return
             */
    	public Stage getPrimaryStage() {
    		return primaryStage;
    	}
     
     
    	/**
             * Shows the person overview page in the center of the root layout.
             */
     
    	public void showPersonOverview() {
    		try {
    			// Load the fxml file and set into the center of the main layout
    			FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/PersonOverview.fxml"));
    			AnchorPane overviewPage = (AnchorPane) loader.load();
    			rootLayout.setCenter(overviewPage);
     
    			// Give the controller access to the main app
    			PersonOverviewController controller = loader.getController();
    			controller.setMainApp(this);
     
    		} catch (IOException e) {
    			// Exception gets thrown if the fxml file could not be loaded
    			e.printStackTrace();
    		}
    	}
     
    	public  void showListePerson(){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(MainApp.class.getResource("view/ListePerson.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStage = new Stage();
    		dialogStage.setTitle("Liste du Personnel");
    		dialogStage.initModality(Modality.APPLICATION_MODAL);
    		dialogStage.initOwner(dialogStage);
    		Scene scene = new Scene(page);
    		dialogStage.setScene(scene);
    		dialogStage.show();
     
    		// Set the permission formulaire into the controller
    	    ListePerson controller = loader2.getController();
    	    controller.setMainApp(this);
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
     
    		}
     
    	}
     
    //******************************************************************************************************
     
    	public void showAbscenceListe(){
     
    				try {
    				FXMLLoader loader = new FXMLLoader(AbscenceOverviewController.class.getResource("view/RootLayoutAbsc.fxml"));
    				BorderPane borderPane = (BorderPane) loader.load();	
    				Stage dialogStageAbscL = new Stage();
    				dialogStageAbscL.setTitle("Liste des Abscences");
    				dialogStageAbscL.initModality(Modality.APPLICATION_MODAL);
    				dialogStageAbscL.getIcons().add(new Image("file:resources/images/aldhis_list.png"));
    				dialogStageAbscL.initOwner(primaryStage);
    				Scene scene = new Scene(borderPane);
    				dialogStageAbscL.setScene(scene);
     
    				dialogStageAbscL.show();
     
    				FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceOverview.fxml"));
    				AnchorPane overviewPage = (AnchorPane) loader2.load();
    				borderPane.setCenter(overviewPage);
     
    				// Give the controller access to the main app
    			    AbscenceOverviewController controller = loader2.getController();
    			    controller.setAbscenceListController(abscenceOverviewController);
     
    				}
    				catch (IOException e) {
    				// TODO Bloc catch généré automatiquement
    				e.printStackTrace();
    			 	}
     
    	}
     
     
    	public  boolean showNouvelleAbscence(){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceEdit.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStageAbscN = new Stage();
    		dialogStageAbscN.setTitle("Formulaire Abscence");
    		dialogStageAbscN.initModality(Modality.APPLICATION_MODAL);
    		dialogStageAbscN.initOwner(dialogStageAbscN);
    		Scene scene = new Scene(page);
    		dialogStageAbscN.setScene(scene);
    		dialogStageAbscN.show();
     
    		// Set the permission formulaire into the controller
    	   AbscenceEditDialogController controller = loader2.getController();
    	    controller.setDialogStage(dialogStageAbscN);
     
    		return controller.isValideClicked();
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
    			return false;
    		}
     
    	}
    //******************************************************************************************************
     
    	/**
             * Opens a dialog to edit details for the specified person. If the user
             * clicks OK, the changes are saved into the provided person object and
             * true is returned.
             * 
             * @param person the person object to be edited
             * @return true if the user clicked OK, false otherwise.
             */
    	public boolean showPersonEditDialog(Person person) {
    		try {
    			// Load the fxml file and create a new stage for the popup
    			FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/PersonEditDialog.fxml"));
    			AnchorPane page = (AnchorPane) loader.load();
    			Stage dialogStage = new Stage();
    			dialogStage.setTitle("Edit Person");
    			dialogStage.initModality(Modality.WINDOW_MODAL);
    			dialogStage.getIcons().add(new Image("file:resources/images/edit.png"));
    			dialogStage.initOwner(primaryStage);
    			Scene scene = new Scene(page);
    			dialogStage.setScene(scene);
     
    			// Set the person into the controller
    			PersonEditDialogController controller = loader.getController();
    			controller.setDialogStage(dialogStage);
    			controller.setPerson(person);
     
    			// Show the dialog and wait until the user closes it
    			dialogStage.showAndWait();
     
    			return controller.isOkClicked();
     
    		} catch (IOException e) {
    			// Exception gets thrown if the fxml file could not be loaded
    			e.printStackTrace();
    			return false;
    		}
    	}
     
     
     
    	/**
             * Returns the person file preference, i.e. the file that was last opened.
             * The preference is read from the OS specific registry. If no such
             * preference can be found, null is returned.
             * 
             * @return
             */
    	public File getPersonFilePath() {
    		Preferences prefs = Preferences.userNodeForPackage(MainApp.class);
    		String filePath = prefs.get("filePath", null);
    		if (filePath != null) {
    			return new File(filePath);
    		} else {
    			return null;
    		}
    	}
     
    	//*******************************************************************************
     
    	/**
             * Sets the file path of the currently loaded file.
             * The path is persisted in the OS specific registry.
             * 
             * @param file the file or null to remove the path
             */
    	public void setPersonFilePath(File filePerson) {
    		Preferences prefs = Preferences.userNodeForPackage(MainApp.class);
    		if (filePerson != null) {
    			prefs.put("filePath", filePerson.getPath());
     
    			// Update the stage title
    			primaryStage.setTitle("Base de Données ALDIS - " + filePerson.getName());
    		} else {
    			prefs.remove("filePath");
     
    			// Update the stage title
    			primaryStage.setTitle("Base de Données ALDIS");
    		}
    	}
     
    	//*************************************************************************************
     
    	/**
             * Loads person data from the specified file. The current person data will
             * be replaced.
             * 
             * @param file
             */
    	@SuppressWarnings("unchecked")
    	public void loadPersonDataFromFile(File filePerson) {
    		XStream xstreamPerson = new XStream();
    		xstreamPerson.alias("person", Person.class);
     
    		try {
    			String xml = FileUtil.readFile(filePerson);
     
    			ArrayList<Person> personList = (ArrayList<Person>) xstreamPerson.fromXML(xml);
     
    			personData.clear();
    			personData.addAll(personList);
     
    			setPersonFilePath(filePerson);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(primaryStage,
    					"Could not load data from file:\n" + filePerson.getPath(),
    					"Could not load data", "Error", e);
    		}
    	}
     
     
    	//******************************************************************************************************************
     
    	/**
             * Saves the current person data to the specified file.
             * 
             * @param file
             */
    	public void savePersonDataToFile(File filePerson) {
    		XStream xstreamPerson = new XStream();
    		xstreamPerson.alias("person", Person.class);
     
    		// Convert ObservableList to a normal ArrayList
    		ArrayList<Person> personList = new ArrayList<>(personData);
     
    		String xml = xstreamPerson.toXML(personList);
    		try {
    			FileUtil.saveFile(xml, filePerson);
     
    			setPersonFilePath(filePerson);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(primaryStage,
    					"Could not save data to file:\n" + filePerson.getPath(),
    					"Could not save data", "Error", e);
    		}
    	}
     
    	/**
             * Opens a dialog to show birthday statistics. 
             */
    	public void showBirthdayStatistics() {
    	  try {
    	    // Load the fxml file and create a new stage for the popup
    	    FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/BirthdayStatistics.fxml"));
    	    AnchorPane page = (AnchorPane) loader.load();
    	    Stage dialogStage = new Stage();
    	    dialogStage.setTitle("Birthday Statistics");
    	    dialogStage.initModality(Modality.WINDOW_MODAL);
    	    dialogStage.initOwner(primaryStage);
    	    Scene scene = new Scene(page);
    	    dialogStage.setScene(scene);
     
    	    // Set the persons into the controller
    	    BirthdayStatisticsController controller = loader.getController();
    	    controller.setPersonData(personData);
     
    	    dialogStage.show();
     
    	  } catch (IOException e) {
    	    // Exception gets thrown if the fxml file could not be loaded
    	    e.printStackTrace();
    	  }
    	}
     
     
     
     
    	public static void main(String[] args) {
    		launch(args);
    	}
    }
    - PersonOverview
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    package ch.makery.address;
     
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.image.ImageView;
    import ch.makery.address.model.Person;
    import ch.makery.address.util.CalendarUtil;
     
    /**
     * The controller for the overview with address table and details view.
     * 
     * @author Marco Jakob
     */
    public class PersonOverviewController {
    	@FXML
    	private TableView<Person> personTable;
    	@FXML
    	private TableColumn<Person, String> nomColumn;
    	@FXML
    	private TableColumn<Person, String> prenomColumn;
     
    	@FXML
    	private Label nomLabel;
    	@FXML
    	private Label prenomLabel;
    	@FXML
    	private Label sexeLabel;
    	@FXML
    	private Label dateNaissLabel;
    	@FXML
    	private Label lieuNaissLabel;
    	@FXML
    	private Label matrimonialeLabel;
    	@FXML
    	private Label enfMinLabel;
    	@FXML
    	private Label enfMajLabel;
    	@FXML
    	private Label totalEnfLabel;
    	@FXML
    	private Label adresseLabel;
    	@FXML
    	private Label tel1Label;
    	@FXML
    	private Label tel2Label;
    	@FXML
    	private Label mail1Label;
    	@FXML
    	private Label mail2Label;
    	@FXML
    	private Label fonctionLabel;
    	@FXML
    	private Label categorieLabel;
    	@FXML
    	private Label contratLabel;
    	@FXML
    	private Label dateEmbLabel;
    	@FXML
    	private Label diplomeLabel;
    	@FXML
    	private Label ancienLabel;
    	@FXML
    	private Label salaireDebutLabel;
    	@FXML
    	private Label salaireActuelLabel;
    	@FXML
    	private ImageView imageView;
     
    	// Reference to the main application
    	private MainApp mainApp;
     
    	/**
             * The constructor. The constructor is called before the initialize()
             * method.
             */
    	public PersonOverviewController() {
    	}
     
    	@FXML
    	private void initialize() {
    		// Initialize the person table
    		nomColumn.setCellValueFactory(new PropertyValueFactory<Person, String>("nom"));
    		prenomColumn.setCellValueFactory(new PropertyValueFactory<Person, String>("prenom"));
     
    		// Auto resize columns
    		personTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
     
    		// clear person
    		showPersonDetails(null);
     
    		// Listen for selection changes
    		personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
     
    			@Override
    			public void changed(ObservableValue<? extends Person> observable,
    					Person oldValue, Person newValue) {
    				showPersonDetails(newValue);
    			}
    		});
    	}
     
    	/**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setMainApp(MainApp mainApp) {
    		this.mainApp = mainApp;
     
    		// Add observable list data to the table
    		personTable.setItems(mainApp.getPersonData());
    	}
     
    	/**
             * Fills all text fields to show details about the person.
             * If the specified person is null, all text fields are cleared.
             * 
             * @param person the person or null
             */
    	private void showPersonDetails(Person person) {
    		if (person != null) {
    			nomLabel.setText(person.getNom());
    			prenomLabel.setText(person.getPrenom());
    			sexeLabel.setText(person.getSexe());
    			dateNaissLabel.setText(CalendarUtil.format(person.getDateNaiss()));
    			//dLabel.setText(Integer.toString(person.getPostalCode()));
    			lieuNaissLabel.setText(person.getLieuNaiss());
    			matrimonialeLabel.setText(person.getMatrimoniale());
    			enfMinLabel.setText(Integer.toString(person.getEnfMin()));
    			enfMajLabel.setText(Integer.toString(person.getEnfMaj()));
    			totalEnfLabel.setText(Integer.toString(person.getTotalEnf()));
    			adresseLabel.setText(person.getAdresse());
    			tel1Label.setText(person.getTel1());
    			tel2Label.setText(person.getTel2());
    			mail1Label.setText(person.getMail1());
    			mail2Label.setText(person.getMail2());
    			fonctionLabel.setText(person.getFonction());
    			categorieLabel.setText(person.getCategorie());
    			contratLabel.setText(person.getContrat());
    			dateEmbLabel.setText(CalendarUtil.format(person.getDateEmb()));
    			diplomeLabel.setText(person.getDiplome());
    			ancienLabel.setText(Integer.toString(person.getAncien()));
    			salaireDebutLabel.setText(Integer.toString(person.getSalaireDebut()));
    			salaireActuelLabel.setText(Integer.toString(person.getSalaireActuel()));
    			imageView.setImage(person.getImagePers());
     
    		} else {
    			nomLabel.setText("");
    			prenomLabel.setText("");
    			sexeLabel.setText("");
    			dateNaissLabel.setText("");
    			lieuNaissLabel.setText("");
    			matrimonialeLabel.setText("");
    			enfMinLabel.setText("");
    			enfMajLabel.setText("");
    			totalEnfLabel.setText("");
    			adresseLabel.setText("");
    			tel1Label.setText("");
    			tel2Label.setText("");
    			mail1Label.setText("");
    			mail2Label.setText("");
    			fonctionLabel.setText("");
    			categorieLabel.setText("");
    			contratLabel.setText("");
    			dateEmbLabel.setText("");
    			diplomeLabel.setText("");
    			ancienLabel.setText("");
    			salaireDebutLabel.setText("");
    			salaireActuelLabel.setText("");
    			imageView.setImage(null);
    		}
    	}
     
    	/**
             * Called when the user clicks on the delete button.
             */
    	@FXML
    	private void handleSupprimerPerson() {
    		int selectedIndex = personTable.getSelectionModel().getSelectedIndex();
    		if (selectedIndex >= 0) {
    			personTable.getItems().remove(selectedIndex);
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(mainApp.getPrimaryStage(),
    					"Please select a person in the table.",
    					"No Person Selected", "No Selection");
    		}
    	}
     
    	/**
             * Called when the user clicks the new button.
             * Opens a dialog to edit details for a new person.
             */
    	@FXML
    	private void handleNouveauPerson() {
    		Person tempPerson = new Person();
    		boolean okClicked = mainApp.showPersonEditDialog(tempPerson);
    		if (okClicked) {
    			mainApp.getPersonData().add(tempPerson);
    		}
    	}
     
    	/**
             * Called when the user clicks the edit button.
             * Opens a dialog to edit details for the selected person.
             */
    	@FXML
    	private void handleModifierPerson() {
    		Person selectedPerson = personTable.getSelectionModel().getSelectedItem();
    		if (selectedPerson != null) {
    			boolean okClicked = mainApp.showPersonEditDialog(selectedPerson);
    			if (okClicked) {
    				refreshPersonTable();
    				showPersonDetails(selectedPerson);
    			}
     
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(mainApp.getPrimaryStage(),
    					"Please select a person in the table.",
    					"No Person Selected", "No Selection");
    		}
    	}
     
    	/**
             * Refreshes the table. This is only necessary if an item that is already in
             * the table is changed. New and deleted items are refreshed automatically.
             * 
             * This is a workaround because otherwise we would need to use property
             * bindings in the model class and add a *property() method for each
             * property. Maybe this will not be necessary in future versions of JavaFX
             * (see http://javafx-jira.kenai.com/browse/RT-22599)
             */
    	private void refreshPersonTable() {
    		int selectedIndex = personTable.getSelectionModel().getSelectedIndex();
    		personTable.setItems(null);
    		personTable.layout();
    		personTable.setItems(mainApp.getPersonData());
    		// Must set the selected index again (see http://javafx-jira.kenai.com/browse/RT-26291)
    		personTable.getSelectionModel().select(selectedIndex);
    	}
    }
    - RootLayout

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    package ch.makery.address;
     
    import java.io.File;
     
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.stage.FileChooser;
     
    /**
     * The controller for the root layout. The root layout provides the basic
     * application layout containing a menu bar and space where other JavaFX
     * elements can be placed.
     * 
     * @author Marco Jakob
     */
    public class RootLayoutController {
     
      // Reference to the main application
      private MainApp mainApp;
      /**
      * Is called by the main application to give a reference back to itself.
      * 
      * @param mainApp
      */
      public void setMainApp(MainApp mainApp) {
          this.mainApp = mainApp;
      }
     
      /**
      * Creates an empty address book.
      */
      @FXML
      protected void handleNew() {
          mainApp.getPersonData().clear();
          mainApp.setPersonFilePath(null);
      }
     
      /**
      * Opens a FileChooser to let the user select an address book to load.
      */
      @FXML
      protected void handleOpen() {
          FileChooser fileChooser = new FileChooser();
     
          // Set extension filter
          FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
          fileChooser.getExtensionFilters().add(extFilter);
     
          // Show save file dialog
          File file = fileChooser.showOpenDialog(mainApp.getPrimaryStage());
     
          if (file != null) {
              mainApp.loadPersonDataFromFile(file);
          }
      }
     
      /**
      * Saves the file to the person file that is currently open. If there is no
      * open file, the "save as" dialog is shown.
      */
      @FXML
      protected void handleSave() {
          File personFile = mainApp.getPersonFilePath();
          if (personFile != null) {
              mainApp.savePersonDataToFile(personFile);
          } else {
              handleSaveAs();
          }
      }
     
      /**
      * Opens a FileChooser to let the user select a file to save to.
      */
      @FXML
      protected void handleSaveAs() {
        FileChooser fileChooser = new FileChooser();
     
        // Set extension filter
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
        fileChooser.getExtensionFilters().add(extFilter);
     
        // Show save file dialog
        File file = fileChooser.showSaveDialog(mainApp.getPrimaryStage());
     
        if (file != null) {
          // Make sure it has the correct extension
          if (!file.getPath().endsWith(".xml")) {
            file = new File(file.getPath() + ".xml");
          }
          mainApp.savePersonDataToFile(file);
        }
      }
     
      /**
      * Opens an about dialog.
      */
      @FXML
      protected void handleAbout() {
          Dialogs.showInformationDialog(mainApp.getPrimaryStage(), "Author: Marco Jakob\nWebsite: http://edu.makery.ch", "AddressApp", "About");
      }
     
      /**
      * Closes the application.
      */
      @FXML
      protected void handleExit() {
          System.exit(0);
      }
     
      /**
      * Opens the birthday statistics.
      */
     @FXML
     protected void handleShowBirthdayStatistics() {
       mainApp.showBirthdayStatistics();
     }
     
     @FXML
     protected void handleNouvellePermission(){
    	// mainApp.showNouvellePermission();
     }
     
     
     @FXML
     protected void handleNouvelleAbscence(){
    	 mainApp.showNouvelleAbscence();
     }
     
     @FXML
     protected void handleAbscenceListe(){
    	 mainApp.showAbscenceListe();
     }
     
     @FXML
     protected void handleListePerson(){
    	 mainApp.showListePerson();
     }
    }
    - Person
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    package ch.makery.address.model;
     
    import java.util.Calendar;
     
    import javafx.scene.image.Image;
     
    /**
     * Model class for a Person.
     *
     * @author Marco Jakob
     */
    public class Person {
     
    	private String nom;
    	private String prenom;
    	private String sexe;
    	private String matrimoniale;
    	private Calendar dateNaiss;
    	private String lieuNaiss;
    	private int enfMin;
    	private int enfMaj;
    	private int totalEnf;
    	private String adresse;
    	private String tel1;
    	private String tel2;
    	private String mail1;
    	private String mail2;
    	private String fonction;
    	private String categorie;
    	private String contrat;
    	private Calendar dateEmb;
    	private String diplome;
    	private int ancien;
    	private int salaireDebut;
    	private int salaireActuel;
    	private boolean photoPerson;
    	private Image imagePers;
     
    	/**
             * Default constructor.
             */
    	public Person() {
    	}
     
    	/**
             * Constructor with some initial data.
             * 
             * @param nom
             * @param prenom
             */
    	public Person(String nom, String prenom) {
    		this.nom = nom;
    		this.prenom = prenom;
     
    		// some initial dummy data
    		this.sexe =" ";
    		this.dateNaiss = Calendar.getInstance();
    		this.matrimoniale = " Célibataire";
    		this.enfMin = 0;
    		this.enfMaj = 0;
    		this.totalEnf = (this.enfMin + this.enfMaj);
    		this.adresse = " 09 BP 1815 Abidjan 09";
    		this.contrat = "CDI ";
    		this.dateEmb = Calendar.getInstance();
    		this.salaireDebut = 0;
    		this.salaireActuel = 0;
    		//this.photoPerson = ImageView.SMOOTH_DEFAULT;
     
    	}
     
     
    	//*************************************************************
    	/**
             * Creation des Getter et Setter
             * @return
             */
     
    	public String getNom() {
    		return nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	//*************************************************************
     
    	public String getPrenom() {
    		return prenom;
    	}
     
    	public void setPrenom(String prenom) {
    		this.prenom = prenom;
    	}
     
    	//**************************************************************
     
    	public String getSexe() {
    		return sexe;
    	}
     
    	public void setSexe(String sexe) {
    		this.sexe = sexe;
    	}
     
    	//***************************************************************
     
    	public Calendar getDateNaiss() {
    		return dateNaiss;
    	}
     
    	public void setDateNaiss(Calendar dateNaiss) {
    		this.dateNaiss = dateNaiss;
    	}
     
    	//***************************************************************
     
    	public String getMatrimoniale(){
    		return matrimoniale;
    	}
    	public void setMatimoniale(String matrimoniale) {
    		this.matrimoniale = matrimoniale;
    	}
     
    	//***************************************************************
     
    	public String getLieuNaiss(){
    		return lieuNaiss;
    	}
    	public void setLieuNaiss(String lieuNaiss) {
    		this.lieuNaiss = lieuNaiss;
    	}
     
    	//***************************************************************
     
    	public int getEnfMin() {
    		return enfMin;
    	}
     
    	public void setEnfMaj(int enfMaj) {
    		this.enfMaj = enfMaj;
    	}
     
    	//****************************************************************
     
    	public int getEnfMaj() {
    		return enfMaj;
    	}
     
    	public void setEnfMin(int enfMin) {
    		this.enfMin = enfMin;
    	}
     
    	//****************************************************************
     
    	public int getTotalEnf() {
    		return totalEnf;
    	}
     
    	public void setTotalEnf(int totalEnf) {
    		this.totalEnf = totalEnf;
    	}
     
    	//****************************************************************
     
    	public String getAdresse() {
    		return adresse;
    	}
     
    	public void setAdresse(String adresse) {
    		this.adresse = adresse;
    	}
     
    	//*****************************************************************
     
    	public String getTel1() {
    		return tel1;
    	}
     
    	public void setTel1(String tel1) {
    		this.tel1 = tel1;
    	}
     
    	//*****************************************************************
     
    	public String getTel2() {
    		return tel2;
    	}
     
    	public void setTel2(String tel2) {
    		this.tel2 = tel2;
    	}
     
    	//*****************************************************************
     
    	public String getMail1() {
    		return mail1;
    	}
     
    	public void setMail1(String mail1) {
    		this.mail1 = mail1;
    	}
     
    	//*****************************************************************
    	public String getMail2() {
    		return mail2;
    	}
     
    	public void setMail2(String mail2) {
    		this.mail2 = mail2;
    	}
     
    	//*****************************************************************
     
    	public String getFonction() {
    		return fonction;
    	}
     
    	public void setFonction(String fonction) {
    		this.fonction = fonction;
    	}
     
    	//*****************************************************************
     
    	public String getCategorie() {
    		return categorie;
    	}
     
    	public void setCategorie(String categorie) {
    		this.categorie = categorie;
    	}
     
    	//*****************************************************************
     
    	public String getContrat() {
    		return contrat;
    	}
     
    	public void setContrat(String contrat) {
    		this.contrat = contrat;
    	}
     
    	//******************************************************************
     
    	public Calendar getDateEmb() {
    		return dateEmb;
    	}
     
    	public void setDateEmb(Calendar dateEmb) {
    		this.dateEmb = dateEmb;
    	}
     
    	//******************************************************************
     
    	public String getDiplome() {
    		return diplome;
    	}
     
    	public void setDiplome(String diplome) {
    		this.diplome = diplome;
    	}
     
    	//******************************************************************
     
    	public int getAncien() {
    		return ancien;
    	}
     
    	public void setAncien(int ancien) {
    		this.ancien = ancien;
    	}
     
    	//*****************************************************************
     
    	public int getSalaireDebut() {
    		return salaireDebut;
    	}
     
    	public void setSalaireDebut(int salaireDebut) {
    		this.salaireDebut = salaireDebut;
    	}
     
    	//*****************************************************************
     
    	public int getSalaireActuel() {
    		return salaireActuel;
    	}
     
    	public void setSalaireActuel(int salaireActuel) {
    		this.salaireActuel = salaireActuel;
    	}
     
    	//*****************************************************************
     
    	public boolean getPhotoPerson(){
    		return photoPerson;
     
    	}
     
    	public void setPhotoPerson(boolean photoPerson){
    		this.photoPerson = photoPerson;
    	}
     
    	//******************************************************************
     
    	public Image getImagePers(){
    		return imagePers;
    	}
     
    	public void setImagePers(Image imagePers){
    		this.imagePers = imagePers;
    	}
    }

    La 2em l'image presente ma boite de dialogue et c'est dans celle-ci que ne fonctionnent pas les MenuItems(New, Open, Save, Save As).
    je vous mets les codes ensuite les erreurs generees

    -Abscence

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    package ch.makery.address.model;
     
    import java.util.Calendar;
     
    import ch.makery.address.MainApp;
     
    public class Abscence extends MainApp{
     
    	private String nomPers;
    	private String prenomPers;
    	private String fonction;
    	private Calendar dateDebut,dateFin;
    	private int dureeAbsc;
    	private String motif;
     
    	//Le constructeur par defaut
     
    	public Abscence(){
     
    	}
     
    	// constructeur avec parametre
    	/**
             * Constructor with some initial data.
             * 
             * @param nomPers
             * @param prenomPers
             */
     
    	public Abscence(String nomPers, String prenomPers){
    		this.nomPers = nomPers;
    		this.prenomPers = prenomPers;
     
    		// Donnees initiales
    		this.setFonction(" ");
    		this.dateDebut = Calendar.getInstance();
    		this.dateFin = Calendar.getInstance();
    		this.dureeAbsc = 0;
    		this.motif = " ";
     
    	}
     
    		//****************************************
    		public String getNomPers(){
    			return nomPers;
    		}
     
    		public void setNomPers(String nomPers){
    			this.nomPers = nomPers;
    		}
     
    		//****************************************
     
    		public String getPrenomPers(){
    			return prenomPers;
    		}
     
    		public void setPrenomPers(String prenomPers){
    			this.prenomPers = prenomPers;
    		}
     
    		//**********************************************
     
    		public String getFonction() {
    			return fonction;
    		}
     
    		public void setFonction(String fonction) {
    			this.fonction = fonction;
    		}
     
     
     
    		//******************************************
     
    		public Calendar getDateDebut(){
    			return dateDebut;
    		}
     
    		public void setDateDebut( Calendar dateDebut){
    			this.dateDebut = dateDebut;
    		}
     
    		//*****************************************
    		public Calendar getDateFin(){
    			return dateFin;
    		}
     
    		public void setDateFin( Calendar dateFin){
    			this.dateFin = dateFin;
    		}
     
    		//******************************************
    		public int getDureeAbsc(){
    			return dureeAbsc;
    		}
     
    		public void setDureeAbsc(int dureeAbsc){
    			this.dureeAbsc = dureeAbsc;
    		}
     
    		//*****************************************
     
    		public String getMotif(){
    			return motif;
    		}
     
    		public void setMotif(String motif){
    			this.motif = motif;
    		}
     
    	}
    -RootLayoutAbscController

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    package ch.makery.address;
     
    import java.io.File;
     
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.stage.FileChooser;
    import ch.makery.address.model.Abscence;
     
    public class RootLayoutAbscController {
     
     
    	private AbscenceOverviewController abscenceOverviewController;
     
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController){
    		this.abscenceOverviewController = abscenceOverviewController;
     
    	}
     
     
    	//*****************************************************************************************
    	@FXML
    	  private void handleNouveau() {
    		  abscenceOverviewController.getAbscenceData().clear();
    		  abscenceOverviewController.setAbscenceFilePath(null);
    	  }
     
    	/**
              * Opens a FileChooser to let the user select an address book to load.
             */
     
    	  @FXML
    	  private void handleOuvrir() {
     
    		FileChooser fileChooser = new FileChooser();
     
    		// Set extension filter
    		FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
    		fileChooser.getExtensionFilters().add(extFilter);
     
    		// Show save file dialog
    		File abscenceFile = fileChooser.showOpenDialog(null);
     
    			if (abscenceFile != null) {
    			   abscenceOverviewController.loadAbscenceDataFromFile(abscenceFile);
    			   }
    	}
     
    	  /**
              * Saves the file to the abscence file that is currently open. If there is no
              * open file, the "save as" dialog is shown.
              */
     
    	  @FXML
    	  private void handleEnregistrer() {
    		File abscenceFile = abscenceOverviewController.getAbscenceFilePath();
    		if (abscenceFile != null) {
    			abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		} else{
    			handleEnregistrerSous();
    			}   
    	  }
     
    	  /**
              * Opens a FileChooser to let the user select a file to save to.
              *
               */
    	  @FXML
    	  private void handleEnregistrerSous() {
     
    		FileChooser fileChooser = new FileChooser();
     
    		// Set extension filter
    		FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
    		fileChooser.getExtensionFilters().add(extFilter);
     
    		// Show save file dialog
    		File abscenceFile = fileChooser.showSaveDialog(null);
     
    		if (abscenceFile != null) {
     
    		// Make sure it has the correct extension
    			if (!abscenceFile.getPath().endsWith(".xml")) {
    				abscenceFile = new File(abscenceFile.getPath() + ".xml");
    			  }
    			  abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		}
    	  }
     
    	  @FXML
    	  protected void handleQuitter() {
    	      System.exit(0);
    	  }
     
     
    	/*
    	 * 
    	 * 
     
    	  @FXML
    	  private void handleExit(ActionEvent event) {
    	        System.exit(0);
    	      }
    	  */
     
    	  @FXML
    		private void handleModifierAbscence() {
    			Abscence selectedAbscence = abscenceOverviewController.abscenceTable.getSelectionModel().getSelectedItem();
    			if (selectedAbscence != null) {
    				boolean okClicked = abscenceOverviewController.showAbscenceEditDialog(selectedAbscence);
    				if (okClicked) {
    					abscenceOverviewController.refreshAbscenceTable();
    					abscenceOverviewController.showAbscenceDetails(selectedAbscence);
    				}
     
    			} else {
    				// Nothing selected
    				Dialogs.showWarningDialog(null,
    						"Veillez sélectionnez une personne dans la Table.",
    						"Pas de Personne Sélectionnée", "Pas de Sélection");
    			}
    		}
     
    		/**
                     * Called when the user clicks on the delete button.
                     */
    		@FXML
    		private void handleSupprimerAbscence() {
    			int selectedIndex = abscenceOverviewController.abscenceTable.getSelectionModel().getSelectedIndex();
    			if (selectedIndex >= 0) {
    				abscenceOverviewController.abscenceTable.getItems().remove(selectedIndex);
    			} else {
    				// Nothing selected
    				Dialogs.showErrorDialog( null,
    						"Please select a person in the table.",
    						"No Person Selected", "No Selection");
    			}
    		}
     
     
     
    }
    -AbscenceOverview

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    package ch.makery.address;
     
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.prefs.Preferences;
     
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXML;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.Dialogs;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.AnchorPane;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import ch.makery.address.model.Abscence;
    import ch.makery.address.util.CalendarUtil;
    import ch.makery.address.util.FileUtil;
     
    import com.thoughtworks.xstream.XStream;
     
    /**
     * 
     * @author Anohjp
     *
     */
     
    public class AbscenceOverviewController{
     
    	@FXML
    	protected TextField filterField;
    	@FXML 
    	protected TableView<Abscence> abscenceTable;
    	@FXML
    	private TableColumn<Abscence, String> nomPersColumn;
    	@FXML
    	private TableColumn<Abscence, String> prenomPersColumn;
     
    	@FXML
    	private Label nomPersLabel;
    	@FXML
    	private Label prenomPersLabel;
    	@FXML
    	private Label fonctionLabel;
    	@FXML
    	private Label dateDebutLabel;
    	@FXML
    	private Label dateFinLabel;
    	@FXML
    	private Label dureeLabel;
    	@FXML
    	private Label motifLabel;
    	@FXML
    	ComboBox<String> trimestreComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<String> moisComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<String> semestreComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<Integer> anneeComboBox = new ComboBox<Integer>();
     
    	//private String mois[] = new String[]{};
    	//final ComboBox comboBox = new ComboBox();
     
    	private ObservableList<Abscence> abscenceData = FXCollections.observableArrayList();
    	//private ObservableList<Abscence> filteredData = FXCollections.observableArrayList();
    	//private ObservableList<Abscence> comboBoxData = FXCollections.observableArrayList();
     
    	private Stage dialogStageAbscL;
     
     
    	// Creation d constructeur
    	public AbscenceOverviewController(){
     
    		abscenceData.add(new Abscence("Jean", "Ezan"));
    		abscenceData.add(new Abscence("Paul", "Anoh"));
    		abscenceData.add(new Abscence("Germain", "Ezan"));
    		abscenceData.add(new Abscence("Jean", "Anoh"));
    		abscenceData.add(new Abscence("Paul", "Ezan"));
    		abscenceData.add(new Abscence("Germain", "Anoh"));
    		abscenceData.add(new Abscence("Hans", "Muster"));
    		abscenceData.add(new Abscence("Ruth", "Mueller"));
    		abscenceData.add(new Abscence("Heinz", "Kurz"));
    		abscenceData.add(new Abscence("Cornelia", "Meier"));
    		abscenceData.add(new Abscence("Werner", "Meyer"));
    	}
     
    	@FXML
    	private void initialize() {
     
    		// Initialise la table permission
    		nomPersColumn.setCellValueFactory(new PropertyValueFactory<Abscence, String>("nomPers"));
    		prenomPersColumn.setCellValueFactory(new PropertyValueFactory<Abscence, String>("prenomPers"));		
     
    		// Auto resize columns
    		abscenceTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
     
    		// effacer Abscence
    		showAbscenceDetails(null);
     
    		// Listen for selection changes/ Ecouteur de changement de selection
    		abscenceTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Abscence>() {
     
    			@Override
    			public void changed(ObservableValue<? extends Abscence> observable,
    				Abscence oldValue, Abscence newValue) {
    					showAbscenceDetails(newValue);
    				}
    			});
     
    	}//Fin de private void initialize()
     
    //****************************************************************************************************	   
     
    	public ObservableList<Abscence> getAbscenceData() {
    		return abscenceData;
    	}
     
    	/**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController) {
    		// Add observable list data to the table
    		abscenceTable.setItems(getAbscenceData());	
    	}
     
     
    	/**
             * Fills all text fields to show details about the permission.
             * If the specified permission is null, all text fields are cleared.
             * 
             * @param Abscence the abscence or null
             */
    	protected void showAbscenceDetails(Abscence abscence) {
    		if (abscence != null) {
    			nomPersLabel.setText(abscence.getNomPers());
    			prenomPersLabel.setText(abscence.getPrenomPers());
    			fonctionLabel.setText(abscence.getFonction());
    			dateDebutLabel.setText(CalendarUtil.format(abscence.getDateDebut()));
    			dateFinLabel.setText(CalendarUtil.format(abscence.getDateFin()));
    			dureeLabel.setText(Integer.toString(abscence.getDureeAbsc()));
    			motifLabel.setText(abscence.getMotif());
     
     
    		} else {
    			nomPersLabel.setText("");
    			prenomPersLabel.setText("");
    			fonctionLabel.setText("");
    			dateDebutLabel.setText("");
    			dateFinLabel.setText("");
    			dureeLabel.setText("");
    			motifLabel.setText("");
     
    		}
    	}
     
    	/***
             * 
             * @param abscence, montre le formulaire d'abscence
             * @return
             */
     
    	public  boolean showAbscenceEditDialog(Abscence abscence){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceEditDialog.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStageAbscE = new Stage();
    		dialogStageAbscE.setTitle("Formulaire Abscence");
    		dialogStageAbscE.initModality(Modality.WINDOW_MODAL);
    		dialogStageAbscE.initOwner(dialogStageAbscE);
    		Scene scene = new Scene(page);
    		dialogStageAbscE.setScene(scene);
    		dialogStageAbscE.show();
     
    		// Set the permission formulaire into the controller
    		AbscenceEditDialogController controller = loader2.getController();
    	    controller.setDialogStageAbscE(dialogStageAbscE);
    	    controller.setAbscence(abscence);
     
    		return controller.isValideClicked();
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
    			return false;
    		}
     
    	}
     
     
    	/**
             * Called when the user clicks the new button.
             * Opens a dialog to edit details for a new person.
            */
    	@FXML
    	private void handleNouvelleAbscence() {
    		Abscence tempAbscence = new Abscence();
    		boolean nouveauClicked = showAbscenceEditDialog(tempAbscence);
    		if (nouveauClicked) {
    			getAbscenceData().add(tempAbscence);
    		}
    	} 
     
    	/***
             * Param du bouton Modifier
             */
    	@FXML
    	private void handleModifierAbscence() {
    		Abscence selectedAbscence = abscenceTable.getSelectionModel().getSelectedItem();
    		if (selectedAbscence != null) {
    			boolean okClicked = showAbscenceEditDialog(selectedAbscence);
    			if (okClicked) {
    				refreshAbscenceTable();
    				showAbscenceDetails(selectedAbscence);
    			}
     
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(null,
    					"Veillez sélectionnez une Abscence dans la Table.",
    					"Pas d'Abscence Sélectionnée", "Pas de Sélection");
    		}
    	}
     
    	/**
             * Called when the user clicks on the delete button.
             */
    	@FXML
    	private void handleSupprimerAbscence() {
    		int selectedIndex = abscenceTable.getSelectionModel().getSelectedIndex();
    		if (selectedIndex >= 0) {
    			abscenceTable.getItems().remove(selectedIndex);
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(null,
    					"Veillez sélectionner une Abscence dans la table",
    					"Pas d'Abscence Sélectionnée", "Pas de Sélection");
    		}
    	}
     
     
    	/**
             * Returns the data as an observable list of Abscence
             * @return
             */
     
     
    	public File getAbscenceFilePath() {
    		Preferences prefsAbs = Preferences.systemNodeForPackage(AbscenceOverviewController.class);
    		String filePathAbsc = prefsAbs.get("filePathAbsc", null);
    		if (filePathAbsc != null) {
    			return new File(filePathAbsc);
    		} 
    		else {
    			return null;
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, setAbscenceFilePath
             */
     
    	public void setAbscenceFilePath(File abscenceFile) {
    		Preferences prefsAbs = Preferences.userNodeForPackage(AbscenceOverviewController.class);
    		if (abscenceFile != null) {
    			prefsAbs.put("filePath", abscenceFile.getPath());
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence - " + abscenceFile.getName());
    		} 
    		else {
    			prefsAbs.remove("filePathAbsc");
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence");
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, loadAbscenceDataFromFile
             */
    	@SuppressWarnings("unchecked")
    	public void loadAbscenceDataFromFile(File abscenceFile) {
    		XStream xstreamAbscence = new XStream();
    		xstreamAbscence.alias("abscence", Abscence.class);
     
    		try {
    			String xml = FileUtil.readFile(abscenceFile);
     
    			ArrayList<Abscence> abscenceList = (ArrayList<Abscence>) xstreamAbscence.fromXML(xml);
     
    			abscenceData.clear();
    			abscenceData.addAll(abscenceList);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    					"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    					"Impossible de charger les données", "Error", e);
    		}
    	}
     
    	/****
             * 
             * @param file, saveAbscenceDataToFile
             */
    	public void saveAbscenceDataToFile(File abscenceFile) {
    		XStream xstream = new XStream();
    		xstream.alias("abscence", Abscence.class);
     
    		// Convert ObservableList to a normal ArrayList
    		ArrayList<Abscence> abscenceList = new ArrayList<>(abscenceData);		
    		String xml = xstream.toXML(abscenceList);
     
    		try {
    			FileUtil.saveFile(xml, abscenceFile);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    				"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    				"Impossible de charger les données", "Error", e);
    		}
    	}
     
     
     
    	/**
             * Refreshes the table. This is only necessary if an item that is already in
             * the table is changed. New and deleted items are refreshed automatically.
             * 
             * This is a workaround because otherwise we would need to use property
             * bindings in the model class and add a *property() method for each
             * property. Maybe this will not be necessary in future versions of JavaFX
             * (see http://javafx-jira.kenai.com/browse/RT-22599)
             */
     
    	protected void refreshAbscenceTable() {
    		int selectedIndex = abscenceTable.getSelectionModel().getSelectedIndex();
    		abscenceTable.setItems(null);
    		abscenceTable.layout();
    		abscenceTable.setItems(getAbscenceData());
    		// Must set the selected index again (see http://javafx-jira.kenai.com/browse/RT-26291)
    		abscenceTable.getSelectionModel().select(selectedIndex);
    	}
     
    	public void start(Stage arg0) throws Exception {
    		// TODO Stub de la méthode généré automatiquement
     
    	}
     
     
     
    }
    La 3em image presente les erreurs generees lorsque je clique par exemple sur le menuItem Save

    je vous mets en pieces jointes les fichiers FXML

    Donc en resumé, les menuItems au niveau de la boite de dialogue ne fonctionnent pas com ceux du Main principal
    Images attachées Images attachées    
    Fichiers attachés Fichiers attachés

  4. #4
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    absenceOverviewController est donc null. Est-ce que le FXML secondaire qui contient ce contrôleur est bien inclus dans le FXML principal avec fx:id="absenceOverview" ?
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  5. #5
    Membre averti
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2012
    Messages
    42
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2012
    Messages : 42
    Par défaut
    Voici la Methode qui affiche la boite de dialogue :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    public void showAbscenceListe(){
     
    				try {
    				FXMLLoader loader = new FXMLLoader(AbscenceOverviewController.class.getResource("view/RootLayoutAbsc.fxml"));
    				BorderPane borderPane = (BorderPane) loader.load();	
    				Stage dialogStageAbscL = new Stage();
    				dialogStageAbscL.setTitle("Liste des Abscences");
    				dialogStageAbscL.initModality(Modality.APPLICATION_MODAL);
    				dialogStageAbscL.getIcons().add(new Image("file:resources/images/aldhis_list.png"));
    				dialogStageAbscL.initOwner(primaryStage);
    				Scene scene = new Scene(borderPane);
    				dialogStageAbscL.setScene(scene);
     
    				dialogStageAbscL.show();
     
    				FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceOverview.fxml"));
    				AnchorPane overviewPage = (AnchorPane) loader2.load();
    				borderPane.setCenter(overviewPage);
     
    				// Give the controller access to the main app
    			    AbscenceOverviewController controller = loader2.getController();
    			    controller.setAbscenceListController(abscenceOverviewController);
     
    				}
    				catch (IOException e) {
    				// TODO Bloc catch généré automatiquement
    				e.printStackTrace();
    			 	}
     
    	}
    cette methode se trouve dans le MainApp( Main Principal).

    Voici le contenu de RootLayoutAbsc.fxml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import java.lang.*?>
    <?import java.net.*?>
    <?import javafx.geometry.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.image.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.layout.BorderPane?>
     
    <BorderPane id="absenceOverview" prefHeight="580.0" prefWidth="850.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="ch.makery.address.RootLayoutAbscController" fx:id="AbscenceOverview">
      <left>
        <Pane prefHeight="568.0" prefWidth="66.0">
          <children>
            <ImageView id="logo_aldis_verti" fitHeight="561.0" fitWidth="67.0" layoutX="-1.0" layoutY="-2.0" pickOnBounds="true">
              <image>
                <Image url="@../../../../../resources/images/logo_aldis_verti.png" preserveRatio="true" smooth="true" />
              </image>
            </ImageView>
          </children>
          <padding>
            <Insets top="70.0" />
          </padding>
        </Pane>
      </left>
      <stylesheets>
        <URL value="@../css/DarkTheme.css" />
      </stylesheets>
      <top>
        <MenuBar>
          <menus>
            <Menu mnemonicParsing="false" text="File">
              <items>
                <MenuItem mnemonicParsing="false" onAction="#handleNouveau" text="New" />
                <MenuItem mnemonicParsing="false" onAction="#handleOuvrir" text="Open" />
                <SeparatorMenuItem mnemonicParsing="false" />
                <MenuItem mnemonicParsing="false" onAction="#handleEnregistrer" text="Save" />
                <MenuItem mnemonicParsing="false" onAction="#handleEnregistrerSous" text="Save As" />
                <SeparatorMenuItem mnemonicParsing="false" />
                <MenuItem mnemonicParsing="false" onAction="#handleQuitter" text="Exit" />
              </items>
            </Menu>
            <Menu mnemonicParsing="false" text="Edit">
              <items>
                <MenuItem mnemonicParsing="false" text="Delete" />
              </items>
            </Menu>
            <Menu mnemonicParsing="false" text="Statistics">
              <items>
                <MenuItem mnemonicParsing="false" text="Show Statistics" />
              </items>
            </Menu>
            <Menu mnemonicParsing="false" text="Help">
              <items>
                <MenuItem mnemonicParsing="false" text="About" />
              </items>
            </Menu>
          </menus>
        </MenuBar>
      </top>
    </BorderPane>
    et voici le contenu de AbscenceOvervier.fxml

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import java.lang.*?>
    <?import java.net.*?>
    <?import javafx.collections.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.effect.*?>
    <?import javafx.scene.image.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.layout.AnchorPane?>
    <?import javafx.scene.text.*?>
     
    <AnchorPane prefHeight="547.0" prefWidth="787.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="ch.makery.address.AbscenceOverviewController" >
      <!-- TODO Add Nodes -->
      <children>
        <SplitPane dividerPositions="0.4027954256670902" focusTraversable="true" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
          <items>
            <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="546.0" prefWidth="300.0">
              <children>
                <TableView id="permissionTable" fx:id="abscenceTable" prefHeight="309.0" prefWidth="332.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="90.0">
                  <columns>
                    <TableColumn prefWidth="75.0" text="Nom" fx:id="nomPersColumn" />
                    <TableColumn prefWidth="75.0" text="Prénoms" fx:id="prenomPersColumn" />
                  </columns>
                  <stylesheets>
                    <URL value="@../css/DarkTheme2.css" />
                  </stylesheets>
                </TableView>
              </children>
            </AnchorPane>
            <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" styleClass="background">
              <children>
                <HBox id="HBox" alignment="CENTER" layoutX="30.0" layoutY="140.0" spacing="5.0">
                  <children>
                    <ComboBox id="semestreComboBox" prefHeight="25.0" prefWidth="200.0" promptText="Semestre">
                      <items>
                        <FXCollections fx:factory="observableArrayList">
                          <String fx:value="...Sélectionnez un Semestre..." />
                          <String fx:value="1er Semestre" />
                          <String fx:value="2em Semestre" />
                        </FXCollections>
                      </items>
                    </ComboBox>
                    <ComboBox id="anneeComboBox" editable="true" prefHeight="25.0" prefWidth="200.0" promptText="Année">
                      <items>
                        <FXCollections fx:factory="observableArrayList">
                          <String fx:value="...Sélectionnez une Année..." />
                          <String fx:value="2013" />
                          <String fx:value="2014" />
                          <String fx:value="2015" />
                        </FXCollections>
                      </items>
                    </ComboBox>
                  </children>
                </HBox>
                <HBox id="HBox" alignment="CENTER" layoutX="30.0" layoutY="101.0" spacing="5.0">
                  <children>
                    <ComboBox id="moisComboBox" prefHeight="24.999900000002526" prefWidth="199.9998779296875" promptText="Mois">
                      <items>
                        <FXCollections fx:factory="observableArrayList">
                          <String fx:value="...Sélectionnez un Mois..." />
                          <String fx:value="Janvier" />
                          <String fx:value="Février" />
                          <String fx:value="Mars" />
                          <String fx:value="Avril" />
                          <String fx:value="Mai" />
                          <String fx:value="Juin" />
                          <String fx:value="Juillet" />
                          <String fx:value="Août" />
                          <String fx:value="Septembre" />
                          <String fx:value="Octobre" />
                          <String fx:value="Novembre" />
                          <String fx:value="Décembre" />
                        </FXCollections>
                      </items>
                    </ComboBox>
                    <ComboBox id="trimestreComboBox" prefHeight="25.0" prefWidth="200.0" promptText="Trimestre">
                      <items>
                        <FXCollections fx:factory="observableArrayList">
                          <String fx:value="...Sélectionnez un Trimestre..." />
                          <String fx:value="1er Trimestre" />
                          <String fx:value="2em Trimestre" />
                          <String fx:value="3em Trimestre" />
                          <String fx:value="4em Trimestre" />
                        </FXCollections>
                      </items>
                    </ComboBox>
                  </children>
                </HBox>
                <GridPane prefHeight="310.0" prefWidth="539.0" AnchorPane.bottomAnchor="47.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="189.0">
                  <children>
                    <Label text="Nom :" GridPane.columnIndex="0" GridPane.rowIndex="0" />
                    <Label fx:id="nomPersLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="0" />
                    <Label text="Prénoms :" GridPane.columnIndex="0" GridPane.rowIndex="1" />
                    <Label fx:id="prenomPersLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
                    <Label text="Fonction :" GridPane.columnIndex="0" GridPane.rowIndex="2" />
                    <Label fx:id="fonctionLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="2" />
                    <Label text="Date Début :" GridPane.columnIndex="0" GridPane.rowIndex="3" />
                    <Label fx:id="dateDebutLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="3" />
                    <Label text="Date Fin :" GridPane.columnIndex="0" GridPane.rowIndex="4" />
                    <Label fx:id="dateFinLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="4" />
                    <Label text="Durée :" GridPane.columnIndex="0" GridPane.rowIndex="5" />
                    <Label fx:id="dureeLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="5" />
                    <Label text="Motif :" GridPane.columnIndex="0" GridPane.rowIndex="6" />
                    <Label fx:id="motifLabel" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="6" />
                  </children>
                  <columnConstraints>
                    <ColumnConstraints hgrow="SOMETIMES" maxWidth="159.0" minWidth="10.0" prefWidth="102.0" />
                    <ColumnConstraints hgrow="SOMETIMES" maxWidth="356.0" minWidth="10.0" prefWidth="356.0" />
                  </columnConstraints>
                  <rowConstraints>
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                  </rowConstraints>
                </GridPane>
                <HBox id="HBox" alignment="CENTER" layoutX="64.0" layoutY="509.0" spacing="5.0">
                  <children>
                    <Button defaultButton="true" mnemonicParsing="false" prefHeight="25.0" text="Nouveau" />
                    <Button mnemonicParsing="false" prefHeight="25.0" text="Modifier" />
                    <Button mnemonicParsing="false" text="Imprimer" />
                    <Button mnemonicParsing="false" prefHeight="25.0" text="Supprimer" />
                  </children>
                </HBox>
              </children>
            </AnchorPane>
          </items>
        </SplitPane>
        <ImageView id="img_logo_AbscenceView" layoutX="0.0" layoutY="0.0" pickOnBounds="true">
          <image>
            <Image url="@../../../../../resources/images/img_logo_AbscenceView.png" preserveRatio="true" smooth="true" />
          </image>
        </ImageView>
        <TextField id="filtreField" cache="true" disable="false" focusTraversable="true" layoutX="0.0" layoutY="62.0" mouseTransparent="false" opacity="0.8" pickOnBounds="true" prefHeight="35.0" prefWidth="320.0" promptText="Veillez entrer un Nom ou Prenom" styleClass="text-field-text, prompt-text" text="">
          <effect>
            <InnerShadow />
          </effect>
        </TextField>
      </children>
      <stylesheets>
        <URL value="@../css/DarkTheme2.css" />
      </stylesheets>
    </AnchorPane>
    Ensuite le contenu de RootLayoutAbscController qui gère le RootLayoutAbsc.fxml

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    package ch.makery.address;
     
    import java.io.File;
     
    import javafx.fxml.FXML;
    import javafx.scene.control.Dialogs;
    import javafx.stage.FileChooser;
    import ch.makery.address.model.Abscence;
     
    public class RootLayoutAbscController {
     
     
    	private AbscenceOverviewController abscenceOverviewController;
     
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController){
    		this.abscenceOverviewController = abscenceOverviewController;
     
    	}
     
     
    	//*****************************************************************************************
    	@FXML
    	  private void handleNouveau() {
    		  abscenceOverviewController.getAbscenceData().clear();
    		  abscenceOverviewController.setAbscenceFilePath(null);
    	  }
     
    	/**
              * Opens a FileChooser to let the user select an address book to load.
             */
     
    	  @FXML
    	  private void handleOuvrir() {
     
    		FileChooser fileChooser = new FileChooser();
     
    		// Set extension filter
    		FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
    		fileChooser.getExtensionFilters().add(extFilter);
     
    		// Show save file dialog
    		File abscenceFile = fileChooser.showOpenDialog(null);
     
    			if (abscenceFile != null) {
    			   abscenceOverviewController.loadAbscenceDataFromFile(abscenceFile);
    			   }
    	}
     
    	  /**
              * Saves the file to the abscence file that is currently open. If there is no
              * open file, the "save as" dialog is shown.
              */
     
    	  @FXML
    	  private void handleEnregistrer() {
    		File abscenceFile = abscenceOverviewController.getAbscenceFilePath();
    		if (abscenceFile != null) {
    			abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		} else{
    			handleEnregistrerSous();
    			}   
    	  }
     
    	  /**
              * Opens a FileChooser to let the user select a file to save to.
              *
               */
    	  @FXML
    	  private void handleEnregistrerSous() {
     
    		FileChooser fileChooser = new FileChooser();
     
    		// Set extension filter
    		FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
    		fileChooser.getExtensionFilters().add(extFilter);
     
    		// Show save file dialog
    		File abscenceFile = fileChooser.showSaveDialog(null);
     
    		if (abscenceFile != null) {
     
    		// Make sure it has the correct extension
    			if (!abscenceFile.getPath().endsWith(".xml")) {
    				abscenceFile = new File(abscenceFile.getPath() + ".xml");
    			  }
    			  abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		}
    	  }
     
    	  @FXML
    	  protected void handleQuitter() {
    	      System.exit(0);
    	  }
     
     
    	/*
    	 * 
    	 * 
     
    	  @FXML
    	  private void handleExit(ActionEvent event) {
    	        System.exit(0);
    	      }
    	  */
     
    	  @FXML
    		private void handleModifierAbscence() {
    			Abscence selectedAbscence = abscenceOverviewController.abscenceTable.getSelectionModel().getSelectedItem();
    			if (selectedAbscence != null) {
    				boolean okClicked = abscenceOverviewController.showAbscenceEditDialog(selectedAbscence);
    				if (okClicked) {
    					abscenceOverviewController.refreshAbscenceTable();
    					abscenceOverviewController.showAbscenceDetails(selectedAbscence);
    				}
     
    			} else {
    				// Nothing selected
    				Dialogs.showWarningDialog(null,
    						"Veillez sélectionnez une personne dans la Table.",
    						"Pas de Personne Sélectionnée", "Pas de Sélection");
    			}
    		}
     
    		/**
                     * Called when the user clicks on the delete button.
                     */
    		@FXML
    		private void handleSupprimerAbscence() {
    			int selectedIndex = abscenceOverviewController.abscenceTable.getSelectionModel().getSelectedIndex();
    			if (selectedIndex >= 0) {
    				abscenceOverviewController.abscenceTable.getItems().remove(selectedIndex);
    			} else {
    				// Nothing selected
    				Dialogs.showErrorDialog( null,
    						"Please select a person in the table.",
    						"No Person Selected", "No Selection");
    			}
    		}
     
     
     
    }

    et le contenu de AbscenceOverview qui gère le fichier AbscenceOverviewController

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    package ch.makery.address;
     
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.prefs.Preferences;
     
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXML;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.Dialogs;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.AnchorPane;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import ch.makery.address.model.Abscence;
    import ch.makery.address.util.CalendarUtil;
    import ch.makery.address.util.FileUtil;
     
    import com.thoughtworks.xstream.XStream;
     
    /**
     * 
     * @author Anohjp
     *
     */
     
    public class AbscenceOverviewController{
     
    	@FXML
    	protected TextField filterField;
    	@FXML 
    	protected TableView<Abscence> abscenceTable;
    	@FXML
    	private TableColumn<Abscence, String> nomPersColumn;
    	@FXML
    	private TableColumn<Abscence, String> prenomPersColumn;
     
    	@FXML
    	private Label nomPersLabel;
    	@FXML
    	private Label prenomPersLabel;
    	@FXML
    	private Label fonctionLabel;
    	@FXML
    	private Label dateDebutLabel;
    	@FXML
    	private Label dateFinLabel;
    	@FXML
    	private Label dureeLabel;
    	@FXML
    	private Label motifLabel;
    	@FXML
    	ComboBox<String> trimestreComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<String> moisComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<String> semestreComboBox = new ComboBox<String>();
    	@FXML
    	ComboBox<Integer> anneeComboBox = new ComboBox<Integer>();
     
    	//private String mois[] = new String[]{};
    	//final ComboBox comboBox = new ComboBox();
     
    	private ObservableList<Abscence> abscenceData = FXCollections.observableArrayList();
    	//private ObservableList<Abscence> filteredData = FXCollections.observableArrayList();
    	//private ObservableList<Abscence> comboBoxData = FXCollections.observableArrayList();
     
    	private Stage dialogStageAbscL;
     
     
    	// Creation d constructeur
    	public AbscenceOverviewController(){
     
    		abscenceData.add(new Abscence("Jean", "Ezan"));
    		abscenceData.add(new Abscence("Paul", "Anoh"));
    		abscenceData.add(new Abscence("Germain", "Ezan"));
    		abscenceData.add(new Abscence("Jean", "Anoh"));
    		abscenceData.add(new Abscence("Paul", "Ezan"));
    		abscenceData.add(new Abscence("Germain", "Anoh"));
    		abscenceData.add(new Abscence("Hans", "Muster"));
    		abscenceData.add(new Abscence("Ruth", "Mueller"));
    		abscenceData.add(new Abscence("Heinz", "Kurz"));
    		abscenceData.add(new Abscence("Cornelia", "Meier"));
    		abscenceData.add(new Abscence("Werner", "Meyer"));
    	}
     
    	@FXML
    	private void initialize() {
     
    		// Initialise la table permission
    		nomPersColumn.setCellValueFactory(new PropertyValueFactory<Abscence, String>("nomPers"));
    		prenomPersColumn.setCellValueFactory(new PropertyValueFactory<Abscence, String>("prenomPers"));		
     
    		// Auto resize columns
    		abscenceTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
     
    		// effacer Abscence
    		showAbscenceDetails(null);
     
    		// Listen for selection changes/ Ecouteur de changement de selection
    		abscenceTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Abscence>() {
     
    			@Override
    			public void changed(ObservableValue<? extends Abscence> observable,
    				Abscence oldValue, Abscence newValue) {
    					showAbscenceDetails(newValue);
    				}
    			});
     
    	}//Fin de private void initialize()
     
    //****************************************************************************************************	   
     
    	public ObservableList<Abscence> getAbscenceData() {
    		return abscenceData;
    	}
     
    	/**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController) {
    		// Add observable list data to the table
    		abscenceTable.setItems(getAbscenceData());	
    	}
     
     
    	/**
             * Fills all text fields to show details about the permission.
             * If the specified permission is null, all text fields are cleared.
             * 
             * @param Abscence the abscence or null
             */
    	protected void showAbscenceDetails(Abscence abscence) {
    		if (abscence != null) {
    			nomPersLabel.setText(abscence.getNomPers());
    			prenomPersLabel.setText(abscence.getPrenomPers());
    			fonctionLabel.setText(abscence.getFonction());
    			dateDebutLabel.setText(CalendarUtil.format(abscence.getDateDebut()));
    			dateFinLabel.setText(CalendarUtil.format(abscence.getDateFin()));
    			dureeLabel.setText(Integer.toString(abscence.getDureeAbsc()));
    			motifLabel.setText(abscence.getMotif());
     
     
    		} else {
    			nomPersLabel.setText("");
    			prenomPersLabel.setText("");
    			fonctionLabel.setText("");
    			dateDebutLabel.setText("");
    			dateFinLabel.setText("");
    			dureeLabel.setText("");
    			motifLabel.setText("");
     
    		}
    	}
     
    	/***
             * 
             * @param abscence, montre le formulaire d'abscence
             * @return
             */
     
    	public  boolean showAbscenceEditDialog(Abscence abscence){
    		try {
     
    		FXMLLoader loader2 = new FXMLLoader(AbscenceOverviewController.class.getResource("view/AbscenceEditDialog.fxml"));
    		AnchorPane page = (AnchorPane) loader2.load();
    		Stage dialogStageAbscE = new Stage();
    		dialogStageAbscE.setTitle("Formulaire Abscence");
    		dialogStageAbscE.initModality(Modality.WINDOW_MODAL);
    		dialogStageAbscE.initOwner(dialogStageAbscE);
    		Scene scene = new Scene(page);
    		dialogStageAbscE.setScene(scene);
    		dialogStageAbscE.show();
     
    		// Set the permission formulaire into the controller
    		AbscenceEditDialogController controller = loader2.getController();
    	    controller.setDialogStageAbscE(dialogStageAbscE);
    	    controller.setAbscence(abscence);
     
    		return controller.isValideClicked();
     
    		} catch (IOException e) {
    			// TODO Bloc catch généré automatiquement
    			e.printStackTrace();
    			return false;
    		}
     
    	}
     
     
    	/**
             * Called when the user clicks the new button.
             * Opens a dialog to edit details for a new person.
            */
    	@FXML
    	private void handleNouvelleAbscence() {
    		Abscence tempAbscence = new Abscence();
    		boolean nouveauClicked = showAbscenceEditDialog(tempAbscence);
    		if (nouveauClicked) {
    			getAbscenceData().add(tempAbscence);
    		}
    	} 
     
    	/***
             * Param du bouton Modifier
             */
    	@FXML
    	private void handleModifierAbscence() {
    		Abscence selectedAbscence = abscenceTable.getSelectionModel().getSelectedItem();
    		if (selectedAbscence != null) {
    			boolean okClicked = showAbscenceEditDialog(selectedAbscence);
    			if (okClicked) {
    				refreshAbscenceTable();
    				showAbscenceDetails(selectedAbscence);
    			}
     
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(null,
    					"Veillez sélectionnez une Abscence dans la Table.",
    					"Pas d'Abscence Sélectionnée", "Pas de Sélection");
    		}
    	}
     
    	/**
             * Called when the user clicks on the delete button.
             */
    	@FXML
    	private void handleSupprimerAbscence() {
    		int selectedIndex = abscenceTable.getSelectionModel().getSelectedIndex();
    		if (selectedIndex >= 0) {
    			abscenceTable.getItems().remove(selectedIndex);
    		} else {
    			// Nothing selected
    			Dialogs.showWarningDialog(null,
    					"Veillez sélectionner une Abscence dans la table",
    					"Pas d'Abscence Sélectionnée", "Pas de Sélection");
    		}
    	}
     
     
    	/**
             * Returns the data as an observable list of Abscence
             * @return
             */
     
     
    	public File getAbscenceFilePath() {
    		Preferences prefsAbs = Preferences.systemNodeForPackage(AbscenceOverviewController.class);
    		String filePathAbsc = prefsAbs.get("filePathAbsc", null);
    		if (filePathAbsc != null) {
    			return new File(filePathAbsc);
    		} 
    		else {
    			return null;
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, setAbscenceFilePath
             */
     
    	public void setAbscenceFilePath(File abscenceFile) {
    		Preferences prefsAbs = Preferences.userNodeForPackage(AbscenceOverviewController.class);
    		if (abscenceFile != null) {
    			prefsAbs.put("filePath", abscenceFile.getPath());
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence - " + abscenceFile.getName());
    		} 
    		else {
    			prefsAbs.remove("filePathAbsc");
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence");
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, loadAbscenceDataFromFile
             */
    	@SuppressWarnings("unchecked")
    	public void loadAbscenceDataFromFile(File abscenceFile) {
    		XStream xstreamAbscence = new XStream();
    		xstreamAbscence.alias("abscence", Abscence.class);
     
    		try {
    			String xml = FileUtil.readFile(abscenceFile);
     
    			ArrayList<Abscence> abscenceList = (ArrayList<Abscence>) xstreamAbscence.fromXML(xml);
     
    			abscenceData.clear();
    			abscenceData.addAll(abscenceList);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    					"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    					"Impossible de charger les données", "Error", e);
    		}
    	}
     
    	/****
             * 
             * @param file, saveAbscenceDataToFile
             */
    	public void saveAbscenceDataToFile(File abscenceFile) {
    		XStream xstream = new XStream();
    		xstream.alias("abscence", Abscence.class);
     
    		// Convert ObservableList to a normal ArrayList
    		ArrayList<Abscence> abscenceList = new ArrayList<>(abscenceData);		
    		String xml = xstream.toXML(abscenceList);
     
    		try {
    			FileUtil.saveFile(xml, abscenceFile);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    				"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    				"Impossible de charger les données", "Error", e);
    		}
    	}
     
     
     
    	/**
             * Refreshes the table. This is only necessary if an item that is already in
             * the table is changed. New and deleted items are refreshed automatically.
             * 
             * This is a workaround because otherwise we would need to use property
             * bindings in the model class and add a *property() method for each
             * property. Maybe this will not be necessary in future versions of JavaFX
             * (see http://javafx-jira.kenai.com/browse/RT-22599)
             */
     
    	protected void refreshAbscenceTable() {
    		int selectedIndex = abscenceTable.getSelectionModel().getSelectedIndex();
    		abscenceTable.setItems(null);
    		abscenceTable.layout();
    		abscenceTable.setItems(getAbscenceData());
    		// Must set the selected index again (see http://javafx-jira.kenai.com/browse/RT-26291)
    		abscenceTable.getSelectionModel().select(selectedIndex);
    	}
     
    	public void start(Stage arg0) throws Exception {
    		// TODO Stub de la méthode généré automatiquement
     
    	}
     
     
     
    }// Fin de la classe PermissionListController

  6. #6
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    Super... je suis noyé dans bien plus de code que de necessaire

    Ton controlleur est null vu que apparement tu choppes une NullPointerException. Et apparemment tu ne l'obtiens pas par inclusion de FXML.
    Est ce que tu utilises ce qu'il faut pour l'initialiser ? Est ce que cette méthode est jamais appelée dans le cas où ça plante et si oui est ce que la valeur passée est null ? Fait un peu fonctionner le débogueur que diable histoire ce voir ce qui se passe à l'initialisation de tes classes ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    private AbscenceOverviewController abscenceOverviewController;
     
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController){
    		this.abscenceOverviewController = abscenceOverviewController;
     
    	}
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  7. #7
    Membre averti
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2012
    Messages
    42
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2012
    Messages : 42
    Par défaut
    Ok, j'avoue que je n'y comprends rien. Mais voici ce que je peux repondre:

    Alors, dans mon fichier AbscenceOverviewController.java qui gère le fichier AbscenceOverview.FXML, j'ai ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    **
    	 * Returns the AbscenceOverviewController.
    	 * @return
    	 */
    	public AbscenceOverviewController getAbscenceOverviewController() {
    		return abscenceOverviewController;
    	}
    	/**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController) {
    		// Add observable list data to the table
    		abscenceTable.setItems(getAbscenceData());	
    	}
    Maintenant les codes suivants permettant d'enregistrer un fichier au format .XML, se trouve dans AbscenceListController.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    public File getAbscenceFilePath() {
    		Preferences prefsAbs = Preferences.systemNodeForPackage(AbscenceOverviewController.class);
    		String filePathAbsc = prefsAbs.get("filePathAbsc", null);
    		if (filePathAbsc != null) {
    			return new File(filePathAbsc);
    		} 
    		else {
    			return null;
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, setAbscenceFilePath
             */
     
    	public void setAbscenceFilePath(File abscenceFile) {
    		Preferences prefsAbs = Preferences.userNodeForPackage(AbscenceOverviewController.class);
    		if (abscenceFile != null) {
    			prefsAbs.put("filePath", abscenceFile.getPath());
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence - " + abscenceFile.getName());
    		} 
    		else {
    			prefsAbs.remove("filePathAbsc");
     
    			// Update the stage title
    			dialogStageAbscL.setTitle("Abscence");
    		}
    	}
     
    	/**
             * 
             * @param abscenceFile, loadAbscenceDataFromFile
             */
    	@SuppressWarnings("unchecked")
    	public void loadAbscenceDataFromFile(File abscenceFile) {
    		XStream xstreamAbscence = new XStream();
    		xstreamAbscence.alias("abscence", Abscence.class);
     
    		try {
    			String xml = FileUtil.readFile(abscenceFile);
     
    			ArrayList<Abscence> abscenceList = (ArrayList<Abscence>) xstreamAbscence.fromXML(xml);
     
    			abscenceData.clear();
    			abscenceData.addAll(abscenceList);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    					"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    					"Impossible de charger les données", "Error", e);
    		}
    	}
     
    	/****
             * 
             * @param file, saveAbscenceDataToFile
             */
    	public void saveAbscenceDataToFile(File abscenceFile) {
    		XStream xstream = new XStream();
    		xstream.alias("abscence", Abscence.class);
     
    		// Convert ObservableList to a normal ArrayList
    		ArrayList<Abscence> abscenceList = new ArrayList<>(abscenceData);		
    		String xml = xstream.toXML(abscenceList);
     
    		try {
    			FileUtil.saveFile(xml, abscenceFile);
     
    			setAbscenceFilePath(abscenceFile);
    		} catch (Exception e) { // catches ANY exception
    			Dialogs.showErrorDialog(null,
    				"Impossible de charger les données du fichier:\n" + abscenceFile.getPath(),
    				"Impossible de charger les données", "Error", e);
    		}
    	}
    - L'erreur qui a été géneré est lq suivqnte:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Caused by: java.lang.NullPointerException
    	at ch.makery.address.RootLayoutAbscController.handleEnregistrer(RootLayoutAbscController.java:54)
    	... 50 more
    Cette erreur indique la ligne en gras rouge de la methode suivante qui se trouve dans le fichier RootLayoutAbscController qui gère le fichier RootLayoutAbsc.FXML:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    @FXML
    	  private void handleEnregistrer() {
    		File abscenceFile = abscenceOverviewController.getAbscenceFilePath();
    		if (abscenceFile != null) {
    			abscenceOverviewController.saveAbscenceDataToFile(abscenceFile);
    		} else{
    			handleEnregistrerSous();
    			}   
    	  }
    Alors je n'arrive pas a comprendre pourquoi mon controler abscenceOverviewController peut etre nul?

  8. #8
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    Et là y a pas un truc qui cloche ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    /**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController) {
    		// Add observable list data to the table
    		abscenceTable.setItems(getAbscenceData());	
    	}
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  9. #9
    Membre averti
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2012
    Messages
    42
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2012
    Messages : 42
    Par défaut
    Oui c'est vrai, il y une ligne de code qui manque. voici donc comment je la corrige:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    /**
             * Is called by the main application to give a reference back to itself.
             * 
             * @param mainApp
             */
    	public void setAbscenceListController(AbscenceOverviewController abscenceOverviewController) {
    		this.abscenceOverviewController = abscenceOverviewController;
     
                    // Ajout des donnees de la liste a la table
    		abscenceTable.setItems(getAbscenceData());	
    	}
    Mais seulement que ça ne resoud pas le probleme.
    Diable, ou ce trouve l'erreur donc. ma tete va s'exploser a force de reflechir

  10. #10
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    Je vais le répéter une dernière fois et après je laisse tomber : débogueur et regarder en particulier si les initialisations ont lieu correctement !
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  11. #11
    Membre averti
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2012
    Messages
    42
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2012
    Messages : 42
    Par défaut
    voici ce que j'obtient lorsque je debogue
    Images attachées Images attachées  

  12. #12
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    Super Eclipse... Ca veut dire j'imagine qu'il n'est pas possible d'y débogger une app FX pour le moment ?

    Eh ben tu vas revenir à l'antique et noble coutume des System.out.println() pour vérifier l'état de tes variable et l'ordre d'appel de tes fonctions.
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

Discussions similaires

  1. Items dans une boite de dialgue
    Par yasminacha dans le forum Android
    Réponses: 2
    Dernier message: 14/06/2011, 09h38
  2. tracer un trait dans une boite de dialog
    Par clement127 dans le forum MFC
    Réponses: 6
    Dernier message: 21/11/2007, 15h28
  3. Ascenseur dans une boite de dialog sous visual c++
    Par Minos2 dans le forum Visual C++
    Réponses: 1
    Dernier message: 26/06/2007, 18h40
  4. comment afficher un CString dans une boite de dialog?
    Par meera dans le forum Visual C++
    Réponses: 22
    Dernier message: 04/11/2006, 12h04
  5. [mfc] affichage dans une boite de dialog
    Par chronos dans le forum MFC
    Réponses: 3
    Dernier message: 14/06/2004, 15h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo