List of usage examples for java.beans PropertyChangeEvent getSource
public Object getSource()
From source file:org.datavyu.views.DataControllerV.java
@Override public void propertyChange(final PropertyChangeEvent e) { if (e.getSource() == mixerController.getNeedleController().getNeedleModel()) { handleNeedleChanged(e);//from w w w. j a v a 2 s .com } else if (e.getSource() == mixerController.getMixerModel().getViewportModel()) { handleViewportChanged(e); } else if (e.getSource() == mixerController.getRegionController().getModel()) { handleRegionChanged(e); } }
From source file:org.apache.log4j.chainsaw.LogUI.java
private void buildLogPanel(boolean customExpression, final String ident, final List events) throws IllegalArgumentException { final LogPanel thisPanel = new LogPanel(getStatusBar(), ident, cyclicBufferSize, allColorizers, applicationPreferenceModel); getSettingsManager().addSettingsListener(thisPanel); getSettingsManager().configure(thisPanel); /**/* w w w . j ava2s .co m*/ * Now add the panel as a batch listener so it can handle it's own * batchs */ if (customExpression) { handler.addCustomEventBatchListener(ident, thisPanel); } else { identifierPanels.add(thisPanel); handler.addEventBatchListener(thisPanel); } TabIconHandler iconHandler = new TabIconHandler(ident); thisPanel.addEventCountListener(iconHandler); tabbedPane.addChangeListener(iconHandler); PropertyChangeListener toolbarMenuUpdateListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { tbms.stateChange(); } }; thisPanel.addPropertyChangeListener(toolbarMenuUpdateListener); thisPanel.addPreferencePropertyChangeListener(toolbarMenuUpdateListener); thisPanel.addPropertyChangeListener("docked", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { LogPanel logPanel = (LogPanel) evt.getSource(); if (logPanel.isDocked()) { getPanelMap().put(logPanel.getIdentifier(), logPanel); getTabbedPane().addANewTab(logPanel.getIdentifier(), logPanel, null); getTabbedPane().setSelectedTab(getTabbedPane().indexOfTab(logPanel.getIdentifier())); } else { getTabbedPane().remove(logPanel); } } }); logger.debug("adding logpanel to tabbed pane: " + ident); //NOTE: tab addition is a very fragile process - if you modify this code, //verify the frames in the individual log panels initialize to their //correct sizes getTabbedPane().add(ident, thisPanel); getPanelMap().put(ident, thisPanel); /** * Let the new LogPanel receive this batch */ SwingUtilities.invokeLater(new Runnable() { public void run() { getTabbedPane().addANewTab(ident, thisPanel, new ImageIcon(ChainsawIcons.ANIM_RADIO_TOWER)); thisPanel.layoutComponents(); thisPanel.receiveEventBatch(ident, events); if (!getTabbedPane().tabSetting.isChainsawLog()) { displayPanel("chainsaw-log", false); } } }); String msg = "added tab " + ident; MessageCenter.getInstance().getLogger().debug(msg); }
From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java
@Override public PropertyChangeListener createPropertyChangeListener(VFSJFileChooser fc) { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String s = e.getPropertyName(); if (s.equals(VFSJFileChooserConstants.SELECTED_FILE_CHANGED_PROPERTY)) { doSelectedFileChanged(e); } else if (s.equals(VFSJFileChooserConstants.SELECTED_FILES_CHANGED_PROPERTY)) { doSelectedFilesChanged(e); } else if (s.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY)) { doDirectoryChanged(e);/*from www.j a v a 2s . com*/ } else if (s.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY)) { doFilterChanged(e); } else if (s.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY)) { doFileSelectionModeChanged(e); } else if (s.equals(VFSJFileChooserConstants.ACCESSORY_CHANGED_PROPERTY)) { doAccessoryChanged(e); } else if (s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) || s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) { doApproveButtonTextChanged(e); } else if (s.equals(VFSJFileChooserConstants.DIALOG_TYPE_CHANGED_PROPERTY)) { doDialogTypeChanged(e); } else if (s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) { doApproveButtonMnemonicChanged(e); } else if (s.equals(VFSJFileChooserConstants.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) { doControlButtonsChanged(e); } else if (s.equals("componentOrientation")) { ComponentOrientation o = (ComponentOrientation) e.getNewValue(); VFSJFileChooser cc = (VFSJFileChooser) e.getSource(); if (o != (ComponentOrientation) e.getOldValue()) { cc.applyComponentOrientation(o); } } else if (s.equals("FileChooser.useShellFolder")) { updateUseShellFolder(); doDirectoryChanged(e); } else if (s.equals("ancestor")) { if ((e.getOldValue() == null) && (e.getNewValue() != null)) { // Ancestor was added, set initial focus fileNameTextField.selectAll(); fileNameTextField.requestFocus(); } } } }; }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
public void propertyChange(PropertyChangeEvent e) { if (viewType == -1) { setViewType(VIEWTYPE_LIST);//from ww w.j a va 2 s .com } String s = e.getPropertyName(); if (s.equals(VFSJFileChooserConstants.SELECTED_FILE_CHANGED_PROPERTY)) { doSelectedFileChanged(e); } else if (s.equals(VFSJFileChooserConstants.SELECTED_FILES_CHANGED_PROPERTY)) { doSelectedFilesChanged(e); } else if (s.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY)) { doDirectoryChanged(e); } else if (s.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY)) { doFilterChanged(e); } else if (s.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY)) { doFileSelectionModeChanged(e); } else if (s.equals(VFSJFileChooserConstants.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) { doMultiSelectionChanged(e); } else if (s.equals(VFSJFileChooserConstants.CANCEL_SELECTION)) { applyEdit(); } else if (s.equals("busy")) { setCursor((Boolean) e.getNewValue() ? waitCursor : null); } else if (s.equals("componentOrientation")) { ComponentOrientation o = (ComponentOrientation) e.getNewValue(); VFSJFileChooser cc = (VFSJFileChooser) e.getSource(); if (o != e.getOldValue()) { cc.applyComponentOrientation(o); } } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Reacts to property fired by the table. * //from w ww. j a v a2 s . co m * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FileSelectionTable.ADD_PROPERTY.equals(name)) { showLocationDialog(); } else if (FileSelectionTable.REMOVE_PROPERTY.equals(name)) { int n = handleFilesSelection(chooser.getSelectedFiles()); table.allowAddition(n > 0); importButton.setEnabled(table.hasFilesToImport()); } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(name)) { int n = handleFilesSelection(chooser.getSelectedFiles()); table.allowAddition(n > 0); } else if (NumericalTextField.TEXT_UPDATED_PROPERTY.equals(name)) { if (partialName.isSelected()) { Integer number = (Integer) numberOfFolders.getValueAsNumber(); if (number != null && number >= 0) table.applyToAll(); } } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) { Map m = (Map) evt.getNewValue(); if (m == null || m.size() != 1) return; Set set = m.entrySet(); Entry entry; Iterator i = set.iterator(); Class type; while (i.hasNext()) { entry = (Entry) i.next(); type = (Class) entry.getKey(); if (TagAnnotationData.class.getName().equals(type.getName())) handleTagsSelection((Collection<TagAnnotationData>) entry.getValue()); } } else if (ImportDialog.PROPERTY_GROUP_CHANGED.equals(name) || ImportDialog.REFRESH_LOCATION_PROPERTY.equals(name) || ImportDialog.CREATE_OBJECT_PROPERTY.equals(name)) { firePropertyChange(name, evt.getOldValue(), evt.getNewValue()); } else if (LocationDialog.ADD_TO_QUEUE_PROPERTY.equals(name)) { Object src = evt.getSource(); if (src != detachedDialog) { addImageJFiles(null, null); } } }
From source file:org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.checkPrevisionnelle = new JCheckBox(); this.checkComplement = new JCheckBox(); this.fieldTTC = new DeviseField(); final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration .getInstance());/*from w ww. j av a 2 s .c o m*/ this.textAvoirTTC = new DeviseField(); // Champ Module c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 1)); this.add(addP, c); c.gridy++; c.gridwidth = 1; if (getTable().contains("ID_POLE_PRODUIT")) { JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT")); labelPole.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelPole, c); c.gridx++; ElementComboBox pole = new ElementComboBox(); this.add(pole, c); this.addSQLObject(pole, "ID_POLE_PRODUIT"); c.gridy++; c.gridwidth = 1; c.gridx = 0; } /******************************************************************************************* * * RENSEIGNEMENTS ******************************************************************************************/ // Ligne 1 : Numero de facture JLabel labelNum = new JLabel(getLabelFor("NUMERO")); labelNum.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; this.add(labelNum, c); this.textNumeroUnique = new JUniqueTextField(16); c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique); this.add(textNumeroUnique, c); // Date c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; final JDate dateSaisie = new JDate(true); // listener permettant la mise jour du numro de facture en fonction de la date // slectionne dateSaisie.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!isFilling() && dateSaisie.getValue() != null) { final String nextNumero = NumerotationAutoSQLElement .getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue()); if (textNumeroUnique.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) { int answer = JOptionPane.showConfirmDialog(SaisieVenteFactureSQLComponent.this, "Voulez vous actualiser le numro de la facture?", "Changement du numro de facture", JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.NO_OPTION) { return; } } textNumeroUnique.setText(nextNumero); } } }); this.add(dateSaisie, c); // Ligne 2 : reference c.gridx = 0; c.gridwidth = 1; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; JLabel labelLibelle = new JLabel(getLabelFor("NOM")); labelLibelle.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelLibelle, c); SQLTextCombo textLibelle = new SQLTextCombo(); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.BOTH; this.add(textLibelle, c); this.addSQLObject(textLibelle, "NOM"); c.fill = GridBagConstraints.HORIZONTAL; this.comboCommercial = new ElementComboBox(false); // Commercial String field; field = "ID_COMMERCIAL"; c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.comboCommercial, c); this.addRequiredSQLObject(this.comboCommercial, field); // Client c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.comboClient = new ElementComboBox(); this.add(this.comboClient, c); if (getTable().contains("ID_ECHEANCIER_CCI")) { // Echeancier c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_ECHEANCIER_CCI"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; final ElementComboBox echeancier = new ElementComboBox(); final SQLElement contactElement = Configuration.getInstance().getDirectory() .getElement("ECHEANCIER_CCI"); echeancier.init(contactElement, contactElement.getComboRequest(true)); DefaultGridBagConstraints.lockMinimumSize(echeancier); this.addView(echeancier, "ID_ECHEANCIER_CCI"); selAffaire.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { // TODO Raccord de mthode auto-gnr if (selAffaire.getSelectedRow() != null) { echeancier.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_AFFAIRE"), "=", selAffaire.getSelectedRow().getID())); if (!isFilling()) { SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT"); comboCommercial.setValue(rowPole); } } else { echeancier.getRequest().setWhere(null); } } }); this.add(echeancier, c); } this.comboClient.addValueListener(this.changeClientListener); this.comboAdresse = new ElementComboBox(); this.comboAdresse.setAddIconVisible(false); this.comboAdresse.setListIconVisible(false); JLabel labelAdresse = new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; labelAdresse.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelAdresse, c); c.gridx++; c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(this.comboAdresse, c); // Acompte this.checkAcompte = new JCheckBox(getLabelFor("ACOMPTE")); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // this.add(this.checkAcompte, c); c.gridwidth = 1; this.addView(this.checkAcompte, "ACOMPTE"); // Compte Service this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO")); this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO"); this.compteSelService = new ISQLCompteSelector(); this.labelCompteServ = new JLabel("Compte Service"); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT); this.add(this.labelCompteServ, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(this.compteSelService, c); String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService"); Boolean bServ = Boolean.valueOf(valServ); this.checkCompteServiceAuto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setCompteServiceVisible(!SaisieVenteFactureSQLComponent.this.checkCompteServiceAuto.isSelected()); } }); // FIXME A checker si utile pour Preventec ou KD setCompteServiceVisible(false); // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue())); final JPanel pAcompte = new JPanel(); final DeviseField textAcompteHT = new DeviseField(); pAcompte.add(new JLabel("Acompte HT")); pAcompte.add(textAcompteHT); pAcompte.add(new JLabel("soit")); final JTextField textAcompte = new JTextField(5); pAcompte.add(textAcompte); pAcompte.add(new JLabel("%")); c.gridx = 0; c.gridy++; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; this.add(pAcompte, c); c.anchor = GridBagConstraints.WEST; this.addView(textAcompte, "POURCENT_ACOMPTE"); pAcompte.setVisible(false); /******************************************************************************************* * * DETAILS ******************************************************************************************/ this.tableFacture = new SaisieVenteFactureItemTable(); final ElementComboBox boxTarif = new ElementComboBox(); if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel("Tarif appliquer", SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1; DefaultGridBagConstraints.lockMinimumSize(boxTarif); this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID()); tableFacture.setTarif(selectedRow, false); } }); } c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; ITextArea infos = new ITextArea(4, 4); this.add(this.tableFacture, c); // FIXME this.addView(this.tableFacture.getRowValuesTable(), ""); /******************************************************************************************* * * MODE DE REGLEMENT ******************************************************************************************/ JPanel panelBottom = new JPanel(new GridBagLayout()); GridBagConstraints cBottom = new DefaultGridBagConstraints(); cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.NORTHWEST; // Mode de rglement this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP); this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT"); panelBottom.add(this.eltModeRegl, cBottom); /******************************************************************************************* * * FRAIS DE PORT ET REMISE ******************************************************************************************/ JPanel panelFrais = new JPanel(); panelFrais.setLayout(new GridBagLayout()); final GridBagConstraints cFrais = new DefaultGridBagConstraints(); this.textPortHT = new DeviseField(5); DefaultGridBagConstraints.lockMinimumSize(textPortHT); addSQLObject(this.textPortHT, "PORT_HT"); this.textRemiseHT = new DeviseField(5); DefaultGridBagConstraints.lockMinimumSize(textRemiseHT); addSQLObject(this.textRemiseHT, "REMISE_HT"); // Frais de port cFrais.gridheight = 1; cFrais.gridx = 1; SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8); if (getTable().contains("ID_TAXE_PORT")) { JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT")); labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridy++; panelFrais.add(labelPortHT, cFrais); cFrais.gridx++; panelFrais.add(this.textPortHT, cFrais); JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT")); labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridx = 1; cFrais.gridy++; panelFrais.add(labelTaxeHT, cFrais); cFrais.gridx++; panelFrais.add(boxTaxePort, cFrais); this.addView(boxTaxePort, "ID_TAXE_PORT", REQ); boxTaxePort.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // TODO Raccord de mthode auto-gnr totalTTC.updateTotal(); } }); } // Remise JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT")); labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridy++; cFrais.gridx = 1; panelFrais.add(labelRemiseHT, cFrais); cFrais.gridx++; panelFrais.add(this.textRemiseHT, cFrais); cFrais.gridy++; cBottom.gridx++; cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.NORTHEAST; cBottom.fill = GridBagConstraints.NONE; panelBottom.add(panelFrais, cBottom); /******************************************************************************************* * * CALCUL DES TOTAUX ******************************************************************************************/ DeviseField fieldHT = new DeviseField(); final DeviseField fieldTVA = new DeviseField(); DeviseField fieldService = new DeviseField(); DeviseField fieldTHA = new DeviseField(); DeviseField fieldDevise = null; if (getTable().getFieldsName().contains("T_DEVISE")) { fieldDevise = new DeviseField(); addSQLObject(fieldDevise, "T_DEVISE"); } // FIXME was required but not displayed for KD addSQLObject(fieldTHA, "T_HA"); addRequiredSQLObject(fieldHT, "T_HT"); addRequiredSQLObject(fieldTVA, "T_TVA"); addRequiredSQLObject(this.fieldTTC, "T_TTC"); addRequiredSQLObject(fieldService, "T_SERVICE"); JTextField poids = new JTextField(); addSQLObject(poids, "T_POIDS"); totalTTC = new TotalPanel(this.tableFacture, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null, (getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null)); DefaultGridBagConstraints.lockMinimumSize(totalTTC); cBottom.gridx++; cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.EAST; cBottom.fill = GridBagConstraints.HORIZONTAL; panelBottom.add(totalTTC, cBottom); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; c.weighty = 0; this.add(panelBottom, c); // Ligne : Avoir c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; this.add(createPanelAvoir(), c); // Infos c.gridy++; c.gridx = 0; c.gridwidth = 4; c.fill = GridBagConstraints.BOTH; this.add(new TitledSeparator(getLabelFor("INFOS")), c); c.gridy++; final JScrollPane comp = new JScrollPane(infos); infos.setBorder(null); DefaultGridBagConstraints.lockMinimumSize(comp); this.add(comp, c); this.panelOO = new PanelOOSQLComponent(this); c.gridy++; c.gridx = 0; c.weightx = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; this.add(this.panelOO, c); this.addSQLObject(this.textAvoirTTC, "T_AVOIR_TTC"); this.addRequiredSQLObject(dateSaisie, "DATE"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); this.addSQLObject(this.comboAdresse, "ID_ADRESSE"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addSQLObject(infos, "INFOS"); this.addSQLObject(this.checkPrevisionnelle, "PREVISIONNELLE"); this.addSQLObject(this.checkComplement, "COMPLEMENT"); this.addSQLObject(this.selAvoir, "ID_AVOIR_CLIENT"); this.addSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE"); ModeDeReglementSQLComponent modeReglComp; modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild(); this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE)); this.selAvoir.fillCombo(); // Selection du compte de service int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE"); if (idCompteVenteService <= 1) { try { idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices"); } catch (Exception e) { e.printStackTrace(); } } this.compteSelService.setValue(idCompteVenteService); // Lock DefaultGridBagConstraints.lockMinimumSize(this.comboClient); DefaultGridBagConstraints.lockMinimumSize(this.comboCommercial); DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse); // Listeners this.comboClient.addValueListener(this.listenerModeReglDefaut); this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { refreshText(); } }); this.selAvoir.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { refreshText(); } }); this.checkAcompte.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { pAcompte.setVisible(SaisieVenteFactureSQLComponent.this.checkAcompte.isSelected()); } }); this.changeClientListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SaisieVenteFactureSQLComponent.this.comboClient.getValue() != null) { final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow(); final int id = row == null ? SQLRow.NONEXISTANT_ID : row.getID(); SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row); if (row != null) { if (SaisieVenteFactureSQLComponent.this.contact != null) { Where w = new Where( SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", SQLRow.NONEXISTANT_ID); w = w.or(new Where( SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", id)); SaisieVenteFactureSQLComponent.this.contact.getRequest().setWhere(w); } if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) { Where w = new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE")); w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE_L"))); w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE_F"))); SQLRow rowCli = row; w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getField("ID_CLIENT"), "=", rowCli.getID())); SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(w); } } else { if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) { SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(null); } } SaisieVenteFactureSQLComponent.this.previousClient = id; } } }; this.changeCompteListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SQLSelect sel = new SQLSelect(getTable().getBase()); sel.addSelect(SaisieVenteFactureSQLComponent.this.client.getTable().getKey()); Where where = new Where( SaisieVenteFactureSQLComponent.this.client.getTable().getField("ID_COMPTE_PCE"), "=", SaisieVenteFactureSQLComponent.this.compteSel.getValue()); sel.setWhere(where); String req = sel.asString(); List l = getTable().getBase().getDataSource().execute(req); if (l != null) { if (l.size() == 1) { Map<String, Object> m = (Map<String, Object>) l.get(0); Object o = m.get(SaisieVenteFactureSQLComponent.this.client.getTable().getKey().getName()); System.err.println("Only one value match :: " + o); if (o != null) { SaisieVenteFactureSQLComponent.this.comboClient .setValue(Integer.valueOf(((Number) o).intValue())); } } } } }; this.textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { totalTTC.updateTotal(); } }); this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { totalTTC.updateTotal(); } }); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (SaisieVenteFactureSQLComponent.this.isFilling()) return; final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow(); if (row != null) { SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row); if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) { SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (foreignRow != null && !foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID()) && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) { boxTarif.setValue(foreignRow.getID()); // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow, // true); } else { boxTarif.setValue(foreignRow); } } int idCpt = row.getInt("ID_COMPTE_PCE"); if (idCpt <= 1) { // Select Compte client par defaut idCpt = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT"); if (idCpt <= 1) { try { idCpt = ComptePCESQLElement.getIdComptePceDefault("Clients"); } catch (Exception e) { e.printStackTrace(); } } } if (SaisieVenteFactureSQLComponent.this.compteSel != null) { Integer i = SaisieVenteFactureSQLComponent.this.compteSel.getValue(); if (i == null || i.intValue() != idCpt) { SaisieVenteFactureSQLComponent.this.compteSel.setValue(idCpt); } } } } }); }