List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:org.tinymediamanager.core.Settings.java
/** * Instantiates a new settings./*from ww w . ja v a 2s . c o m*/ */ private Settings() { propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { setDirty(); } }; addPropertyChangeListener(propertyChangeListener); // default values movieSettings = new MovieSettings(); movieSettings.addPropertyChangeListener(propertyChangeListener); tvShowSettings = new TvShowSettings(); tvShowSettings.addPropertyChangeListener(propertyChangeListener); movieScraperMetadataConfig = new MovieScraperMetadataConfig(); movieScraperMetadataConfig.addPropertyChangeListener(propertyChangeListener); tvShowScraperMetadataConfig = new TvShowScraperMetadataConfig(); tvShowScraperMetadataConfig.addPropertyChangeListener(propertyChangeListener); }
From source file:de.fu_berlin.inf.dpp.netbeans.ListenerForDocumentSwap.java
/** * The global plug-in preferences, shared among all workspaces. Should only * be accessed over {@link #getGlobalPreferences()} from outside this class. *///from w w w . ja v a2 s . c om //protected Preferences configPrefs; // private final de.fu_berlin.inf.dpp.preferences.Preferences preferences; public ListenerForDocumentSwap() { sarosVersion = "13.12.6"; ArrayList<ISarosContextFactory> factories = new ArrayList<ISarosContextFactory>(); factories.add(new SarosNetbeansContextFactory(this)); factories.add(new SarosCoreContextFactory()); sarosContext = new SarosContext(factories, null); sarosContext.initialize(); preferences = sarosContext.getComponent(de.fu_berlin.inf.dpp.preferences.Preferences.class); sarosFeatureID = PLUGIN_ID + "_" + sarosVersion; //$NON-NLS-1$ //FeedbackPreferences.setPreferences(sarosContext // .getComponent(Preferences.class)); FeedbackPreferences.setPreferences(NbPreferences.forModule(FeedbackPanel.class)); int favoriteColorID = new Random().nextInt(5); NbPreferences.forModule(SarosPanel.class).put("FAVORITE_COLOR_ID_HACK_CREATE_RANDOM_COLOR", Integer.toString(favoriteColorID)); //NbPreferences.forModule(ListenerForDocumentSwap.class).put(PLUGIN_ID, "test"); initVersionCompatibilityChart(VERSION_COMPATIBILITY_PROPERTY_FILE, sarosContext.getComponent(VersionManager.class)); connectionHandler = sarosContext.getComponent(ConnectionHandler.class); sessionManager = sarosContext.getComponent(ISarosSessionManager.class); SarosPluginContext.setSarosContext(sarosContext); // sarosContext.getComponents(Object.class); isInitialized = true; // setDefault(this); /* * Sets up a Listener to get noticed when the first * file/document is selected * Listener then gets removed and the LookupListener takes over */ initialPropertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { JTextComponent jtc = EditorRegistry.lastFocusedComponent(); if (jtc != null) { Document currentDocument = jtc.getDocument(); DataObject dataObjectForDocument = NbEditorUtilities.getDataObject(currentDocument); addListenerToCurrentlySelectedDocument(dataObjectForDocument); } } }; EditorRegistry.addPropertyChangeListener(initialPropertyChangeListener); listenerForDocumentSwap = new LookupListener() { /* * The selected file in the editor changed * Remove the listener from the old file and/or * Set a listener on the new one * Get the relative and absolut path of the current file * Get the absolute path of the filecontaining project */ public void resultChanged(final LookupEvent evt) { processDocumentSwap(evt); }; }; dataObjectOfSelectedDocument.addLookupListener(listenerForDocumentSwap); }
From source file:net.sf.jhylafax.JHylaFAX.java
public JHylaFAX() { app = this;/* w w w.j a va2s .c o m*/ try { Settings.load(getSettingsFile()); // XXX load does not trigger a property change event, therefore // this needs to be updated manually Settings.DEFAULT_COMPLETION_MODE.updateMode(); } catch (FileNotFoundException e) { logger.debug("Error loading settings", e); // ignore, probably the first time } catch (IOException e) { logger.debug("Error loading settings", e); ErrorDialog.showError(this, i18n.tr("Could not load settings"), i18n.tr("JHylaFAX Error"), e); } updateResourceBundle(); I18nManager.getInstance().addLocaleChangeListener(new LabelUpdater()); IconHelper.classLoader = JHylaFAX.class.getClassLoader(); initializeToolkit(); initialize(); restoreLayout(); PropertyChangeListener disconnector = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (connection != null) { try { connection.quit(); } catch (Exception e) { logger.debug("Error closing connection", e); } connection = null; } } }; Settings.HOSTNAME.addPropertyChangeListener(disconnector); Settings.PORT.addPropertyChangeListener(disconnector); Settings.USE_PASSIVE.addPropertyChangeListener(disconnector); Settings.USERNAME.addPropertyChangeListener(disconnector); Settings.LOCALE.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { updateResourceBundle(); } }); notificationTimer.settingsUpdated(); }
From source file:org.jfree.chart.demo.CompassDemo.java
/** * Initialises the user interface.//from w w w .ja v a 2s. c om * * @throws Exception if there are any exceptions. */ void jbInit() throws Exception { this.titledBorder1 = new TitledBorder(""); this.titledBorder2 = new TitledBorder(""); this.titledBorder3 = new TitledBorder(""); setLayout(this.gridLayout1); this.panelCompassHolder.setLayout(this.borderLayout); this.windNullCheckBox.setHorizontalTextPosition(SwingConstants.LEADING); this.windNullCheckBox.setText("Null"); this.windNullCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { checkWindNullActionPerformed(e); } }); this.shipNullCheckBox.setHorizontalTextPosition(SwingConstants.LEFT); this.shipNullCheckBox.setText("Null"); this.shipNullCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { checkShipNullActionPerformed(e); } }); this.spinShip.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinShipPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { shipData.setValue(new Double(spinner.getValue())); } } }); this.spinWind.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinWindPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { compassData.setValue(new Double(spinner.getValue())); } } }); this.jPanel12.setLayout(this.gridLayout2); this.jPanel2.setBorder(this.titledBorder1); this.jPanel2.setLayout(this.gridBagLayout2); this.jPanel1.setBorder(this.titledBorder2); this.jPanel1.setLayout(this.gridBagLayout1); this.titledBorder1.setTitle("Second Pointer"); this.titledBorder2.setTitle("First Pointer"); this.titledBorder3.setTitle("Plot Options"); this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick2PointerActionPerformed(e); } }); this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick1PointerActionPerformed(e); } }); add(this.panelCompassHolder, null); this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH); this.jPanel12.add(this.jPanel1, null); this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel12.add(this.jPanel2, null); this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER); }
From source file:org.openconcerto.erp.core.sales.pos.element.SaisieVenteComptoirSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private final JCheckBox checkService = new JCheckBox("dont "); private SQLSearchableTextCombo textNom; private DeviseField textMontantTTC; private DeviseField textMontantService; private ElementComboBox comboFournisseur; private JTextField textEcheance; private ElementComboBox comboTaxe; private DeviseField textMontantHT; private JCheckBox checkCommande; private JDate dateSaisie; private ElementComboBox nomArticle; private Date dateEch; private JLabel labelEcheancejours = new JLabel("jours"); private ElementComboBox comboAvoir; private ElementComboBox comboClient; private final JLabel labelWarning = new JLabelWarning( "le montant du service ne peut pas dpasser le total HT!"); private ValidState validState = ValidState.getTrueInstance(); // FIXME: use w private Where w; private DocumentListener docTTCListen; private PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ((nomArticle.getValidState().isValid()) && (!nomArticle.isEmpty()) && !isFilling()) { int idArticle = nomArticle.getValue().intValue(); SQLTable tableArticle = ((ComptaPropsConfiguration) Configuration.getInstance()) .getRootSociete().getTable("ARTICLE"); SQLRow rowArticle = tableArticle.getRow(idArticle); if (rowArticle != null) { comboTaxe.setValue(rowArticle.getInt("ID_TAXE")); textMontantTTC.setText(((BigDecimal) rowArticle.getObject("PV_TTC")).toString()); }/*www . j a va2s .co m*/ System.out.println("value article Changed"); } } }; public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.docTTCListen = new DocumentListener() { public void changedUpdate(DocumentEvent e) { calculMontant(); } public void removeUpdate(DocumentEvent e) { calculMontant(); } public void insertUpdate(DocumentEvent e) { calculMontant(); } }; /*********************************************************************************** * * RENSEIGNEMENTS **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; TitledSeparator sep = new TitledSeparator("Renseignements"); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridwidth = 1; // Libell vente JLabel labelNom = new JLabel(getLabelFor("NOM")); labelNom.setHorizontalAlignment(SwingConstants.RIGHT); c.gridy++; c.gridx = 0; c.weightx = 0; this.add(labelNom, c); this.textNom = new SQLSearchableTextCombo(); c.gridx++; c.weightx = 1; c.gridwidth = 2; this.add(this.textNom, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); this.dateSaisie = new JDate(true); c.gridwidth = 1; // c.gridx += 2; c.gridx = 0; c.gridy++; c.weightx = 0; labelDate.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelDate, c); c.gridx++; c.weightx = 1; this.add(this.dateSaisie, c); // article c.gridy++; c.gridx = 0; this.nomArticle = new ElementComboBox(); JLabel labelNomArticle = new JLabel(getLabelFor("ID_ARTICLE")); c.weightx = 0; labelNomArticle.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelNomArticle, c); c.gridx++; c.weightx = 0; c.gridwidth = GridBagConstraints.REMAINDER; // this.add(this.nomArticle, c); this.nomArticle.addValueListener(this.propertyChangeListener); // client this.comboClient = new ElementComboBox(); this.comboClient.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (comboClient.isEmpty()) { w = new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", -1); } else { w = new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", comboClient.getSelectedId()); } } }); JLabel labelNomClient = new JLabel(getLabelFor("ID_CLIENT")); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; labelNomClient.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNomClient, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; this.add(this.comboClient, c); // Selection d'un avoir si le client en possede this.comboAvoir = new ElementComboBox(); JLabel labelAvoirClient = new JLabel(getLabelFor("ID_AVOIR_CLIENT")); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; labelAvoirClient.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelAvoirClient, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; // this.add(this.comboAvoir, c); /*********************************************************************************** * * MONTANT **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; c.weightx = 1; sep = new TitledSeparator("Montant en Euros"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridwidth = 1; final JLabel labelMontantHT = new JLabel(getLabelFor("MONTANT_HT")); labelMontantHT.setHorizontalAlignment(SwingConstants.RIGHT); this.textMontantHT = new DeviseField(); this.textMontantHT.setEditable(false); this.textMontantHT.setEnabled(false); this.textMontantHT.setFocusable(false); final JLabel labelMontantTTC = new JLabel(getLabelFor("MONTANT_TTC")); labelMontantTTC.setHorizontalAlignment(SwingConstants.RIGHT); this.textMontantTTC = new DeviseField(); this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen); // Montant HT c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridy++; c.gridx = 0; c.gridwidth = 1; this.add(labelMontantHT, c); c.gridx++; c.weightx = 1; this.add(this.textMontantHT, c); // Montant Service c.gridx++; c.weightx = 0; this.add(checkService, c); checkService.addActionListener(new ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (isFilling()) return; boolean b = checkService.isSelected(); textMontantService.setEditable(b); textMontantService.setEnabled(b); textMontantService.setFocusable(b); if (!b) { textMontantService.setText(""); // montantServiceValide = true; } else { textMontantService.setText(textMontantHT.getText()); } }; }); this.textMontantService = new DeviseField(); c.gridx++; c.weightx = 1; this.add(this.textMontantService, c); JLabel labelMontantService = new JLabel("de service HT"); c.weightx = 0; c.gridx++; this.add(labelMontantService, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; this.add(this.labelWarning, c); this.labelWarning.setVisible(false); // Choix TVA c.gridy++; c.gridx = 0; c.weightx = 0; c.gridwidth = 1; final JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE")); labelTaxe.setHorizontalAlignment(SwingUtilities.RIGHT); this.add(labelTaxe, c); c.gridx++; this.comboTaxe = new ElementComboBox(false); c.fill = GridBagConstraints.NONE; this.add(this.comboTaxe, c); c.fill = GridBagConstraints.HORIZONTAL; // Montant TTC c.gridy++; c.gridx = 0; c.weightx = 0; this.add(labelMontantTTC, c); c.gridx++; c.weightx = 0; this.add(this.textMontantTTC, c); /*********************************************************************************** * * MODE DE REGLEMENT **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; sep = new TitledSeparator("Mode de rglement"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP); ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT"); this.add(eltModeRegl, c); /*********************************************************************************** * * COMMANDE **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; sep = new TitledSeparator("Commande"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); this.checkCommande = new JCheckBox("Produit commander"); c.gridx = 0; c.gridy++; c.weightx = 0; c.gridwidth = 2; // this.add(this.checkCommande, c); this.checkCommande.addActionListener(new ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { boolean b = checkCommande.isSelected(); comboFournisseur.setEnabled(b); comboFournisseur.setEditable(b); textEcheance.setEditable(b); textEcheance.setEnabled(b); updateValidState(); }; }); // Fournisseurs JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR")); c.gridx = 0; c.gridy++; c.weightx = 0; c.gridwidth = 1; labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelFournisseur, c); this.comboFournisseur = new ElementComboBox(); c.gridx++; c.weightx = 1; c.gridwidth = 4; // this.add(this.comboFournisseur, c); // Echeance JLabel labelEcheance = new JLabel("Echeance"); c.gridx = 0; c.gridy++; c.weightx = 0; c.gridwidth = 1; labelEcheance.setHorizontalAlignment(SwingConstants.RIGHT); // this.add(labelEcheance, c); c.gridx++; c.weightx = 1; this.textEcheance = new JTextField(); // this.add(this.textEcheance, c); this.textEcheance.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { calculDate(); } }); c.gridx++; c.weightx = 0; // this.add(this.labelEcheancejours, c); /*********************************************************************************** * * INFORMATIONS COMPLEMENTAIRES **********************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 0; c.gridy++; sep = new TitledSeparator("Informations complmentaires"); c.insets = new Insets(10, 2, 1, 2); // this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); ITextArea textInfos = new ITextArea(); c.gridx = 0; c.gridy++; c.gridheight = GridBagConstraints.REMAINDER; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; // this.add(textInfos, c); this.addSQLObject(this.textNom, "NOM"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); this.addSQLObject(this.nomArticle, "ID_ARTICLE"); this.addRequiredSQLObject(this.textMontantTTC, "MONTANT_TTC"); this.addRequiredSQLObject(this.textMontantHT, "MONTANT_HT"); this.addSQLObject(this.textMontantService, "MONTANT_SERVICE"); this.addRequiredSQLObject(this.dateSaisie, "DATE"); this.addSQLObject(textInfos, "INFOS"); this.addSQLObject(this.comboFournisseur, "ID_FOURNISSEUR"); this.addSQLObject(this.textEcheance, "ECHEANCE"); this.addRequiredSQLObject(this.comboTaxe, "ID_TAXE"); this.addSQLObject(this.comboAvoir, "ID_AVOIR_CLIENT"); this.comboTaxe.setButtonsVisible(false); this.comboTaxe.setValue(2); checkService.setSelected(false); this.textMontantService.setEditable(false); this.textMontantService.setEnabled(false); this.checkCommande.setSelected(false); this.comboFournisseur.setEditable(false); this.comboFournisseur.setEnabled(false); this.textEcheance.setEditable(false); this.textEcheance.setEnabled(false); this.comboTaxe.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { calculMontant(); } }); final SimpleDocumentListener docL = new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateValidState(); } }; this.textMontantService.getDocument().addDocumentListener(docL); this.textMontantHT.getDocument().addDocumentListener(docL); this.comboFournisseur.addEmptyListener(new EmptyListener() { @Override public void emptyChange(EmptyObj src, boolean newValue) { updateValidState(); } }); /* * this.nomClient.addValueListener(new PropertyChangeListener() { * * public void propertyChange(PropertyChangeEvent evt) { if (nomClient.isValid()) { * System.err.println("Changed Combo Avoir"); comboAvoir = new ElementComboBox(new * AvoirClientSQLElement(new Where(new * AvoirClientSQLElement().getTable().getField("ID_CLIENT"), "=", * nomClient.getValue()))); if (comboAvoir != null) { comboAvoir.setEnabled(true); } * } else { comboAvoir.setEnabled(false); } } }); */ } @Override public Set<String> getPartialResetNames() { Set<String> s = new HashSet<String>(); s.addAll(super.getPartialResetNames()); s.add("MONTANT_TTC"); s.add("MONTANT_SERVICE"); s.add("MONTANT_HT"); s.add("NOM"); s.add("ID_AVOIR_CLIENT"); s.add("ID_ARTICLE"); s.add("INFOS"); return s; } private void calculMontant() { if (!isFilling()) { float taux; // PrixHT pHT; PrixTTC pTTC; // taux de la TVA selectionnee int idTaxe = this.comboTaxe.getSelectedId(); if (idTaxe > 1) { SQLRow ligneTaxe = getTable().getBase().getTable("TAXE").getRow(idTaxe); if (ligneTaxe != null) { taux = (ligneTaxe.getFloat("TAUX")) / 100.0F; // calcul des montants HT ou TTC if (this.textMontantTTC.getText().trim().length() > 0) { if (this.textMontantTTC.getText().trim().equals("-")) { pTTC = new PrixTTC(0); } else { pTTC = new PrixTTC( GestionDevise.parseLongCurrency(this.textMontantTTC.getText())); } // affichage updateTextHT(GestionDevise.currencyToString(pTTC.calculLongHT(taux))); } else { updateTextHT(""); } } } } } private boolean isMontantServiceValid() { String montant = this.textMontantService.getText().trim(); String montantHT = this.textMontantHT.getText().trim(); boolean b; if (montant.length() == 0) { b = true; } else { if (montantHT.length() == 0) { b = false; } else { b = (GestionDevise.parseLongCurrency(montantHT) >= GestionDevise .parseLongCurrency(montant)); } } this.labelWarning.setVisible(!b); System.err.println("Montant service is valid ? " + b + " --> HT val " + montantHT + " --> service val " + montant); return b; } /* * private void calculMontantHT() { * * float taux; PrixHT pHT; * * if (!this.comboTaxe.isEmpty()) { // taux de la TVA selectionnee SQLRow ligneTaxe = * Configuration.getInstance().getBase().getTable("TAXE").getRow(((Integer) * this.comboTaxe.getValue()).intValue()); taux = (ligneTaxe.getFloat("TAUX")) / 100; // * calcul des montants HT ou TTC if (this.textMontantHT.getText().trim().length() > 0) { * * if (this.textMontantHT.getText().trim().equals("-")) { pHT = new PrixHT(0); } else { * pHT = new PrixHT(Float.parseFloat(this.textMontantHT.getText())); } // affichage * updateTextTTC(String.valueOf(pHT.CalculTTC(taux))); } else updateTextTTC(""); } } */ private void updateTextHT(final String prixHT) { SwingUtilities.invokeLater(new Runnable() { public void run() { textMontantHT.setText(prixHT); } }); } @Override protected SQLRowValues createDefaults() { SQLRowValues vals = new SQLRowValues(this.getTable()); SQLRowAccessor r; try { r = ModeReglementDefautPrefPanel.getDefaultRow(true); SQLElement eltModeReglement = Configuration.getInstance().getDirectory() .getElement("MODE_REGLEMENT"); if (r.getID() > 1) { SQLRowValues rowVals = eltModeReglement.createCopy(r.getID()); System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT")); vals.put("ID_MODE_REGLEMENT", rowVals); } } catch (SQLException e) { System.err.println("Impossible de slectionner le mode de rglement par dfaut du client."); e.printStackTrace(); } return vals; } // private void updateTextTTC(final String prixTTC) { // SwingUtilities.invokeLater(new Runnable() { // // public void run() { // // if (docTTCListen != null) { // // textMontantTTC.getDocument().removeDocumentListener(docTTCListen); // } // // textMontantTTC.setText(prixTTC); // // // textTaxe.setText(prixTVA); // textMontantTTC.getDocument().addDocumentListener(docTTCListen); // } // }); // } private void calculDate() { int aJ = 0; // on rcupre les valeurs saisies if (this.textEcheance.getText().trim().length() != 0) { try { aJ = Integer.parseInt(this.textEcheance.getText()); } catch (Exception e) { System.out.println("Erreur de format sur TextField Ajour " + this.textEcheance.getText()); } } Calendar cal = Calendar.getInstance(); // on fixe le temps sur ToDay + Ajour cal.setTime(new Date()); long tempsMil = aJ * 86400000; cal.setTimeInMillis(cal.getTimeInMillis() + tempsMil); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy"); this.dateEch = cal.getTime(); this.labelEcheancejours.setText("jours, soit le " + dateFormat.format(this.dateEch)); } private void updateValidState() { this.setValidState(this.computeValidState()); } private ValidState computeValidState() { ValidState res = ValidState.getTrueInstance(); if (!this.isMontantServiceValid()) res = res.and(ValidState.createCached(false, this.labelWarning.getText())); if (this.checkCommande.isSelected()) res = res.and(ValidState.createCached(!this.comboFournisseur.isEmpty(), "Fournisseur non renseign")); return res; } private final void setValidState(ValidState validState) { if (!validState.equals(this.validState)) { this.validState = validState; this.fireValidChange(); } } @Override public synchronized ValidState getValidState() { return super.getValidState().and(this.validState); } public int insert(SQLRow order) { // On teste si l'article n'existe pas, on le cre if (this.nomArticle.isEmpty()) { createArticle(); } if (this.textNom.getValue() == null || this.textNom.getValue().trim().length() <= 0) { this.textNom.setValue(this.nomArticle.getTextComp().getText()); } final int id = super.insert(order); // on verifie si le produit est commander if (this.checkCommande.isSelected()) { createCommande(id); } SQLRow rowArt = getTable().getRow(id).getForeignRow("ID_ARTICLE"); if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) { Configuration.getInstance().getNonInteractiveSQLExecutor().execute(new Runnable() { @Override public void run() { final SQLRow rowVC = getTable().getRow(id); // Mise jour des stocks final SQLElement eltMvtStock = Configuration.getInstance().getDirectory() .getElement("MOUVEMENT_STOCK"); final SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable()); rowVals.put("QTE", -1); rowVals.put("NOM", "Saisie vente comptoir"); rowVals.put("IDSOURCE", id); rowVals.put("SOURCE", getTable().getName()); rowVals.put("ID_ARTICLE", rowVC.getInt("ID_ARTICLE")); rowVals.put("DATE", rowVC.getObject("DATE")); try { final SQLRow row = rowVals.insert(); final ListMap<SQLRow, SQLRowValues> map = ((MouvementStockSQLElement) Configuration .getInstance().getDirectory().getElement("MOUVEMENT_STOCK")) .updateStock(Arrays.asList(row), false); MouvementStockSQLElement.createCommandeF(map, null); } catch (SQLException e) { ExceptionHandler.handle("Erreur lors de la cration des mouvements de stock", e); } } }); } new GenerationMvtSaisieVenteComptoir(id); return id; } private void createCommande(final int id) { System.out.println("Ajout d'une commande"); SQLRow rowSaisie = SaisieVenteComptoirSQLElement.this.getTable().getRow(id); Map<String, Object> m = new HashMap<String, Object>(); // NOM, DATE, ECHEANCE, IDSOURCE, SOURCE, ID_CLI, ID_FOURN, ID_ARTICLE m.put("NOM", rowSaisie.getObject("NOM")); m.put("DATE", rowSaisie.getObject("DATE")); m.put("DATE_ECHEANCE", new java.sql.Date(this.dateEch.getTime())); m.put("IDSOURCE", new Integer(id)); m.put("SOURCE", "SAISIE_VENTE_COMPTOIR"); m.put("ID_CLIENT", rowSaisie.getObject("ID_CLIENT")); m.put("ID_FOURNISSEUR", rowSaisie.getObject("ID_FOURNISSEUR")); m.put("ID_ARTICLE", rowSaisie.getObject("ID_ARTICLE")); SQLTable tableCmd = getTable().getBase().getTable("COMMANDE_CLIENT"); SQLRowValues valCmd = new SQLRowValues(tableCmd, m); try { if (valCmd.getInvalid() == null) { // ajout de l'ecriture valCmd.insert(); } } catch (Exception e) { System.err.println("Erreur l'insertion dans la table " + valCmd.getTable().getName()); e.printStackTrace(); } } private void createArticle() { System.out.println("Cration de l'article"); String tNomArticle = this.nomArticle.getTextComp().getText(); String codeArticle = "";// this.nomArticle.getTextOpt(); if (tNomArticle.trim().length() == 0 && codeArticle.trim().length() == 0) { return; } SQLTable articleTable = getTable().getBase().getTable("ARTICLE"); int idTaxe = this.comboTaxe.getSelectedId(); final BigDecimal prix = StringUtils.getBigDecimalFromUserText(this.textMontantHT.getText()); final BigDecimal prixTTC = StringUtils.getBigDecimalFromUserText(this.textMontantTTC.getText()); if (tNomArticle.trim().length() == 0) { tNomArticle = "Nom Indefini"; } if (codeArticle.trim().length() == 0) { codeArticle = "Indefini"; } SQLRowValues vals = new SQLRowValues(articleTable); vals.put("NOM", tNomArticle); vals.put("CODE", codeArticle); vals.put("PA_HT", prix); vals.put("PV_HT", prix); vals.put("PRIX_METRIQUE_VT_1", prix); vals.put("PRIX_METRIQUE_HA_1", prix); vals.put("PV_TTC", prixTTC); vals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE); vals.put("ID_TAXE", new Integer(idTaxe)); vals.put("CREATION_AUTO", Boolean.TRUE); vals.put("GESTION_STOCK", Boolean.FALSE); try { SQLRow row = vals.insert(); this.nomArticle.setValue(row); } catch (SQLException e) { e.printStackTrace(); } } public void update() { if (JOptionPane.showConfirmDialog(this, "Attention en modifiant cette vente comptoir, vous supprimerez les chques et les chances associs. Continuer?", "Modification de vente comptoir", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { // on efface les mouvements de stocks associs SQLRow row = getTable().getRow(this.getSelectedID()); SQLElement eltMvtStock = Configuration.getInstance().getDirectory() .getElement("MOUVEMENT_STOCK"); SQLSelect sel = new SQLSelect(); sel.addSelect(eltMvtStock.getTable().getField("ID")); Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", row.getID()); Where w2 = new Where(eltMvtStock.getTable().getField("SOURCE"), "=", getTable().getName()); sel.setWhere(w.and(w2)); List l = (List) eltMvtStock.getTable().getBase().getDataSource().execute(sel.asString(), new ArrayListHandler()); if (l != null) { for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); try { eltMvtStock.archive(((Number) tmp[0]).intValue()); } catch (SQLException e) { e.printStackTrace(); } } } if (this.textNom.getValue() != null && this.textNom.getValue().trim().length() <= 0) { this.textNom.setValue(this.nomArticle.getTextComp().getText()); } // On teste si l'article n'existe pas, on le cre if (this.nomArticle.getValue() == null || Integer.parseInt(this.nomArticle.getValue().toString()) == -1) { createArticle(); } // TODO check echeance, ---> creation article, commande?? super.update(); row = getTable().getRow(this.getSelectedID()); int idMvt = row.getInt("ID_MOUVEMENT"); System.out.println(row.getID() + "__________***************** UPDATE " + idMvt); // on supprime tout ce qui est li la facture EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory() .getElement("ECRITURE"); eltEcr.archiveMouvementProfondeur(idMvt, false); SQLRow rowArt = row.getForeignRow("ID_ARTICLE"); if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) { // Mise jour des stocks SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable()); rowVals.put("QTE", -1); rowVals.put("NOM", "Saisie vente comptoir"); rowVals.put("IDSOURCE", getSelectedID()); rowVals.put("SOURCE", getTable().getName()); rowVals.put("ID_ARTICLE", row.getInt("ID_ARTICLE")); rowVals.put("DATE", row.getObject("DATE")); try { SQLRow rowNew = rowVals.insert(); final ListMap<SQLRow, SQLRowValues> map = ((MouvementStockSQLElement) Configuration .getInstance().getDirectory().getElement("MOUVEMENT_STOCK")) .updateStock(Arrays.asList(rowNew), false); ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor() .execute(new Runnable() { @Override public void run() { MouvementStockSQLElement.createCommandeF(map, null); } }); } catch (SQLException e) { e.printStackTrace(); } } if (idMvt > 1) { new GenerationMvtSaisieVenteComptoir(this.getSelectedID(), idMvt); } else { new GenerationMvtSaisieVenteComptoir(this.getSelectedID()); } } } @Override public void select(SQLRowAccessor r) { this.textMontantTTC.getDocument().removeDocumentListener(this.docTTCListen); this.nomArticle.rmValueListener(this.propertyChangeListener); super.select(r); checkService.setSelected( r != null && r.getObject("MONTANT_SERVICE") != null && r.getLong("MONTANT_SERVICE") > 0); this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen); this.nomArticle.addValueListener(this.propertyChangeListener); } @Override public void select(SQLRowAccessor r, Set<String> views) { super.select(r, views); checkService.setSelected( r != null && r.getObject("MONTANT_SERVICE") != null && r.getLong("MONTANT_SERVICE") > 0); } }; }
From source file:org.tinymediamanager.core.tvshow.entities.TvShow.java
/** * Instantiates a tv show. To initialize the propertychangesupport after loading *///from w w w . j a va 2 s .c o m public TvShow() { // register for dirty flag listener super(); // give tag events from episodes up to the TvShowList propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("tag".equals(evt.getPropertyName()) && evt.getSource() instanceof TvShowEpisode) { firePropertyChange(evt); } } }; }
From source file:ui.panel.UILicenseDetail.java
public JPanel createButtonPanel() { JPanel panel = p.createPanel(Layouts.flow); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); btnSubmit = b.createButton("Next"); btnBack = b.createButton("Back"); btnAdd = b.createButton("Add License"); panel.add(btnBack);/*from w w w .j ava2 s. co m*/ panel.add(btnAdd); panel.add(btnSubmit); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("bucket"); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.addPanel(Data.mainFrame.uiLicenseAdd = new UILicenseAdd(), "licenseAdd"); Data.mainFrame.showPanel("licenseAdd"); } }); btnSubmit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int row = tblInfo.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a License", "Error", JOptionPane.ERROR_MESSAGE); } else { Data.licenseNumber = (String) tblInfo.getModel().getValueAt(row, 0); Data.mainFrame.uiAccessKeySelect = new UIAccessKeySelect(); Data.mainFrame.addPanel(Data.mainFrame.uiAccessKeySelect, "access"); Data.mainFrame.showPanel("access"); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Retrieving Access Keys"), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.showPanel("bucket"); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.addPanel(Data.mainFrame.uiLicenseAdd = new UILicenseAdd(), "licenseAdd"); Data.mainFrame.pack(); Data.mainFrame.showPanel("licenseAdd"); } }); return panel; }
From source file:org.rdv.viz.image.HighResImageViz.java
private void initImagePanel() { imagePanel = new ImagePanel(); imagePanel.setBackground(Color.black); imagePanel.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { String propertyName = pce.getPropertyName(); if (propertyName.equals(ImagePanel.AUTO_SCALING_PROPERTY)) { boolean autoScaling = (Boolean) pce.getNewValue(); //autoScaleMenuItem.setSelected(autoScaling); if (autoScaling) { properties.setProperty(DATA_PANEL_PROPERTY_AUTOSCALE, "true"); properties.remove(DATA_PANEL_PROPERTY_SCALE); properties.remove(DATA_PANEL_PROPERTY_ORIGIN); } else { properties.setProperty(DATA_PANEL_PROPERTY_SCALE, Double.toString(imagePanel.getScale())); properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, pointToString(imagePanel.getOrigin())); properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE); }/*from w w w. j a v a 2 s .c o m*/ } else if (propertyName.equals(ImagePanel.SCALE_PROPERTY) && !imagePanel.isAutoScaling()) { properties.setProperty(DATA_PANEL_PROPERTY_SCALE, pce.getNewValue().toString()); properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE); } else if (propertyName.equals(ImagePanel.ORIGIN_PROPERTY) && !imagePanel.isAutoScaling()) { Point origin = (Point) pce.getNewValue(); String originString = pointToString(origin); properties.setProperty(DATA_PANEL_PROPERTY_ORIGIN, originString); properties.remove(DATA_PANEL_PROPERTY_AUTOSCALE); } else if (propertyName.equals(ImagePanel.NAVIGATION_IMAGE_ENABLED_PROPERTY)) { boolean showNavigationImage = (Boolean) pce.getNewValue(); //showNavigationImageMenuItem.setSelected(showNavigationImage); if (showNavigationImage) { properties.setProperty(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE, "true"); } else { properties.remove(DATA_PANEL_PROPERTY_SHOW_NAVIGATION_IMAGE); } } } }); panel.add(imagePanel, BorderLayout.CENTER); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.CloturePanel.java
public CloturePanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.gridx = 0;/*from w w w . j ava 2 s . c o m*/ c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.weightx = 0; c.weighty = 0; JLabel rappel = new JLabelBold("Oprations effectuer avant de continuer: "); JLabel label = new JLabel("- report des charges et produits constats d'avance"); JLabel label2 = new JLabel("- report des charges payer et produits recevoir"); JLabel label3 = new JLabel("- impression du bilan, compte de rsultat, grand livre, journaux et balance"); JLabel label5 = new JLabel("- gnration les critures comptables des payes"); JLabel label4 = new JLabel("Il est prfrable de raliser une sauvegarde avant de continuer."); JLabel op = new JLabelBold("Oprations qui vont etre effectues: "); JLabel labelValid = new JLabel( "- validation de toutes les critures concernant la priode de l'exercice."); JLabel labelSoldeGestion = new JLabel("- soldes de tous les comptes de gestions 6* et 7*"); JLabel labelSoldeBilan = new JLabel("- soldes de tous les comptes de bilan"); JLabel labelAN = new JLabel("- report des nouveaux"); c.gridy = GridBagConstraints.RELATIVE; c.gridx = 0; // Date de l'ancien exercice Calendar dDebut = this.rowExercice.getDate("DATE_DEB"); Calendar dFin = this.rowExercice.getDate("DATE_FIN"); JLabel labelAncienExercice = new JLabel("Clture de l'exercice du " + dateFormat.format(dDebut.getTime()) + " au " + dateFormat.format(dFin.getTime())); this.add(labelAncienExercice, c); c.insets = new Insets(10, 2, 1, 2); this.add(rappel, c); this.add(label, c); this.add(label2, c); this.add(label3, c); this.add(label5, c); this.add(label4, c); c.insets = new Insets(15, 2, 1, 2); this.add(op, c); c.insets = new Insets(10, 2, 1, 2); this.add(labelValid, c); this.add(labelSoldeGestion, c); this.add(labelSoldeBilan, c); this.add(labelAN, c); // Date du prochain exercice c.gridwidth = 1; c.gridy = GridBagConstraints.RELATIVE; c.gridx = 0; c.gridx = GridBagConstraints.RELATIVE; c.fill = GridBagConstraints.NONE; this.add(new JLabel("Date du nouvel exercice du "), c); dDebut.set(Calendar.YEAR, dDebut.get(Calendar.YEAR) + 1); this.dateOuv.setValue(dDebut.getTime()); this.add(this.dateOuv, c); this.add(new JLabel("au"), c); dFin.set(Calendar.YEAR, dFin.get(Calendar.YEAR) + 1); this.dateFerm.setValue(dFin.getTime()); this.add(this.dateFerm, c); c.gridx = 0; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 2; c.weightx = 1; this.add(this.opEnCours, c); c.gridwidth = 4; c.gridx = 0; c.weightx = 1; this.add(this.bar, c); // this.add(this.boxValid, c); // Button final JPanel buttonBar = new JPanel(); buttonBar.add(this.valider); buttonBar.add(this.annul); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.gridx = 0; this.add(buttonBar, c); final PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { CloturePanel.this.valider.setEnabled(isDateValid()); } }; this.dateFerm.addValueListener(listener); this.dateOuv.addValueListener(listener); // TODO afficher le deroulement de etapes apres validation this.valider.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { clotureExercice(); // show OK works fine Component comp = SwingUtilities.getRoot(CloturePanel.this); JOptionPane.showMessageDialog(CloturePanel.this, "Exercice cltur", "Fin de la clture", JOptionPane.INFORMATION_MESSAGE); ((JFrame) comp).dispose(); } catch (Exception ex) { ExceptionHandler.handle("Erreur lors de la clture", ex); } } }); this.valider.setEnabled(isDateValid()); this.boxValid.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CloturePanel.this.valider.setEnabled(isDateValid()); } }); this.annul.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(CloturePanel.this)).dispose(); } }); }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void initColorComboBox() { comboBoxColor.addActionListener(new ActionListener() { @Override// www . jav a 2s. c om public void actionPerformed(ActionEvent event) { model.setColorAndFileName((String) comboBoxColor.getSelectedItem()); textFieldFileName.setText(model.getFileName()); showIconPreview(); } }); comboBoxColor.getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName()) && AccessibleState.FOCUSED.equals(event.getNewValue()) && comboBoxColor.getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) { ComboPopup popup = (ComboPopup) comboBoxColor.getAccessibleContext().getAccessibleChild(0); JList list = popup.getList(); comboBoxColor.setSelectedItem(String.valueOf(list.getSelectedValue())); } } }); }