List of usage examples for javax.swing JTextPane JTextPane
public JTextPane()
JTextPane
. From source file:src.gui.ItSIMPLE.java
/** * This method initializes planDatabasePanel * * @return javax.swing.JPanel//from www.j a v a2 s .co m */ private JPanel getPlanDatabasePanel() { //TODO: if (planDatabasePanel == null) { planDatabasePanel = new JPanel(new BorderLayout()); //planDatabasePanel.add(getPlanDatabaseToolBar(), BorderLayout.NORTH); //top panel (toolbar + filter filed JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(getPlanDatabaseToolBar(), BorderLayout.NORTH); planFilterPanel = new JPanel(new BorderLayout()); planfilterTextPane = new JTextPane(); planfilterTextPane.setBackground(Color.WHITE); //planfilterTextPane.setPreferredSize(new Dimension(250,100)); planfilterTextPane.setFont(new Font("Monospaced", Font.PLAIN, 14)); planfilterTextPane.setToolTipText("<html>Please use only the following column names:<br>" + "id<br>project<br>domain<br>plannername<br>plannerversion<br>nactions<br>quality</html>"); JScrollPane scrollText = new JScrollPane(); scrollText.setViewportView(planfilterTextPane); JLabel descriptionLabel = new JLabel("<html>Filter: </html>"); planFilterPanel.add(descriptionLabel, BorderLayout.NORTH); planFilterPanel.add(scrollText, BorderLayout.CENTER); planFilterPanel.setPreferredSize(new Dimension(250, 90)); planFilterPanel.setVisible(false); topPanel.add(planFilterPanel, BorderLayout.CENTER); planDatabasePanel.add(topPanel, BorderLayout.NORTH); resultPlanTableModel = new DefaultTableModel(); resultPlanTable = new JTable(resultPlanTableModel) { @Override public boolean isCellEditable(int row, int column) { //avoid columns that can not edit (leaving only the evaluation to edit) return false; //if(column < 4){ // return false; //}else{ // return true; //} } }; //resultPlanTableModel.addTableModelListener(this); //allows a single row selection resultPlanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resultPlanTableModel.addColumn("id"); //resultPlanTableModel.addColumn("#"); resultPlanTableModel.addColumn("project"); resultPlanTableModel.addColumn("domain"); resultPlanTableModel.addColumn("problem"); //resultPlanTableModel.addColumn("planner"); resultPlanTableModel.addColumn("plannername"); resultPlanTableModel.addColumn("nactions"); //resultPlanTableModel.addColumn("# actions"); resultPlanTableModel.addColumn("cost"); resultPlanTableModel.addColumn("quality"); //resultPlanTable.getColumnModel().getColumn(0).setMinWidth(25); //resultPlanTable.getColumnModel().getColumn(0).setMaxWidth(50); //resultPlanTable.getColumnModel().getColumn(1).setMinWidth(30); //resultPlanTable.getColumnModel().getColumn(1).setMaxWidth(40); //resultPlanTable.getColumnModel().getColumn(2).setMinWidth(150); //resultPlanTable.getColumnModel().getColumn(2).setMaxWidth(300); //resultPlanTable.getColumnModel().getColumn(3).setMinWidth(150); //resultPlanTable.getColumnModel().getColumn(3).setMaxWidth(300); //resultPlanTable.getColumnModel().getColumn(4).setMinWidth(150); //resultPlanTable.getColumnModel().getColumn(4).setMaxWidth(300); //resultPlanTable.getColumnModel().getColumn(6).setMinWidth(55); //resultPlanTable.getColumnModel().getColumn(6).setMaxWidth(75); //resultPlanTable.getColumnModel().getColumn(7).setMinWidth(50); //resultPlanTable.getColumnModel().getColumn(7).setMaxWidth(70); resultPlanTable.getColumnModel().getColumn(0).setMinWidth(25); resultPlanTable.getColumnModel().getColumn(0).setMaxWidth(50); resultPlanTable.getColumnModel().getColumn(1).setMinWidth(150); resultPlanTable.getColumnModel().getColumn(1).setMaxWidth(300); resultPlanTable.getColumnModel().getColumn(2).setMinWidth(150); resultPlanTable.getColumnModel().getColumn(2).setMaxWidth(300); resultPlanTable.getColumnModel().getColumn(3).setMinWidth(150); resultPlanTable.getColumnModel().getColumn(3).setMaxWidth(300); resultPlanTable.getColumnModel().getColumn(5).setMinWidth(55); resultPlanTable.getColumnModel().getColumn(5).setMaxWidth(75); resultPlanTable.getColumnModel().getColumn(6).setMinWidth(50); resultPlanTable.getColumnModel().getColumn(6).setMaxWidth(70); resultPlanTable.getColumnModel().getColumn(7).setMinWidth(50); resultPlanTable.getColumnModel().getColumn(7).setMaxWidth(70); //do not show the id (for now) //resultPlanTable.removeColumn(resultPlanTable.getColumnModel().getColumn(0)); JScrollPane scrollPlanResultPane = new JScrollPane(resultPlanTable); planDatabasePanel.add(scrollPlanResultPane, BorderLayout.CENTER); //planDatabasePanel.add(new JPanel(), BorderLayout.CENTER); } return planDatabasePanel; }
From source file:src.gui.ItSIMPLE.java
public JTextPane getPetriDetailsTextPane() { if (petriDetailsTextPane == null) { petriDetailsTextPane = new JTextPane(); petriDetailsTextPane.setEditable(false); petriDetailsTextPane.setContentType("text/html"); }//from w w w . jav a 2s . c om return petriDetailsTextPane; }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Main entry class for the application// www.j a v a2 s.c o m * * @param config - ImportConfig file */ public GuiImporter(ImportConfig config) { //super(TITLE); //javax.swing.ToolTipManager.sharedInstance().setDismissDelay(0); this.setConfig(config); this.bounds = config.getUIBounds(); Level level = org.apache.log4j.Level.toLevel(config.getDebugLevel()); LogAppender.setLoggingLevel(level); historyHandler = new HistoryHandler(this); setHistoryTable(historyHandler.table); // Add a shutdown hook for when app closes Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { log.debug("Running shutdown hook."); shutdown(); } }); // Set app defaults setTitle(config.getAppTitle()); setIconImage(GuiCommonElements.getImageIcon(GuiImporter.ICON).getImage()); setPreferredSize(new Dimension(bounds.width, bounds.height)); setSize(bounds.width, bounds.height); setLocation(bounds.x, bounds.y); setLayout(new BorderLayout()); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); pack(); addWindowListener(this); // capture move info addComponentListener(new ComponentAdapter() { public void componentMoved(ComponentEvent evt) { bounds = getBounds(); } }); // capture resize info addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { bounds = getBounds(); } }); // menu bar menubar = new JMenuBar(); fileMenu = new JMenu("File"); menubar.add(fileMenu); login = new JMenuItem("Login to the server...", GuiCommonElements.getImageIcon(LOGIN_ICON)); login.setActionCommand("login"); login.addActionListener(this); fileMenu.add(login); options = new JMenuItem("Options...", GuiCommonElements.getImageIcon(CONFIG_ICON)); options.setActionCommand("options"); options.addActionListener(this); fileMenu.add(options); fileQuit = new JMenuItem("Quit", GuiCommonElements.getImageIcon(QUIT_ICON)); fileQuit.setActionCommand("quit"); fileQuit.addActionListener(this); fileMenu.add(fileQuit); helpMenu = new JMenu("Help"); menubar.add(helpMenu); helpComment = new JMenuItem("Send a Comment...", GuiCommonElements.getImageIcon(COMMENT_ICON)); helpComment.setActionCommand("comment"); helpComment.addActionListener(this); helpHome = new JMenuItem("Visit Importer Homepage...", GuiCommonElements.getImageIcon(HOME_ICON)); helpHome.setActionCommand("home"); helpHome.addActionListener(this); helpForums = new JMenuItem("Visit the OMERO Forums...", GuiCommonElements.getImageIcon(FORUM_ICON)); helpForums.setActionCommand("forums"); helpForums.addActionListener(this); helpAbout = new JMenuItem("About the Importer...", GuiCommonElements.getImageIcon(ABOUT_ICON)); helpAbout.setActionCommand("about"); helpAbout.addActionListener(this); helpMenu.add(helpComment); helpMenu.add(helpHome); helpMenu.add(helpForums); // Help --> Show log file location... JMenuItem helpShowLog = new JMenuItem("Show log file location...", GuiCommonElements.getImageIcon(LOGFILE_ICON)); helpShowLog.setActionCommand(show_log_file); helpShowLog.addActionListener(this); helpMenu.add(helpShowLog); helpMenu.add(helpAbout); // Help --> About setJMenuBar(menubar); // tabbed panes tPane = new JTabbedPane(); tPane.setOpaque(false); // content panes must be opaque // file chooser pane JPanel filePanel = new JPanel(new BorderLayout()); setStatusBar(new StatusBar()); getStatusBar().setStatusIcon("gfx/server_disconn16.png", "Server disconnected."); getStatusBar().setProgress(false, 0, ""); this.getContentPane().add(getStatusBar(), BorderLayout.SOUTH); // The file chooser sub-pane setFileQueueHandler(new FileQueueHandler(scanEx, importEx, this, config)); //splitPane.setResizeWeight(0.5); filePanel.add(getFileQueueHandler(), BorderLayout.CENTER); tPane.addTab("File Chooser", GuiCommonElements.getImageIcon(CHOOSER_ICON), filePanel, "Add and delete images here to the import queue."); tPane.setMnemonicAt(0, KeyEvent.VK_1); // history pane historyPanel = new JPanel(); historyPanel.setOpaque(false); historyPanel.setLayout(new BorderLayout()); tPane.addTab("Import History", GuiCommonElements.getImageIcon(HISTORY_ICON), historyPanel, "Import history is displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_4); // output text pane JPanel outputPanel = new JPanel(); outputPanel.setLayout(new BorderLayout()); outputTextPane = new JTextPane(); outputTextPane.setEditable(false); JScrollPane outputScrollPane = new JScrollPane(); outputScrollPane.getViewport().add(outputTextPane); outputScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { outputTextPane.setCaretPosition(outputTextPane.getDocument().getLength()); } catch (IllegalArgumentException e1) { log.error("Error setting cursor:" + e1); } } }); outputPanel.add(outputScrollPane, BorderLayout.CENTER); tPane.addTab("Output Text", GuiCommonElements.getImageIcon(OUTPUT_ICON), outputPanel, "Standard output text goes here."); tPane.setMnemonicAt(0, KeyEvent.VK_2); // debug pane JPanel debugPanel = new JPanel(); debugPanel.setLayout(new BorderLayout()); debugTextPane = new JTextPane(); debugTextPane.setEditable(false); JScrollPane debugScrollPane = new JScrollPane(); debugScrollPane.getViewport().add(debugTextPane); debugScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { debugTextPane.setCaretPosition(debugTextPane.getDocument().getLength()); } catch (IllegalArgumentException e1) { log.error("Error setting cursor:" + e1); } } }); debugPanel.add(debugScrollPane, BorderLayout.CENTER); tPane.addTab("Debug Text", GuiCommonElements.getImageIcon(BUG_ICON), debugPanel, "Debug messages are displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_3); // Error Pane errorPanel = new JPanel(); errorPanel.setOpaque(false); errorPanel.setLayout(new BorderLayout()); tPane.addTab("Import Errors", GuiCommonElements.getImageIcon(ERROR_ICON), errorPanel, "Import errors are displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_5); tPane.setSelectedIndex(0); if (getHistoryTable().db.historyEnabled == false) tPane.setEnabledAt(historyTabIndex, false); // Add the tabbed pane to this panel. add(tPane); this.setVisible(false); historyPanel.add(historyHandler, BorderLayout.CENTER); tPane.setEnabledAt(historyTabIndex, false); setLoginHandler(new LoginHandler(this, getHistoryTable())); LogAppender.getInstance().setTextArea(debugTextPane); appendToOutputLn("> Starting the importer (revision " + getPrintableKeyword(Version.revision) + ")."); appendToOutputLn("> Build date: " + getPrintableKeyword(Version.revisionDate)); appendToOutputLn("> Release date: " + Version.releaseDate); // TODO : should this be a third executor? setErrorHandler(new ErrorHandler(importEx, config)); getErrorHandler().addObserver(this); errorPanel.add(getErrorHandler(), BorderLayout.CENTER); macMenuFix(); //displayLoginDialog(this, true); }
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 . j a v a 2 s . co 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// www. ja v a2 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.care.med.inventory.DlgCloseStock.java
/** * This method is called from within the constructor to * initialize the form.// w w w . j a va2s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new JPanel(); jScrollPane1 = new JScrollPane(); txtInfo = new JTextPane(); rbLeer = new JRadioButton(); rbStellen = new JRadioButton(); txtLetzte = new JTextField(); lblEinheiten = new JLabel(); rbAbgelaufen = new JRadioButton(); jSeparator1 = new JSeparator(); jLabel2 = new JLabel(); jLabel3 = new JLabel(); rbGefallen = new JRadioButton(); cmbBestID = new JComboBox(); panel1 = new JPanel(); btnClose = new JButton(); btnOk = new JButton(); //======== this ======== setResizable(false); setModalityType(Dialog.ModalityType.APPLICATION_MODAL); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); //======== jPanel1 ======== { jPanel1.setBorder(null); jPanel1.setLayout(new FormLayout("14dlu, $lcgap, 145dlu, $lcgap, 41dlu, $lcgap, 93dlu, $lcgap, 14dlu", "14dlu, $lgap, fill:70dlu:grow, 4*($lgap, fill:default), $lgap, $rgap, $lgap, fill:default, $lgap, $rgap, $lgap, default, $lgap, 14dlu")); //======== jScrollPane1 ======== { //---- txtInfo ---- txtInfo.setEditable(false); txtInfo.setFont(new Font("Arial", Font.PLAIN, 14)); jScrollPane1.setViewportView(txtInfo); } jPanel1.add(jScrollPane1, CC.xywh(3, 3, 5, 1)); //---- rbLeer ---- rbLeer.setSelected(true); rbLeer.setText("Die Packung ist nun leer"); rbLeer.setFont(new Font("Arial", Font.PLAIN, 14)); rbLeer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rbLeerActionPerformed(e); } }); jPanel1.add(rbLeer, CC.xy(3, 5)); //---- rbStellen ---- rbStellen.setText("Beim Vorab Stellen haben Sie die letzten "); rbStellen.setFont(new Font("Arial", Font.PLAIN, 14)); rbStellen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rbStellenActionPerformed(e); } }); jPanel1.add(rbStellen, CC.xywh(3, 7, 2, 1)); //---- txtLetzte ---- txtLetzte.setText("jTextField1"); txtLetzte.setFont(new Font("Arial", Font.PLAIN, 14)); txtLetzte.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { txtLetzteFocusLost(e); } }); jPanel1.add(txtLetzte, CC.xy(5, 7)); //---- lblEinheiten ---- lblEinheiten.setText("Einheiten verbraucht."); lblEinheiten.setFont(new Font("Arial", Font.PLAIN, 14)); jPanel1.add(lblEinheiten, CC.xy(7, 7)); //---- rbAbgelaufen ---- rbAbgelaufen.setText( "Die Packung ist abgelaufen oder wird nicht mehr ben\u00f6tigt. Bereit zur Entsorgung."); rbAbgelaufen.setFont(new Font("Arial", Font.PLAIN, 14)); rbAbgelaufen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rbAbgelaufenActionPerformed(e); } }); jPanel1.add(rbAbgelaufen, CC.xywh(3, 9, 5, 1)); jPanel1.add(jSeparator1, CC.xywh(3, 13, 5, 1)); //---- jLabel2 ---- jLabel2.setText("Als n\u00e4chstes Packung soll die Nummer"); jLabel2.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel2.setHorizontalAlignment(SwingConstants.TRAILING); jPanel1.add(jLabel2, CC.xy(3, 15)); //---- jLabel3 ---- jLabel3.setText("angebrochen werden."); jLabel3.setFont(new Font("Arial", Font.PLAIN, 14)); jPanel1.add(jLabel3, CC.xy(7, 15)); //---- rbGefallen ---- rbGefallen.setText( "<html>Die Packung ist <font color=\"red\">runter gefallen</font> oder <font color=\"red\">verschwunden</font> und muss ausgebucht werden.</html>"); rbGefallen.setFont(new Font("Arial", Font.PLAIN, 14)); rbGefallen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rbGefallenActionPerformed(e); } }); jPanel1.add(rbGefallen, CC.xywh(3, 11, 5, 1)); //---- cmbBestID ---- cmbBestID.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbBestID.setFont(new Font("Arial", Font.PLAIN, 14)); cmbBestID.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbBestIDItemStateChanged(e); } }); jPanel1.add(cmbBestID, CC.xy(5, 15)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.setText(null); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCloseActionPerformed(e); } }); panel1.add(btnClose); //---- btnOk ---- btnOk.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnOk.setText(null); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnOkActionPerformed(e); } }); panel1.add(btnOk); } jPanel1.add(panel1, CC.xy(7, 19, CC.RIGHT, CC.DEFAULT)); } contentPane.add(jPanel1); pack(); setLocationRelativeTo(getOwner()); //---- buttonGroup1 ---- ButtonGroup buttonGroup1 = new ButtonGroup(); buttonGroup1.add(rbLeer); buttonGroup1.add(rbStellen); buttonGroup1.add(rbAbgelaufen); buttonGroup1.add(rbGefallen); }
From source file:op.care.prescription.DlgOnDemand.java
/** * This method is called from within the constructor to * initialize the form.//from w ww . j a va2 s. c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new JPanel(); txtMed = new JXSearchField(); cmbMed = new JComboBox<>(); panel4 = new JPanel(); btnMedWizard = new JButton(); cmbIntervention = new JComboBox<>(); txtSit = new JXSearchField(); cmbSit = new JComboBox<>(); panel3 = new JPanel(); btnAddSit = new JButton(); txtIntervention = new JXSearchField(); jPanel2 = new JPanel(); lblNumber = new JLabel(); lblDose = new JLabel(); lblMaxPerDay = new JLabel(); txtMaxTimes = new JTextField(); lblX = new JLabel(); txtEDosis = new JTextField(); lblCheckResultAfter = new JLabel(); cmbCheckAfter = new JComboBox<>(); jPanel3 = new JPanel(); pnlOFF = new JPanel(); rbActive = new JRadioButton(); rbDate = new JRadioButton(); txtOFF = new JTextField(); jScrollPane3 = new JScrollPane(); txtBemerkung = new JTextPane(); lblText = new JLabel(); pnlON = new JPanel(); cmbDocON = new JComboBox<>(); cmbHospitalON = new JComboBox<>(); panel1 = new JPanel(); btnClose = new JButton(); btnSave = new JButton(); //======== this ======== setModalityType(Dialog.ModalityType.APPLICATION_MODAL); setResizable(false); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("14dlu, $lcgap, default, 6dlu, 355dlu, $lcgap, 14dlu", "14dlu, $lgap, fill:default:grow, $lgap, fill:default, $lgap, 14dlu")); //======== jPanel1 ======== { jPanel1.setBorder(null); jPanel1.setLayout(new FormLayout("68dlu, $lcgap, pref:grow, $lcgap, pref", "3*(16dlu, $lgap), default, $lgap, fill:113dlu:grow, $lgap, 60dlu")); //---- txtMed ---- txtMed.setFont(new Font("Arial", Font.PLAIN, 14)); txtMed.setPrompt("Medikamente"); txtMed.setFocusBehavior(PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT); txtMed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMedActionPerformed(e); } }); txtMed.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtMedFocusGained(e); } }); jPanel1.add(txtMed, CC.xy(1, 1)); //---- cmbMed ---- cmbMed.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbMed.setFont(new Font("Arial", Font.PLAIN, 14)); cmbMed.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbMedItemStateChanged(e); } }); jPanel1.add(cmbMed, CC.xy(3, 1)); //======== panel4 ======== { panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS)); //---- btnMedWizard ---- btnMedWizard.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnMedWizard.setBorderPainted(false); btnMedWizard.setBorder(null); btnMedWizard.setContentAreaFilled(false); btnMedWizard.setToolTipText("Neues Medikament eintragen"); btnMedWizard.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMedWizard.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnMedWizard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnMedActionPerformed(e); } }); panel4.add(btnMedWizard); } jPanel1.add(panel4, CC.xy(5, 1)); //---- cmbIntervention ---- cmbIntervention .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbIntervention.setFont(new Font("Arial", Font.PLAIN, 14)); jPanel1.add(cmbIntervention, CC.xywh(3, 5, 3, 1)); //---- txtSit ---- txtSit.setPrompt("Situationen"); txtSit.setFont(new Font("Arial", Font.PLAIN, 14)); txtSit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtSitActionPerformed(e); } }); jPanel1.add(txtSit, CC.xy(1, 3)); //---- cmbSit ---- cmbSit.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbSit.setFont(new Font("Arial", Font.PLAIN, 14)); cmbSit.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbSitItemStateChanged(e); } }); cmbSit.addPropertyChangeListener("model", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { cmbSitPropertyChange(e); } }); jPanel1.add(cmbSit, CC.xy(3, 3)); //======== panel3 ======== { panel3.setLayout(new BoxLayout(panel3, BoxLayout.LINE_AXIS)); //---- btnAddSit ---- btnAddSit.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnAddSit.setBorderPainted(false); btnAddSit.setBorder(null); btnAddSit.setContentAreaFilled(false); btnAddSit.setToolTipText("Neue Situation eintragen"); btnAddSit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnAddSit.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnAddSit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSituationActionPerformed(e); } }); panel3.add(btnAddSit); } jPanel1.add(panel3, CC.xy(5, 3, CC.RIGHT, CC.DEFAULT)); //---- txtIntervention ---- txtIntervention.setFont(new Font("Arial", Font.PLAIN, 14)); txtIntervention.setPrompt("Massnahmen"); txtIntervention.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMassActionPerformed(e); } }); jPanel1.add(txtIntervention, CC.xy(1, 5)); //======== jPanel2 ======== { jPanel2.setLayout(new FormLayout("default, $lcgap, pref, $lcgap, default, $lcgap, 37dlu:grow", "23dlu, fill:22dlu, $ugap, default")); //---- lblNumber ---- lblNumber.setText("Anzahl"); jPanel2.add(lblNumber, CC.xy(3, 1)); //---- lblDose ---- lblDose.setText("Dosis"); jPanel2.add(lblDose, CC.xy(7, 1, CC.CENTER, CC.DEFAULT)); //---- lblMaxPerDay ---- lblMaxPerDay.setText("Max. Tagesdosis:"); jPanel2.add(lblMaxPerDay, CC.xy(1, 2)); //---- txtMaxTimes ---- txtMaxTimes.setHorizontalAlignment(SwingConstants.CENTER); txtMaxTimes.setText("1"); txtMaxTimes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMaxTimesActionPerformed(e); } }); txtMaxTimes.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtMaxTimesFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtMaxTimesFocusLost(e); } }); jPanel2.add(txtMaxTimes, CC.xy(3, 2)); //---- lblX ---- lblX.setText("x"); jPanel2.add(lblX, CC.xy(5, 2)); //---- txtEDosis ---- txtEDosis.setHorizontalAlignment(SwingConstants.CENTER); txtEDosis.setText("1.0"); txtEDosis.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtEDosisFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtEDosisFocusLost(e); } }); txtEDosis.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtEDosisActionPerformed(e); } }); jPanel2.add(txtEDosis, CC.xy(7, 2)); //---- lblCheckResultAfter ---- lblCheckResultAfter.setText("Nachkontrolle:"); jPanel2.add(lblCheckResultAfter, CC.xy(1, 4)); //---- cmbCheckAfter ---- cmbCheckAfter.setModel(new DefaultComboBoxModel<>(new String[] { "keine Nachkontrolle", "nach 1 Stunde", "nach 2 Stunden", "nach 3 Stunden" })); jPanel2.add(cmbCheckAfter, CC.xywh(3, 4, 5, 1)); } jPanel1.add(jPanel2, CC.xywh(1, 9, 5, 1, CC.CENTER, CC.TOP)); } contentPane.add(jPanel1, CC.xy(5, 3)); //======== jPanel3 ======== { jPanel3.setBorder(null); jPanel3.setLayout(new FormLayout("149dlu", "3*(fill:default, $lgap), fill:100dlu:grow")); //======== pnlOFF ======== { pnlOFF.setBorder(new TitledBorder("Absetzung")); pnlOFF.setLayout(new FormLayout("pref, 86dlu:grow", "fill:17dlu, $lgap, fill:17dlu")); //---- rbActive ---- rbActive.setText("text"); rbActive.setSelected(true); rbActive.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rbActiveItemStateChanged(e); } }); pnlOFF.add(rbActive, CC.xywh(1, 1, 2, 1)); //---- rbDate ---- rbDate.setText(null); rbDate.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rbDateItemStateChanged(e); } }); pnlOFF.add(rbDate, CC.xy(1, 3)); //---- txtOFF ---- txtOFF.setEnabled(false); txtOFF.setFont(new Font("Arial", Font.PLAIN, 14)); txtOFF.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { txtOFFFocusLost(e); } }); pnlOFF.add(txtOFF, CC.xy(2, 3)); } jPanel3.add(pnlOFF, CC.xy(1, 3)); //======== jScrollPane3 ======== { //---- txtBemerkung ---- txtBemerkung.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent e) { txtBemerkungCaretUpdate(e); } }); jScrollPane3.setViewportView(txtBemerkung); } jPanel3.add(jScrollPane3, CC.xy(1, 7)); //---- lblText ---- lblText.setText("Bemerkung:"); jPanel3.add(lblText, CC.xy(1, 5)); //======== pnlON ======== { pnlON.setBorder(new TitledBorder("Ansetzung")); pnlON.setLayout(new FormLayout("119dlu:grow", "17dlu, $lgap, fill:17dlu")); //---- cmbDocON ---- cmbDocON.setModel( new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbDocON.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { cmbDocONKeyPressed(e); } }); pnlON.add(cmbDocON, CC.xy(1, 1)); //---- cmbHospitalON ---- cmbHospitalON.setModel( new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); pnlON.add(cmbHospitalON, CC.xy(1, 3)); } jPanel3.add(pnlON, CC.xy(1, 1)); } contentPane.add(jPanel3, CC.xy(3, 3)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCloseActionPerformed(e); } }); panel1.add(btnClose); //---- btnSave ---- btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnSave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSaveActionPerformed(e); } }); panel1.add(btnSave); } contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT)); setSize(1035, 515); setLocationRelativeTo(getOwner()); //---- bgMedikament ---- ButtonGroup bgMedikament = new ButtonGroup(); bgMedikament.add(rbActive); bgMedikament.add(rbDate); }
From source file:op.care.prescription.DlgRegular.java
/** * This method is called from within the constructor to * initialize the form./*from w w w . ja va 2 s . c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new JPanel(); txtMed = new JXSearchField(); cmbMed = new JComboBox<>(); panel4 = new JPanel(); btnMed = new JButton(); cmbIntervention = new JComboBox<>(); txtIntervention = new JXSearchField(); jPanel8 = new JPanel(); jspDosis = new JScrollPane(); tblDosis = new JTable(); panel2 = new JPanel(); btnAddDosis = new JButton(); jPanel3 = new JPanel(); pnlOFF = new JPanel(); rbActive = new JRadioButton(); rbDate = new JRadioButton(); txtTo = new JTextField(); rbEndOfPackage = new JRadioButton(); jScrollPane3 = new JScrollPane(); txtBemerkung = new JTextPane(); lblText = new JLabel(); pnlON = new JPanel(); cmbDocON = new JComboBox<>(); btnAddGP = new JButton(); cmbHospitalON = new JComboBox<>(); btnAddHospital = new JButton(); panel1 = new JPanel(); btnClose = new JButton(); btnSave = new JButton(); lblTX = new JLabel(); //======== this ======== setModalityType(Dialog.ModalityType.APPLICATION_MODAL); setResizable(false); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("$rgap, $lcgap, default, $lcgap, pref, $lcgap, $rgap", "$rgap, $lgap, fill:default:grow, $lgap, fill:default, $lgap, $rgap")); //======== jPanel1 ======== { jPanel1.setBorder(null); jPanel1.setLayout(new FormLayout("68dlu, $lcgap, 284dlu, $lcgap, pref", "2*(16dlu, $lgap), default, $lgap, fill:default:grow")); //---- txtMed ---- txtMed.setFont(new Font("Arial", Font.PLAIN, 14)); txtMed.setPrompt("Medikamente"); txtMed.setFocusBehavior(PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT); txtMed.addActionListener(e -> txtMedActionPerformed(e)); txtMed.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtMedFocusGained(e); } }); jPanel1.add(txtMed, CC.xy(1, 1)); //---- cmbMed ---- cmbMed.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbMed.setFont(new Font("Arial", Font.PLAIN, 14)); cmbMed.addItemListener(e -> cmbMedItemStateChanged(e)); jPanel1.add(cmbMed, CC.xy(3, 1)); //======== panel4 ======== { panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS)); //---- btnMed ---- btnMed.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnMed.setBorderPainted(false); btnMed.setBorder(null); btnMed.setContentAreaFilled(false); btnMed.setToolTipText("Neues Medikament eintragen"); btnMed.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMed.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnMed.addActionListener(e -> btnMedActionPerformed(e)); panel4.add(btnMed); } jPanel1.add(panel4, CC.xy(5, 1)); //---- cmbIntervention ---- cmbIntervention .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbIntervention.setFont(new Font("Arial", Font.PLAIN, 14)); jPanel1.add(cmbIntervention, CC.xywh(3, 3, 3, 1)); //---- txtIntervention ---- txtIntervention.setFont(new Font("Arial", Font.PLAIN, 14)); txtIntervention.setPrompt("Massnahmen"); txtIntervention.addActionListener(e -> txtMassActionPerformed(e)); jPanel1.add(txtIntervention, CC.xy(1, 3)); //======== jPanel8 ======== { jPanel8.setBorder(new TitledBorder(null, "Dosis / H\u00e4ufigkeit", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, new Font("Arial", Font.PLAIN, 14))); jPanel8.setFont(new Font("Arial", Font.PLAIN, 14)); jPanel8.setLayout(new FormLayout("370dlu", "fill:default:grow, $lgap, pref")); //======== jspDosis ======== { jspDosis.setToolTipText(null); //---- tblDosis ---- tblDosis.setModel(new DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); tblDosis.setSurrendersFocusOnKeystroke(true); tblDosis.setToolTipText(null); tblDosis.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { tblDosisMousePressed(e); } }); jspDosis.setViewportView(tblDosis); } jPanel8.add(jspDosis, CC.xy(1, 1)); //======== panel2 ======== { panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS)); //---- btnAddDosis ---- btnAddDosis.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnAddDosis.setBorderPainted(false); btnAddDosis.setBorder(null); btnAddDosis.setContentAreaFilled(false); btnAddDosis.setToolTipText("Neue Dosierung eintragen"); btnAddDosis.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnAddDosis.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnAddDosis.addActionListener(e -> btnAddDosisActionPerformed(e)); panel2.add(btnAddDosis); } jPanel8.add(panel2, CC.xy(1, 3, CC.LEFT, CC.DEFAULT)); } jPanel1.add(jPanel8, CC.xywh(1, 7, 5, 1)); } contentPane.add(jPanel1, CC.xy(5, 3)); //======== jPanel3 ======== { jPanel3.setBorder(null); jPanel3.setLayout(new FormLayout("149dlu", "3*(fill:default, $lgap), fill:108dlu:grow, $lgap, 60dlu")); //======== pnlOFF ======== { pnlOFF.setBorder(new TitledBorder("Absetzung")); pnlOFF.setLayout(new FormLayout("pref, 86dlu:grow", "2*(fill:17dlu, $lgap), fill:17dlu")); //---- rbActive ---- rbActive.setText("text"); rbActive.setSelected(true); rbActive.addItemListener(e -> rbActiveItemStateChanged(e)); pnlOFF.add(rbActive, CC.xywh(1, 1, 2, 1)); //---- rbDate ---- rbDate.setText(null); rbDate.addItemListener(e -> rbDateItemStateChanged(e)); pnlOFF.add(rbDate, CC.xy(1, 3)); //---- txtTo ---- txtTo.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { txtToFocusLost(e); } }); pnlOFF.add(txtTo, CC.xy(2, 3)); //---- rbEndOfPackage ---- rbEndOfPackage.setText("text"); rbEndOfPackage.addItemListener(e -> rbEndOfPackageItemStateChanged(e)); pnlOFF.add(rbEndOfPackage, CC.xywh(1, 5, 2, 1)); } jPanel3.add(pnlOFF, CC.xy(1, 3)); //======== jScrollPane3 ======== { //---- txtBemerkung ---- txtBemerkung.addCaretListener(e -> txtBemerkungCaretUpdate(e)); jScrollPane3.setViewportView(txtBemerkung); } jPanel3.add(jScrollPane3, CC.xy(1, 7)); //---- lblText ---- lblText.setText("Bemerkung:"); jPanel3.add(lblText, CC.xy(1, 5)); //======== pnlON ======== { pnlON.setBorder(new TitledBorder("Ansetzung")); pnlON.setLayout(new FormLayout("119dlu:grow, $lcgap, default", "default, $lgap, default")); //---- cmbDocON ---- cmbDocON.setModel( new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbDocON.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { cmbDocONKeyPressed(e); } }); pnlON.add(cmbDocON, CC.xy(1, 1)); //---- btnAddGP ---- btnAddGP.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnAddGP.setBorderPainted(false); btnAddGP.setBorder(null); btnAddGP.setContentAreaFilled(false); btnAddGP.setToolTipText("Neues Medikament eintragen"); btnAddGP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnAddGP.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnAddGP.addActionListener(e -> btnAddGPActionPerformed(e)); pnlON.add(btnAddGP, CC.xy(3, 1)); //---- cmbHospitalON ---- cmbHospitalON.setModel( new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); pnlON.add(cmbHospitalON, CC.xy(1, 3)); //---- btnAddHospital ---- btnAddHospital.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnAddHospital.setBorderPainted(false); btnAddHospital.setBorder(null); btnAddHospital.setContentAreaFilled(false); btnAddHospital.setToolTipText("Neues Medikament eintragen"); btnAddHospital.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnAddHospital.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnAddHospital.addActionListener(e -> btnAddHospitalActionPerformed(e)); pnlON.add(btnAddHospital, CC.xy(3, 3)); } jPanel3.add(pnlON, CC.xy(1, 1)); } contentPane.add(jPanel3, CC.xy(3, 3)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnClose.addActionListener(e -> btnCloseActionPerformed(e)); panel1.add(btnClose); //---- btnSave ---- btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnSave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnSave.addActionListener(e -> btnSaveActionPerformed(e)); panel1.add(btnSave); } contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT)); //---- lblTX ---- lblTX.setText(null); lblTX.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/ambulance2.png"))); contentPane.add(lblTX, CC.xy(3, 5)); setSize(1015, 640); setLocationRelativeTo(getOwner()); //---- bgMedikament ---- ButtonGroup bgMedikament = new ButtonGroup(); bgMedikament.add(rbActive); bgMedikament.add(rbDate); bgMedikament.add(rbEndOfPackage); }
From source file:op.care.supervisor.DlgHOReport.java
/** * This method is called from within the constructor to * initialize the form.//w w w.j a v a2 s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new JScrollPane(); txtReport = new JTextPane(); panel1 = new JPanel(); btnCancel = new JButton(); btnSave = new JButton(); //======== this ======== setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("default, $lcgap, default:grow, $lcgap, default", "2*(default, $lgap), fill:default:grow, $lgap, fill:default, $lgap, default")); //======== jScrollPane1 ======== { jScrollPane1.setViewportView(txtReport); } contentPane.add(jScrollPane1, CC.xy(3, 5)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS)); //---- btnCancel ---- btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnCancel.setText(null); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCancelActionPerformed(e); } }); panel1.add(btnCancel); //---- btnSave ---- btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnSave.setText(null); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSaveActionPerformed(e); } }); panel1.add(btnSave); } contentPane.add(panel1, CC.xy(3, 7, CC.RIGHT, CC.DEFAULT)); setSize(462, 379); setLocationRelativeTo(null); }
From source file:op.FrmMain.java
public void afterLogin() { OPDE.getDisplayManager().touch();/*w ww. ja va 2 s . co 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); }