List of usage examples for javax.swing SwingUtilities getRoot
@SuppressWarnings("deprecation") public static Component getRoot(Component c)
From source file:org.openconcerto.erp.core.finance.accounting.ui.ResultatPanel.java
public ResultatPanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.add(new JLabel("Vous allez gnrer le fichier result_2033B.pdf contenant le rsultat."), c); c.gridy++;//from w w w . j a va 2 s . c o m try { this.add(new JLabel("Il se trouvera dans le dossier " + new File(TemplateNXProps.getInstance().getStringProperty("Location2033BPDF")) .getCanonicalPath()), c); } catch (IOException e1) { e1.printStackTrace(); } final JButton buttonFermer = new JButton("Fermer"); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { ((JFrame) SwingUtilities.getRoot(ResultatPanel.this)).dispose(); } }); final JButton buttonOuvrir = new JButton("Ouvrir dossier"); buttonOuvrir.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { final String file = TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"); File f = new File(file); FileUtils.browseFile(f); } }); // FIXME impossible de gnrer si le fichier est ouvert final JButton buttonGenerer = new JButton("Gnrer"); buttonGenerer.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { final Map2033B map = new Map2033B(new JProgressBar()); map.generateMap(); } }); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.NONE; this.add(buttonOuvrir, c); c.gridy++; c.anchor = GridBagConstraints.EAST; c.weightx = 1; buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT); this.add(buttonGenerer, c); c.weightx = 0; this.add(buttonFermer, c); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel.java
public SuppressionEcrituresPanel(final int idMvt) { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.weightx = 1;/*w ww . j av a2s . c o m*/ SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); SQLTable tableMouvement = base.getTable("MOUVEMENT"); SQLRow rowMvt = tableMouvement.getRow(idMvt); JLabel label = new JLabel("Vous allez supprimer la pice n" + rowMvt.getInt("ID_PIECE")); JLabelWarning warning = new JLabelWarning(); JPanel panelLabel = new JPanel(); panelLabel.add(warning); panelLabel.add(label); c.gridwidth = GridBagConstraints.REMAINDER; this.add(panelLabel, c); // TODO afficher les numeros de mouvement implique int[] idS = getMouvement(rowMvt.getInt("ID_PIECE")); if (idS == null) { ExceptionHandler.handle("Aucun mouvement associ la pice n" + ((rowMvt != null) ? rowMvt.getInt("ID_PIECE") : "mouvement nul")); } else { StringBuffer s = new StringBuffer(); s.append("Elle est compose par les mouvements : ("); JLabel labelMouv = new JLabel(); // c.gridwidth = 1; c.gridy++; c.gridx = 0; this.add(labelMouv, c); s.append(idS[0]); for (int i = 1; i < idS.length; i++) { s.append(", "); s.append(idS[i]); } s.append(')'); labelMouv.setText(s.toString()); } JButton buttonOK = new JButton("OK"); JButton buttonCancel = new JButton("Annuler"); c.gridwidth = 1; c.gridy++; c.gridx = 0; this.add(buttonOK, c); c.gridx++; this.add(buttonCancel, c); buttonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { EcritureSQLElement elt = (EcritureSQLElement) Configuration.getInstance().getDirectory() .getElement("ECRITURE"); elt.archiveMouvement(idMvt); ((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose(); } }); buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose(); } }); }
From source file:org.openconcerto.erp.core.sales.credit.component.AvoirClientSQLComponent.java
@Override public int insert(SQLRow order) { int id = getSelectedID(); final SQLTable tableNum = this.getTable().getBase().getTable("NUMEROTATION_AUTO"); if (this.textNumero.checkValidation()) { id = super.insert(order); try {/* ww w.j a v a2 s .com*/ this.table.updateField("ID_AVOIR_CLIENT", id); final SQLRow row = getTable().getRow(id); // incrmentation du numro auto if (NumerotationAutoSQLElement .getNextNumero(AvoirClientSQLElement.class, row.getDate("DATE").getTime()) .equalsIgnoreCase(this.textNumero.getText().trim())) { SQLRowValues rowVals = new SQLRowValues(tableNum); String label = NumerotationAutoSQLElement.getLabelNumberFor(AvoirClientSQLElement.class); int val = tableNum.getRow(2).getInt(label); val++; rowVals.put(label, Integer.valueOf(val)); try { rowVals.update(2); } catch (SQLException e) { e.printStackTrace(); } } SQLRowValues rowVals2 = row.createUpdateRow(); Long l = rowVals2.getLong("MONTANT_SOLDE"); Long l2 = rowVals2.getLong("MONTANT_TTC"); rowVals2.put("MONTANT_RESTANT", l2 - l); rowVals2.update(); // updateStock(id); GenerationMvtAvoirClient gen = new GenerationMvtAvoirClient(id); gen.genereMouvement(); // generation du document createAvoirClient(row); } catch (Exception e) { ExceptionHandler.handle("Erreur lors de la cration de l'avoir", e); } } else { ExceptionHandler.handle("Impossible de modifier, numro d'avoir existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); } } return id; }
From source file:org.openconcerto.erp.core.sales.credit.component.AvoirClientSQLComponent.java
@Override public void update() { if (this.textNumero.checkValidation()) { super.update(); try {/* ww w . j av a2 s .c o m*/ this.table.updateField("ID_AVOIR_CLIENT", getSelectedID()); // On efface les anciens mouvements de stocks SQLRow row = getTable().getRow(getSelectedID()); SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK"); SQLSelect sel = new SQLSelect(eltMvtStock.getTable().getBase()); 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); eltMvtStock.archive(((Number) tmp[0]).intValue()); } } SQLRowValues rowVals2 = getTable().getRow(getSelectedID()).createUpdateRow(); Long l2 = rowVals2.getLong("MONTANT_SOLDE"); Long l3 = rowVals2.getLong("MONTANT_TTC"); rowVals2.put("MONTANT_RESTANT", l3 - l2); rowVals2.update(); // On met jour le stock // updateStock(getSelectedID()); int idMvt = row.getInt("ID_MOUVEMENT"); // on supprime tout ce qui est li la facture d'avoir System.err.println("Archivage des fils"); EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory() .getElement("ECRITURE"); eltEcr.archiveMouvementProfondeur(idMvt, false); GenerationMvtAvoirClient gen = new GenerationMvtAvoirClient(getSelectedID(), idMvt); gen.genereMouvement(); createAvoirClient(row); } catch (Exception e) { ExceptionHandler.handle("Erreur de mise jour de l'avoir", e); } } else { ExceptionHandler.handle("Impossible de modifier, numro d'avoir existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); } return; } }
From source file:org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent.java
public int commit(SQLRow order) { int idSaisieVF = -1; long lFactureOld = 0; SQLRow rowFactureOld = null;// w w w . ja v a2s .c o m SQLRow rowFacture = null; SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK"); if (this.textNumeroUnique.checkValidation()) { try { if (getMode() == Mode.INSERTION) { idSaisieVF = super.insert(order); rowFacture = getTable().getRow(idSaisieVF); // incrmentation du numro auto if (NumerotationAutoSQLElement .getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime()) .equalsIgnoreCase(this.textNumeroUnique.getText().trim())) { SQLRowValues rowVals = new SQLRowValues(this.tableNum); String labelNumberFor = NumerotationAutoSQLElement .getLabelNumberFor(SaisieVenteFactureSQLElement.class); int val = this.tableNum.getRow(2).getInt(labelNumberFor); val++; rowVals.put(labelNumberFor, Integer.valueOf(val)); rowVals.update(2); } } else { if (JOptionPane.showConfirmDialog(this, "Attention en modifiant cette facture, vous supprimerez les chques et les chances associs. Continuer?", "Modification de facture", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) { // On efface les anciens mouvements de stocks SQLSelect sel = new SQLSelect(); sel.addSelect(eltMvtStock.getTable().getField("ID")); Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", getSelectedID()); 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(); } } } } // On recupere l'ancien total HT rowFactureOld = this.getTable().getRow(getSelectedID()); lFactureOld = ((Number) rowFactureOld.getObject("T_HT")).longValue(); super.update(); idSaisieVF = getSelectedID(); } else { // Annulation par l'utilisateur return idSaisieVF; } } rowFacture = getTable().getRow(idSaisieVF); final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration .getInstance()); // Mise jour des tables lies this.tableFacture.updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF); createDocument(rowFacture); int idMvt = -1; if (!this.checkPrevisionnelle.isSelected()) { if (getMode() == Mode.MODIFICATION) { idMvt = rowFacture.getInt("ID_MOUVEMENT"); // on supprime tout ce qui est li la facture System.err.println("Archivage des fils"); EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory() .getElement("ECRITURE"); eltEcr.archiveMouvementProfondeur(idMvt, false); } System.err.println("Regeneration des ecritures"); if (idMvt > 1) { new GenerationMvtSaisieVenteFacture(idSaisieVF, idMvt); } else { new GenerationMvtSaisieVenteFacture(idSaisieVF); } System.err.println("Fin regeneration"); // Mise jour des stocks updateStock(idSaisieVF); // On retire l'avoir if (rowFactureOld != null && rowFactureOld.getInt("ID_AVOIR_CLIENT") > 1) { SQLRow rowAvoir = rowFactureOld.getForeignRow("ID_AVOIR_CLIENT"); Long montantSolde = (Long) rowAvoir.getObject("MONTANT_SOLDE"); Long avoirTTC = (Long) rowFactureOld.getObject("T_AVOIR_TTC"); long montant = montantSolde - avoirTTC; if (montant < 0) { montant = 0; } SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow(); // Sold rowVals.put("SOLDE", Boolean.FALSE); rowVals.put("MONTANT_SOLDE", montant); Long restant = (Long) rowAvoir.getObject("MONTANT_TTC") - montantSolde; rowVals.put("MONTANT_RESTANT", restant); rowVals.update(); } final int idAvoir = rowFacture.getInt("ID_AVOIR_CLIENT"); // on solde l'avoir if (idAvoir > 1) { SQLRow rowAvoir = rowFacture.getForeignRow("ID_AVOIR_CLIENT"); Long montantTTC = (Long) rowAvoir.getObject("MONTANT_TTC"); Long montantSolde = (Long) rowAvoir.getObject("MONTANT_SOLDE"); Long factTTC = (Long) rowFacture.getObject("T_TTC"); long restant = montantTTC - montantSolde; SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow(); final long l2 = factTTC - restant; // Sold if (l2 >= 0) { rowVals.put("SOLDE", Boolean.TRUE); rowVals.put("MONTANT_SOLDE", montantTTC); rowVals.put("MONTANT_RESTANT", 0); } else { // Il reste encore de l'argent pour l'avoir final long m = montantSolde + factTTC; rowVals.put("MONTANT_SOLDE", m); rowVals.put("MONTANT_RESTANT", montantTTC - m); } rowVals.update(); } } } catch (Exception e) { ExceptionHandler.handle("", e); } } else { ExceptionHandler.handle("Impossible d'ajouter, numro de facture existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); } } return idSaisieVF; }
From source file:org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java
public int insert(SQLRow order) { final int idCommande; // on verifie qu'un devis du meme numero n'a pas t insr entre temps if (this.numeroUniqueCommande.checkValidation()) { idCommande = super.insert(order); this.table.updateField("ID_COMMANDE_CLIENT", idCommande); try {//from w w w.j a va2 s. c o m updateStock(idCommande); } catch (SQLException e1) { ExceptionHandler.handle("Erreur lors de la mise du stock!", e1); } // Cration des articles this.table.createArticle(idCommande, this.getElement()); // generation du document try { CommandeClientXmlSheet sheet = new CommandeClientXmlSheet(getTable().getRow(idCommande)); sheet.createDocumentAsynchronous(); sheet.showPrintAndExportAsynchronous( CommandeClientSQLComponent.this.panelOO.isVisualisationSelected(), CommandeClientSQLComponent.this.panelOO.isImpressionSelected(), true); } catch (Exception e) { ExceptionHandler.handle("Impossible de crer la commande", e); } // incrmentation du numro auto if (NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()) .equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) { SQLRowValues rowVals = new SQLRowValues(this.tableNum); int val = this.tableNum.getRow(2).getInt("COMMANDE_CLIENT_START"); val++; rowVals.put("COMMANDE_CLIENT_START", new Integer(val)); try { rowVals.update(2); } catch (SQLException e) { e.printStackTrace(); } } } else { idCommande = getSelectedID(); ExceptionHandler.handle("Impossible d'ajouter, numro de commande client existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); } } return idCommande; }
From source file:org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java
@Override public void update() { if (!this.numeroUniqueCommande.checkValidation()) { ExceptionHandler.handle("Impossible d'ajouter, numro de commande client existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); }/*from w w w . j a va 2s. c om*/ return; } super.update(); final int id = getSelectedID(); this.table.updateField("ID_COMMANDE_CLIENT", id); this.table.createArticle(id, this.getElement()); final SQLRow row = getTable().getRow(id); try { updateStock(id); } catch (SQLException e1) { ExceptionHandler.handle("Erreur lors de la mise du stock!", e1); } // generation du document try { CommandeClientXmlSheet sheet = new CommandeClientXmlSheet(row); sheet.createDocumentAsynchronous(); sheet.showPrintAndExportAsynchronous(CommandeClientSQLComponent.this.panelOO.isVisualisationSelected(), CommandeClientSQLComponent.this.panelOO.isImpressionSelected(), true); } catch (Exception e) { ExceptionHandler.handle("Impossible de crer la commande", e); } }
From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java
public int insert(SQLRow order) { int idBon = getSelectedID(); // on verifie qu'un bon du meme numero n'a pas t insr entre temps if (this.textNumeroUnique.checkValidation()) { idBon = super.insert(order); this.tableBonItem.updateField("ID_BON_DE_LIVRAISON", idBon); this.tableBonItem.createArticle(idBon, this.getElement()); // generation du document BonLivraisonXmlSheet bSheet = new BonLivraisonXmlSheet(getTable().getRow(idBon)); bSheet.createDocumentAsynchronous(); bSheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); // incrmentation du numro auto if (NumerotationAutoSQLElement.getNextNumero(BonDeLivraisonSQLElement.class) .equalsIgnoreCase(this.textNumeroUnique.getText().trim())) { SQLRowValues rowVals = new SQLRowValues(this.tableNum); int val = this.tableNum.getRow(2).getInt("BON_L_START"); val++; rowVals.put("BON_L_START", new Integer(val)); try { rowVals.update(2);//w w w . j a v a 2s . co m } catch (SQLException e) { e.printStackTrace(); } } SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot()); if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) { try { updateStock(idBon); } catch (SQLException e) { throw new IllegalStateException(e); } } // updateQte(idBon); } else { ExceptionHandler.handle("Impossible d'ajouter, numro de bon de livraison existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); } } return idBon; }
From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java
@Override public void update() { if (!this.textNumeroUnique.checkValidation()) { ExceptionHandler.handle("Impossible d'ajouter, numro de bon de livraison existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); }// www. j a v a 2s. c o m return; } super.update(); this.tableBonItem.updateField("ID_BON_DE_LIVRAISON", getSelectedID()); this.tableBonItem.createArticle(getSelectedID(), this.getElement()); // generation du document BonLivraisonXmlSheet bSheet = new BonLivraisonXmlSheet(getTable().getRow(getSelectedID())); bSheet.createDocumentAsynchronous(); bSheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot()); SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK"); if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) { // On efface les anciens mouvements de stocks SQLSelect sel = new SQLSelect(eltMvtStock.getTable().getBase()); sel.addSelect(eltMvtStock.getTable().getField("ID")); Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", getSelectedID()); 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(); } } } try { updateStock(getSelectedID()); } catch (SQLException e) { throw new IllegalStateException(e); } } }
From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java
public int insert(SQLRow order) { int idCommande = getSelectedID(); // on verifie qu'un devis du meme numero n'a pas t insr entre temps if (this.numeroUniqueCommande.checkValidation()) { idCommande = super.insert(order); this.table.updateField("ID_COMMANDE", idCommande); // Cration des articles this.table.createArticle(idCommande, this.getElement()); try {//from w ww .java2s .c om updateStock(idCommande); } catch (SQLException e) { ExceptionHandler.handle("Erreur lors de la mise jour du stock!", e); } // generation du document final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(idCommande)); sheet.createDocumentAsynchronous(); sheet.showPrintAndExportAsynchronous(this.checkVisu.isSelected(), this.checkImpression.isSelected(), true); // incrmentation du numro auto if (NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class) .equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) { SQLRowValues rowVals = new SQLRowValues(this.tableNum); int val = this.tableNum.getRow(2) .getInt(NumerotationAutoSQLElement.getLabelNumberFor(CommandeSQLElement.class)); val++; rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(CommandeSQLElement.class), new Integer(val)); try { rowVals.update(2); } catch (SQLException e) { e.printStackTrace(); } } } else { ExceptionHandler.handle("Impossible d'ajouter, numro de commande client existant."); Object root = SwingUtilities.getRoot(this); if (root instanceof EditFrame) { EditFrame frame = (EditFrame) root; frame.getPanel().setAlwaysVisible(true); } } return idCommande; }