public void loadAsynchronous() { // On recupere les differents journaux SQLTable journalTable = base.getTable("JOURNAL"); // SQLSelect selJournal = new SQLSelect(base); // // selJournal.addSelect(journalTable.getField("ID")); // selJournal.addSelect(journalTable.getField("NOM")); // selJournal.addSelect(journalTable.getField("CODE")); // // selJournal.addRawOrder("\"JOURNAL\".\"NOM\""); // // String reqJournal = selJournal.asString(); // Object obJournal = base.getDataSource().execute(reqJournal, new ArrayListHandler()); // // List myListJournal = (List) obJournal; // // if (myListJournal.size() != 0) { List<SQLRow> liste = SQLBackgroundTableCache.getInstance().getCacheForTable(journalTable).getRows(); for (int k = 0; k < liste.size(); k++) { SQLRow row = liste.get(k); fireIsLoading(true); final Journal jrnlTmp = new Journal(row.getID(), row.getString("NOM"), row.getString("CODE")); new SwingWorker<JPanel, Object>() { @Override protected JPanel doInBackground() throws Exception { final JPanel initJournalPanel = initJournalPanel(jrnlTmp); return initJournalPanel; } @Override protected void done() { JPanel initJournalPanel; try { initJournalPanel = get(); initJournalPanel.setOpaque(false); JScrollPane scroll = new JScrollPane(initJournalPanel); scroll.setBorder(null); scroll.setOpaque(false); scroll.getViewport().setOpaque(false); EtatJournauxPanel.this.tabbedJournaux.addTab(jrnlTmp.getNom(), scroll); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } fireIsLoading(false); super.done(); } }.execute(); } }
@Override protected SQLRowValues createDefaults() { System.err.println("Create defaults"); setSiteEnabled(false, Type_Diff.DONNEUR_ORDRE); setSiteEnabled(false, Type_Diff.SITE); // Numero incremental auto final SQLRowValues rowVals = new SQLRowValues(getTable()); rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class)); // User // final SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase()); final SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL"); final int idUser = UserManager.getInstance().getCurrentUser().getId(); // // sel.addSelect(eltComm.getTable().getKey()); // sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser)); // final List<SQLRow> rowsComm = (List<SQLRow>) // Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new // SQLRowListRSH(eltComm.getTable())); SQLRow rowsComm = SQLBackgroundTableCache.getInstance() .getCacheForTable(eltComm.getTable()) .getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON")); if (rowsComm != null) { rowVals.put("ID_COMMERCIAL", rowsComm.getID()); } if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) { rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE); } else { SQLRowValues foreign = UndefinedRowValuesCache.getInstance().getDefaultRowValues(getTable()); if (foreign != null && !foreign.isUndefined()) { rowVals.put("ID_ETAT_DEVIS", foreign.getObject("ID_ETAT_DEVIS")); } else { rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE); } } rowVals.put("T_HT", Long.valueOf(0)); rowVals.put("T_TVA", Long.valueOf(0)); rowVals.put("T_SERVICE", Long.valueOf(0)); rowVals.put("T_TTC", Long.valueOf(0)); if (getTable().getFieldsName().contains("DATE_VALIDITE")) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1); rowVals.put("DATE_VALIDITE", cal.getTime()); } return rowVals; }