List of usage examples for java.text DateFormat getDateInstance
public static final DateFormat getDateInstance()
From source file:op.allowance.PnlAllowance.java
private JPanel createContentPanel4(final Resident resident, LocalDate month) { final String key = getKey(resident, month); if (!contentmap.containsKey(key)) { JPanel pnlMonth = new JPanel(new VerticalLayout()); pnlMonth.setBackground(getBG(resident, 11)); pnlMonth.setOpaque(false);// w w w .j a v a2s. c om // final String prevKey = resident.getRID() + "-" + SYSCalendar.eom(month.minusMonths(1)).getYear() + "-" + SYSCalendar.eom(month.minusMonths(1)).getMonthOfYear(); if (!carrySums.containsKey(key)) { carrySums.put(key, AllowanceTools.getSUM(resident, SYSCalendar.eom(month.minusMonths(1)))); } BigDecimal rowsum = carrySums.get(key); if (!cashmap.containsKey(key)) { cashmap.put(key, AllowanceTools.getMonth(resident, month.toDate())); } JLabel lblEOM = new JLabel("<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateInstance().format(month.dayOfMonth().withMaximumValue().toDate()) + "</td>" + "<td width=\"400\" align=\"left\">" + SYSTools.xx("admin.residents.cash.endofmonth") + "</td>" + "<td width=\"100\" align=\"right\"></td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"); pnlMonth.add(lblEOM); for (final Allowance allowance : cashmap.get(key)) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateInstance().format(allowance.getPit()) + "</td>" + "<td width=\"400\" align=\"left\">" + allowance.getText() + "</td>" + "<td width=\"100\" align=\"right\">" + (allowance.getAmount().compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(allowance.getAmount()) + (allowance.getAmount().compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }); cptitle.getButton().setIcon( allowance.isReplaced() || allowance.isReplacement() ? SYSConst.icon22eraser : null); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /*** * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = new JButton(SYSConst.icon22edit3); btnEdit.setPressedIcon(SYSConst.icon22edit3Pressed); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnEdit.setContentAreaFilled(false); btnEdit.setBorder(null); btnEdit.setToolTipText(SYSTools.xx("admin.residents.cash.btnedit.tooltip")); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popupTX = new JidePopup(); popupTX.setMovable(false); PnlTX pnlTX = getPnlTX(resident, allowance); popupTX.setContentPane(pnlTX); popupTX.removeExcludedComponent(pnlTX); popupTX.setDefaultFocusComponent(pnlTX); popupTX.setOwner(btnEdit); GUITools.showPopup(popupTX, SwingConstants.WEST); } }); cptitle.getRight().add(btnEdit); // you can edit your own entries or you are a manager. once they are replaced or a replacement record, its over. btnEdit.setEnabled((OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, internalClassID) || allowance.getUser().equals(OPDE.getLogin().getUser())) && !allowance.isReplaced() && !allowance.isReplacement()); /*** * _ _ _ _______ __ * | | | |_ __ __| | ___ |_ _\ \/ / * | | | | '_ \ / _` |/ _ \ | | \ / * | |_| | | | | (_| | (_) | | | / \ * \___/|_| |_|\__,_|\___/ |_| /_/\_\ * */ 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("admin.residents.cash.btnundotx.tooltip")); btnUndoTX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.undo1") + "<br/><i>" + "<br/><i>" + allowance.getText() + " " + cf.format(allowance.getAmount()) + "</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(); Allowance myOldAllowance = em.merge(allowance); Allowance myCancelAllowance = em .merge(new Allowance(myOldAllowance)); em.lock(em.merge(myOldAllowance.getResident()), LockModeType.OPTIMISTIC); em.lock(myOldAllowance, LockModeType.OPTIMISTIC); myOldAllowance.setReplacedBy(myCancelAllowance, em.merge(OPDE.getLogin().getUser())); em.getTransaction().commit(); DateTime txDate = new DateTime(myCancelAllowance.getPit()); final String keyMonth = myCancelAllowance.getResident().getRID() + "-" + txDate.getYear() + "-" + txDate.getMonthOfYear(); contentmap.remove(keyMonth); cpMap.remove(keyMonth); cashmap.get(keyMonth).remove(allowance); cashmap.get(keyMonth).add(myOldAllowance); cashmap.get(keyMonth).add(myCancelAllowance); Collections.sort(cashmap.get(keyMonth)); updateCarrySums(myCancelAllowance); createCP4(myCancelAllowance.getResident()); try { cpMap.get(keyMonth).setCollapsed(false); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } 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(); } } } }); } }); cptitle.getRight().add(btnUndoTX); btnUndoTX.setEnabled(!allowance.isReplaced() && !allowance.isReplacement()); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = new JButton(SYSConst.icon22delete); btnDelete.setPressedIcon(SYSConst.icon22deletePressed); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnDelete.setContentAreaFilled(false); btnDelete.setBorder(null); btnDelete.setToolTipText(SYSTools.xx("admin.residents.cash.btndelete.tooltip")); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.delete1") + "<br/><i>" + allowance.getText() + " " + cf.format(allowance.getAmount()) + "</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(); Allowance myAllowance = em.merge(allowance); em.lock(em.merge(myAllowance.getResident()), LockModeType.OPTIMISTIC); Allowance theOtherOne = null; // Check for special cases if (myAllowance.isReplacement()) { theOtherOne = em.merge(myAllowance.getReplacementFor()); theOtherOne.setReplacedBy(null); theOtherOne.setEditedBy(null); myAllowance.setEditPit(null); } if (myAllowance.isReplaced()) { theOtherOne = em.merge(myAllowance.getReplacedBy()); theOtherOne.setReplacementFor(null); } em.remove(myAllowance); em.getTransaction().commit(); DateTime txDate = new DateTime(myAllowance.getPit()); final String keyMonth = myAllowance.getResident().getRID() + "-" + txDate.getYear() + "-" + txDate.getMonthOfYear(); cpMap.remove(keyMonth); cashmap.get(keyMonth).remove(myAllowance); if (theOtherOne != null) { cashmap.get(keyMonth).remove(theOtherOne); cashmap.get(keyMonth).add(theOtherOne); Collections.sort(cashmap.get(keyMonth)); } // only to update the carrysums. myAllowance will be discarded soon. myAllowance.setAmount(myAllowance.getAmount().negate()); updateCarrySums(myAllowance); createCP4(myAllowance.getResident()); try { if (cpMap.containsKey(keyMonth)) { cpMap.get(keyMonth).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } 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(); } } } }); } }); cptitle.getRight().add(btnDelete); } pnlMonth.add(cptitle.getMain()); linemap.put(allowance, cptitle.getMain()); rowsum = rowsum.subtract(allowance.getAmount()); } JLabel lblBOM = new JLabel("<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateInstance().format(month.dayOfMonth().withMinimumValue().toDate()) + "</td>" + "<td width=\"400\" align=\"left\">" + SYSTools.xx("admin.residents.cash.startofmonth") + "</td>" + "<td width=\"100\" align=\"right\"></td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"); lblBOM.setBackground(getBG(resident, 11)); pnlMonth.add(lblBOM); contentmap.put(key, pnlMonth); } return contentmap.get(key); }
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/* w w w.j a v a2 s .com*/ 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.care.reports.PnlReport.java
private JPanel createContentPanel4Day(LocalDate day) { // OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage("misc.msg.wait", progress, progressMax)); // progress++; final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (contentmap) { if (contentmap.containsKey(key)) { return contentmap.get(key); }//from ww w .ja v a 2 s. c o m } final JPanel dayPanel = new JPanel(new VerticalLayout()); dayPanel.setOpaque(false); synchronized (valuecache) { if (!valuecache.containsKey(key)) { valuecache.put(key, NReportTools.getNReports4Day(resident, day)); } int i = 0; // for zebra pattern for (final NReport nreport : valuecache.get(key)) { if (tbShowReplaced.isSelected() || !nreport.isObsolete()) { String title = SYSTools.toHTMLForScreen(SYSConst.html_table(SYSConst .html_table_tr("<td width=\"800\" align=\"left\">" + "<b><p>" + (nreport.isObsolete() ? SYSConst.html_16x16_Eraser_internal : "") + (nreport.isReplacement() ? SYSConst.html_16x16_Edited_internal : "") + DateFormat.getTimeInstance(DateFormat.SHORT).format(nreport.getPit()) + " " + SYSTools.xx("misc.msg.Time.short") + ", " + nreport.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + ", " + nreport.getUser().getFullname() + (nreport.getCommontags().isEmpty() ? "" : " " + CommontagsTools.getAsHTML(nreport.getCommontags(), SYSConst.html_16x16_tagPurple_internal)) + "</p></b></td>") + SYSConst.html_table_tr("<td width=\"800\" align=\"left\">" + SYSTools.replace(nreport.getText(), "\n", "<br/>", false) + "</td>"), "0")); final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title), null); pnlSingle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup(GUITools.getHTMLPopup(pnlSingle.getButton(), NReportTools.getInfoAsHTML(nreport)), SwingConstants.NORTH); } }); if (!nreport.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(nreport.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final NReport myReport = em.find(NReport.class, nreport.getID()); em.close(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } }; new DlgFiles(nreport, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlSingle.getRight().add(btnFiles); } if (!nreport.getAttachedQProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(nreport.getAttachedQProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(nreport, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSNR2PROCESS> attached = new ArrayList<SYSNR2PROCESS>( myReport.getAttachedQProcessConnections()); for (SYSNR2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getNReport().getAttachedQProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess .getElements(); if (!listElements.contains(myReport)) { QProcess myQProcess = em.merge(qProcess); SYSNR2PROCESS myLinkObject = em .merge(new SYSNR2PROCESS(myQProcess, myReport)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedNReportConnections().add(myLinkObject); myReport.getAttachedQProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), 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(); } else { reloadDisplay(true); } } catch (RollbackException 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(); } } }); } }); btnProcess.setEnabled( OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlSingle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(nreport); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!nreport.isObsolete()); pnlSingle.getRight().add(btnMenu); 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); linemap.put(nreport, pnlSingle.getMain()); } } } synchronized (contentmap) { contentmap.put(key, dayPanel); } return dayPanel; }
From source file:op.care.supervisor.PnlHandover.java
private java.util.List<Component> addCommands() { java.util.List<Component> list = new ArrayList<Component>(); /***// ww w . j a v a 2s . c o m * _ _ * | \ | | _____ __ * | \| |/ _ \ \ /\ / / * | |\ | __/\ V V / * |_| \_|\___| \_/\_/ * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.INSERT, internalClassID)) { JideButton addButton = GUITools.createHyperlinkButton( SYSTools.xx("nursingrecords.handover.tooltips.btnadd"), SYSConst.icon22add, new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgHOReport(new Handovers((Homes) cmbHomes.getSelectedItem()), new Closure() { @Override public void execute(Object report) { if (report != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); final Handovers myHO = em.merge((Handovers) report); myHO.getUsersAcknowledged().add( em.merge(new Handover2User(myHO, OPDE.getLogin().getUser()))); em.getTransaction().commit(); LocalDate day = new LocalDate(myHO.getPit()); final String key = DateFormat.getDateInstance().format(myHO.getPit()); createCP4Day(day); expandDay(day); buildPanel(); GUITools.scroll2show(jspHandover, cpMap.get(key), cpsHandover, new Closure() { @Override public void execute(Object o) { // GUITools.flashBackground(linemapHO.get(myHO), 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(); } } } }); } }); list.add(addButton); } final JideButton btnControllingToday = GUITools.createHyperlinkButton( SYSTools.xx("nursingrecords.handover.tooltips.btnControllingToday"), SYSConst.icon22magnify1, null); btnControllingToday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { btnControllingToday.setEnabled(false); HandoversTools.printSupervision(new LocalDate(), (Homes) cmbHomes.getSelectedItem(), new Closure() { @Override public void execute(Object o) { btnControllingToday.setEnabled(true); } }); } }); list.add(btnControllingToday); final JideButton btnControllingYesterday = GUITools.createHyperlinkButton( SYSTools.xx("nursingrecords.handover.tooltips.btnControllingYesterday"), SYSConst.icon22magnify1, null); btnControllingYesterday.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { btnControllingYesterday.setEnabled(false); HandoversTools.printSupervision(new LocalDate().minusDays(1), (Homes) cmbHomes.getSelectedItem(), new Closure() { @Override public void execute(Object o) { btnControllingYesterday.setEnabled(true); } }); } }); list.add(btnControllingYesterday); return list; }
From source file:org.pentaho.platform.uifoundation.chart.TimeSeriesCollectionChartDefinition.java
public void setDateMaximum(final Node dateMaximumNode) { if (dateMaximumNode != null) { try {//from ww w . j av a 2 s.c o m setDateMaximum(DateFormat.getDateInstance().parse(dateMaximumNode.getText())); } catch (ParseException e) { getLogger().error(Messages.getInstance().getString( "TimeSeriesCollectionChartDefinition.ERROR_0001_INVALID_DATE", //$NON-NLS-1$ dateMaximumNode.getText()), e); } } }
From source file:org.pentaho.platform.uifoundation.chart.TimeSeriesCollectionChartDefinition.java
public void setDateMinimum(final Node dateMinimumNode) { if (dateMinimumNode != null) { try {/* w w w .j ava 2 s .co m*/ setDateMinimum(DateFormat.getDateInstance().parse(dateMinimumNode.getText())); } catch (ParseException e) { getLogger().error(Messages.getInstance().getString( "TimeSeriesCollectionChartDefinition.ERROR_0001_INVALID_DATE", //$NON-NLS-1$ dateMinimumNode.getText()), e); } } }
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a Gantt chart using the supplied attributes plus default values * where required. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link DateAxis} as the range axis, and a * {@link GanttRenderer} as the renderer. * * @param title the chart title ({@code null} permitted). * @param categoryAxisLabel the label for the category axis * ({@code null} permitted). * @param dateAxisLabel the label for the date axis * ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * * @return A Gantt chart.// w w w.jav a 2 s. c o m */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); renderer.setDefaultToolTipGenerator( new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance())); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Formats as a <code>String</code> the specified time. * /*www . j a va2s . c om*/ * @param time The timestamp to format. * @return Returns the stringified version of the passed timestamp. */ public static String formatTime(Timestamp time) { if (time == null) return ""; return DateFormat.getDateInstance().format(time); }
From source file:com.akop.bach.parser.XboxLiveParser.java
private FriendsOfFriend parseFriendsOfFriend(XboxLiveAccount account, String friendGamertag) throws IOException, ParserException { long started = System.currentTimeMillis(); FriendsOfFriend list = new FriendsOfFriend(mContext.getContentResolver()); String token = getVToken(String.format(URL_VTOKEN_FRIENDS, mLocale)); String url = String.format(URL_JSON_FOF_LIST, mLocale); List<NameValuePair> inputs = new ArrayList<NameValuePair>(3); // Req. ver. token addValue(inputs, "__RequestVerificationToken", token); addValue(inputs, "gamertag", friendGamertag); String page = getResponse(url, inputs, true); JSONObject json = getXboxJsonObject(page); if (json == null) return list; JSONArray friends = json.optJSONArray("Friends"); if (friends == null) return list; ArrayList<Gamer> shared = new ArrayList<Gamer>(); ArrayList<Gamer> notYet = new ArrayList<Gamer>(); for (int i = 0, n = friends.length(); i < n; i++) { String gamertag;//from w w w.ja v a 2 s. com JSONObject friend = friends.optJSONObject(i); if (friend == null || (gamertag = friend.optString("GamerTag")) == null) continue; long lastSeen = parseTicks(friend.optString("LastSeen")); Gamer gamer = new Gamer(); gamer.Gamertag = gamertag; gamer.Gamerscore = friend.optInt("GamerScore", 0); gamer.IconUrl = friend.optString("LargeGamerTileUrl"); JSONObject titleInfo = friend.optJSONObject("TitleInfo"); if (titleInfo != null) { gamer.TitleIconUrl = getBoxArt(titleInfo.optInt("Id", 0), false); if (titleInfo.optInt("Id") == 0) { gamer.CurrentActivity = mContext.getString(R.string.online_status_unavailable); } else { gamer.CurrentActivity = mContext.getString(R.string.last_seen_playing_f, DateFormat.getDateInstance().format(lastSeen), titleInfo.optString("Name")); } } gamer.IsFriend = Friends.isFriend(mContext, account, gamertag); if (gamer.IsFriend) shared.add(gamer); else notYet.add(gamer); } if (App.getConfig().logToConsole()) started = displayTimeTaken("Friends of friend page loading", started); Gamer.Comparator cmp = new Gamer.Comparator(); Collections.sort(shared, cmp); Collections.sort(notYet, cmp); if (App.getConfig().logToConsole()) started = displayTimeTaken("Friends of friend page sorting", started); long id = 0; for (Gamer gamer : shared) { list.SharedFriends.addItem(id++, gamer.Gamertag, gamer.CurrentActivity, gamer.IconUrl, gamer.TitleIconUrl, gamer.TitleId, gamer.Gamerscore, gamer.IsFriend); } for (Gamer gamer : notYet) { list.NotYetFriends.addItem(id++, gamer.Gamertag, gamer.CurrentActivity, gamer.IconUrl, gamer.TitleIconUrl, gamer.TitleId, gamer.Gamerscore, gamer.IsFriend); } return list; }
From source file:com.akop.bach.parser.XboxLiveParser.java
private RecentPlayers parseRecentPlayers(XboxLiveAccount account) throws IOException, ParserException { long started = System.currentTimeMillis(); RecentPlayers list = new RecentPlayers(mContext.getContentResolver()); String token = getVToken(String.format(URL_VTOKEN_FRIENDS, mLocale)); String url = String.format(URL_JSON_RECENT_LIST, mLocale); List<NameValuePair> inputs = new ArrayList<NameValuePair>(3); // Req. ver. token addValue(inputs, "__RequestVerificationToken", token); JSONArray players = getXboxJsonArray(url, inputs); if (App.getConfig().logToConsole()) started = displayTimeTaken("Player list page fetch", started); if (players == null) throw new ParserException(mContext, R.string.error_player_retrieval); ArrayList<Gamer> notYet = new ArrayList<Gamer>(); for (int i = 0, n = players.length(); i < n; i++) { String gamertag;//from w ww . ja v a 2s .c om JSONObject player = players.optJSONObject(i); if (player == null || (gamertag = player.optString("GamerTag")) == null) continue; long lastSeen = parseTicks(player.optString("LastSeen")); Gamer gamer = new Gamer(); gamer.Gamertag = gamertag; gamer.Gamerscore = player.optInt("GamerScore", 0); gamer.IconUrl = player.optString("LargeGamerTileUrl"); JSONObject titleInfo = player.optJSONObject("TitleInfo"); if (titleInfo != null) { gamer.TitleIconUrl = getBoxArt(titleInfo.optInt("Id", 0), false); if (titleInfo.optInt("Id") == 0) { gamer.CurrentActivity = mContext.getString(R.string.online_status_unavailable); } else { gamer.CurrentActivity = mContext.getString(R.string.last_seen_playing_f, DateFormat.getDateInstance().format(lastSeen), titleInfo.optString("Name")); } } notYet.add(gamer); } if (App.getConfig().logToConsole()) started = displayTimeTaken("Recent players page loading", started); Gamer.Comparator cmp = new Gamer.Comparator(); Collections.sort(notYet, cmp); if (App.getConfig().logToConsole()) started = displayTimeTaken("Recent players page sorting", started); for (Gamer gamer : notYet) { list.Players.addItem(gamer.Gamertag, gamer.CurrentActivity, gamer.IconUrl, gamer.TitleIconUrl, gamer.TitleId, gamer.Gamerscore, gamer.IsFriend); } return list; }