List of usage examples for javax.swing JTextPane setEditable
@BeanProperty(description = "specifies if the text can be edited") public void setEditable(boolean b)
TextComponent
should be editable. From source file:org.biojava.bio.view.MotifAnalyzer.java
private JScrollPane getOutputTextPane(String text) { JScrollPane jScrollPane = new JScrollPane(); JTextPane outputPane = new JTextPane(); outputPane.setEditable(false); outputPane.setText(text);// w ww .j a v a2s. com jScrollPane.setViewportView(outputPane); return jScrollPane; }
From source file:es.ubu.XRayDetector.interfaz.PanelAplicacion.java
/** * Gets the application log.//w ww .j a v a2 s.c o m * * @param panelLog The panel of the log. * @return The application log. */ private JTextPane getTxtLog(JPanel panelLog) { JTextPane textPaneLog = new JTextPane(); textPaneLog.setBounds(4, 4, 209, 195); textPaneLog.setEditable(false); panelLog.add(textPaneLog); textPaneLog.setContentType("text/html"); kit = new HTMLEditorKit(); doc = new HTMLDocument(); panelLog_1.setLayout(null); textPaneLog.setEditorKit(kit); textPaneLog.setDocument(doc); textPaneLog.setText("<!DOCTYPE html>" + "<html>" + "<head>" + "<style>" + "p.normal {font-weight:normal;}" + "p.error {font-weight:bold; color:red}" + "p.exito {font-weight:bold; color:green}" + "p.stop {font-weight:bold; color:blue}" + "</style>" + "</head>" + "<body>"); JScrollPane scroll = new JScrollPane(textPaneLog); scroll.setBounds(10, 16, 242, 254); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); panelLog.add(scroll); return textPaneLog; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a text pane to the parent container * /*from www . ja v a2 s. c om*/ * @param container - parent container * @param text - text for new Text Pane * @param placement - TableLayout placement within the parent container * @param debug - turn on/off red debug borders * @return new JTextPane */ public static synchronized JTextPane addTextPane(Container container, String text, String placement, boolean debug) { StyleContext context = new StyleContext(); StyledDocument document = new DefaultStyledDocument(context); Style style = context.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT); try { document.insertString(document.getLength(), text, null); } catch (BadLocationException e) { log.error("BadLocationException inserting text to document."); } JTextPane textPane = new JTextPane(document); textPane.setOpaque(false); textPane.setEditable(false); textPane.setFocusable(false); container.add(textPane, placement); if (debug == true) textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), textPane.getBorder())); return textPane; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * A version of addTextPane that lets you add a style and context * // w ww. ja v a2s . c o m * @param container - parent container * @param text - text for new Text Pane * @param placement - TableLayout placement within the parent container * @param context - context for new text pane * @param style - style to apply to new text pane * @param debug - turn on/off red debug borders * @return new JTextPane */ public static synchronized JTextPane addTextPane(Container container, String text, String placement, StyleContext context, Style style, boolean debug) { StyledDocument document = new DefaultStyledDocument(context); try { document.insertString(document.getLength(), text, style); } catch (BadLocationException e) { log.error("BadLocationException inserting text to document."); } JTextPane textPane = new JTextPane(document); textPane.setOpaque(false); textPane.setEditable(false); textPane.setFocusable(false); container.add(textPane, placement); if (debug == true) textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), textPane.getBorder())); return textPane; }
From source file:op.care.bhp.PnlBHP.java
private CollapsiblePane createCP4(final BHP bhp) { final CollapsiblePane bhpPane = new CollapsiblePane(); bhpPane.setCollapseOnTitleClick(false); ActionListener applyActionListener = new ActionListener() { @Override/*from ww w .ja va2 s .c o m*/ public void actionPerformed(ActionEvent actionEvent) { if (bhp.getState() != BHPTools.STATE_OPEN) { return; } if (bhp.getPrescription().isClosed()) { return; } if (BHPTools.isChangeable(bhp)) { outcomeText = null; if (bhp.getNeedsText()) { new DlgYesNo(SYSConst.icon48comment, new Closure() { @Override public void execute(Object o) { if (SYSTools.catchNull(o).isEmpty()) { outcomeText = null; } else { outcomeText = o.toString(); } } }, "nursingrecords.bhp.describe.outcome", null, null); } if (bhp.getNeedsText() && outcomeText == null) { OPDE.getDisplayManager().addSubMessage( new DisplayMessage("nursingrecords.bhp.notext.nooutcome", DisplayMessage.WARNING)); return; } if (bhp.getPrescription().isWeightControlled()) { new DlgYesNo(SYSConst.icon48scales, new Closure() { @Override public void execute(Object o) { if (SYSTools.catchNull(o).isEmpty()) { weight = null; } else { weight = (BigDecimal) o; } } }, "nursingrecords.bhp.weight", null, new Validator<BigDecimal>() { @Override public boolean isValid(String value) { BigDecimal bd = parse(value); return bd != null && bd.compareTo(BigDecimal.ZERO) > 0; } @Override public BigDecimal parse(String text) { return SYSTools.parseDecimal(text); } }); } if (bhp.getPrescription().isWeightControlled() && weight == null) { OPDE.getDisplayManager().addSubMessage(new DisplayMessage( "nursingrecords.bhp.noweight.nosuccess", DisplayMessage.WARNING)); return; } EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); BHP myBHP = em.merge(bhp); em.lock(myBHP, LockModeType.OPTIMISTIC); if (myBHP.isOnDemand()) { em.lock(myBHP.getPrescriptionSchedule(), LockModeType.OPTIMISTIC_FORCE_INCREMENT); em.lock(myBHP.getPrescription(), LockModeType.OPTIMISTIC_FORCE_INCREMENT); } else { em.lock(myBHP.getPrescriptionSchedule(), LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescription(), LockModeType.OPTIMISTIC); } myBHP.setState(BHPTools.STATE_DONE); myBHP.setUser(em.merge(OPDE.getLogin().getUser())); myBHP.setIst(new Date()); myBHP.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myBHP.setMDate(new Date()); myBHP.setText(outcomeText); Prescription involvedPresciption = null; if (myBHP.shouldBeCalculated()) { MedInventory inventory = TradeFormTools.getInventory4TradeForm(resident, myBHP.getTradeForm()); MedInventoryTools.withdraw(em, em.merge(inventory), myBHP.getDose(), weight, myBHP); // Was the prescription closed during this withdraw ? involvedPresciption = em.find(Prescription.class, myBHP.getPrescription().getID()); } BHP outcomeBHP = null; // add outcome check BHP if necessary if (!myBHP.isOutcomeText() && myBHP.getPrescriptionSchedule().getCheckAfterHours() != null) { outcomeBHP = em.merge(new BHP(myBHP)); mapShift2BHP.get(BHPTools.SHIFT_ON_DEMAND).add(outcomeBHP); } em.getTransaction().commit(); if (myBHP.shouldBeCalculated() && involvedPresciption.isClosed()) { // && reload(); } else if (outcomeBHP != null) { reload(); } else { mapBHP2Pane.put(myBHP, createCP4(myBHP)); int position = mapShift2BHP.get(myBHP.getShift()).indexOf(bhp); mapShift2BHP.get(myBHP.getShift()).remove(position); mapShift2BHP.get(myBHP.getShift()).add(position, myBHP); if (myBHP.isOnDemand()) { // This whole thing here is only to handle the BPHs on Demand // Fix the other BHPs on demand. If not, you will get locking exceptions, // we FORCED INCREMENTED LOCKS on the Schedule and the Prescription. ArrayList<BHP> changeList = new ArrayList<BHP>(); for (BHP bhp : mapShift2BHP.get(BHPTools.SHIFT_ON_DEMAND)) { if (bhp.getPrescription().getID() == myBHP.getPrescription().getID() && bhp.getBHPid() != myBHP.getBHPid()) { bhp.setPrescription(myBHP.getPrescription()); bhp.setPrescriptionSchedule(myBHP.getPrescriptionSchedule()); changeList.add(bhp); } } for (BHP bhp : changeList) { mapBHP2Pane.put(bhp, createCP4(myBHP)); position = mapShift2BHP.get(bhp.getShift()).indexOf(bhp); mapShift2BHP.get(myBHP.getShift()).remove(position); mapShift2BHP.get(myBHP.getShift()).add(position, bhp); } Collections.sort(mapShift2BHP.get(myBHP.getShift()), BHPTools.getOnDemandComparator()); } else { Collections.sort(mapShift2BHP.get(myBHP.getShift())); } mapShift2Pane.put(myBHP.getShift(), createCP4(myBHP.getShift())); buildPanel(false); } } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.bhp.notchangeable"))); } } }; // JPanel titlePanelleft = new JPanel(); // titlePanelleft.setLayout(new BoxLayout(titlePanelleft, BoxLayout.LINE_AXIS)); MedStock stock = mapPrescription2Stock.get(bhp.getPrescription()); if (bhp.hasMed() && stock == null) { stock = MedStockTools .getStockInUse(TradeFormTools.getInventory4TradeForm(resident, bhp.getTradeForm())); mapPrescription2Stock.put(bhp.getPrescription(), stock); } String title; if (bhp.isOutcomeText()) { title = "<html><font size=+1>" + SYSConst.html_italic(SYSTools .left("“" + PrescriptionTools.getShortDescriptionAsCompactText( bhp.getPrescriptionSchedule().getPrescription()), MAX_TEXT_LENGTH) + BHPTools.getScheduleText(bhp.getOutcome4(), "”, ", "")) + " [" + bhp.getPrescriptionSchedule().getCheckAfterHours() + " " + SYSTools.xx("misc.msg.Hour(s)") + "] " + BHPTools.getScheduleText(bhp, ", ", "") + (bhp.getPrescription().isWeightControlled() ? " " + SYSConst.html_16x16_scales_internal + (bhp.isOpen() ? "" : (bhp.getStockTransaction().isEmpty() ? " " : NumberFormat.getNumberInstance() .format(bhp.getStockTransaction().get(0).getWeight()) + "g ")) : "") + (bhp.getUser() != null ? ", <i>" + SYSTools.anonymizeUser(bhp.getUser().getUID()) + "</i>" : "") + "</font></html>"; } else { title = "<html><font size=+1>" + SYSTools.left(PrescriptionTools.getShortDescriptionAsCompactText( bhp.getPrescriptionSchedule().getPrescription()), MAX_TEXT_LENGTH) + (bhp.hasMed() ? ", <b>" + SYSTools.getAsHTML(bhp.getDose()) + " " + DosageFormTools.getUsageText( bhp.getPrescription().getTradeForm().getDosageForm()) + "</b>" : "") + BHPTools.getScheduleText(bhp, ", ", "") + (bhp.getPrescription().isWeightControlled() ? " " + SYSConst.html_16x16_scales_internal + (bhp.isOpen() ? "" : (bhp.getStockTransaction().isEmpty() ? " " : NumberFormat.getNumberInstance() .format(bhp.getStockTransaction().get(0).getWeight()) + "g ")) : "") + (bhp.getUser() != null ? ", <i>" + SYSTools.anonymizeUser(bhp.getUser().getUID()) + "</i>" : "") + "</font></html>"; } DefaultCPTitle cptitle = new DefaultCPTitle(title, OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? applyActionListener : null); JLabel icon1 = new JLabel(BHPTools.getIcon(bhp)); icon1.setOpaque(false); if (!bhp.isOpen()) { icon1.setToolTipText(DateFormat.getDateTimeInstance().format(bhp.getIst())); } JLabel icon2 = new JLabel(BHPTools.getWarningIcon(bhp, stock)); icon2.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon1); cptitle.getAdditionalIconPanel().add(icon2); if (bhp.getPrescription().isClosed()) { JLabel icon3 = new JLabel(SYSConst.icon22stopSign); icon3.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon3); } if (bhp.isOutcomeText()) { JLabel icon4 = new JLabel(SYSConst.icon22comment); icon4.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon4); } if (!bhp.isOutcomeText() && bhp.getPrescriptionSchedule().getCheckAfterHours() != null) { JLabel icon4 = new JLabel(SYSConst.icon22intervalBySecond); icon4.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon4); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { if (!bhp.getPrescription().isClosed()) { /*** * _ _ _ _ * | |__ | |_ _ __ / \ _ __ _ __ | |_ _ * | '_ \| __| '_ \ / _ \ | '_ \| '_ \| | | | | * | |_) | |_| | | |/ ___ \| |_) | |_) | | |_| | * |_.__/ \__|_| |_/_/ \_\ .__/| .__/|_|\__, | * |_| |_| |___/ */ JButton btnApply = new JButton(SYSConst.icon22apply); btnApply.setPressedIcon(SYSConst.icon22applyPressed); btnApply.setAlignmentX(Component.RIGHT_ALIGNMENT); btnApply.setToolTipText(SYSTools.xx("nursingrecords.bhp.btnApply.tooltip")); btnApply.addActionListener(applyActionListener); btnApply.setContentAreaFilled(false); btnApply.setBorder(null); btnApply.setEnabled(bhp.isOpen() && (!bhp.hasMed() || mapPrescription2Stock.containsKey(bhp.getPrescription()))); cptitle.getRight().add(btnApply); /*** * ____ _ _ * ___ _ __ ___ _ __ / ___|| |_ ___ ___| | __ * / _ \| '_ \ / _ \ '_ \\___ \| __/ _ \ / __| |/ / * | (_) | |_) | __/ | | |___) | || (_) | (__| < * \___/| .__/ \___|_| |_|____/ \__\___/ \___|_|\_\ * |_| */ if (bhp.hasMed() && stock == null && MedInventoryTools.getNextToOpen( TradeFormTools.getInventory4TradeForm(resident, bhp.getTradeForm())) != null) { final JButton btnOpenStock = new JButton(SYSConst.icon22ledGreenOn); btnOpenStock.setPressedIcon(SYSConst.icon22ledGreenOff); btnOpenStock.setAlignmentX(Component.RIGHT_ALIGNMENT); btnOpenStock.setContentAreaFilled(false); btnOpenStock.setBorder(null); btnOpenStock.setToolTipText(SYSTools .toHTMLForScreen(SYSTools.xx("nursingrecords.inventory.stock.btnopen.tooltip"))); btnOpenStock.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); BHP myBHP = em.merge(bhp); em.lock(myBHP, LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescriptionSchedule(), LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescription(), LockModeType.OPTIMISTIC); MedStock myStock = em.merge(MedInventoryTools.openNext( TradeFormTools.getInventory4TradeForm(resident, myBHP.getTradeForm()))); em.lock(myStock, LockModeType.OPTIMISTIC); em.getTransaction().commit(); OPDE.getDisplayManager() .addSubMessage(new DisplayMessage( String.format(SYSTools.xx("newstocks.stock.has.been.opened"), myStock.getID().toString()))); reload(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); cptitle.getRight().add(btnOpenStock); } if (!bhp.isOutcomeText()) { /*** * _ _ ____ __ * | |__ | |_ _ __ | _ \ ___ / _|_ _ ___ ___ * | '_ \| __| '_ \| |_) / _ \ |_| | | / __|/ _ \ * | |_) | |_| | | | _ < __/ _| |_| \__ \ __/ * |_.__/ \__|_| |_|_| \_\___|_| \__,_|___/\___| * */ final JButton btnRefuse = new JButton(SYSConst.icon22cancel); btnRefuse.setPressedIcon(SYSConst.icon22cancelPressed); btnRefuse.setAlignmentX(Component.RIGHT_ALIGNMENT); btnRefuse.setContentAreaFilled(false); btnRefuse.setBorder(null); btnRefuse.setToolTipText( SYSTools.toHTMLForScreen(SYSTools.xx("nursingrecords.bhp.btnRefuse.tooltip"))); btnRefuse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (bhp.getState() != BHPTools.STATE_OPEN) { return; } if (BHPTools.isChangeable(bhp)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); BHP myBHP = em.merge(bhp); em.lock(myBHP, LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescriptionSchedule(), LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescription(), LockModeType.OPTIMISTIC); myBHP.setState(BHPTools.STATE_REFUSED); myBHP.setUser(em.merge(OPDE.getLogin().getUser())); myBHP.setIst(new Date()); myBHP.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myBHP.setMDate(new Date()); mapBHP2Pane.put(myBHP, createCP4(myBHP)); int position = mapShift2BHP.get(myBHP.getShift()).indexOf(bhp); mapShift2BHP.get(bhp.getShift()).remove(position); mapShift2BHP.get(bhp.getShift()).add(position, myBHP); if (myBHP.isOnDemand()) { Collections.sort(mapShift2BHP.get(myBHP.getShift()), BHPTools.getOnDemandComparator()); } else { Collections.sort(mapShift2BHP.get(myBHP.getShift())); } em.getTransaction().commit(); mapShift2Pane.put(myBHP.getShift(), createCP4(myBHP.getShift())); buildPanel(false); } 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(); } } else { OPDE.getDisplayManager().addSubMessage( new DisplayMessage(SYSTools.xx("nursingrecords.bhp.notchangeable"))); } } }); btnRefuse.setEnabled(!bhp.isOnDemand() && bhp.isOpen()); cptitle.getRight().add(btnRefuse); /*** * _ _ ____ __ ____ _ _ * | |__ | |_ _ __ | _ \ ___ / _|_ _ ___ ___| _ \(_)___ ___ __ _ _ __ __| | * | '_ \| __| '_ \| |_) / _ \ |_| | | / __|/ _ \ | | | / __|/ __/ _` | '__/ _` | * | |_) | |_| | | | _ < __/ _| |_| \__ \ __/ |_| | \__ \ (_| (_| | | | (_| | * |_.__/ \__|_| |_|_| \_\___|_| \__,_|___/\___|____/|_|___/\___\__,_|_| \__,_| * */ final JButton btnRefuseDiscard = new JButton(SYSConst.icon22deleteall); btnRefuseDiscard.setPressedIcon(SYSConst.icon22deleteallPressed); btnRefuseDiscard.setAlignmentX(Component.RIGHT_ALIGNMENT); btnRefuseDiscard.setContentAreaFilled(false); btnRefuseDiscard.setBorder(null); btnRefuseDiscard.setToolTipText( SYSTools.toHTMLForScreen(SYSTools.xx("nursingrecords.bhp.btnRefuseDiscard.tooltip"))); btnRefuseDiscard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (bhp.getState() != BHPTools.STATE_OPEN) { return; } if (BHPTools.isChangeable(bhp)) { if (bhp.getPrescription().isWeightControlled()) { new DlgYesNo(SYSConst.icon48scales, new Closure() { @Override public void execute(Object o) { if (SYSTools.catchNull(o).isEmpty()) { weight = null; } else { weight = (BigDecimal) o; } } }, "nursingrecords.bhp.weight", null, new Validator<BigDecimal>() { @Override public boolean isValid(String value) { BigDecimal bd = parse(value); return bd != null && bd.compareTo(BigDecimal.ZERO) > 0; } @Override public BigDecimal parse(String text) { return SYSTools.parseDecimal(text); } }); } if (bhp.getPrescription().isWeightControlled() && weight == null) { OPDE.getDisplayManager().addSubMessage(new DisplayMessage( "nursingrecords.bhp.noweight.nosuccess", DisplayMessage.WARNING)); return; } EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); BHP myBHP = em.merge(bhp); em.lock(myBHP, LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescriptionSchedule(), LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescription(), LockModeType.OPTIMISTIC); myBHP.setState(BHPTools.STATE_REFUSED_DISCARDED); myBHP.setUser(em.merge(OPDE.getLogin().getUser())); myBHP.setIst(new Date()); myBHP.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myBHP.setMDate(new Date()); if (myBHP.shouldBeCalculated()) { MedInventory inventory = TradeFormTools.getInventory4TradeForm(resident, myBHP.getTradeForm()); if (inventory != null) { MedInventoryTools.withdraw(em, em.merge(inventory), myBHP.getDose(), weight, myBHP); } else { OPDE.getDisplayManager().addSubMessage( new DisplayMessage("nursingrecords.bhp.NoInventory")); } } mapBHP2Pane.put(myBHP, createCP4(myBHP)); int position = mapShift2BHP.get(myBHP.getShift()).indexOf(bhp); mapShift2BHP.get(bhp.getShift()).remove(position); mapShift2BHP.get(bhp.getShift()).add(position, myBHP); if (myBHP.isOnDemand()) { Collections.sort(mapShift2BHP.get(myBHP.getShift()), BHPTools.getOnDemandComparator()); } else { Collections.sort(mapShift2BHP.get(myBHP.getShift())); } em.getTransaction().commit(); mapShift2Pane.put(myBHP.getShift(), createCP4(myBHP.getShift())); buildPanel(false); } 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(); } } else { OPDE.getDisplayManager().addSubMessage( new DisplayMessage(SYSTools.xx("nursingrecords.bhp.notchangeable"))); } } }); btnRefuseDiscard.setEnabled( !bhp.isOnDemand() && bhp.hasMed() && bhp.shouldBeCalculated() && bhp.isOpen()); cptitle.getRight().add(btnRefuseDiscard); } /*** * _ _ _____ _ * | |__ | |_ _ __ | ____|_ __ ___ _ __ | |_ _ _ * | '_ \| __| '_ \| _| | '_ ` _ \| '_ \| __| | | | * | |_) | |_| | | | |___| | | | | | |_) | |_| |_| | * |_.__/ \__|_| |_|_____|_| |_| |_| .__/ \__|\__, | * |_| |___/ */ final JButton btnEmpty = new JButton(SYSConst.icon22empty); btnEmpty.setPressedIcon(SYSConst.icon22emptyPressed); btnEmpty.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEmpty.setContentAreaFilled(false); btnEmpty.setBorder(null); btnEmpty.setToolTipText(SYSTools.xx("nursingrecords.bhp.btnEmpty.tooltip")); btnEmpty.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (bhp.getState() == BHPTools.STATE_OPEN) { return; } BHP outcomeBHP = BHPTools.getComment(bhp); if (outcomeBHP != null && !outcomeBHP.isOpen()) { // already commented return; } if (BHPTools.isChangeable(bhp)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); BHP myBHP = em.merge(bhp); em.lock(myBHP, LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescriptionSchedule(), LockModeType.OPTIMISTIC); em.lock(myBHP.getPrescription(), LockModeType.OPTIMISTIC); // the normal BHPs (those assigned to a NursingProcess) are reset to the OPEN state. // TXs are deleted myBHP.setState(BHPTools.STATE_OPEN); myBHP.setUser(null); myBHP.setIst(null); myBHP.setiZeit(null); myBHP.setMDate(new Date()); myBHP.setText(null); if (myBHP.shouldBeCalculated()) { for (MedStockTransaction tx : myBHP.getStockTransaction()) { em.remove(tx); } myBHP.getStockTransaction().clear(); } if (outcomeBHP != null) { BHP myOutcomeBHP = em.merge(outcomeBHP); em.remove(myOutcomeBHP); } if (myBHP.isOnDemand()) { em.remove(myBHP); } em.getTransaction().commit(); if (myBHP.isOnDemand()) { reload(); } else { mapBHP2Pane.put(myBHP, createCP4(myBHP)); int position = mapShift2BHP.get(myBHP.getShift()).indexOf(bhp); mapShift2BHP.get(bhp.getShift()).remove(position); mapShift2BHP.get(bhp.getShift()).add(position, myBHP); if (myBHP.isOnDemand()) { Collections.sort(mapShift2BHP.get(myBHP.getShift()), BHPTools.getOnDemandComparator()); } else { Collections.sort(mapShift2BHP.get(myBHP.getShift())); } mapShift2Pane.put(myBHP.getShift(), createCP4(myBHP.getShift())); buildPanel(false); } } 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(); } } else { OPDE.getDisplayManager().addSubMessage( new DisplayMessage(SYSTools.xx("nursingrecords.bhp.notchangeable"))); } } }); btnEmpty.setEnabled(!bhp.isOpen()); cptitle.getRight().add(btnEmpty); } /*** * _ _ ___ __ * | |__ | |_ _ __ |_ _|_ __ / _| ___ * | '_ \| __| '_ \ | || '_ \| |_ / _ \ * | |_) | |_| | | || || | | | _| (_) | * |_.__/ \__|_| |_|___|_| |_|_| \___/ * */ final JButton btnInfo = new JButton(SYSConst.icon22info); btnInfo.setPressedIcon(SYSConst.icon22infoPressed); btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT); btnInfo.setContentAreaFilled(false); btnInfo.setBorder(null); btnInfo.setToolTipText(SYSTools.xx("nursingrecords.bhp.btnInfo.tooltip")); final JTextPane txt = new JTextPane(); txt.setContentType("text/html"); txt.setEditable(false); final JidePopup popupInfo = new JidePopup(); popupInfo.setMovable(false); popupInfo.setContentPane(new JScrollPane(txt)); popupInfo.removeExcludedComponent(txt); popupInfo.setDefaultFocusComponent(txt); btnInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { popupInfo.setOwner(btnInfo); if (bhp.isOutcomeText() && !bhp.isOpen()) { txt.setText(SYSTools.toHTML(SYSConst.html_div(bhp.getText()))); } else { txt.setText(SYSTools.toHTML(SYSConst.html_div(bhp.getPrescription().getText()))); } // txt.setText(SYSTools.toHTML(SYSConst.html_div(bhp.getPrescription().getText()))); GUITools.showPopup(popupInfo, SwingConstants.SOUTH_WEST); } }); if (bhp.isOutcomeText() && !bhp.isOpen()) { btnInfo.setEnabled(true); } else { btnInfo.setEnabled(!SYSTools.catchNull(bhp.getPrescription().getText()).isEmpty()); } cptitle.getRight().add(btnInfo); } bhpPane.setTitleLabelComponent(cptitle.getMain()); bhpPane.setSlidingDirection(SwingConstants.SOUTH); final JTextPane contentPane = new JTextPane(); contentPane.setEditable(false); contentPane.setContentType("text/html"); bhpPane.setContentPane(contentPane); bhpPane.setBackground(bhp.getBG()); bhpPane.setForeground(bhp.getFG()); try { bhpPane.setCollapsed(true); } catch (PropertyVetoException e) { OPDE.error(e); } bhpPane.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { contentPane.setText(SYSTools.toHTML( PrescriptionTools.getPrescriptionAsHTML(bhp.getPrescription(), false, false, true, false))); } }); bhpPane.setHorizontalAlignment(SwingConstants.LEADING); bhpPane.setOpaque(false); return bhpPane; }
From source file:op.care.dfn.PnlDFN.java
private CollapsiblePane createCP4(final DFN dfn) { final CollapsiblePane dfnPane = new CollapsiblePane(); ActionListener applyActionListener = new ActionListener() { @Override/*from w w w. j a va2 s .c o m*/ public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_DONE) { return; } if (!dfn.isOnDemand() && dfn.getNursingProcess().isClosed()) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setState(DFNTools.STATE_DONE); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setIst(new Date()); myDFN.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }; String title = "<html><font size=+1>" + // (dfn.isFloating() ? (dfn.isActive() ? "(!) " : "(OK) ") : "") + SYSTools.left(dfn.getIntervention().getBezeichnung(), MAX_TEXT_LENGTH) + DFNTools.getScheduleText(dfn, " [", "]") + ", " + dfn.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + (dfn.getUser() != null ? ", <i>" + SYSTools.anonymizeUser(dfn.getUser().getUID()) + "</i>" : "") + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? applyActionListener : null); dfnPane.setCollapseOnTitleClick(false); // cptitle.getTitleButton().setIcon(DFNTools.getIcon(dfn)); JLabel icon1 = new JLabel(DFNTools.getIcon(dfn)); icon1.setOpaque(false); JLabel icon2 = new JLabel(DFNTools.getFloatingIcon(dfn)); icon2.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon1); cptitle.getAdditionalIconPanel().add(icon2); if (dfn.isFloating()) { cptitle.getButton().setToolTipText(SYSTools.xx("nursingrecords.dfn.enforced.tooltip") + ": " + DateFormat.getDateInstance().format(dfn.getStDatum())); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) && (dfn.isOnDemand() || !dfn.getNursingProcess().isClosed())) { /*** * _ _ _ _ * | |__ | |_ _ __ / \ _ __ _ __ | |_ _ * | '_ \| __| '_ \ / _ \ | '_ \| '_ \| | | | | * | |_) | |_| | | |/ ___ \| |_) | |_) | | |_| | * |_.__/ \__|_| |_/_/ \_\ .__/| .__/|_|\__, | * |_| |_| |___/ */ JButton btnApply = new JButton(SYSConst.icon22apply); btnApply.setPressedIcon(SYSConst.icon22applyPressed); btnApply.setAlignmentX(Component.RIGHT_ALIGNMENT); btnApply.setContentAreaFilled(false); btnApply.setBorder(null); btnApply.addActionListener(applyActionListener); btnApply.setEnabled(!dfn.isOnDemand() && dfn.isOpen()); cptitle.getRight().add(btnApply); // JPanel spacer = new JPanel(); // spacer.setOpaque(false); // cptitle.getRight().add(spacer); /*** * _ _ ____ _ * | |__ | |_ _ __ / ___|__ _ _ __ ___ ___| | * | '_ \| __| '_ \| | / _` | '_ \ / __/ _ \ | * | |_) | |_| | | | |__| (_| | | | | (_| __/ | * |_.__/ \__|_| |_|\____\__,_|_| |_|\___\___|_| * */ final JButton btnCancel = new JButton(SYSConst.icon22cancel); btnCancel.setPressedIcon(SYSConst.icon22cancelPressed); btnCancel.setAlignmentX(Component.RIGHT_ALIGNMENT); btnCancel.setContentAreaFilled(false); btnCancel.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_REFUSED) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setState(DFNTools.STATE_REFUSED); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setIst(new Date()); myDFN.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }); btnCancel.setEnabled(!dfn.isOnDemand() && dfn.isOpen()); cptitle.getRight().add(btnCancel); /*** * _ _ _____ _ * | |__ | |_ _ __ | ____|_ __ ___ _ __ | |_ _ _ * | '_ \| __| '_ \| _| | '_ ` _ \| '_ \| __| | | | * | |_) | |_| | | | |___| | | | | | |_) | |_| |_| | * |_.__/ \__|_| |_|_____|_| |_| |_| .__/ \__|\__, | * |_| |___/ */ final JButton btnEmpty = new JButton(SYSConst.icon22empty); btnEmpty.setPressedIcon(SYSConst.icon22emptyPressed); btnEmpty.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEmpty.setContentAreaFilled(false); btnEmpty.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnEmpty.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_OPEN) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } // on demand DFNs are deleted if they not wanted anymore if (myDFN.isOnDemand()) { em.remove(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.remove(myDFN); } synchronized (mapShift2DFN) { mapShift2DFN.get(myDFN.getShift()).remove(myDFN); } } else { // the normal DFNs (those assigned to a NursingProcess) are reset to the OPEN state. myDFN.setState(DFNTools.STATE_OPEN); myDFN.setUser(null); myDFN.setIst(null); myDFN.setiZeit(null); myDFN.setMdate(new Date()); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } } em.getTransaction().commit(); CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }); btnEmpty.setEnabled(!dfn.isOpen()); cptitle.getRight().add(btnEmpty); /*** * _ _ __ __ _ _ * | |__ | |_ _ __ | \/ (_)_ __ _ _| |_ ___ ___ * | '_ \| __| '_ \| |\/| | | '_ \| | | | __/ _ \/ __| * | |_) | |_| | | | | | | | | | | |_| | || __/\__ \ * |_.__/ \__|_| |_|_| |_|_|_| |_|\__,_|\__\___||___/ * */ final JButton btnMinutes = new JButton(SYSConst.icon22clock); btnMinutes.setPressedIcon(SYSConst.icon22clockPressed); btnMinutes.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMinutes.setContentAreaFilled(false); btnMinutes.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnMinutes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!DFNTools.isChangeable(dfn)) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); return; } 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); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setMinutes(new BigDecimal((Integer) o)); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } }); menu.show(btnMinutes, 0, btnMinutes.getHeight()); } }); btnMinutes.setEnabled(dfn.getState() != DFNTools.STATE_OPEN); cptitle.getRight().add(btnMinutes); } /*** * _ _ ___ __ * | |__ | |_ _ __ |_ _|_ __ / _| ___ * | '_ \| __| '_ \ | || '_ \| |_ / _ \ * | |_) | |_| | | || || | | | _| (_) | * |_.__/ \__|_| |_|___|_| |_|_| \___/ * */ final JButton btnInfo = new JButton(SYSConst.icon22info); final JidePopup popupInfo = new JidePopup(); btnInfo.setPressedIcon(SYSConst.icon22infoPressed); btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT); btnInfo.setContentAreaFilled(false); btnInfo.setBorder(null); final JTextPane txt = new JTextPane(); txt.setContentType("text/html"); txt.setEditable(false); popupInfo.setMovable(false); popupInfo.getContentPane().setLayout(new BoxLayout(popupInfo.getContentPane(), BoxLayout.LINE_AXIS)); popupInfo.getContentPane().add(new JScrollPane(txt)); popupInfo.removeExcludedComponent(txt); popupInfo.setDefaultFocusComponent(txt); btnInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { popupInfo.setOwner(btnInfo); txt.setText(SYSTools.toHTML(SYSConst.html_div(dfn.getInterventionSchedule().getBemerkung()))); GUITools.showPopup(popupInfo, SwingConstants.WEST); } }); btnInfo.setEnabled( !dfn.isOnDemand() && !SYSTools.catchNull(dfn.getInterventionSchedule().getBemerkung()).isEmpty()); cptitle.getRight().add(btnInfo); dfnPane.setTitleLabelComponent(cptitle.getMain()); dfnPane.setBackground(dfn.getBG()); dfnPane.setForeground(dfn.getFG()); try { dfnPane.setCollapsed(true); } catch (PropertyVetoException e) { OPDE.error(e); } dfnPane.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { JTextPane contentPane = new JTextPane(); contentPane.setContentType("text/html"); contentPane.setEditable(false); contentPane.setText(SYSTools .toHTML(NursingProcessTools.getAsHTML(dfn.getNursingProcess(), false, true, false, false))); dfnPane.setContentPane(contentPane); } }); dfnPane.setCollapsible(dfn.getNursingProcess() != null); dfnPane.setHorizontalAlignment(SwingConstants.LEADING); dfnPane.setOpaque(false); return dfnPane; }
From source file:op.FrmMain.java
public void afterLogin() { OPDE.getDisplayManager().touch();/*from w w w.j a v a 2s .c o m*/ dlgLogin = null; if (OPDE.isTraining()) { JTextPane txtMessage = new JTextPane(); txtMessage.setFont(new Font("Arial", Font.PLAIN, 18)); txtMessage.setEditable(false); txtMessage.setContentType("text/html"); txtMessage.setText(SYSTools.toHTMLForScreen(SYSTools.xx("opde.general.training.version.message"))); JOptionPane.showConfirmDialog(this, txtMessage, SYSTools.xx("opde.general.training.version.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); } if (specialities != null) { synchronized (specialities) { SYSTools.clear(specialities); } } specialities = Collections.synchronizedMap(new HashMap<Integer, Set<Resident>>()); synchronized (specialities) { specialities.put(ResInfoTypeTools.TYPE_ABSENCE, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_INFECTION, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_WARNING, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_ALLERGY, new HashSet<Resident>()); specialities.put(ResInfoTypeTools.TYPE_DIABETES, new HashSet<Resident>()); for (ResInfo info : ResInfoTools.getSpecialInfos()) { specialities.get(info.getResInfoType().getType()).add(info.getResident()); } } prepareSearchArea(); labelUSER.setText(OPDE.getLogin().getUser().getFullname()); Runnable runnable = new Runnable() { @Override public void run() { initPhase = true; double pos; try { pos = Double.parseDouble( OPDE.getProps().getProperty("opde.mainframe:splitPaneLeftDividerLocation")); } catch (Exception e) { pos = 0.5d; } splitPaneLeft.setDividerLocation(0, SYSTools.getDividerInAbsolutePosition(splitPaneLeft, pos)); initPhase = false; homeButton.doClick(); } }; SwingUtilities.invokeLater(runnable); }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private JTextPane createLabel(String txt) { JTextPane pane = new JTextPane(); pane.setText(txt);//from www . j a v a 2 s .c o m setBorder(pane); pane.setEditable(false); return pane; }
From source file:org.drugis.addis.gui.wizard.AddStudyWizard.java
private static JComponent buildTip(String tip) { JTextPane area = new JTextPane(); StyledDocument doc = area.getStyledDocument(); addStylesToDoc(doc);//w w w. j a va 2 s . c om area.setBackground(new Color(255, 180, 180)); try { doc.insertString(0, "x", doc.getStyle("tip")); doc.insertString(doc.getLength(), " Tip: \n", doc.getStyle("bold")); doc.insertString(doc.getLength(), tip, doc.getStyle("regular")); } catch (BadLocationException e) { e.printStackTrace(); } area.setEditable(false); JScrollPane pane = new JScrollPane(area); pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); pane.setPreferredSize(TextComponentFactory.textPaneDimension(area, 270, 70)); pane.setWheelScrollingEnabled(true); pane.getVerticalScrollBar().setValue(0); return pane; }
From source file:org.echocat.velma.dialogs.AboutDialog.java
protected void createIntroduction(@Nonnull Resources resources) { final URL iconUrl = resources.getIconUrl(48); final StringBuilder body = new StringBuilder(); body.append("<html>"); body.append("<head><style>" + "td { margin-right: 10px; }" + "</style></head>"); body.append("<body style='font-family: sans; font-size: 1em'><table><tr>"); body.append("<td valign='top'><img src='").append(iconUrl).append("' /></td>"); body.append("<td valign='top'>"); body.append("<h2>").append(escapeHtml4(resources.getApplicationName())); final String version = resources.getVersion(); if (!isEmpty(version)) { body.append("<br/><span style='font-size: 0.6em'>") .append(resources.formatEscaped("versionText", version)).append("</span>"); }/*from w w w . j a va 2s. c o m*/ body.append("</h2>"); body.append("<p>Copyright 2011-2012 <a href='https://echocat.org'>echocat</a></p>"); body.append("<p><a href='http://mozilla.org/MPL/2.0/'>") .append(resources.formatEscaped("licensedUnder", "MPL 2.0")).append("</a></p>"); body.append("<p><table cellpadding='0' cellspacing='0'>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "echocat")) .append(":</td><td><a href='https://echocat.org'>echocat.org</a></td></tr>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "Velma")) .append(":</td><td><a href='https://velma.echocat.org'>velma.echocat.org</a></td></tr>"); body.append("</table></p>"); body.append("<h4>").append(resources.formatEscaped("developers")) .append("</h4><table cellpadding='0' cellspacing='0'>"); body.append( "<tr><td>Gregor Noczinski</td><td><a href='mailto:gregor@noczinski.eu'>gregor@noczinski.eu</a></td><td><a href='https://github.com/blaubaer'>github.com/blaubaer</a></td></tr>"); body.append("</table>"); body.append("</td>"); body.append("</tr></table></body></html>"); final JTextPane text = new JTextPane(); text.setMargin(new Insets(0, 0, 0, 0)); text.setContentType("text/html"); text.setText(body.toString()); text.setFont(new Font(DIALOG, PLAIN, 12)); text.setBackground(new Color(255, 255, 255, 0)); text.setEditable(false); text.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == ACTIVATED && isDesktopSupported()) { final Desktop desktop = getDesktop(); if (desktop.isSupported(BROWSE)) { try { desktop.browse(e.getURL().toURI()); } catch (IOException | URISyntaxException exception) { LOG.error("Could not open " + e.getURL() + " because of an exception.", exception); } } else { LOG.error("Could not open " + e.getURL() + " because browse is not supported by desktop."); } } repaint(); } }); text.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { repaint(); } @Override public void mousePressed(MouseEvent e) { repaint(); } @Override public void mouseReleased(MouseEvent e) { repaint(); } @Override public void mouseEntered(MouseEvent e) { repaint(); } @Override public void mouseExited(MouseEvent e) { repaint(); } }); add(text, new CC().spanX(2).growX().minWidth("10px")); }