List of usage examples for javax.swing JSeparator JSeparator
public JSeparator()
From source file:op.care.nursingprocess.PnlNursingProcess.java
private JPanel getMenu(final NursingProcess np) { final JPanel pnlMenu = new JPanel(new VerticalLayout()); long numDFNs = DFNTools.getNumDFNs(np); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /***//from ww w .jav a 2s . c o m * ____ _ * / ___| |__ __ _ _ __ __ _ ___ * | | | '_ \ / _` | '_ \ / _` |/ _ \ * | |___| | | | (_| | | | | (_| | __/ * \____|_| |_|\__,_|_| |_|\__, |\___| * |___/ */ JButton btnChange = GUITools.createHyperlinkButton("nursingrecords.nursingprocess.btnchange.tooltip", SYSConst.icon22playerPlay, null); btnChange.setAlignmentX(Component.RIGHT_ALIGNMENT); btnChange.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { NursingProcess template = np.clone(); template.setTo(SYSConst.DATE_UNTIL_FURTHER_NOTICE); template.setUserOFF(null); template.setUserON(OPDE.getLogin().getUser()); template.setNextEval(new DateTime().plusWeeks(4).toDate()); new DlgNursingProcess(template, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); // Fetch the new Plan from the PAIR NursingProcess myNewNP = em.merge( ((Pair<NursingProcess, ArrayList<InterventionSchedule>>) o).getFirst()); NursingProcess myOldNP = em.merge(np); em.lock(myOldNP, LockModeType.OPTIMISTIC); // Close old NP myOldNP.setUserOFF(em.merge(OPDE.getLogin().getUser())); myOldNP.setTo(new DateTime().minusSeconds(1).toDate()); NPControl lastValidation = em .merge(new NPControl(myNewNP.getSituation(), myOldNP)); lastValidation.setLastValidation(true); myOldNP.getEvaluations().add(lastValidation); // Starts 1 second after the old one stopped myNewNP.setFrom(new DateTime(myOldNP.getTo()).plusSeconds(1).toDate()); // Create new DFNs according to plan DFNTools.generate(em, myNewNP.getInterventionSchedule(), new LocalDate(), true); em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myOldNP.getCategory()).add(myOldNP); valuecache.get(myNewNP.getCategory()).add(myNewNP); Collections.sort(valuecache.get(myNewNP.getCategory())); createCP4(myNewNP.getCategory()); boolean reloadSearch = false; for (Commontags ctag : myNewNP.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } buildPanel(); GUITools.flashBackground(contenPanelMap.get(myNewNP), 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(); } // reloadTable(); } } }); } }); btnChange.setEnabled(!np.isClosed() && numDFNs != 0); pnlMenu.add(btnChange); /*** * ____ _ _ ____ _ * | __ ) _ _| |_| |_ ___ _ __ / ___|| |_ ___ _ __ * | _ \| | | | __| __/ _ \| '_ \ \___ \| __/ _ \| '_ \ * | |_) | |_| | |_| || (_) | | | | ___) | || (_) | |_) | * |____/ \__,_|\__|\__\___/|_| |_| |____/ \__\___/| .__/ * |_| */ final JButton btnStop = GUITools.createHyperlinkButton("nursingrecords.nursingprocess.btnstop.tooltip", SYSConst.icon22stop, null); btnStop.setAlignmentX(Component.RIGHT_ALIGNMENT); btnStop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); JPanel dlg = new PnlEval(np, new Closure() { @Override public void execute(Object o) { if (o != null) { popup.hidePopup(); Pair<NursingProcess, String> result = (Pair<NursingProcess, String>) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NursingProcess myOldNP = em.merge(np); em.lock(myOldNP, LockModeType.OPTIMISTIC); myOldNP.setUserOFF(em.merge(OPDE.getLogin().getUser())); myOldNP.setTo(new Date()); NPControl lastValidation = em.merge(new NPControl(result.getSecond(), myOldNP)); lastValidation.setLastValidation(true); myOldNP.getEvaluations().add(lastValidation); em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myOldNP.getCategory()).add(myOldNP); Collections.sort(valuecache.get(myOldNP.getCategory())); createCP4(myOldNP.getCategory()); buildPanel(); // GUITools.flashBackground(contenPanelMap.get(myOldNP), 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(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getSuccessMessage(np.getTopic(), "closed")); reloadDisplay(); } } }, true); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(dlg); popup.setOwner(btnStop); popup.removeExcludedComponent(btnStop); popup.setDefaultFocusComponent(dlg); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnStop.setEnabled(!np.isClosed() && numDFNs != 0); pnlMenu.add(btnStop); /*** * ____ _ _ _____ _ _ _ * | __ ) _ _| |_| |_ ___ _ __ | ____|__| (_) |_ * | _ \| | | | __| __/ _ \| '_ \ | _| / _` | | __| * | |_) | |_| | |_| || (_) | | | | | |__| (_| | | |_ * |____/ \__,_|\__|\__\___/|_| |_| |_____\__,_|_|\__| * */ JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.nursingprocess.btnedit.tooltip", SYSConst.icon22edit, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgNursingProcess(np, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NursingProcess mynp = em.merge( ((Pair<NursingProcess, ArrayList<InterventionSchedule>>) o).getFirst()); em.lock(mynp, LockModeType.OPTIMISTIC); // Schedules to delete for (InterventionSchedule is : ((Pair<NursingProcess, ArrayList<InterventionSchedule>>) o) .getSecond()) { em.remove(em.merge(is)); } // No unused DFNs to delete Query delQuery = em.createQuery( "DELETE FROM DFN dfn WHERE dfn.nursingProcess = :nursingprocess "); delQuery.setParameter("nursingprocess", mynp); delQuery.executeUpdate(); // Create new DFNs according to plan DFNTools.generate(em, mynp.getInterventionSchedule(), new LocalDate(), true); em.getTransaction().commit(); boolean reloadSearch = false; for (Commontags ctag : mynp.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(mynp.getCategory()).add(mynp); Collections.sort(valuecache.get(mynp.getCategory())); createCP4(mynp.getCategory()); buildPanel(); GUITools.flashBackground(contenPanelMap.get(mynp), 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(); } // reloadTable(); } } }); } }); btnEdit.setEnabled(!np.isClosed() && numDFNs == 0); pnlMenu.add(btnEdit); } /*** * ____ _ _ ____ _ _ * | __ ) _ _| |_| |_ ___ _ __ | _ \ ___| | ___| |_ ___ * | _ \| | | | __| __/ _ \| '_ \ | | | |/ _ \ |/ _ \ __/ _ \ * | |_) | |_| | |_| || (_) | | | | | |_| | __/ | __/ || __/ * |____/ \__,_|\__|\__\___/|_| |_| |____/ \___|_|\___|\__\___| * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { // => ACL_MATRIX JButton btnDelete = GUITools.createHyperlinkButton("nursingrecords.nursingprocess.btndelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><b>" + np.getTopic() + "</b><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NursingProcess myOldNP = em.merge(np); em.lock(myOldNP, LockModeType.OPTIMISTIC); // DFNs to delete Query delQuery = em.createQuery( "DELETE FROM DFN dfn WHERE dfn.nursingProcess = :nursingprocess "); delQuery.setParameter("nursingprocess", myOldNP); // delQuery.setParameter("status", DFNTools.STATE_OPEN); delQuery.executeUpdate(); em.remove(myOldNP); em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); createCP4(myOldNP.getCategory()); buildPanel(); OPDE.getDisplayManager().addSubMessage( DisplayManager.getSuccessMessage(np.getTopic(), "deleted")); } 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(); } } } }); } }); btnDelete.setEnabled(!np.isClosed() && numDFNs == 0); pnlMenu.add(btnDelete); } /*** * ____ _ _____ _ * | __ )| |_ _ __ | ____|_ ____ _| | * | _ \| __| '_ \| _| \ \ / / _` | | * | |_) | |_| | | | |___ \ V / (_| | | * |____/ \__|_| |_|_____| \_/ \__,_|_| * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { final JButton btnEval = GUITools.createHyperlinkButton("nursingrecords.nursingprocess.btneval.tooltip", SYSConst.icon22redo, null); btnEval.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEval.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); JPanel dlg = new PnlEval(np, new Closure() { @Override public void execute(Object o) { if (o != null) { popup.hidePopup(); Pair<NursingProcess, String> result = (Pair<NursingProcess, String>) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NursingProcess evaluatedNP = em.merge(result.getFirst()); em.lock(evaluatedNP, LockModeType.OPTIMISTIC); NPControl newEvaluation = em .merge(new NPControl(result.getSecond(), evaluatedNP)); evaluatedNP.getEvaluations().add(newEvaluation); em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(evaluatedNP.getCategory()).add(evaluatedNP); Collections.sort(valuecache.get(evaluatedNP.getCategory())); createCP4(evaluatedNP.getCategory()); buildPanel(); GUITools.flashBackground(contenPanelMap.get(evaluatedNP), 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(); } OPDE.getDisplayManager().addSubMessage(new DisplayMessage( SYSTools.xx("nursingrecords.nursingprocess.success.neweval"))); reloadDisplay(); } } }, false); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(dlg); popup.setOwner(btnEval); popup.removeExcludedComponent(btnEval); popup.setDefaultFocusComponent(dlg); GUITools.showPopup(popup, SwingConstants.NORTH_WEST); } }); btnEval.setEnabled(!np.isClosed()); pnlMenu.add(btnEval); /*** * _ _ _____ _ ____ * | |__ | |_ _ _|_ _|/ \ / ___|___ * | '_ \| __| '_ \| | / _ \| | _/ __| * | |_) | |_| | | | |/ ___ \ |_| \__ \ * |_.__/ \__|_| |_|_/_/ \_\____|___/ * */ final JButton btnTAGs = GUITools.createHyperlinkButton("misc.msg.editTags", SYSConst.icon22tagPurple, null); btnTAGs.setAlignmentX(Component.RIGHT_ALIGNMENT); btnTAGs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); final JPanel pnl = new JPanel(new BorderLayout(5, 5)); final PnlCommonTags pnlCommonTags = new PnlCommonTags(np.getCommontags(), true, 3); pnl.add(new JScrollPane(pnlCommonTags), BorderLayout.CENTER); JButton btnApply = new JButton(SYSConst.icon22apply); pnl.add(btnApply, BorderLayout.SOUTH); btnApply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NursingProcess myNP = em.merge(np); em.lock(myNP, LockModeType.OPTIMISTIC_FORCE_INCREMENT); myNP.getCommontags().clear(); for (Commontags commontag : pnlCommonTags.getListSelectedTags()) { myNP.getCommontags().add(em.merge(commontag)); } em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myNP.getCategory()).add(myNP); Collections.sort(valuecache.get(myNP.getCategory())); boolean reloadSearch = false; for (Commontags ctag : myNP.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } createCP4(myNP.getCategory()); buildPanel(); GUITools.flashBackground(contenPanelMap.get(myNP), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnTAGs); popup.removeExcludedComponent(btnTAGs); pnl.setPreferredSize(new Dimension(350, 150)); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnTAGs.setEnabled(!np.isClosed()); pnlMenu.add(btnTAGs); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = np.isClosed() ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final NursingProcess myNP = em.find(NursingProcess.class, np.getID()); em.close(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myNP.getCategory()).add(myNP); Collections.sort(valuecache.get(myNP.getCategory())); createCP4(myNP.getCategory()); buildPanel(); } }; new DlgFiles(np, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(np, 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); final NursingProcess myNP = em.merge(np); em.lock(myNP, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSNP2PROCESS> attached = new ArrayList<SYSNP2PROCESS>( myNP.getAttachedQProcessConnections()); for (SYSNP2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getNursingProcess().getAttachedQProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myNP.getTitle() + " ID: " + myNP.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(myNP)) { QProcess myQProcess = em.merge(qProcess); SYSNP2PROCESS myLinkObject = em.merge(new SYSNP2PROCESS(myQProcess, myNP)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myNP.getTitle() + " ID: " + myNP.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedNursingProcessesConnections().add(myLinkObject); myNP.getAttachedQProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myNP.getCategory()).add(myNP); Collections.sort(valuecache.get(myNP.getCategory())); createCP4(myNP.getCategory()); 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(); } else { reloadDisplay(); } } 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(!np.isClosed()); pnlMenu.add(btnProcess); } return pnlMenu; }
From source file:op.care.prescription.PnlPrescription.java
private java.util.List<Component> addKey() { java.util.List<Component> list = new ArrayList<Component>(); list.add(new JSeparator()); list.add(new JLabel(SYSTools.xx("misc.msg.key"))); list.add(new JLabel(SYSTools.xx("nursingrecords.prescription.keydescription1"), SYSConst.icon22stopSign, SwingConstants.LEADING)); // if (resident.isCalcMediUPR1()) { list.add(new JLabel(SYSTools.xx("nursingrecords.prescription.keydescription2"), SYSConst.icon22ledYellowOn, SwingConstants.LEADING)); list.add(new JLabel(SYSTools.xx("nursingrecords.prescription.keydescription3"), SYSConst.icon22ledRedOn, SwingConstants.LEADING)); list.add(new JLabel(SYSTools.xx("nursingrecords.prescription.keydescription4"), SYSConst.icon22ledOrangeOn, SwingConstants.LEADING)); // }/*from ww w . j a v a 2 s.c om*/ return list; }
From source file:op.care.prescription.PnlPrescription.java
private JPanel getMenu(final Prescription prescription) { JPanel pnlMenu = new JPanel(new VerticalLayout()); long numBHPs = BHPTools.getConfirmedBHPs(prescription); final MedInventory inventory = prescription.shouldBeCalculated() ? TradeFormTools.getInventory4TradeForm(prescription.getResident(), prescription.getTradeForm()) : null;/*from w w w. j a va 2s. c o m*/ final MedStock stockInUse = MedStockTools.getStockInUse(inventory); // checked for acls if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /*** * ____ _ * / ___| |__ __ _ _ __ __ _ ___ * | | | '_ \ / _` | '_ \ / _` |/ _ \ * | |___| | | | (_| | | | | (_| | __/ * \____|_| |_|\__,_|_| |_|\__, |\___| * |___/ */ final JButton btnChange = GUITools.createHyperlinkButton( "nursingrecords.prescription.btnChange.tooltip", SYSConst.icon22playerPlay, null); btnChange.setAlignmentX(Component.RIGHT_ALIGNMENT); btnChange.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgRegular(prescription.clone(), DlgRegular.MODE_CHANGE, new Closure() { @Override public void execute(Object o) { if (o != null) { Pair<Prescription, java.util.List<PrescriptionSchedule>> returnPackage = (Pair<Prescription, List<PrescriptionSchedule>>) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); // Fetch the new prescription from the PAIR Prescription newPrescription = em.merge(returnPackage.getFirst()); Prescription oldPrescription = em.merge(prescription); em.lock(oldPrescription, LockModeType.OPTIMISTIC); // First close the old prescription DateTime now = new DateTime(); oldPrescription.setTo(now.toDate()); oldPrescription.setUserOFF(em.merge(OPDE.getLogin().getUser())); oldPrescription.setDocOFF(newPrescription.getDocON() == null ? null : em.merge(newPrescription.getDocON())); oldPrescription.setHospitalOFF(newPrescription.getHospitalON() == null ? null : em.merge(newPrescription.getHospitalON())); // the new prescription starts 1 second after the old one closes newPrescription.setFrom(now.plusSeconds(1).toDate()); // create new BHPs according to the prescription BHPTools.generate(em, newPrescription.getPrescriptionSchedule(), new LocalDate(), true); em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(oldPrescription); lstPrescriptions.add(newPrescription); Collections.sort(lstPrescriptions); // Refresh Display createCP4(oldPrescription); final CollapsiblePane myNewCP = createCP4(newPrescription); buildPanel(); GUITools.flashBackground(myNewCP, 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(); } // buildPanel(); } } }); } }); btnChange.setEnabled(!prescription.isClosed() && !prescription.isOnDemand() && numBHPs != 0); pnlMenu.add(btnChange); /*** * ____ _ * / ___|| |_ ___ _ __ * \___ \| __/ _ \| '_ \ * ___) | || (_) | |_) | * |____/ \__\___/| .__/ * |_| */ final JButton btnStop = GUITools.createHyperlinkButton("nursingrecords.prescription.btnStop.tooltip", SYSConst.icon22playerStop, null); btnStop.setAlignmentX(Component.RIGHT_ALIGNMENT); btnStop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgDiscontinue(prescription, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Prescription myPrescription = (Prescription) em.merge(o); em.lock(myPrescription.getResident(), LockModeType.OPTIMISTIC); em.lock(myPrescription, LockModeType.OPTIMISTIC); myPrescription.setTo(new Date()); em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GUITools.scroll2show(jspPrescription, myCP.getLocation().y - 100, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(myCP, 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) { em.getTransaction().rollback(); OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnStop.setEnabled(!prescription.isClosed()); // && numBHPs != 0 pnlMenu.add(btnStop); /*** * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__/ * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.prescription.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (prescription.isOnDemand()) { new DlgOnDemand(prescription, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); Prescription myPrescription = em.merge((Prescription) o); em.lock(myPrescription, LockModeType.OPTIMISTIC); Query queryDELBHP = em.createQuery( "DELETE FROM BHP bhp WHERE bhp.prescription = :prescription"); queryDELBHP.setParameter("prescription", myPrescription); queryDELBHP.executeUpdate(); em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myPrescription.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GUITools.scroll2show(jspPrescription, myCP.getLocation().y - 100, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(myCP, 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(); } // buildPanel(); } } }); } else { new DlgRegular(prescription, DlgRegular.MODE_EDIT, new Closure() { @Override public void execute(Object o) { if (o != null) { Pair<Prescription, java.util.List<PrescriptionSchedule>> returnPackage = (Pair<Prescription, List<PrescriptionSchedule>>) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); Prescription myPrescription = em.merge(returnPackage.getFirst()); em.lock(myPrescription, LockModeType.OPTIMISTIC); // delete whats not in the new prescription anymore for (PrescriptionSchedule schedule : returnPackage.getSecond()) { em.remove(em.merge(schedule)); } Query queryDELBHP = em.createQuery( "DELETE FROM BHP bhp WHERE bhp.prescription = :prescription"); queryDELBHP.setParameter("prescription", myPrescription); queryDELBHP.executeUpdate(); BHPTools.generate(em, myPrescription.getPrescriptionSchedule(), new LocalDate(), true); em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myPrescription.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GUITools.scroll2show(jspPrescription, myCP.getLocation().y - 100, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(myCP, 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(); } // buildPanel(); } } }); } } }); btnEdit.setEnabled(!prescription.isClosed() && numBHPs == 0); pnlMenu.add(btnEdit); /*** * _ _ _____ _ ____ * | |__ | |_ _ _|_ _|/ \ / ___|___ * | '_ \| __| '_ \| | / _ \| | _/ __| * | |_) | |_| | | | |/ ___ \ |_| \__ \ * |_.__/ \__|_| |_|_/_/ \_\____|___/ * */ final JButton btnTAGs = GUITools.createHyperlinkButton("misc.msg.editTags", SYSConst.icon22tagPurple, null); btnTAGs.setAlignmentX(Component.RIGHT_ALIGNMENT); btnTAGs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); final JPanel pnl = new JPanel(new BorderLayout(5, 5)); final PnlCommonTags pnlCommonTags = new PnlCommonTags(prescription.getCommontags(), true, 3); pnl.add(new JScrollPane(pnlCommonTags), BorderLayout.CENTER); JButton btnApply = new JButton(SYSConst.icon22apply); pnl.add(btnApply, BorderLayout.SOUTH); btnApply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); Prescription myPrescription = em.merge(prescription); em.lock(myPrescription, LockModeType.OPTIMISTIC_FORCE_INCREMENT); // merging is important, hence no addAll() for this one ArrayList<Commontags> listTags2Add = new ArrayList<Commontags>(); for (Commontags tag2add : pnlCommonTags.getListSelectedTags()) { listTags2Add.add(em.merge(tag2add)); } // Annotations need to be added, tooo // these are the remaining tags, that need to be disconnected myPrescription.getCommontags().addAll(listTags2Add); ArrayList<Commontags> listTags2Remove = new ArrayList<Commontags>( myPrescription.getCommontags()); listTags2Remove.removeAll(listTags2Add); myPrescription.getCommontags().removeAll(listTags2Remove); ArrayList<ResInfo> annotations2remove = new ArrayList<ResInfo>(); for (Commontags commontag : listTags2Remove) { for (ResInfo annotation : myPrescription.getAnnotations()) { if (CommontagsTools.getTagForAnnotation(annotation).equals(commontag)) { annotations2remove.add(annotation); em.remove(annotation); } } } myPrescription.getAnnotations().removeAll(annotations2remove); em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myPrescription.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GUITools.scroll2show(jspPrescription, myCP.getLocation().y - 100, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(myCP, Color.YELLOW, 2); } }); } }); } catch (OptimisticLockException ole) { OPDE.warn(ole); OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnTAGs); popup.removeExcludedComponent(btnTAGs); pnl.setPreferredSize(new Dimension(350, 150)); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnTAGs.setEnabled(!prescription.isClosed()); pnlMenu.add(btnTAGs); /*** * _ _ * __ _ _ __ _ __ ___ | |_ __ _| |_ ___ * / _` | '_ \| '_ \ / _ \| __/ _` | __/ _ \ * | (_| | | | | | | | (_) | || (_| | || __/ * \__,_|_| |_|_| |_|\___/ \__\__,_|\__\___| * */ final JButton btnAnnotation = GUITools.createHyperlinkButton( "nursingrecords.prescription.edit.annotations", SYSConst.icon22annotate, null); btnAnnotation.setAlignmentX(Component.RIGHT_ALIGNMENT); btnAnnotation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DlgAnnotations dlg = new DlgAnnotations(prescription, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); ResInfo annotation = em.merge((ResInfo) o); annotation.setHtml(ResInfoTools.getContentAsHTML(annotation)); Prescription myPrescription = em.merge(prescription); em.lock(myPrescription, LockModeType.OPTIMISTIC_FORCE_INCREMENT); myPrescription.getAnnotations().remove(annotation); // just in case, it was an EDIT rather than an ADD myPrescription.getAnnotations().add(annotation); em.lock(annotation, LockModeType.OPTIMISTIC); em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GUITools.scroll2show(jspPrescription, myCP.getLocation().y - 100, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(myCP, Color.YELLOW, 2); } }); } }); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); OPDE.debug(lstPrescriptions); dlg.setVisible(true); } }); btnAnnotation.setEnabled(!prescription.isClosed() && prescription.hasMed() && PrescriptionTools.isAnnotationNecessary(prescription)); pnlMenu.add(btnAnnotation); } // checked for acls if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton( "nursingrecords.prescription.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/>" + PrescriptionTools.toPrettyString(prescription) + "</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(); Prescription myverordnung = em.merge(prescription); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); em.lock(myverordnung, LockModeType.OPTIMISTIC); em.remove(myverordnung); Query delQuery = em.createQuery( "DELETE FROM BHP b WHERE b.prescription = :prescription"); delQuery.setParameter("prescription", myverordnung); delQuery.executeUpdate(); em.getTransaction().commit(); OPDE.getDisplayManager().addSubMessage( new DisplayMessage(SYSTools.xx("misc.msg.Deleted") + ": " + PrescriptionTools.toPrettyString(myverordnung))); lstPrescriptions.remove(prescription); 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) { em.getTransaction().rollback(); OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelete.setEnabled(numBHPs == 0 && !prescription.isClosed()); pnlMenu.add(btnDelete); } // checked for acls if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { pnlMenu.add(new JSeparator()); /*** * ____ _ _____ _ ____ _ * / ___| ___| |_| ____|_ ___ __ (_)_ __ _ _| _ \ __ _| |_ ___ * \___ \ / _ \ __| _| \ \/ / '_ \| | '__| | | | | | |/ _` | __/ _ \ * ___) | __/ |_| |___ > <| |_) | | | | |_| | |_| | (_| | || __/ * |____/ \___|\__|_____/_/\_\ .__/|_|_| \__, |____/ \__,_|\__\___| * |_| |___/ */ final JButton btnExpiry = GUITools.createHyperlinkButton( "nursingrecords.inventory.tooltip.btnSetExpiry", SYSConst.icon22gotoEnd, null); btnExpiry.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); popup.setMovable(false); PnlExpiry pnlExpiry = new PnlExpiry(stockInUse.getExpires(), SYSTools.xx("nursingrecords.inventory.pnlExpiry.title") + ": " + stockInUse.getID(), new Closure() { @Override public void execute(Object o) { popup.hidePopup(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStock myStock = em.merge(stockInUse); em.lock(em.merge(myStock.getInventory().getResident()), LockModeType.OPTIMISTIC); em.lock(em.merge(myStock.getInventory()), LockModeType.OPTIMISTIC); myStock.setExpires((Date) o); em.getTransaction().commit(); createCP4(prescription); 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(); } } }); popup.setOwner(btnExpiry); popup.setContentPane(pnlExpiry); popup.removeExcludedComponent(pnlExpiry); popup.setDefaultFocusComponent(pnlExpiry); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnExpiry.setEnabled(inventory != null && stockInUse != null); pnlMenu.add(btnExpiry); /*** * ____ _ ____ _ _ * / ___| | ___ ___ ___/ ___|| |_ ___ ___| | __ * | | | |/ _ \/ __|/ _ \___ \| __/ _ \ / __| |/ / * | |___| | (_) \__ \ __/___) | || (_) | (__| < * \____|_|\___/|___/\___|____/ \__\___/ \___|_|\_\ * */ final JButton btnCloseStock = GUITools.createHyperlinkButton( "nursingrecords.inventory.stock.btnout.tooltip", SYSConst.icon22ledRedOn, null); btnCloseStock.setAlignmentX(Component.RIGHT_ALIGNMENT); btnCloseStock.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgCloseStock(stockInUse, new Closure() { @Override public void execute(Object o) { if (o != null) { // The prescription itself is not changed, but the stock in question. // this information is requested by a single DB request every time // the CP is created for that particular prescription. // A new call to the createCP4 method will reuse the old // CollapsiblePane and set a new TextContent to it. // Now with the MedStock information. // If this current stock was valid until the end of package // it needs to be reread here. if (prescription.isUntilEndOfPackage()) { EntityManager em = OPDE.createEM(); Prescription myPrescription = em.merge(prescription); em.refresh(myPrescription); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); } else { final CollapsiblePane myCP = createCP4(prescription); GUITools.flashBackground(myCP, Color.YELLOW, 2); } buildPanel(); } } }); } }); btnCloseStock.setEnabled(inventory != null && stockInUse != null && !stockInUse.isToBeClosedSoon()); pnlMenu.add(btnCloseStock); /*** * ___ ____ _ _ * / _ \ _ __ ___ _ __ / ___|| |_ ___ ___| | __ * | | | | '_ \ / _ \ '_ \\___ \| __/ _ \ / __| |/ / * | |_| | |_) | __/ | | |___) | || (_) | (__| < * \___/| .__/ \___|_| |_|____/ \__\___/ \___|_|\_\ * |_| */ final JButton btnOpenStock = GUITools.createHyperlinkButton( "nursingrecords.inventory.stock.btnopen.tooltip", SYSConst.icon22ledGreenOn, null); btnOpenStock.setAlignmentX(Component.RIGHT_ALIGNMENT); btnOpenStock.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgOpenStock(prescription.getTradeForm(), resident, new Closure() { @Override public void execute(Object o) { if (o != null) { final CollapsiblePane myCP = createCP4(prescription); GUITools.flashBackground(myCP, Color.YELLOW, 2); } } }); } }); btnOpenStock.setEnabled(inventory != null && stockInUse == null && !prescription.isClosed()); pnlMenu.add(btnOpenStock); /*** * ____ _ _ _____ __ __ _ * / ___|(_) __| | ___| ____|/ _|/ _| ___ ___| |_ ___ * \___ \| |/ _` |/ _ \ _| | |_| |_ / _ \/ __| __/ __| * ___) | | (_| | __/ |___| _| _| __/ (__| |_\__ \ * |____/|_|\__,_|\___|_____|_| |_| \___|\___|\__|___/ * */ final JButton btnEditSideEffects = GUITools.createHyperlinkButton( "nursingrecords.prescription.edit.sideeffects", SYSConst.icon22sideeffects, null); btnEditSideEffects.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEditSideEffects.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSConst.icon48sideeffects, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedProducts myProduct = em.merge(prescription.getTradeForm().getMedProduct()); myProduct.setSideEffects(o.toString().trim()); for (TradeForm tf : myProduct.getTradeforms()) { em.lock(em.merge(tf), LockModeType.OPTIMISTIC_FORCE_INCREMENT); for (MedPackage mp : tf.getPackages()) { em.lock(em.merge(mp), LockModeType.OPTIMISTIC_FORCE_INCREMENT); } } em.lock(myProduct, LockModeType.OPTIMISTIC); em.getTransaction().commit(); reload(); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }, "nursingrecords.prescription.edit.sideeffects", prescription.getTradeForm().getMedProduct().getSideEffects(), null); } }); // checked for acls btnEditSideEffects.setEnabled(prescription.hasMed() && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, "opde.medication")); pnlMenu.add(btnEditSideEffects); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure closure = null; if (!prescription.isClosed()) { closure = new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final Prescription myPrescription = em.find(Prescription.class, prescription.getID()); em.close(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); GUITools.flashBackground(myCP, Color.YELLOW, 2); } }; } btnFiles.setEnabled(OPDE.isFTPworking()); new DlgFiles(prescription, closure); } }); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(prescription, 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); Prescription myPrescription = em.merge(prescription); em.lock(myPrescription, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSPRE2PROCESS> attached = new ArrayList<SYSPRE2PROCESS>( prescription.getAttachedProcessConnections()); for (SYSPRE2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getPrescription().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myPrescription.getTitle() + " ID: " + myPrescription.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myPrescription)) { QProcess myQProcess = em.merge(qProcess); SYSPRE2PROCESS myLinkObject = em .merge(new SYSPRE2PROCESS(myQProcess, myPrescription)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myPrescription.getTitle() + " ID: " + myPrescription.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedPrescriptionConnections().add(myLinkObject); myPrescription.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); GUITools.flashBackground(myCP, 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 (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(!prescription.isClosed()); // if (!prescription.getAttachedProcessConnections().isEmpty()) { // JLabel lblNum = new JLabel(Integer.toString(prescription.getAttachedProcessConnections().size()), SYSConst.icon16redStar, SwingConstants.CENTER); // lblNum.setFont(SYSConst.ARIAL10BOLD); // lblNum.setForeground(Color.YELLOW); // lblNum.setHorizontalTextPosition(SwingConstants.CENTER); // DefaultOverlayable overlayableBtn = new DefaultOverlayable(btnProcess, lblNum, DefaultOverlayable.SOUTH_EAST); // overlayableBtn.setOpaque(false); // pnlMenu.add(overlayableBtn); // } else { pnlMenu.add(btnProcess); // } } return pnlMenu; }
From source file:op.care.reports.PnlReport.java
private JPanel getMenu(final NReport nreport) { JPanel pnlMenu = new JPanel(new VerticalLayout()); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /***//ww w. j a v a 2 s. com * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.reports.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgReport(nreport.clone(), new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport newReport = em.merge((NReport) o); NReport oldReport = em.merge(nreport); em.lock(oldReport, LockModeType.OPTIMISTIC); newReport.setReplacementFor(oldReport); for (SYSNR2FILE oldAssignment : oldReport.getAttachedFilesConnections()) { em.remove(oldAssignment); } oldReport.getAttachedFilesConnections().clear(); for (SYSNR2PROCESS oldAssignment : oldReport.getAttachedQProcessConnections()) { em.remove(oldAssignment); } oldReport.getAttachedQProcessConnections().clear(); oldReport.setEditedBy(em.merge(OPDE.getLogin().getUser())); oldReport.setEditDate(new Date()); oldReport.setReplacedBy(newReport); em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance() .format(newReport.getPit()); final String keyOldDay = DateFormat.getDateInstance() .format(oldReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); contentmap.remove(keyOldDay); } synchronized (linemap) { linemap.remove(oldReport); } synchronized (valuecache) { valuecache.get(keyOldDay).remove(nreport); valuecache.get(keyOldDay).add(oldReport); Collections.sort(valuecache.get(keyOldDay)); if (valuecache.containsKey(keyNewDay)) { valuecache.get(keyNewDay).add(newReport); Collections.sort(valuecache.get(keyNewDay)); } } synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : newReport.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } if (minmax.isAfter(new DateTime(newReport.getPit()))) { minmax.setStart(new DateTime(newReport.getPit())); } if (minmax.isBefore(new DateTime(newReport.getPit()))) { minmax.setEnd(new DateTime(newReport.getPit())); } createCP4Day(new LocalDate(oldReport.getPit())); createCP4Day(new LocalDate(newReport.getPit())); buildPanel(); GUITools.scroll2show(jspReports, cpMap.get(keyNewDay), cpsReports, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(linemap.get(newReport), 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 (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnEdit.setEnabled(NReportTools.isChangeable(nreport)); pnlMenu.add(btnEdit); /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton("nursingrecords.reports.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.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( nreport.getPit()) + "</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(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport delReport = em.merge(nreport); em.lock(delReport, LockModeType.OPTIMISTIC); delReport.setDeletedBy(em.merge(OPDE.getLogin().getUser())); for (SYSNR2FILE oldAssignment : delReport .getAttachedFilesConnections()) { em.remove(oldAssignment); } delReport.getAttachedFilesConnections().clear(); for (SYSNR2PROCESS oldAssignment : delReport .getAttachedQProcessConnections()) { em.remove(oldAssignment); } delReport.getAttachedQProcessConnections().clear(); em.getTransaction().commit(); final String keyDay = DateFormat.getDateInstance() .format(delReport.getPit()); synchronized (contentmap) { contentmap.remove(keyDay); } synchronized (linemap) { linemap.remove(delReport); } synchronized (valuecache) { valuecache.get(keyDay).remove(nreport); valuecache.get(keyDay).add(delReport); Collections.sort(valuecache.get(keyDay)); } createCP4Day(new LocalDate(delReport.getPit())); buildPanel(); if (tbShowReplaced.isSelected()) { GUITools.flashBackground(linemap.get(delReport), 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 (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelete.setEnabled(NReportTools.isChangeable(nreport)); pnlMenu.add(btnDelete); /*** * _ _ _____ _ ____ * | |__ | |_ _ _|_ _|/ \ / ___|___ * | '_ \| __| '_ \| | / _ \| | _/ __| * | |_) | |_| | | | |/ ___ \ |_| \__ \ * |_.__/ \__|_| |_|_/_/ \_\____|___/ * */ final JButton btnTAGs = GUITools.createHyperlinkButton("misc.msg.editTags", SYSConst.icon22tagPurple, null); btnTAGs.setAlignmentX(Component.RIGHT_ALIGNMENT); btnTAGs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); final JPanel pnl = new JPanel(new BorderLayout(5, 5)); final PnlCommonTags pnlCommonTags = new PnlCommonTags(nreport.getCommontags(), true, 3); pnl.add(new JScrollPane(pnlCommonTags), BorderLayout.CENTER); JButton btnApply = new JButton(SYSConst.icon22apply); pnl.add(btnApply, BorderLayout.SOUTH); btnApply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT); myReport.getCommontags().clear(); for (Commontags commontag : pnlCommonTags.getListSelectedTags()) { myReport.getCommontags().add(em.merge(commontag)); } 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)); } synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myReport.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); 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 (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnTAGs); popup.removeExcludedComponent(btnTAGs); pnl.setPreferredSize(new Dimension(350, 150)); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnTAGs.setEnabled(NReportTools.isChangeable(nreport) && NReportTools.isMine(nreport)); pnlMenu.add(btnTAGs); /*** * _ _ __ __ _ _ * | |__ | |_ _ __ | \/ (_)_ __ _ _| |_ ___ ___ * | '_ \| __| '_ \| |\/| | | '_ \| | | | __/ _ \/ __| * | |_) | |_| | | | | | | | | | | |_| | || __/\__ \ * |_.__/ \__|_| |_|_| |_|_|_| |_|\__,_|\__\___||___/ * */ final JButton btnMinutes = GUITools.createHyperlinkButton("nursingrecords.reports.btnminutes.tooltip", SYSConst.icon22clock, null); btnMinutes.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMinutes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JPopupMenu menu = SYSCalendar.getMinutesMenu( new int[] { 1, 2, 3, 4, 5, 10, 15, 20, 30, 45, 60, 120, 240, 360 }, new Closure() { @Override public void execute(Object o) { 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); myReport.setMinutes((Integer) o); myReport.setEditDate(new Date()); 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 (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); menu.show(btnMinutes, 0, btnMinutes.getHeight()); } }); btnMinutes.setEnabled(!nreport.isObsolete() && NReportTools.isMine(nreport)); pnlMenu.add(btnMinutes); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = nreport.isObsolete() ? 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()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); 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(); } } }); } }); pnlMenu.add(btnProcess); } return pnlMenu; }
From source file:op.care.supervisor.PnlHandover.java
private java.util.List<Component> addKey() { java.util.List<Component> list = new ArrayList<Component>(); list.add(new JSeparator()); list.add(new JLabel(SYSTools.xx("misc.msg.key"))); list.add(new JLabel(SYSTools.xx("nursingrecords.handover.keydescription1"), SYSConst.icon22ledRedOn, SwingConstants.LEADING)); list.add(new JLabel(SYSTools.xx("nursingrecords.handover.keydescription2"), SYSConst.icon22ledGreenOn, SwingConstants.LEADING)); return list;//from ww w . ja va 2 s . co m }
From source file:op.care.values.PnlValues.java
private JPanel getMenu(final ResValue resValue) { final ResValueTypes vtype = resValue.getType(); JPanel pnlMenu = new JPanel(new VerticalLayout()); boolean doesNotBelongToResInfos = ResInfoTools.getInfosFor(resValue).isEmpty(); if (doesNotBelongToResInfos && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /***//from ww w . j a v a 2 s . co m * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.vitalparameters.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgValue(resValue.clone(), DlgValue.MODE_EDIT, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final ResValue newValue = em.merge((ResValue) o); ResValue oldValue = em.merge(resValue); em.lock(oldValue, LockModeType.OPTIMISTIC); newValue.setReplacementFor(oldValue); for (SYSVAL2FILE oldAssignment : oldValue.getAttachedFilesConnections()) { em.remove(oldAssignment); } oldValue.getAttachedFilesConnections().clear(); for (SYSVAL2PROCESS oldAssignment : oldValue.getAttachedProcessConnections()) { em.remove(oldAssignment); } oldValue.getAttachedProcessConnections().clear(); oldValue.setEditedBy(em.merge(OPDE.getLogin().getUser())); oldValue.setEditDate(new Date()); oldValue.setReplacedBy(newValue); em.getTransaction().commit(); DateTime dt = new DateTime(newValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(oldValue); mapType2Values.get(key).add(newValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).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(); } } } }); } }); btnEdit.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnEdit); /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton( "nursingrecords.vitalparameters.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance().format(resValue.getPit()) + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); ResValue myValue = em.merge(resValue); myValue.setDeletedBy(em.merge(OPDE.getLogin().getUser())); for (SYSVAL2FILE file : myValue.getAttachedFilesConnections()) { em.remove(file); } myValue.getAttachedFilesConnections().clear(); // Vorgangszuordnungen entfernen for (SYSVAL2PROCESS connObj : myValue.getAttachedProcessConnections()) { em.remove(connObj); } myValue.getAttachedProcessConnections().clear(); myValue.getAttachedProcesses().clear(); em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).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(); } } } }); } }); btnDelete.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnDelete); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } buildPanel(); } }); } }); btnFiles.setEnabled(!resValue.isObsolete() && OPDE.isFTPworking()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, 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); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getResValue().getAttachedProcessConnections().remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.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(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); buildPanel(); //GUITools.flashBackground(contentmap.get(keyMonth), 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 (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(!resValue.isObsolete()); pnlMenu.add(btnProcess); } return pnlMenu; }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
private void initComponents() { URL icon;/*from w ww . java 2s . c om*/ icon = getClass().getResource("/org/bigwiv/blastgraph/icons/icon.png"); this.setIconImage(Toolkit.getDefaultToolkit().createImage(icon)); JComponent pane; pane = (JComponent) getContentPane(); // ====================Menu Setting======================= newItem = new JMenuItem("New From Blast"); newItem.setMnemonic('n'); newItem.addActionListener(commandActionListener); openItem = new JMenuItem("Open"); openItem.setMnemonic('o'); openItem.addActionListener(commandActionListener); appendGraphItem = new JMenuItem("Append Graph"); appendGraphItem.setMnemonic('a'); appendGraphItem.addActionListener(commandActionListener); saveItem = new JMenuItem("Save"); saveItem.setMnemonic('s'); saveItem.addActionListener(commandActionListener); saveAsGraphItem = new JMenuItem("Save As"); saveAsGraphItem.addActionListener(commandActionListener); exportGraphItem = new JMenuItem("Export"); exportGraphItem.addActionListener(commandActionListener); saveCurGraphItem = new JMenuItem("Save Current Graph"); saveCurGraphItem.addActionListener(commandActionListener); saveCurImgItem = new JMenuItem("Save Image"); saveCurImgItem.addActionListener(commandActionListener); saveAllVertexAttrItem = new JMenuItem("Save Vertex Attribute"); saveAllVertexAttrItem.addActionListener(commandActionListener); saveCurVertexAttrItem = new JMenuItem("Save Vertex Attribute"); saveCurVertexAttrItem.addActionListener(commandActionListener); saveAsMenu = new JMenu("Save As"); saveAsMenu.add(saveAsGraphItem); saveAsMenu.add(saveAllVertexAttrItem); saveCurGraphMenu = new JMenu("Save Current Graph"); saveCurGraphMenu.add(saveCurGraphItem); saveCurGraphMenu.add(saveCurImgItem); saveCurGraphMenu.add(saveCurVertexAttrItem); printItem = new JMenuItem("Print..."); printItem.setMnemonic('p'); printItem.addActionListener(commandActionListener); importVertexAttrItem = new JMenuItem("Import Vertex Attribute"); importVertexAttrItem.addActionListener(commandActionListener); closeItem = new JMenuItem("Close"); closeItem.setMnemonic('c'); closeItem.addActionListener(commandActionListener); exitItem = new JMenuItem("Exit"); exitItem.setMnemonic('x'); exitItem.addActionListener(commandActionListener); fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(newItem); fileMenu.add(openItem); fileMenu.add(appendGraphItem); fileMenu.add(new JSeparator()); fileMenu.add(closeItem); fileMenu.add(new JSeparator()); fileMenu.add(saveItem); fileMenu.add(saveAsMenu); fileMenu.add(saveCurGraphMenu); fileMenu.add(new JSeparator()); fileMenu.add(printItem); fileMenu.add(new JSeparator()); fileMenu.add(importVertexAttrItem); fileMenu.add(exportGraphItem); fileMenu.add(new JSeparator()); fileMenu.add(exitItem); // edit menu undoItem = new JMenuItem("Undo"); redoItem = new JMenuItem("Redo"); Global.COMMAND_MANAGER.registerUndoRedoItem(undoItem, redoItem); removeSingleItem = new JMenuItem("Remove Single Vertices"); removeSingleItem.addActionListener(commandActionListener); filterItem = new JMenuItem("Filt Graph"); filterItem.addActionListener(commandActionListener); settingItem = new JMenuItem("Setting"); settingItem.addActionListener(commandActionListener); markovClusterItem = new JMenuItem("Markov Cluster"); markovClusterItem.addActionListener(commandActionListener); // genomeNumFiltItem = new JMenuItem("GenomeNum Filt"); // genomeNumFiltItem.addActionListener(commandActionListener); // removeSingleLinkageItem = new JMenuItem("Remove Single Linkage"); // removeSingleLinkageItem.addActionListener(commandActionListener); editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoItem); editMenu.add(redoItem); editMenu.add(filterItem); editMenu.add(markovClusterItem); editMenu.add(removeSingleItem); // editMenu.add(genomeNumFiltItem); // editMenu.add(removeSingleLinkageItem); editMenu.add(settingItem); // Tools Item geneContentItem = new JMenuItem("Gene Content Table"); geneContentItem.addActionListener(commandActionListener); batchSaveItem = new JMenuItem("Batch Save"); batchSaveItem.addActionListener(commandActionListener); mstItem = new JMenuItem("Minimum Spanning Tree"); mstItem.addActionListener(commandActionListener); viewNeighborItem = new JMenuItem("View Neighbor of..."); viewNeighborItem.addActionListener(commandActionListener); // // tempWorkItem = new JMenuItem("Temp Work"); // tempWorkItem.addActionListener(commandActionListener); toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(geneContentItem); toolsMenu.add(viewNeighborItem); toolsMenu.add(mstItem); toolsMenu.add(batchSaveItem); // toolsMenu.add(tempWorkItem); // graph Menu graphMenu = new JMenu("Graph"); previousItem = new JMenuItem("Previous"); previousItem.addActionListener(commandActionListener); nextItem = new JMenuItem("Next"); nextItem.addActionListener(commandActionListener); resortItem = new JMenuItem("Resort graphs"); resortItem.addActionListener(commandActionListener); graphMenu.add(nextItem); graphMenu.add(previousItem); graphMenu.add(resortItem); // help Menu helpContentItem = new JMenuItem("Online Manual"); helpContentItem.addActionListener(commandActionListener); aboutItem = new JMenuItem("About BlastGraph"); aboutItem.addActionListener(commandActionListener); helpMenu = new JMenu("Help"); helpMenu.add(helpContentItem); helpMenu.add(aboutItem); // menu bar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(graphMenu); menuBar.add(toolsMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); // ===================mainPanel Setting=================== GridBagManager.reset(); GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.GRID_BAG.anchor = GridBagConstraints.FIRST_LINE_START; GridBagManager.GRID_BAG.weightx = 0; GridBagManager.GRID_BAG.weighty = 0; GridBagManager.GRID_BAG.insets = new Insets(2, 2, 1, 1); mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); pane.add(mainPanel); hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); hsplitPane.setContinuousLayout(true); hsplitPane.setOneTouchExpandable(true); hsplitPane.setResizeWeight(0.9); // ===================toolBarPanel Setting=================== // graph file toolbar fileToolBar = new JToolBar(); fileToolBar.setRollover(true); newButton = new JButton(); newButton.setBorderPainted(false); newButton.setMnemonic('n'); newButton.setToolTipText("New From Blast"); newButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filenew.png"); // System.out.println(icon); newButton.setIcon(new ImageIcon(icon)); openButton = new JButton(); openButton.setBorderPainted(false); openButton.setMnemonic('o'); openButton.setToolTipText("Open"); openButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileopen.png"); openButton.setIcon(new ImageIcon(icon)); saveButton = new JButton(); saveButton.setBorderPainted(false); saveButton.setMnemonic('s'); saveButton.setToolTipText("Save"); saveButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filesave.png"); saveButton.setIcon(new ImageIcon(icon)); saveCurImgButton = new JButton(); saveCurImgButton.setBorderPainted(false); saveCurImgButton.setToolTipText("Save current image"); saveCurImgButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/saveimage.png"); saveCurImgButton.setIcon(new ImageIcon(icon)); printButton = new JButton(); printButton.setBorderPainted(false); printButton.setToolTipText("Print..."); printButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileprint.png"); printButton.setIcon(new ImageIcon(icon)); fileToolBar.add(newButton); fileToolBar.add(openButton); fileToolBar.add(saveButton); fileToolBar.add(saveCurImgButton); fileToolBar.add(printButton); // graph control toolbar graphToolBar = new JToolBar(); graphToolBar.setRollover(true); previousButton = new JButton(); previousButton.setBorderPainted(false); previousButton.setToolTipText("Previous graph"); previousButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/previous.png"); previousButton.setIcon(new ImageIcon(icon)); indexField = new JTextField(); indexField.setSize(new Dimension(25, 16)); indexField.setMinimumSize(new Dimension(25, 16)); indexField.setPreferredSize(new Dimension(25, 16)); indexField.addKeyListener(keyListener); nextButton = new JButton(); nextButton.setBorderPainted(false); nextButton.setToolTipText("Next graph"); nextButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/next.png"); nextButton.setIcon(new ImageIcon(icon)); filterButton = new JButton(); filterButton.setBorderPainted(false); filterButton.setToolTipText("Filt graph"); filterButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filter.png"); filterButton.setIcon(new ImageIcon(icon)); resortButton = new JButton(); resortButton.setBorderPainted(false); resortButton.setToolTipText("Resort graph"); resortButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/resort.png"); resortButton.setIcon(new ImageIcon(icon)); searchField = new JTextField(); searchField.setSize(new Dimension(60, 16)); searchField.setMinimumSize(new Dimension(60, 16)); searchField.setPreferredSize(new Dimension(60, 16)); searchField.addKeyListener(keyListener); searchButton = new JButton(); searchButton.setBorderPainted(false); searchButton.setToolTipText("Search"); searchButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/search.png"); searchButton.setIcon(new ImageIcon(icon)); graphToolBar.add(filterButton); graphToolBar.add(resortButton); // graphToolBar.add(new JToolBar.Separator()); graphToolBar.add(previousButton); graphToolBar.add(indexField); graphToolBar.add(nextButton); graphToolBar.add(searchField); graphToolBar.add(searchButton); // view toolbar (modebox & layoutbox) viewToolBar = new JToolBar(); viewToolBar.setRollover(true); modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int index = modeBox.getSelectedIndex(); if (index == 2) { int annotCount = annotationToolBar.getComponentCount(); for (int i = 0; i < annotCount; i++) { annotationToolBar.getComponent(i).setEnabled(true); } } else { int annotCount = annotationToolBar.getComponentCount(); for (int i = 0; i < annotCount; i++) { annotationToolBar.getComponent(i).setEnabled(false); } } } }); layoutBox = this.getLayoutComboBox(); viewToolBar.add(modeBox); viewToolBar.add(layoutBox); colorComboBox = new JComboBox(new String[] { "vertex color", "index", "strand", "genomeAcc", "organism" }); viewToolBar.add(colorComboBox); // add additional menu to graphMenu modeMenu = graphMouse.getModeMenu(); modeMenu.setText("Mode"); layoutMenu = getLayoutMenu(); layoutMenu.setText("Layout"); graphMenu.add(modeMenu); graphMenu.add(layoutMenu); // annotation toolbar AnnotationControls<HitVertex, ValueEdge> annotationControls = new AnnotationControls<HitVertex, ValueEdge>( annotatingPlugin); annotationToolBar = annotationControls.getAnnotationsToolBar(); ((JButton) annotationToolBar.getComponent(1)).setBorderPainted(false); ((JToggleButton) annotationToolBar.getComponent(2)).setBorderPainted(false); // add toolbars to toolBarPanel toolBarPanel = new JPanel(); toolBarPanel.setLayout(new ModifiedFlowLayout(ModifiedFlowLayout.LEFT, 0, 0)); toolBarPanel.setBorder(new EtchedBorder()); toolBarPanel.add(fileToolBar); toolBarPanel.add(graphToolBar); toolBarPanel.add(viewToolBar); toolBarPanel.add(annotationToolBar); mainPanel.add(toolBarPanel, BorderLayout.NORTH); mainPanel.add(hsplitPane, BorderLayout.CENTER); // GridBagManager.add(mainPanel, toolBarPanel, 0, 0, 1, 1); // GridBagManager.add(mainPanel, hsplitPane, 0, 1, 1, 1); // mainPanel.add(toolBarPanel, BorderLayout.NORTH); // ===================vsplitPane Setting================= vsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); vsplitPane.setContinuousLayout(true); vsplitPane.setOneTouchExpandable(true); vsplitPane.setResizeWeight(0.9); hsplitPane.setLeftComponent(vsplitPane); // GridBagManager.GRID_BAG.weightx = 0.9; // GridBagManager.GRID_BAG.weighty = 1; // GridBagManager.add(mainPanel, vsplitPane, 0, 1, 1, 2); // mainPanel.add(vsplitPane, BorderLayout.CENTER); // ===================vvPanel Setting=================== vvPanel = new GraphZoomScrollPane(vv); vsplitPane.setTopComponent(vvPanel); // ===================Tab Panel Setting======================= // progressPanel = new ProgressPanel(); verticesTable = new VerticesTable(); verticesTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = verticesTable.rowAtPoint(e.getPoint()); int col = verticesTable.columnAtPoint(e.getPoint()); // System.out.println(row + " " + col); String value = verticesTable.getValueAt(row, col).toString(); // System.out.println(value); if (Global.graph.containsVertex(new HitVertex(value))) { for (int i = 0; i < subSetList.size(); i++) { if (subSetList.get(i).contains(new HitVertex(value))) { curGraph = FilterUtils.createInducedSubgraph(subSetList.get(i), Global.graph); PickedState<HitVertex> pickedVertexState = vv.getPickedVertexState(); // picked is a reference to picked vertices // use a temp set to avoid concurrent modification Set<HitVertex> picked = pickedVertexState.getPicked(); Set<HitVertex> temp = new HashSet<HitVertex>(); for (HitVertex hitVertex : picked) { temp.add(hitVertex); } for (HitVertex hv : temp) { pickedVertexState.pick(hv, false); } pickedVertexState.pick(new HitVertex(value), true); // refreshSubGraphView(); return; } } } } }); verticesTable.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int row = verticesTable.rowAtPoint(e.getPoint()); int col = verticesTable.columnAtPoint(e.getPoint()); String value = verticesTable.getValueAt(row, col).toString(); // System.out.println(value); if (Global.graph.containsVertex(value)) { Cursor normalCursor = new Cursor(Cursor.HAND_CURSOR); setCursor(normalCursor); } else { Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR); setCursor(normalCursor); } } }); verticesPanel = new JPanel(); verticesPanel.setLayout(new GridLayout()); verticesPanel.add(new JScrollPane(verticesTable)); edgesTable = new EdgesTable(); edgesPanel = new JPanel(); edgesPanel.setLayout(new GridLayout()); edgesPanel.add(new JScrollPane(edgesTable)); tabbedPane = new JTabbedPane(); tabbedPane.addTab("Vertices", verticesPanel); tabbedPane.addTab("Edges", edgesPanel); vsplitPane.setBottomComponent(tabbedPane); graphMouse.addPichedChangeListener(verticesTable, edgesTable); // ===================Info Panel Setting=================== infoPanel = new JPanel(new GridBagLayout()); GridBagManager.GRID_BAG.weightx = 0.1; GridBagManager.GRID_BAG.weighty = 1; hsplitPane.setRightComponent(infoPanel); JPanel mainInfoPanel = new JPanel(new GridBagLayout()); mainInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Main Info")); JPanel currentInfoPanel = new JPanel(new GridBagLayout()); currentInfoPanel.setBorder( BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Current Graph")); JPanel selectedInfoPanel = new JPanel(new GridBagLayout()); selectedInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Selected")); JPanel statisticsInfoPanel = new JPanel(new GridBagLayout()); statisticsInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Statistics")); JPanel progressInfoPanel = new JPanel(new GridBagLayout()); progressInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Progress")); GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.HORIZONTAL; GridBagManager.GRID_BAG.weighty = 0; GridBagManager.add(infoPanel, mainInfoPanel, 0, 1, 1, 1); GridBagManager.add(infoPanel, currentInfoPanel, 0, 2, 1, 1); GridBagManager.add(infoPanel, selectedInfoPanel, 0, 3, 1, 1); GridBagManager.GRID_BAG.weighty = 0.5; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(infoPanel, statisticsInfoPanel, 0, 4, 1, 1); GridBagManager.add(infoPanel, progressInfoPanel, 0, 5, 1, 1); // mainInfoPanel { JLabel vertices = new JLabel("Vertices:"); vertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); edgeCountLabel = new JLabel("0"); JLabel subGraphs = new JLabel("SubGraphs:"); subGraphCountLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(mainInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(mainInfoPanel, edges, 0, 1, 1, 1); GridBagManager.add(mainInfoPanel, subGraphs, 0, 2, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(mainInfoPanel, vertexCountLabel, 1, 0, 1, 1); GridBagManager.add(mainInfoPanel, edgeCountLabel, 1, 1, 1, 1); GridBagManager.add(mainInfoPanel, subGraphCountLabel, 1, 2, 1, 1); } // end of mainInfoPanel // currentInfoPanel { JLabel vertices = new JLabel("Vertices:"); currentVertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); currentEdgeCountLabel = new JLabel("0"); JLabel acc = new JLabel("ACC:"); currentAccLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(currentInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(currentInfoPanel, edges, 0, 1, 1, 1); GridBagManager.add(currentInfoPanel, acc, 0, 2, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(currentInfoPanel, currentVertexCountLabel, 1, 0, 1, 1); GridBagManager.add(currentInfoPanel, currentEdgeCountLabel, 1, 1, 1, 1); GridBagManager.add(currentInfoPanel, currentAccLabel, 1, 2, 1, 1); } // end of currentInfoPanel // selectedInfoPanel { JLabel vertices = new JLabel("Vertices:"); selectedVertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); selectedEdgeCountLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(selectedInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(selectedInfoPanel, edges, 0, 1, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(selectedInfoPanel, selectedVertexCountLabel, 1, 0, 1, 1); GridBagManager.add(selectedInfoPanel, selectedEdgeCountLabel, 1, 1, 1, 1); CollectionChangeListener<HitVertex> svListener = new CollectionChangeListener<HitVertex>() { @Override public void onCollectionChange(Set<HitVertex> set) { selectedVertexCountLabel.setText("" + set.size()); } }; CollectionChangeListener<ValueEdge> veListener = new CollectionChangeListener<ValueEdge>() { @Override public void onCollectionChange(Set<ValueEdge> set) { selectedEdgeCountLabel.setText("" + set.size()); } }; graphMouse.addPichedChangeListener(svListener, veListener); } // end of selectedInfoPanel {// statistics Panel GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(statisticsInfoPanel, graphStatisticsPanel, 0, 0, 1, 1); } // statistics Panel {// progressInfoPanel GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(progressInfoPanel, progressPanel, 0, 0, 1, 1); } // progressInfoPanel // set frame size Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); setSize((screen.width * 3) / 4, (screen.height * 9) / 10); setLocation(screen.width / 6, screen.height / 16); refreshUI(false); }
From source file:org.broad.igv.cbio.FilterGeneNetworkUI.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license tabbedPane = new JTabbedPane(); dialogPane = new JPanel(); panel1 = new JPanel(); addRow = new JButton(); contentPane = new JPanel(); scrollPane1 = new JScrollPane(); geneTable = new JTable(); buttonBar = new JPanel(); totNumGenes = new JLabel(); keepIsolated = new JCheckBox(); okButton = new JButton(); refFilter = new JButton(); cancelButton = new JButton(); helpButton = new JButton(); saveButton = new JButton(); thresholds = new JPanel(); contentPanel = new JPanel(); label2 = new JLabel(); label3 = new JLabel(); delInput = new JTextField(); label4 = new JLabel(); expUpInput = new JTextField(); label7 = new JLabel(); expDownInput = new JTextField(); ampInput = new JTextField(); label1 = new JLabel(); mutInput = new JTextField(); label6 = new JLabel(); label8 = new JLabel(); separator1 = new JSeparator(); separator3 = new JSeparator(); separator2 = new JSeparator(); panel2 = new JPanel(); textArea1 = new JTextArea(); //======== this ======== setMinimumSize(new Dimension(600, 22)); setModalityType(Dialog.ModalityType.DOCUMENT_MODAL); Container contentPane2 = getContentPane(); contentPane2.setLayout(new BorderLayout()); //======== tabbedPane ======== {/*from w w w. j a v a2 s .c o m*/ tabbedPane.setPreferredSize(new Dimension(550, 346)); tabbedPane.setMinimumSize(new Dimension(550, 346)); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { tabbedPaneStateChanged(e); } }); //======== dialogPane ======== { dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setMinimumSize(new Dimension(443, 300)); dialogPane.setPreferredSize(new Dimension(443, 300)); dialogPane.setLayout(new GridBagLayout()); ((GridBagLayout) dialogPane.getLayout()).columnWidths = new int[] { 0, 0 }; ((GridBagLayout) dialogPane.getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0 }; ((GridBagLayout) dialogPane.getLayout()).columnWeights = new double[] { 1.0, 1.0E-4 }; ((GridBagLayout) dialogPane.getLayout()).rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0E-4 }; //======== panel1 ======== { panel1.setLayout(new GridBagLayout()); ((GridBagLayout) panel1.getLayout()).columnWidths = new int[] { 0, 0, 0 }; ((GridBagLayout) panel1.getLayout()).rowHeights = new int[] { 0, 0 }; ((GridBagLayout) panel1.getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 }; ((GridBagLayout) panel1.getLayout()).rowWeights = new double[] { 0.0, 1.0E-4 }; //---- addRow ---- addRow.setText("Add Filter"); addRow.setMaximumSize(new Dimension(200, 28)); addRow.setMinimumSize(new Dimension(100, 28)); addRow.setPreferredSize(new Dimension(150, 28)); addRow.setVisible(false); addRow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addRowActionPerformed(e); } }); panel1.add(addRow, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } dialogPane.add(panel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //======== contentPane ======== { contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); } dialogPane.add(contentPane, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //======== scrollPane1 ======== { //---- geneTable ---- geneTable.setAutoCreateRowSorter(true); scrollPane1.setViewportView(geneTable); } dialogPane.add(scrollPane1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //======== buttonBar ======== { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] { 0, 85, 85, 80 }; ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0, 0.0, 0.0 }; //---- totNumGenes ---- totNumGenes.setText("Total Genes: #"); buttonBar.add(totNumGenes, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- keepIsolated ---- keepIsolated.setText("Keep Isolated Genes"); keepIsolated.setVisible(false); buttonBar.add(keepIsolated, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- okButton ---- okButton.setText("View Network"); okButton.setToolTipText("Display the network in a web browser"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okButtonActionPerformed(e); } }); buttonBar.add(okButton, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); //---- refFilter ---- refFilter.setText("Refresh Filter"); refFilter.setVisible(false); refFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refFilterActionPerformed(e); } }); buttonBar.add(refFilter, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- cancelButton ---- cancelButton.setText("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cancelButtonActionPerformed(e); } }); buttonBar.add(cancelButton, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); //---- helpButton ---- helpButton.setText("Help"); helpButton.setVisible(false); buttonBar.add(helpButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); //---- saveButton ---- saveButton.setText("Save Table"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButtonActionPerformed(e); } }); buttonBar.add(saveButton, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); } dialogPane.add(buttonBar, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } tabbedPane.addTab("Filter", dialogPane); //======== thresholds ======== { thresholds.setPreferredSize(new Dimension(550, 196)); thresholds.setMinimumSize(new Dimension(550, 196)); thresholds.setLayout(null); //======== contentPanel ======== { contentPanel.setBorder(new EtchedBorder()); contentPanel.setLayout(null); //---- label2 ---- label2.setText("Amplification:"); label2.setHorizontalAlignment(SwingConstants.RIGHT); label2.setLabelFor(ampInput); label2.setToolTipText("Amplification score, on a log-normalized scale"); label2.setPreferredSize(new Dimension(90, 18)); contentPanel.add(label2); label2.setBounds(140, 96, label2.getPreferredSize().width, 18); //---- label3 ---- label3.setText("Deletion:"); label3.setHorizontalAlignment(SwingConstants.RIGHT); label3.setLabelFor(delInput); label3.setToolTipText("Deletion score, on a log-normalized scale"); label3.setPreferredSize(new Dimension(60, 16)); contentPanel.add(label3); label3.setBounds(360, 96, label3.getPreferredSize().width, 18); //---- delInput ---- delInput.setText("0.7"); delInput.setMinimumSize(new Dimension(34, 28)); delInput.setPreferredSize(new Dimension(45, 28)); delInput.setMaximumSize(new Dimension(50, 2147483647)); contentPanel.add(delInput); delInput.setBounds(new Rectangle(new Point(240, 162), delInput.getPreferredSize())); //---- label4 ---- label4.setText("Up:"); label4.setHorizontalAlignment(SwingConstants.RIGHT); label4.setLabelFor(expUpInput); label4.setToolTipText("Expression score, log-normalized scale"); label4.setPreferredSize(new Dimension(100, 18)); contentPanel.add(label4); label4.setBounds(130, 168, label4.getPreferredSize().width, 18); //---- expUpInput ---- expUpInput.setText("0.1"); expUpInput.setMinimumSize(new Dimension(34, 28)); expUpInput.setPreferredSize(new Dimension(45, 28)); contentPanel.add(expUpInput); expUpInput.setBounds(new Rectangle(new Point(430, 91), expUpInput.getPreferredSize())); //---- label7 ---- label7.setText("Down:"); label7.setHorizontalAlignment(SwingConstants.RIGHT); label7.setLabelFor(expDownInput); label7.setToolTipText("Expression score, log-normalized scale"); label7.setPreferredSize(new Dimension(120, 16)); contentPanel.add(label7); label7.setBounds(300, 168, label7.getPreferredSize().width, 18); //---- expDownInput ---- expDownInput.setText("0.1"); expDownInput.setPreferredSize(new Dimension(45, 28)); expDownInput.setMinimumSize(new Dimension(34, 28)); expDownInput.setMaximumSize(new Dimension(50, 2147483647)); contentPanel.add(expDownInput); expDownInput.setBounds(new Rectangle(new Point(430, 162), expDownInput.getPreferredSize())); //---- ampInput ---- ampInput.setText("0.7"); ampInput.setMinimumSize(new Dimension(34, 28)); ampInput.setPreferredSize(new Dimension(45, 28)); contentPanel.add(ampInput); ampInput.setBounds(new Rectangle(new Point(240, 91), ampInput.getPreferredSize())); //---- label1 ---- label1.setText("Mutation:"); label1.setHorizontalAlignment(SwingConstants.RIGHT); label1.setLabelFor(mutInput); label1.setToolTipText("Minimum number of mutations found"); label1.setPreferredSize(new Dimension(66, 18)); contentPanel.add(label1); label1.setBounds(50, 26, label1.getPreferredSize().width, 18); //---- mutInput ---- mutInput.setText("1"); mutInput.setAutoscrolls(false); mutInput.setMinimumSize(new Dimension(34, 28)); mutInput.setPreferredSize(new Dimension(45, 28)); contentPanel.add(mutInput); mutInput.setBounds(new Rectangle(new Point(240, 21), mutInput.getPreferredSize())); //---- label6 ---- label6.setText("Copy Number:"); contentPanel.add(label6); label6.setBounds(30, 96, label6.getPreferredSize().width, 18); //---- label8 ---- label8.setText("Expression:"); label8.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(label8); label8.setBounds(30, 168, 86, 18); contentPanel.add(separator1); separator1.setBounds(0, 135, 500, 10); contentPanel.add(separator3); separator3.setBounds(0, 65, 500, 10); //---- separator2 ---- separator2.setPreferredSize(new Dimension(10, 210)); separator2.setOrientation(SwingConstants.VERTICAL); contentPanel.add(separator2); separator2.setBounds(new Rectangle(new Point(120, 0), separator2.getPreferredSize())); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < contentPanel.getComponentCount(); i++) { Rectangle bounds = contentPanel.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = contentPanel.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; contentPanel.setMinimumSize(preferredSize); contentPanel.setPreferredSize(preferredSize); } } thresholds.add(contentPanel); contentPanel.setBounds(12, 80, 500, 210); //======== panel2 ======== { panel2.setLayout(null); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel2.getComponentCount(); i++) { Rectangle bounds = panel2.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel2.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel2.setMinimumSize(preferredSize); panel2.setPreferredSize(preferredSize); } } thresholds.add(panel2); panel2.setBounds(new Rectangle(new Point(55, 25), panel2.getPreferredSize())); //---- textArea1 ---- textArea1.setText( "Samples are considered to have a given \"event\" if the value is above the thresholds below."); textArea1.setEditable(false); textArea1.setLineWrap(true); textArea1.setBackground(UIManager.getColor("Button.background")); thresholds.add(textArea1); textArea1.setBounds(15, 10, 430, 40); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < thresholds.getComponentCount(); i++) { Rectangle bounds = thresholds.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = thresholds.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; thresholds.setMinimumSize(preferredSize); thresholds.setPreferredSize(preferredSize); } } tabbedPane.addTab("Thresholds", thresholds); } contentPane2.add(tabbedPane, BorderLayout.NORTH); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java
private JToggleButton createMoreMenuButton() { final JMenuItem optionsMenuItem = WidgetFactory.createMenuItem("Options", IconUtils.MENU_OPTIONS); optionsMenuItem.addActionListener(new ActionListener() { @Override//w w w.j a v a2 s . c om public void actionPerformed(ActionEvent e) { OptionsDialog optionsDialog = _optionsDialogProvider.get(); optionsDialog.open(); } }); final JMenuItem monitorMenuItem = WidgetFactory.createMenuItem("DataCleaner monitor", IconUtils.MENU_DQ_MONITOR); monitorMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MonitorConnectionDialog dialog = _monitorConnectionDialogProvider.get(); dialog.open(); } }); final JMenuItem dictionariesMenuItem = WidgetFactory.createMenuItem("Dictionaries", IconUtils.DICTIONARY_IMAGEPATH); dictionariesMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get(); referenceDataDialog.selectDictionariesTab(); referenceDataDialog.open(); } }); final JMenuItem synonymCatalogsMenuItem = WidgetFactory.createMenuItem("Synonyms", IconUtils.SYNONYM_CATALOG_IMAGEPATH); synonymCatalogsMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get(); referenceDataDialog.selectSynonymsTab(); referenceDataDialog.open(); } }); final JMenuItem stringPatternsMenuItem = WidgetFactory.createMenuItem("String patterns", IconUtils.STRING_PATTERN_IMAGEPATH); stringPatternsMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get(); referenceDataDialog.selectStringPatternsTab(); referenceDataDialog.open(); } }); final PopupButton popupButton = new PopupButton("More", imageManager.getImageIcon(IconUtils.ACTION_SCROLLDOWN_BRIGHT)); applyMenuPopupButttonStyling(popupButton); final JMenu windowsMenuItem = WidgetFactory.createMenu("Windows", 'w'); windowsMenuItem.setIcon(imageManager.getImageIcon("images/menu/windows.png", IconUtils.ICON_SIZE_SMALL)); final List<DCWindow> windows = getWindowContext().getWindows(); getWindowContext().addWindowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { windowsMenuItem.removeAll(); for (final DCWindow window : windows) { final Image windowIcon = window.getWindowIcon(); final String title = window.getWindowTitle(); final ImageIcon icon = new ImageIcon(windowIcon.getScaledInstance(IconUtils.ICON_SIZE_SMALL, IconUtils.ICON_SIZE_SMALL, Image.SCALE_DEFAULT)); final JMenuItem switchToWindowItem = WidgetFactory.createMenuItem(title, icon); switchToWindowItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { window.toFront(); } }); windowsMenuItem.add(switchToWindowItem); } windowsMenuItem.add(new JSeparator()); JMenuItem closeAllWindowsItem = WidgetFactory.createMenuItem("Close all dialogs", (ImageIcon) null); closeAllWindowsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<DCWindow> windows = new ArrayList<>(getWindowContext().getWindows()); for (DCWindow window : windows) { if (window instanceof AbstractDialog) { window.close(); } } } }); windowsMenuItem.add(closeAllWindowsItem); } }); popupButton.getMenu().removeAll(); popupButton.getMenu().add(dictionariesMenuItem); popupButton.getMenu().add(synonymCatalogsMenuItem); popupButton.getMenu().add(stringPatternsMenuItem); popupButton.getMenu().add(new JSeparator()); popupButton.getMenu().add(windowsMenuItem); popupButton.getMenu().add(new JSeparator()); popupButton.getMenu().add(monitorMenuItem); popupButton.getMenu().add(optionsMenuItem); return popupButton; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java
/** * Initialise the application's menu bar. *//* ww w .j av a2 s . co m*/ private void initMenus() { JMenuBar appMenuBar = new JMenuBar(); if (this.isStandAloneApplication && OS_NAME_MAC.equals(System.getProperty("os.name"))) { /* * We need to check we're running on a Mac before adding the menu to the * owner frame, otherwise the menus will be displayed *behind* the main * GUI panel on Windows Vista and later [sigh] */ ownerFrame.setJMenuBar(appMenuBar); } else { this.setJMenuBar(appMenuBar); } // Service menu JMenu serviceMenu = new JMenu("Service"); loginMenuItem = new JMenuItem("Log in..."); loginMenuItem.setActionCommand("LoginEvent"); loginMenuItem.addActionListener(this); guiUtils.applyIcon(loginMenuItem, "/images/nuvola/16x16/actions/connect_creating.png"); serviceMenu.add(loginMenuItem); logoutMenuItem = new JMenuItem("Log out"); logoutMenuItem.setActionCommand("LogoutEvent"); logoutMenuItem.addActionListener(this); guiUtils.applyIcon(logoutMenuItem, "/images/nuvola/16x16/actions/connect_no.png"); serviceMenu.add(logoutMenuItem); loginSwitchMenu = new JMenu("Switch login"); loginSwitchMenu.addActionListener(this); serviceMenu.add(new JSeparator()); guiUtils.applyIcon(loginSwitchMenu, "/images/nuvola/16x16/actions/connect_established.png"); serviceMenu.add(loginSwitchMenu); loginSwitchMenu.setEnabled(false); if (isStandAloneApplication) { serviceMenu.add(new JSeparator()); JMenuItem quitMenuItem = new JMenuItem("Quit"); quitMenuItem.setActionCommand("QuitEvent"); quitMenuItem.addActionListener(this); guiUtils.applyIcon(quitMenuItem, "/images/nuvola/16x16/actions/exit.png"); serviceMenu.add(quitMenuItem); } logoutMenuItem.setEnabled(false); // Bucket action menu. bucketActionMenu = new JPopupMenu(); refreshBucketMenuItem = new JMenuItem("Refresh bucket listing"); refreshBucketMenuItem.setActionCommand("RefreshBuckets"); refreshBucketMenuItem.addActionListener(this); guiUtils.applyIcon(refreshBucketMenuItem, "/images/nuvola/16x16/actions/reload.png"); bucketActionMenu.add(refreshBucketMenuItem); viewBucketPropertiesMenuItem = new JMenuItem("View bucket properties..."); viewBucketPropertiesMenuItem.setActionCommand("ViewBucketProperties"); viewBucketPropertiesMenuItem.addActionListener(this); guiUtils.applyIcon(viewBucketPropertiesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); bucketActionMenu.add(viewBucketPropertiesMenuItem); updateBucketACLMenuItem = new JMenuItem("Update bucket's Access Control List..."); updateBucketACLMenuItem.setActionCommand("UpdateBucketACL"); updateBucketACLMenuItem.addActionListener(this); guiUtils.applyIcon(updateBucketACLMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); bucketActionMenu.add(updateBucketACLMenuItem); updateBucketRequesterPaysStatusMenuItem = new JMenuItem("Update bucket's Requester Pays status..."); updateBucketRequesterPaysStatusMenuItem.setActionCommand("UpdateBucketRequesterPaysStatus"); updateBucketRequesterPaysStatusMenuItem.addActionListener(this); guiUtils.applyIcon(updateBucketRequesterPaysStatusMenuItem, "/images/nuvola/16x16/actions/identity.png"); bucketActionMenu.add(updateBucketRequesterPaysStatusMenuItem); bucketActionMenu.add(new JSeparator()); createBucketMenuItem = new JMenuItem("Create new bucket..."); createBucketMenuItem.setActionCommand("CreateBucket"); createBucketMenuItem.addActionListener(this); guiUtils.applyIcon(createBucketMenuItem, "/images/nuvola/16x16/actions/viewmag+.png"); bucketActionMenu.add(createBucketMenuItem); JMenuItem thirdPartyBucketMenuItem = new JMenuItem("Add third-party bucket..."); thirdPartyBucketMenuItem.setActionCommand("AddThirdPartyBucket"); thirdPartyBucketMenuItem.addActionListener(this); guiUtils.applyIcon(thirdPartyBucketMenuItem, "/images/nuvola/16x16/actions/viewmagfit.png"); bucketActionMenu.add(thirdPartyBucketMenuItem); bucketActionMenu.add(new JSeparator()); deleteBucketMenuItem = new JMenuItem("Delete bucket..."); deleteBucketMenuItem.setActionCommand("DeleteBucket"); deleteBucketMenuItem.addActionListener(this); guiUtils.applyIcon(deleteBucketMenuItem, "/images/nuvola/16x16/actions/cancel.png"); bucketActionMenu.add(deleteBucketMenuItem); viewBucketPropertiesMenuItem.setEnabled(false); refreshBucketMenuItem.setEnabled(false); createBucketMenuItem.setEnabled(false); updateBucketACLMenuItem.setEnabled(false); updateBucketRequesterPaysStatusMenuItem.setEnabled(false); deleteBucketMenuItem.setEnabled(false); // Object action menu. objectActionMenu = new JPopupMenu(); refreshObjectMenuItem = new JMenuItem("Refresh object listing"); refreshObjectMenuItem.setActionCommand("RefreshObjects"); refreshObjectMenuItem.addActionListener(this); guiUtils.applyIcon(refreshObjectMenuItem, "/images/nuvola/16x16/actions/reload.png"); objectActionMenu.add(refreshObjectMenuItem); viewOrModifyObjectAttributesMenuItem = new JMenuItem("View or Modify object attributes..."); viewOrModifyObjectAttributesMenuItem.setActionCommand("ViewOrModifyObjectAttributes"); viewOrModifyObjectAttributesMenuItem.addActionListener(this); guiUtils.applyIcon(viewOrModifyObjectAttributesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); objectActionMenu.add(viewOrModifyObjectAttributesMenuItem); copyObjectsMenuItem = new JMenuItem("Copy or Move objects..."); copyObjectsMenuItem.setActionCommand("CopyObjects"); copyObjectsMenuItem.addActionListener(this); guiUtils.applyIcon(copyObjectsMenuItem, "/images/nuvola/16x16/actions/filenew.png"); objectActionMenu.add(copyObjectsMenuItem); updateObjectACLMenuItem = new JMenuItem("View or Modify Access Control Lists..."); updateObjectACLMenuItem.setActionCommand("UpdateObjectACL"); updateObjectACLMenuItem.addActionListener(this); guiUtils.applyIcon(updateObjectACLMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); objectActionMenu.add(updateObjectACLMenuItem); downloadObjectMenuItem = new JMenuItem("Download objects..."); downloadObjectMenuItem.setActionCommand("DownloadObjects"); downloadObjectMenuItem.addActionListener(this); guiUtils.applyIcon(downloadObjectMenuItem, "/images/nuvola/16x16/actions/1downarrow.png"); objectActionMenu.add(downloadObjectMenuItem); uploadFilesMenuItem = new JMenuItem("Upload files..."); uploadFilesMenuItem.setActionCommand("UploadFiles"); uploadFilesMenuItem.addActionListener(this); guiUtils.applyIcon(uploadFilesMenuItem, "/images/nuvola/16x16/actions/1uparrow.png"); objectActionMenu.add(uploadFilesMenuItem); objectActionMenu.add(new JSeparator()); generatePublicGetUrls = new JMenuItem("Generate Public GET URLs..."); generatePublicGetUrls.setActionCommand("GeneratePublicGetURLs"); generatePublicGetUrls.addActionListener(this); guiUtils.applyIcon(generatePublicGetUrls, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generatePublicGetUrls); generateTorrentUrl = new JMenuItem("Generate Torrent URL..."); generateTorrentUrl.setActionCommand("GenerateTorrentURL"); generateTorrentUrl.addActionListener(this); guiUtils.applyIcon(generateTorrentUrl, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generateTorrentUrl); objectActionMenu.add(new JSeparator()); deleteObjectMenuItem = new JMenuItem("Delete objects..."); deleteObjectMenuItem.setActionCommand("DeleteObjects"); deleteObjectMenuItem.addActionListener(this); guiUtils.applyIcon(deleteObjectMenuItem, "/images/nuvola/16x16/actions/cancel.png"); objectActionMenu.add(deleteObjectMenuItem); viewOrModifyObjectAttributesMenuItem.setEnabled(false); copyObjectsMenuItem.setEnabled(false); refreshObjectMenuItem.setEnabled(false); updateObjectACLMenuItem.setEnabled(false); downloadObjectMenuItem.setEnabled(false); uploadFilesMenuItem.setEnabled(false); generatePublicGetUrls.setEnabled(false); generateTorrentUrl.setEnabled(false); deleteObjectMenuItem.setEnabled(false); // Tools menu. JMenu toolsMenu = new JMenu("Tools"); bucketLoggingMenuItem = new JMenuItem("Configure Bucket logging..."); bucketLoggingMenuItem.setActionCommand("BucketLogging"); bucketLoggingMenuItem.addActionListener(this); bucketLoggingMenuItem.setEnabled(false); guiUtils.applyIcon(bucketLoggingMenuItem, "/images/nuvola/16x16/actions/toggle_log.png"); toolsMenu.add(bucketLoggingMenuItem); manageDistributionsMenuItem = new JMenuItem("Manage CloudFront Distributions..."); manageDistributionsMenuItem.setActionCommand("ManageDistributions"); manageDistributionsMenuItem.addActionListener(this); guiUtils.applyIcon(manageDistributionsMenuItem, "/images/nuvola/16x16/actions/irkick.png"); manageDistributionsMenuItem.setEnabled(false); toolsMenu.add(manageDistributionsMenuItem); toolsMenu.add(new JSeparator()); preferencesDialogMenuItem = new JMenuItem("Preferences..."); preferencesDialogMenuItem.setActionCommand("PreferencesDialog"); preferencesDialogMenuItem.addActionListener(this); guiUtils.applyIcon(preferencesDialogMenuItem, "/images/nuvola/16x16/actions/configure.png"); toolsMenu.add(preferencesDialogMenuItem); // Help menu. JMenu helpMenu = new JMenu("Help"); cockpitHelpMenuItem = new JMenuItem("Cockpit Guide"); guiUtils.applyIcon(cockpitHelpMenuItem, "/images/nuvola/16x16/actions/help.png"); cockpitHelpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { followHyperlink(new URL(JETS3T_COCKPIT_HELP_PAGE), "_blank"); } catch (MalformedURLException ex) { throw new IllegalStateException("Invalid URL embedded in program: " + JETS3T_COCKPIT_HELP_PAGE); } } }); helpMenu.add(cockpitHelpMenuItem); amazonS3HelpMenuItem = new JMenuItem("Amazon S3"); guiUtils.applyIcon(amazonS3HelpMenuItem, "/images/nuvola/16x16/actions/gohome.png"); amazonS3HelpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { followHyperlink(new URL(AMAZON_S3_PAGE), "_blank"); } catch (MalformedURLException ex) { throw new IllegalStateException("Invalid URL embedded in program: " + AMAZON_S3_PAGE); } } }); helpMenu.add(amazonS3HelpMenuItem); // Build application menu bar. appMenuBar.add(serviceMenu); appMenuBar.add(toolsMenu); appMenuBar.add(helpMenu); }