List of usage examples for javax.swing SwingWorker SwingWorker
public SwingWorker()
From source file:op.care.med.inventory.PnlInventory.java
private void reloadDisplay(final MedInventory singleInventory, final Closure afterwards) { /***/*from w w w.j av a 2 s. c o m*/ * _ _ ____ _ _ * _ __ ___| | ___ __ _ __| | _ \(_)___ _ __ | | __ _ _ _ * | '__/ _ \ |/ _ \ / _` |/ _` | | | | / __| '_ \| |/ _` | | | | * | | | __/ | (_) | (_| | (_| | |_| | \__ \ |_) | | (_| | |_| | * |_| \___|_|\___/ \__,_|\__,_|____/|_|___/ .__/|_|\__,_|\__, | * |_| |___/ */ // final boolean withworker = true; cpsInventory.removeAll(); synchronized (cpMap) { SYSTools.clear(cpMap); } // synchronized (linemap) { // linemap.clear(); // } synchronized (mapKey2ClosedToggleButton) { mapKey2ClosedToggleButton.clear(); } synchronized (lstInventories) { lstInventories.clear(); if (singleInventory != null) { lstInventories.add(singleInventory); } else { lstInventories = tbClosedInventory.isSelected() ? MedInventoryTools.getAll(resident) : MedInventoryTools.getAllActive(resident); } } OPDE.getMainframe().setBlocked(true); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { int progress = 0; synchronized (lstInventories) { OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, lstInventories.size())); for (MedInventory inventory : lstInventories) { progress++; createCP4(inventory); OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, lstInventories.size())); } } return null; } @Override protected void done() { buildPanel(singleInventory == null); if (afterwards != null) { afterwards.execute(null); } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); }
From source file:op.care.med.inventory.PnlInventory.java
private JPanel createContentPanel4(final MedStock stock) { // final String key = stock.getID() + ".xstock"; // if (!contentmap.containsKey(key)) { final JPanel pnlTX = new JPanel(new VerticalLayout()); // pnlTX.setLayout(new BoxLayout(pnlTX, BoxLayout.PAGE_AXIS)); pnlTX.setOpaque(true);//from ww w.j a v a 2 s .co m // pnlTX.setBackground(Color.white); synchronized (lstInventories) { pnlTX.setBackground(getColor(SYSConst.light2, lstInventories.indexOf(stock.getInventory()) % 2 != 0)); } /*** * _ _ _ _______ __ * / \ __| | __| |_ _\ \/ / * / _ \ / _` |/ _` | | | \ / * / ___ \ (_| | (_| | | | / \ * /_/ \_\__,_|\__,_| |_| /_/\_\ * */ JideButton btnAddTX = GUITools.createHyperlinkButton("nursingrecords.inventory.newmedstocktx", SYSConst.icon22add, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new DlgTX(new MedStockTransaction(stock, BigDecimal.ONE, MedStockTransactionTools.STATE_EDIT_MANUAL), new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); final MedStockTransaction myTX = (MedStockTransaction) em.merge(o); MedStock myStock = em.merge(stock); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.lock(em.merge(myTX.getStock().getInventory().getResident()), LockModeType.OPTIMISTIC); em.getTransaction().commit(); createCP4(myStock.getInventory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnAddTX.setEnabled(!stock.isClosed()); pnlTX.add(btnAddTX); /*** * ____ _ _ _ _______ __ * / ___|| |__ _____ __ __ _| | | |_ _\ \/ /___ * \___ \| '_ \ / _ \ \ /\ / / / _` | | | | | \ // __| * ___) | | | | (_) \ V V / | (_| | | | | | / \\__ \ * |____/|_| |_|\___/ \_/\_/ \__,_|_|_| |_| /_/\_\___/ * */ OPDE.getMainframe().setBlocked(true); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { int progress = 0; List<MedStockTransaction> listTX = MedStockTransactionTools.getAll(stock); OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, listTX.size())); BigDecimal rowsum = MedStockTools.getSum(stock); // BigDecimal rowsum = MedStockTools.getSum(stock); // Collections.sort(stock.getStockTransaction()); for (final MedStockTransaction tx : listTX) { progress++; OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, listTX.size())); String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(tx.getPit()) + "<br/>[" + tx.getID() + "]" + "</td>" + "<td width=\"200\" align=\"center\">" + SYSTools.catchNull(tx.getText(), "--") + "</td>" + "<td width=\"100\" align=\"right\">" + NumberFormat.getNumberInstance().format(tx.getAmount()) + "</td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + NumberFormat.getNumberInstance().format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + (stock.getTradeForm().isWeightControlled() ? "<td width=\"100\" align=\"right\">" + NumberFormat.getNumberInstance().format(tx.getWeight()) + "g" + "</td>" : "") + "<td width=\"100\" align=\"left\">" + SYSTools.anonymizeUser(tx.getUser().getUID()) + "</td>" + "</tr>" + "</table>" + "</font></html>"; rowsum = rowsum.subtract(tx.getAmount()); final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); // pnlTitle.getLeft().addMouseListener(); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, "nursingrecords.inventory")) { /*** * ____ _ _______ __ * | _ \ ___| |_ _\ \/ / * | | | |/ _ \ | | | \ / * | |_| | __/ | | | / \ * |____/ \___|_| |_| /_/\_\ * */ final JButton btnDelTX = new JButton(SYSConst.icon22delete); btnDelTX.setPressedIcon(SYSConst.icon22deletePressed); btnDelTX.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnDelTX.setContentAreaFilled(false); btnDelTX.setBorder(null); btnDelTX.setToolTipText(SYSTools.xx("nursingrecords.inventory.tx.btndelete.tooltip")); btnDelTX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(tx.getPit()) + " " + tx.getUser().getUID() + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStockTransaction myTX = em.merge(tx); MedStock myStock = em.merge(stock); em.lock(em.merge( myTX.getStock().getInventory().getResident()), LockModeType.OPTIMISTIC); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.remove(myTX); // myStock.getStockTransaction().remove(myTX); em.getTransaction().commit(); // synchronized (lstInventories) { // int indexInventory = lstInventories.indexOf(stock.getInventory()); // int indexStock = lstInventories.get(indexInventory).getMedStocks().indexOf(stock); // lstInventories.get(indexInventory).getMedStocks().remove(stock); // lstInventories.get(indexInventory).getMedStocks().add(indexStock, myStock); // } // synchronized (linemap) { // linemap.remove(myTX); // } createCP4(myStock.getInventory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage() .indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelTX.setEnabled( !stock.isClosed() && (tx.getState() == MedStockTransactionTools.STATE_DEBIT || tx.getState() == MedStockTransactionTools.STATE_EDIT_MANUAL)); pnlTitle.getRight().add(btnDelTX); } /*** * _ _ _ _______ __ * | | | |_ __ __| | ___ |_ _\ \/ / * | | | | '_ \ / _` |/ _ \ | | \ / * | |_| | | | | (_| | (_) | | | / \ * \___/|_| |_|\__,_|\___/ |_| /_/\_\ * */ final JButton btnUndoTX = new JButton(SYSConst.icon22undo); btnUndoTX.setPressedIcon(SYSConst.icon22Pressed); btnUndoTX.setAlignmentX(Component.RIGHT_ALIGNMENT); btnUndoTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnUndoTX.setContentAreaFilled(false); btnUndoTX.setBorder(null); btnUndoTX.setToolTipText(SYSTools.xx("nursingrecords.inventory.tx.btnUndoTX.tooltip")); btnUndoTX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.undo1") + "<br/><i>" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(tx.getPit()) + " " + tx.getUser().getUID() + "</i><br/>" + SYSTools.xx("misc.questions.undo2"), SYSConst.icon48undo, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStock myStock = em.merge(stock); final MedStockTransaction myOldTX = em.merge(tx); myOldTX.setState(MedStockTransactionTools.STATE_CANCELLED); final MedStockTransaction myNewTX = em .merge(new MedStockTransaction(myStock, myOldTX.getAmount().negate(), MedStockTransactionTools.STATE_CANCEL_REC)); myOldTX.setText(SYSTools.xx("misc.msg.reversedBy") + ": " + DateFormat .getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(myNewTX.getPit())); myNewTX.setText(SYSTools.xx("misc.msg.reversalFor") + ": " + DateFormat .getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(myOldTX.getPit())); // myStock.getStockTransaction().add(myNewTX); // myStock.getStockTransaction().remove(tx); // myStock.getStockTransaction().add(myOldTX); em.lock(em .merge(myNewTX.getStock().getInventory().getResident()), LockModeType.OPTIMISTIC); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.getTransaction().commit(); // synchronized (lstInventories) { // int indexInventory = lstInventories.indexOf(stock.getInventory()); // int indexStock = lstInventories.get(indexInventory).getMedStocks().indexOf(stock); // lstInventories.get(indexInventory).getMedStocks().remove(stock); // lstInventories.get(indexInventory).getMedStocks().add(indexStock, myStock); // } // synchronized (linemap) { // linemap.remove(tx); // } createCP4(myStock.getInventory()); buildPanel(); // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // synchronized (linemap) { // GUITools.flashBackground(linemap.get(myOldTX), Color.RED, 2); // GUITools.flashBackground(linemap.get(myNewTX), Color.YELLOW, 2); // } // } // }); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage() .indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnUndoTX.setEnabled(!stock.isClosed() && (tx.getState() == MedStockTransactionTools.STATE_DEBIT || tx.getState() == MedStockTransactionTools.STATE_EDIT_MANUAL)); pnlTitle.getRight().add(btnUndoTX); if (stock.getTradeForm().isWeightControlled() && OPDE.getAppInfo() .isAllowedTo(InternalClassACL.MANAGER, "nursingrecords.inventory")) { /*** * _ __ __ _ _ _ * ___ ___| |\ \ / /__(_) __ _| |__ | |_ * / __|/ _ \ __\ \ /\ / / _ \ |/ _` | '_ \| __| * \__ \ __/ |_ \ V V / __/ | (_| | | | | |_ * |___/\___|\__| \_/\_/ \___|_|\__, |_| |_|\__| * |___/ */ final JButton btnSetWeight = new JButton(SYSConst.icon22scales); btnSetWeight.setPressedIcon(SYSConst.icon22Pressed); btnSetWeight.setAlignmentX(Component.RIGHT_ALIGNMENT); btnSetWeight.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnSetWeight.setContentAreaFilled(false); btnSetWeight.setBorder(null); btnSetWeight.setToolTipText(SYSTools.xx("nursingrecords.inventory.tx.btnUndoTX.tooltip")); btnSetWeight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { BigDecimal weight; new DlgYesNo(SYSConst.icon48scales, new Closure() { @Override public void execute(Object o) { if (!SYSTools.catchNull(o).isEmpty()) { BigDecimal weight = (BigDecimal) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStock myStock = em.merge(stock); final MedStockTransaction myTX = em.merge(tx); em.lock(myTX, LockModeType.OPTIMISTIC); myTX.setWeight(weight); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.getTransaction().commit(); createCP4(myStock.getInventory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }, "nursingrecords.bhp.weight", NumberFormat.getNumberInstance().format(tx.getWeight()), new Validator<BigDecimal>() { @Override public boolean isValid(String value) { BigDecimal bd = parse(value); return bd != null && bd.compareTo(BigDecimal.ZERO) > 0; } @Override public BigDecimal parse(String text) { return SYSTools.parseDecimal(text); } }); } }); btnSetWeight.setEnabled( !stock.isClosed() && (tx.getState() == MedStockTransactionTools.STATE_DEBIT || tx.getState() == MedStockTransactionTools.STATE_CREDIT || tx.getState() == MedStockTransactionTools.STATE_EDIT_MANUAL)); pnlTitle.getRight().add(btnSetWeight); } pnlTX.add(pnlTitle.getMain()); } return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); return pnlTX; }
From source file:op.care.prescription.PnlPrescription.java
private void reloadDisplay() { /***//w w w . j a va 2 s . c o m * _ _ ____ _ _ * _ __ ___| | ___ __ _ __| | _ \(_)___ _ __ | | __ _ _ _ * | '__/ _ \ |/ _ \ / _` |/ _` | | | | / __| '_ \| |/ _` | | | | * | | | __/ | (_) | (_| | (_| | |_| | \__ \ |_) | | (_| | |_| | * |_| \___|_|\___/ \__,_|\__,_|____/|_|___/ .__/|_|\__,_|\__, | * |_| |___/ */ final boolean withworker = true; cpsPrescription.removeAll(); lstVisiblePrescriptions.clear(); cpMap.clear(); lstPrescriptions.clear(); if (withworker) { OPDE.getMainframe().setBlocked(true); OPDE.getDisplayManager() .setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { int progress = -1; OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, lstPrescriptions.size())); if (tbClosed.isSelected()) { lstPrescriptions = PrescriptionTools.getAll(resident); } else { lstPrescriptions = PrescriptionTools.getAllActive(resident); } Collections.sort(lstPrescriptions); for (Prescription prescription : lstPrescriptions) { progress++; createCP4(prescription); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage( SYSTools.xx("misc.msg.wait"), progress, lstPrescriptions.size())); } return null; } @Override protected void done() { buildPanel(); OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } else { if (tbClosed.isSelected()) { lstPrescriptions = PrescriptionTools.getAll(resident); } else { lstPrescriptions = PrescriptionTools.getAllActive(resident); } Collections.sort(lstPrescriptions); for (Prescription prescription : lstPrescriptions) { createCP4(prescription); } buildPanel(); } }
From source file:op.care.reports.PnlReport.java
private void reloadDisplay(final boolean lockmessageAfterwards) { /***/*from w w w . jav a2 s . co m*/ * _ _ ____ _ _ * _ __ ___| | ___ __ _ __| | _ \(_)___ _ __ | | __ _ _ _ * | '__/ _ \ |/ _ \ / _` |/ _` | | | | / __| '_ \| |/ _` | | | | * | | | __/ | (_) | (_| | (_| | |_| | \__ \ |_) | | (_| | |_| | * |_| \___|_|\___/ \__,_|\__,_|____/|_|___/ .__/|_|\__,_|\__, | * |_| |___/ */ synchronized (contentmap) { SYSTools.clear(contentmap); } synchronized (cpMap) { SYSTools.clear(cpMap); } synchronized (linemap) { SYSTools.clear(linemap); } synchronized (valuecache) { SYSTools.clear(valuecache); } initPhase = true; OPDE.getMainframe().setBlocked(true); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); final long time = System.currentTimeMillis(); SwingWorker worker = new SwingWorker() { Date max = null; @Override protected Object doInBackground() throws Exception { GUITools.setResidentDisplay(resident); if (minmax == null) { minmax = NReportTools.getMinMax(resident); } holidays = Collections.synchronizedMap( SYSCalendar.getHolidays(minmax.getStart().getYear(), minmax.getEnd().getYear())); if (minmax != null) { max = minmax.getEnd().toDate(); LocalDate start = SYSCalendar.bom(minmax.getStart()).toLocalDate(); LocalDate end = resident.isActive() ? new LocalDate() : SYSCalendar.bom(minmax.getEnd()).toLocalDate(); int maxYears = Years.yearsBetween(start.toDateTimeAtStartOfDay(), end.toDateTimeAtStartOfDay()) .getYears(); int i = 0; for (int year = end.getYear(); year >= start.getYear(); year--) { OPDE.debug((System.currentTimeMillis() - time) + " ms"); i++; OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), i, maxYears)); createCP4Year(year, start, end); } OPDE.debug((System.currentTimeMillis() - time) + " ms1"); } return null; } @Override protected void done() { OPDE.debug((System.currentTimeMillis() - time) + " ms2"); expandTheLast2Weeks(); OPDE.debug((System.currentTimeMillis() - time) + " ms3"); buildPanel(); OPDE.debug((System.currentTimeMillis() - time) + " ms4"); initPhase = false; OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); if (lockmessageAfterwards) OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); if (max != null) { OPDE.getDisplayManager().addSubMessage(new DisplayMessage( SYSTools.xx("misc.msg.lastEntry") + ": " + DateFormat.getDateInstance().format(max), 5)); } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.noentryyet"), 5)); } } }; worker.execute(); }
From source file:op.care.supervisor.PnlHandover.java
private void createContentPanel4Day(final LocalDate day, final CollapsiblePane cpDay) { final JPanel dayPanel = new JPanel(new VerticalLayout()); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override/*from w w w .j a v a 2s .c o m*/ protected Object doInBackground() throws Exception { // final JPanel dayPanel = new JPanel(new VerticalLayout()); dayPanel.setOpaque(false); ArrayList<Handovers> listHO = HandoversTools.getBy(day, (Homes) cmbHomes.getSelectedItem()); ArrayList<NReport> listNR = NReportTools.getNReports4Handover(day, (Homes) cmbHomes.getSelectedItem()); Collections.sort(listNR, myComparator); int max = listHO.size() + listNR.size(); int i = 0; // for zebra pattern and progress for (final Handovers handover : listHO) { OPDE.getDisplayManager() .setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), i, max)); String title = "<html><table border=\"0\">" + "<tr valign=\"top\">" + "<td width=\"100\" align=\"left\">" + DateFormat.getTimeInstance(DateFormat.SHORT).format(handover.getPit()) + " " + SYSTools.xx("misc.msg.Time.short") + "</td>" + "<td width=\"100\" align=\"center\">--</td>" + "<td width=\"400\" align=\"left\">" + handover.getText() + "</td>" + "<td width=\"100\" align=\"left\">" + handover.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title), new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { EntityManager em = OPDE.createEM(); if (Handover2UserTools.containsUser(em, handover, OPDE.getLogin().getUser())) { em.close(); return; } try { em.getTransaction().begin(); Handovers myHO = em.merge(handover); Handover2User connObj = em.merge( new Handover2User(myHO, em.merge(OPDE.getLogin().getUser()))); myHO.getUsersAcknowledged().add(connObj); em.getTransaction().commit(); createCP4Day(day); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); final JButton btnInfo = new JButton(SYSConst.icon22info); btnInfo.setPressedIcon(SYSConst.icon22infoPressed); btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT); btnInfo.setAlignmentY(Component.TOP_ALIGNMENT); btnInfo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnInfo.setContentAreaFilled(false); btnInfo.setBorder(null); btnInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSFilesTools.print(Handover2UserTools.getAsHTML(handover), false); return null; } @Override protected void done() { try { get(); } catch (Exception ex1) { OPDE.fatal(ex1); } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlSingle.getRight().add(btnInfo); EntityManager em = OPDE.createEM(); pnlSingle.getButton() .setIcon(Handover2UserTools.containsUser(em, handover, OPDE.getLogin().getUser()) ? SYSConst.icon22ledGreenOn : SYSConst.icon22ledRedOn); em.close(); pnlSingle.getButton().setVerticalTextPosition(SwingConstants.TOP); JPanel zebra = new JPanel(); zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS)); zebra.setOpaque(true); if (i % 2 == 0) { zebra.setBackground(SYSConst.orange1[SYSConst.light2]); } else { zebra.setBackground(Color.WHITE); } zebra.add(pnlSingle.getMain()); i++; dayPanel.add(zebra); } for (final NReport nreport : listNR) { OPDE.getDisplayManager() .setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), i, max)); String title = "<html><table border=\"0\">" + "<tr valign=\"top\">" + "<td width=\"100\" align=\"left\">" + DateFormat.getTimeInstance(DateFormat.SHORT).format(nreport.getPit()) + " " + SYSTools.xx("misc.msg.Time.short") + "<br/>" + nreport.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + "</td>" + "<td width=\"100\" align=\"left\">" + ResidentTools.getTextCompact(nreport.getResident()) + "</td>" + "<td width=\"400\" align=\"left\">" + nreport.getText() + "</td>" + "<td width=\"100\" align=\"left\">" + nreport.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title), new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { EntityManager em = OPDE.createEM(); if (NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser())) { em.close(); return; } try { em.getTransaction().begin(); NReport myNR = em.merge(nreport); NR2User connObj = em .merge(new NR2User(myNR, em.merge(OPDE.getLogin().getUser()))); myNR.getUsersAcknowledged().add(connObj); em.getTransaction().commit(); createCP4Day(day); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); final JButton btnInfo = new JButton(SYSConst.icon22info); btnInfo.setPressedIcon(SYSConst.icon22infoPressed); btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT); btnInfo.setAlignmentY(Component.TOP_ALIGNMENT); btnInfo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnInfo.setContentAreaFilled(false); btnInfo.setBorder(null); btnInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SYSFilesTools.print(NR2UserTools.getAsHTML(nreport), false); // OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); // OPDE.getMainframe().setBlocked(true); // // SwingWorker worker = new SwingWorker() { // // @Override // protected Object doInBackground() throws Exception { // // return null; // } // // @Override // protected void done() { // OPDE.getDisplayManager().setProgressBarMessage(null); // OPDE.getMainframe().setBlocked(false); // } // // }; // worker.execute(); } }); pnlSingle.getRight().add(btnInfo); EntityManager em = OPDE.createEM(); pnlSingle.getButton() .setIcon(NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser()) ? SYSConst.icon22ledGreenOn : SYSConst.icon22ledRedOn); em.close(); pnlSingle.getButton().setVerticalTextPosition(SwingConstants.TOP); JPanel zebra = new JPanel(); zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS)); zebra.setOpaque(true); if (i % 2 == 0) { zebra.setBackground(SYSConst.orange1[SYSConst.light2]); } else { zebra.setBackground(Color.WHITE); } zebra.add(pnlSingle.getMain()); i++; dayPanel.add(zebra); } final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (cacheHO) { cacheHO.put(key, listHO); } synchronized (cacheNR) { cacheNR.put(key, listNR); } return null; } @Override protected void done() { try { get(); } catch (Exception ex2) { OPDE.fatal(ex2); } cpDay.setContentPane(dayPanel); OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Hygiene() { JPanel pnlContent = new JPanel(new VerticalLayout()); JPanel pnlPrevalence = new JPanel(new BorderLayout()); final JButton btnPrevalence = GUITools.createHyperlinkButton("opde.controlling.hygiene.prevalence", null, null);//w w w . j a v a 2 s . c om final JDateChooser jdc = new JDateChooser(new Date()); final JCheckBox cbAnonymous = new JCheckBox(SYSTools.xx("misc.msg.anon")); cbAnonymous.setSelected(true); jdc.setMaxSelectableDate(new Date()); btnPrevalence.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { MREPrevalenceSheets mre = new MREPrevalenceSheets(new LocalDate(), cbAnonymous.isSelected(), progressClosure); return mre.createSheet(); } @Override protected void done() { try { File source = (File) get(); Object[] options = { SYSTools.xx("prevalence.optiondialog.option1"), SYSTools.xx("prevalence.optiondialog.option2"), SYSTools.xx("opde.wizards.buttontext.cancel") }; int n = JOptionPane.showOptionDialog(OPDE.getMainframe(), SYSTools.xx("prevalence.optiondialog.question"), SYSTools.xx("prevalence.optiondialog.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); File copyTargetDirectory = null; if (n == 1) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("title"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(pnlPrevalence) == JFileChooser.APPROVE_OPTION) { copyTargetDirectory = chooser.getSelectedFile(); } } if (copyTargetDirectory != null) { FileUtils.copyFile(source, copyTargetDirectory); } else { if (n == 0) { SYSFilesTools.handleFile((File) get(), Desktop.Action.OPEN); } } } catch (Exception e) { OPDE.fatal(e); } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlPrevalence.add(btnPrevalence, BorderLayout.WEST); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.LINE_AXIS)); optionPanel.add(cbAnonymous); optionPanel.add(jdc); pnlPrevalence.add(optionPanel, BorderLayout.EAST); pnlContent.add(pnlPrevalence); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Pain() { JPanel pnlContent = new JPanel(new VerticalLayout()); JPanel pnlPainDossier = new JPanel(new BorderLayout()); final JButton btnBVActivities = GUITools.createHyperlinkButton("opde.controlling.orga.paindossier", null, null);//from ww w . j a v a 2s.c om int monthsBack; try { monthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::paindossiermonthsback")); } catch (NumberFormatException nfe) { monthsBack = 1; } final JTextField txtPainMonthsBack = GUITools.createIntegerTextField(1, 52, monthsBack); txtPainMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnBVActivities.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::paindossiermonthsback", txtPainMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ControllingTools.getPainDossierAsHTML( new LocalDate().minusMonths(Integer.parseInt(txtPainMonthsBack.getText())), new LocalDate(), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlPainDossier.add(btnBVActivities, BorderLayout.WEST); pnlPainDossier.add(txtPainMonthsBack, BorderLayout.EAST); pnlContent.add(pnlPainDossier); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Fall() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***/*from w ww . j a v a2s.co m*/ * _____ _ _ _ * | ___|_ _| | |___ / \ _ __ ___ _ __ _ _ _ __ ___ ___ _ _ ___ * | |_ / _` | | / __| / _ \ | '_ \ / _ \| '_ \| | | | '_ ` _ \ / _ \| | | / __| * | _| (_| | | \__ \ / ___ \| | | | (_) | | | | |_| | | | | | | (_) | |_| \__ \ * |_| \__,_|_|_|___/ /_/ \_\_| |_|\___/|_| |_|\__, |_| |_| |_|\___/ \__,_|___/ * |___/ */ JPanel pnlFallsAnon = new JPanel(new BorderLayout()); final JButton btnFallsAnon = GUITools.createHyperlinkButton("opde.controlling.nursing.falls.anonymous", null, null); int fallsMonthsBack; try { fallsMonthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::fallsMonthsBack")); } catch (NumberFormatException nfe) { fallsMonthsBack = 7; } final JTextField txtFallsMonthsBack = GUITools.createIntegerTextField(1, 120, fallsMonthsBack); txtFallsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnFallsAnon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::fallsMonthsBack", txtFallsMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ResInfoTools.getFallsAnonymous( Integer.parseInt(txtFallsMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlFallsAnon.add(btnFallsAnon, BorderLayout.WEST); pnlFallsAnon.add(txtFallsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlFallsAnon); /*** * _____ _ _ _ ____ _ _ _ * | ___|_ _| | |___ | |__ _ _| _ \ ___ ___(_) __| | ___ _ __ | |_ * | |_ / _` | | / __| | '_ \| | | | |_) / _ \/ __| |/ _` |/ _ \ '_ \| __| * | _| (_| | | \__ \ | |_) | |_| | _ < __/\__ \ | (_| | __/ | | | |_ * |_| \__,_|_|_|___/ |_.__/ \__, |_| \_\___||___/_|\__,_|\___|_| |_|\__| * |___/ */ JPanel pnlFallsRes = new JPanel(new BorderLayout()); final JButton btnFallsRes = GUITools.createHyperlinkButton("opde.controlling.nursing.falls.byResident", null, null); int fallsResMonthsBack; try { fallsResMonthsBack = Integer .parseInt(OPDE.getProps().getProperty("opde.controlling::fallsResMonthsBack")); } catch (NumberFormatException nfe) { fallsResMonthsBack = 7; } final JTextField txtResFallsMonthsBack = GUITools.createIntegerTextField(1, 120, fallsResMonthsBack); txtResFallsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnFallsRes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::fallsResMonthsBack", txtResFallsMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ResInfoTools.getFallsByResidents( Integer.parseInt(txtResFallsMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlFallsRes.add(btnFallsRes, BorderLayout.WEST); pnlFallsRes.add(txtResFallsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlFallsRes); /*** * _____ _ _ ___ _ _ _ * | ___|_ _| | |___|_ _|_ __ __| (_) ___ __ _| |_ ___ _ __ * | |_ / _` | | / __|| || '_ \ / _` | |/ __/ _` | __/ _ \| '__| * | _| (_| | | \__ \| || | | | (_| | | (_| (_| | || (_) | | * |_| \__,_|_|_|___/___|_| |_|\__,_|_|\___\__,_|\__\___/|_| * */ JPanel pnlFallsIndicator = new JPanel(new BorderLayout()); final JButton btnFallsIndicator = GUITools .createHyperlinkButton("opde.controlling.nursing.fallsindicators.byMonth", null, null); int fallsIndicatorBack; try { fallsIndicatorBack = Integer .parseInt(OPDE.getProps().getProperty("opde.controlling::fallsIndicatorMonthsBack")); } catch (NumberFormatException nfe) { fallsIndicatorBack = 7; } final JTextField txtFallsIndicatorsMonthsBack = GUITools.createIntegerTextField(1, 120, fallsIndicatorBack); txtFallsIndicatorsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnFallsIndicator.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::fallsIndicatorMonthsBack", txtFallsIndicatorsMonthsBack.getText(), OPDE.getLogin().getUser()); return ResInfoTools.getFallsIndicatorsByMonth( Integer.parseInt(txtFallsIndicatorsMonthsBack.getText()), progressClosure); } @Override protected void done() { try { SYSFilesTools.print(get().toString(), true); } catch (ExecutionException ee) { OPDE.fatal(ee); } catch (InterruptedException ie) { // nop } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlFallsIndicator.add(btnFallsIndicator, BorderLayout.WEST); pnlFallsIndicator.add(txtFallsIndicatorsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlFallsIndicator); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Orga() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***/*from ww w . ja v a 2 s .c om*/ * ______ ___ _ _ _ _ _ * | __ ) \ / / \ ___| |_(_)_ _(_) |_(_) ___ ___ * | _ \\ \ / / _ \ / __| __| \ \ / / | __| |/ _ \/ __| * | |_) |\ V / ___ \ (__| |_| |\ V /| | |_| | __/\__ \ * |____/ \_/_/ \_\___|\__|_| \_/ |_|\__|_|\___||___/ * */ JPanel pnlBV = new JPanel(new BorderLayout()); final JButton btnBVActivities = GUITools.createHyperlinkButton("opde.controlling.orga.bvactivities", null, null); int bvWeeksBack; try { bvWeeksBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::bvactivitiesWeeksBack")); } catch (NumberFormatException nfe) { bvWeeksBack = 7; } final JTextField txtBVWeeksBack = GUITools.createIntegerTextField(1, 52, bvWeeksBack); txtBVWeeksBack.setToolTipText(SYSTools.xx("misc.msg.weeksback")); btnBVActivities.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::bvactivitiesWeeksBack", txtBVWeeksBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(NReportTools.getBVActivites( new LocalDate().minusWeeks(Integer.parseInt(txtBVWeeksBack.getText())), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlBV.add(btnBVActivities, BorderLayout.WEST); pnlBV.add(txtBVWeeksBack, BorderLayout.EAST); pnlContent.add(pnlBV); /*** * _ _ _ * ___ ___ _ __ ___ _ __ | | __ _(_)_ __ | |_ ___ * / __/ _ \| '_ ` _ \| '_ \| |/ _` | | '_ \| __/ __| * | (_| (_) | | | | | | |_) | | (_| | | | | | |_\__ \ * \___\___/|_| |_| |_| .__/|_|\__,_|_|_| |_|\__|___/ * |_| */ JPanel pnlComplaints = new JPanel(new BorderLayout()); final JButton btnComplaints = GUITools.createHyperlinkButton("opde.controlling.orga.complaints", null, null); int complaintsMonthBack; try { complaintsMonthBack = Integer .parseInt(OPDE.getProps().getProperty("opde.controlling::complaintsMonthBack")); } catch (NumberFormatException nfe) { complaintsMonthBack = 7; } final JTextField txtComplaintsMonthsBack = GUITools.createIntegerTextField(1, 12, complaintsMonthBack); txtComplaintsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnComplaints.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::complaintsMonthBack", txtComplaintsMonthsBack.getText(), OPDE.getLogin().getUser()); int monthsback = Integer.parseInt(txtComplaintsMonthsBack.getText()); String content = QProcessTools.getComplaintsAnalysis(monthsback, progressClosure); content += NReportTools.getComplaints( new LocalDate().minusMonths(monthsback).dayOfMonth().withMinimumValue(), progressClosure); SYSFilesTools.print(content, false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlComplaints.add(btnComplaints, BorderLayout.WEST); pnlComplaints.add(txtComplaintsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlComplaints); // ResInfoTypeTools.TYPE_NURSING_INSURANCE JPanel pnlInsuranceGrade = new JPanel(new BorderLayout()); final JButton btnIG = GUITools.createHyperlinkButton("misc.msg.InsuranceGrades", null, null); btnIG.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { String content = SYSConst.html_h1("misc.msg.InsuranceGrades"); String ul = ""; for (Resident resident : ResidentTools.getAllActive()) { if (resident.getAdminonly() == ResidentTools.NORMAL) { ul += SYSConst.html_li(SYSConst.html_bold(ResidentTools.getLabelText(resident))); ResInfo insurance = ResInfoTools.getLastResinfo(resident, ResInfoTypeTools.TYPE_NURSING_INSURANCE); String ins = ""; if (insurance == null) { ins = SYSTools.xx("misc.msg.noentryyet"); } else { Properties props = load(insurance.getProperties()); String grade = SYSTools.xx("ninsurance.grade." + props.getProperty("grade")); ins = grade + (props.getProperty("grade").equals("assigned") ? ": " + props.getProperty("result") : ""); } ul += SYSConst.html_ul(SYSConst.html_li(ins)); } } content += SYSConst.html_ul(ul); SYSFilesTools.print(content, false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlInsuranceGrade.add(btnIG, BorderLayout.WEST); pnlContent.add(pnlInsuranceGrade); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Staff() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***// w w w . j a v a2 s . c o m * ____ _ __ __ * / ___|| |_ __ _ / _|/ _| * \___ \| __/ _` | |_| |_ * ___) | || (_| | _| _| * |____/ \__\__,_|_| |_| * */ JPanel pnlTraining = new JPanel(new BorderLayout()); final JButton btnTrainings = GUITools.createHyperlinkButton("opde.controlling.staff.training", null, null); Pair<LocalDate, LocalDate> minmax = TrainingTools.getMinMax(); btnTrainings.setEnabled(minmax != null); final JComboBox cmbYears = new JComboBox(); if (minmax == null) { cmbYears.setModel(new DefaultComboBoxModel()); } else { ArrayList<Integer> years = new ArrayList<>(); for (int year = minmax.getSecond().getYear(); year >= minmax.getFirst().getYear(); year--) { years.add(year); } cmbYears.setModel(SYSTools.list2cmb(years)); cmbYears.setSelectedIndex(0); } btnTrainings.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSFilesTools.print( TrainingTools.getTraining2Attendees((Integer) cmbYears.getSelectedItem()), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlTraining.add(btnTrainings, BorderLayout.WEST); pnlTraining.add(cmbYears, BorderLayout.EAST); pnlContent.add(pnlTraining); return pnlContent; }