/** Ask for a new Enregistrement. */ public boolean askNew(Enregistrement p_template) { isOk = false; isNext = false; // isCheck = false; // wait for input if (p_template != null) { // use as the base for new enregistrement myJEnregistrement.update(p_template); if (myEnregistrement.hasParent()) { parentText.setText(myEnregistrement.getParent().displayData()); myJEnregistrement.update(); } else { parentText.setText(""); } } setVisible(true); return (isOk | isNext); }
/** Raise Dialog for selecting an parent Enregistrement. */ protected void actionBrowse() { // we know it can have parent logger.debug("select a valid parent"); DialogGetEnregistrement tmpDialog = new DialogGetEnregistrement( this, parentTable, (Enregistrement) myEnregistrement.getParent()); Enregistrement selectedParent = tmpDialog.askForEnregistrement(); // one parent selected ? if (selectedParent != null) { logger.debug("Browse : selectedParent\n" + selectedParent.toString()); myEnregistrement.setParentRecursif(selectedParent); } if (myEnregistrement.hasParent()) { parentText.setText(myEnregistrement.getParent().displayData()); myJEnregistrement.update(); } else { parentText.setText(""); } }
/** * Builds an empty enregistrement. * * <p><b>Todo</b>: get Cell to return an "empty" cell */ protected void buildEmptyEnregistrement(Header p_header) { for (int i = 0; i < p_header.theFields.size(); i++) { myEnregistrement.add(i, "", false /*no inherit*/); } }
/** * Builds the DialogEditEnregistrement GUI from the hardwired data. * * <p>It consist of two parts : parent and fields. And 3 buttons : check, ok, cancel. * * @param p_next Do we enable 'next' buton */ protected JPanel buildEntry(Enregistrement p_data, Table p_parentTable, boolean p_next) { logger.debug("buildEntry"); logger.debug(p_data.displayData()); JPanel mainPanel = new JPanel(); // the JEnregistrement myJEnregistrement = new JEnregistrement(p_data, true /*edit*/); // parent Enregistrement JPanel parentPanel = new JPanel(); parentPanel.setLayout(new BoxLayout(parentPanel, BoxLayout.X_AXIS)); // une border! JLabel parentLabel = new JLabel("Parent : "); parentPanel.add(parentLabel); parentText = new JTextField(); parentText.setEditable(false); if (p_data.hasParent()) { parentText.setText(p_data.getParent().displayData()); } else { parentText.setText(""); } parentPanel.add(parentText); JButton parentButton = new JButton(" ... "); parentButton.setActionCommand("browse"); if (p_parentTable == null) { parentButton.setEnabled(false); } parentButton.addActionListener(this); parentPanel.add(parentButton); // The buttons isCheckBox = new JCheckBox("Vérifie", isCheck); isCheckBox.setMnemonic(KeyEvent.VK_V); isCheckBox.addItemListener(new MyCheckBoxListener()); // JButton checkButton = new JButton( "Check" ); // checkButton.setMnemonic( KeyEvent.VK_C ); // checkButton.setActionCommand("check"); // checkButton.addActionListener( this ); JButton okButton = new JButton("Ok"); okButton.setMnemonic(KeyEvent.VK_O); okButton.setActionCommand("ok"); okButton.addActionListener(this); JButton nextButton = new JButton("Suivant"); nextButton.setMnemonic(KeyEvent.VK_S); nextButton.setActionCommand("next"); nextButton.addActionListener(this); nextButton.setEnabled(p_next); JButton cancelButton = new JButton("Annuler"); cancelButton.setMnemonic(KeyEvent.VK_A); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); buttonPanel.add(isCheckBox); // buttonPanel.add(checkButton); buttonPanel.add(okButton); buttonPanel.add(nextButton); buttonPanel.add(cancelButton); // Put the panels in mainPanel, labels on left, // text fields on right, button down mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10)); mainPanel.setLayout(new BorderLayout()); mainPanel.add(parentPanel, BorderLayout.NORTH); mainPanel.add(myJEnregistrement, BorderLayout.CENTER); mainPanel.add(buttonPanel, BorderLayout.SOUTH); return mainPanel; }