List of usage examples for javax.swing JPanel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:op.care.bhp.PnlBHP.java
private CollapsiblePane createCP4OnDemand() { /***/*from w w w. j a v a2 s . c o m*/ * _ ____ ____ _ _ ___ ____ _ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | / _ \ _ __ | _ \ ___ _ __ ___ __ _ _ __ __| | * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_| | | | '_ \| | | |/ _ \ '_ ` _ \ / _` | '_ \ / _` | * | (__| | | __/ (_| | || __/ |___| __/|__ _| |_| | | | | |_| | __/ | | | | | (_| | | | | (_| | * \___|_| \___|\__,_|\__\___|\____|_| |_| \___/|_| |_|____/ \___|_| |_| |_|\__,_|_| |_|\__,_| * */ String title = "<html><font size=+1><b>" + SYSTools.xx("nursingrecords.bhp.ondemand") + "</b></font></html>"; final CollapsiblePane mainPane = new CollapsiblePane(title); mainPane.setSlidingDirection(SwingConstants.SOUTH); mainPane.setBackground(SYSCalendar.getBGSHIFT(BHPTools.SHIFT_ON_DEMAND)); mainPane.setForeground(SYSCalendar.getFGSHIFT(BHPTools.SHIFT_ON_DEMAND)); mainPane.setOpaque(false); if (!mapShift2BHP.get(BHPTools.SHIFT_ON_DEMAND).isEmpty()) { Prescription currentPrescription = null; CollapsiblePane sitPane = null; JPanel sitPanel = null; JPanel sitOuterPanel = new JPanel(); sitOuterPanel.setLayout(new VerticalLayout()); for (BHP bhp : mapShift2BHP.get(BHPTools.SHIFT_ON_DEMAND)) { if (currentPrescription == null || bhp.getPrescription().getID() != currentPrescription.getID()) { if (currentPrescription != null) { sitPane.setContentPane(sitPanel); sitOuterPanel.add(sitPane); } currentPrescription = bhp.getPrescription(); sitPanel = new JPanel(); sitPanel.setLayout(new VerticalLayout()); sitPanel.setBackground(bhp.getBG()); sitPane = new CollapsiblePane( SYSTools.toHTMLForScreen("<b>" + currentPrescription.getSituation().getText()) + "</b>"); sitPane.setSlidingDirection(SwingConstants.SOUTH); sitPane.setBackground( ColorUtils.getDerivedColor(SYSCalendar.getBGSHIFT(BHPTools.SHIFT_ON_DEMAND), 0.4f)); // a little darker sitPane.setForeground(Color.BLACK); sitPane.setOpaque(false); } sitPane.setContentPane(sitPanel); sitOuterPanel.add(sitPane); mapBHP2Pane.put(bhp, createCP4(bhp)); sitPanel.add(mapBHP2Pane.get(bhp)); } mainPane.setContentPane(sitOuterPanel); mainPane.setCollapsible(true); } else { mainPane.setContentPane(new JPanel()); mainPane.setCollapsible(false); } return mainPane; }
From source file:op.care.bhp.PnlBHP.java
private CollapsiblePane createCP4Shift(final Byte shift) { /***//w ww . j av a 2 s. c o m * _ ____ ____ _ _ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_ * | (__| | | __/ (_| | || __/ |___| __/|__ _| * \___|_| \___|\__,_|\__\___|\____|_| |_| * */ String title = "<html><font size=+1><b>" + GUITools.getLocalizedMessages(BHPTools.SHIFT_TEXT)[shift] + "</b></font></html>"; final CollapsiblePane prPane = new CollapsiblePane(title); prPane.setSlidingDirection(SwingConstants.SOUTH); prPane.setBackground(SYSCalendar.getBGSHIFT(shift)); prPane.setForeground(SYSCalendar.getFGSHIFT(shift)); prPane.setOpaque(false); JPanel prPanel = new JPanel(); prPanel.setLayout(new VerticalLayout()); if (mapShift2BHP.containsKey(shift)) { if (shift == BHPTools.SHIFT_EARLY) { final CollapsiblePane morning = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.morning.long") + "</font></html>", null); morning.setSlidingDirection(SwingConstants.SOUTH); morning.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); morning.setForeground(Color.white); morning.setOpaque(false); JPanel pnlMorning = new JPanel(); pnlMorning.setLayout(new VerticalLayout()); morning.setContentPane(pnlMorning); final CollapsiblePane noon = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.noon.long") + "</font></html>", null); noon.setSlidingDirection(SwingConstants.SOUTH); noon.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); noon.setForeground(Color.white); noon.setOpaque(false); JPanel pnlNoon = new JPanel(); pnlNoon.setLayout(new VerticalLayout()); noon.setContentPane(pnlNoon); final CollapsiblePane clock = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.Time.long") + "</font></html>", null); clock.setSlidingDirection(SwingConstants.SOUTH); clock.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); clock.setForeground(Color.white); clock.setOpaque(false); JPanel pnlClock = new JPanel(); pnlClock.setLayout(new VerticalLayout()); clock.setContentPane(pnlClock); for (BHP bhp : mapShift2BHP.get(shift)) { prPanel.setBackground(bhp.getBG()); mapBHP2Pane.put(bhp, createCP4(bhp)); if (bhp.getSollZeit() == BHPTools.BYTE_MORNING) { pnlMorning.add(mapBHP2Pane.get(bhp)); } else if (bhp.getSollZeit() == BHPTools.BYTE_NOON) { pnlNoon.add(mapBHP2Pane.get(bhp)); } else { pnlClock.add(mapBHP2Pane.get(bhp)); } } if (pnlClock.getComponentCount() > 0) { prPanel.add(clock); } if (pnlMorning.getComponentCount() > 0) { prPanel.add(morning); } if (pnlNoon.getComponentCount() > 0) { prPanel.add(noon); } } else if (shift == BHPTools.SHIFT_LATE) { final CollapsiblePane afternoon = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.afternoon.long") + "</font></html>", null); afternoon.setSlidingDirection(SwingConstants.SOUTH); afternoon.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); afternoon.setForeground(Color.white); afternoon.setOpaque(false); JPanel pnlAfternoon = new JPanel(); pnlAfternoon.setLayout(new VerticalLayout()); afternoon.setContentPane(pnlAfternoon); final CollapsiblePane evening = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.evening.long") + "</font></html>", null); evening.setSlidingDirection(SwingConstants.SOUTH); evening.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); evening.setForeground(Color.white); evening.setOpaque(false); JPanel pnlEvening = new JPanel(); pnlEvening.setLayout(new VerticalLayout()); evening.setContentPane(pnlEvening); final CollapsiblePane clock = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.Time.long") + "</font></html>", null); clock.setSlidingDirection(SwingConstants.SOUTH); clock.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); clock.setForeground(Color.white); clock.setOpaque(false); JPanel pnlClock = new JPanel(); pnlClock.setLayout(new VerticalLayout()); clock.setContentPane(pnlClock); for (BHP bhp : mapShift2BHP.get(shift)) { prPanel.setBackground(bhp.getBG()); mapBHP2Pane.put(bhp, createCP4(bhp)); if (bhp.getSollZeit() == BHPTools.BYTE_AFTERNOON) { pnlAfternoon.add(mapBHP2Pane.get(bhp)); } else if (bhp.getSollZeit() == BHPTools.BYTE_EVENING) { pnlEvening.add(mapBHP2Pane.get(bhp)); } else { pnlClock.add(mapBHP2Pane.get(bhp)); } } if (pnlClock.getComponentCount() > 0) { prPanel.add(clock); } if (pnlAfternoon.getComponentCount() > 0) { prPanel.add(afternoon); } if (pnlEvening.getComponentCount() > 0) { prPanel.add(evening); } } else { for (BHP bhp : mapShift2BHP.get(shift)) { prPanel.setBackground(bhp.getBG()); mapBHP2Pane.put(bhp, createCP4(bhp)); prPanel.add(mapBHP2Pane.get(bhp)); } } prPane.setContentPane(prPanel); prPane.setCollapsible(true); } else { prPane.setContentPane(prPanel); prPane.setCollapsible(false); } return prPane; }
From source file:op.care.bhp.PnlBHP.java
private void prepareSearchArea() { searchPanes = new CollapsiblePanes(); searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS)); jspSearch.setViewportView(searchPanes); JPanel mypanel = new JPanel(); mypanel.setLayout(new VerticalLayout()); mypanel.setBackground(Color.WHITE); CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID)); searchPane.setStyle(CollapsiblePane.PLAIN_STYLE); searchPane.setCollapsible(false);//from w w w.j a va2s. c o m try { searchPane.setCollapsed(false); } catch (PropertyVetoException e) { OPDE.error(e); } GUITools.addAllComponents(searchPanes, addCommands()); GUITools.addAllComponents(searchPanes, addFilter()); GUITools.addAllComponents(searchPanes, addKey()); searchPanes.addExpansion(); }
From source file:op.care.bhp.PnlBHP.java
private java.util.List<Component> addFilter() { java.util.List<Component> list = new ArrayList<Component>(); jdcDatum = new JDateChooser(new Date()); jdcDatum.setFont(new Font("Arial", Font.PLAIN, 18)); jdcDatum.setMinSelectableDate(BHPTools.getMinDatum(resident)); jdcDatum.setBackground(Color.WHITE); jdcDatum.addPropertyChangeListener(new PropertyChangeListener() { @Override/* w w w. j a va 2s.co m*/ public void propertyChange(PropertyChangeEvent evt) { if (initPhase) { return; } if (evt.getPropertyName().equals("date")) { reloadDisplay(); } } }); list.add(jdcDatum); JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.setLayout(new HorizontalLayout(5)); buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); JButton homeButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png"))); homeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDatum.setDate(jdcDatum.getMinSelectableDate()); } }); homeButton.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png"))); homeButton.setBorder(null); homeButton.setBorderPainted(false); homeButton.setOpaque(false); homeButton.setContentAreaFilled(false); homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JButton backButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png"))); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDatum.getDate()); DateMidnight min = new DateMidnight(jdcDatum.getMinSelectableDate()); if (current.equals(min)) { return; } jdcDatum.setDate(SYSCalendar.addDate(jdcDatum.getDate(), -1)); } }); backButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png"))); backButton.setBorder(null); backButton.setBorderPainted(false); backButton.setOpaque(false); backButton.setContentAreaFilled(false); backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JButton fwdButton = new JButton(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png"))); fwdButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDatum.getDate()); if (current.equals(new DateMidnight())) { return; } jdcDatum.setDate(SYSCalendar.addDate(jdcDatum.getDate(), 1)); } }); fwdButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png"))); fwdButton.setBorder(null); fwdButton.setBorderPainted(false); fwdButton.setOpaque(false); fwdButton.setContentAreaFilled(false); fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JButton endButton = new JButton(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png"))); endButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDatum.setDate(new Date()); } }); endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png"))); endButton.setBorder(null); endButton.setBorderPainted(false); endButton.setOpaque(false); endButton.setContentAreaFilled(false); endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); buttonPanel.add(homeButton); buttonPanel.add(backButton); buttonPanel.add(fwdButton); buttonPanel.add(endButton); list.add(buttonPanel); // panelFilter.setContentPane(labelPanel); return list; }
From source file:op.care.dfn.PnlDFN.java
private CollapsiblePane createCP4Shift(Byte shift) { String title = "<html><font size=+1><b>" + GUITools.getLocalizedMessages(DFNTools.SHIFT_TEXT)[shift] + "</b></font></html>"; final CollapsiblePane mainPane = new CollapsiblePane(title); mainPane.setSlidingDirection(SwingConstants.SOUTH); mainPane.setBackground(SYSCalendar.getBGSHIFT(shift)); mainPane.setForeground(SYSCalendar.getFGSHIFT(shift)); mainPane.setOpaque(false);//from www. j av a2s.c om JPanel npPanel = new JPanel(); npPanel.setLayout(new VerticalLayout()); boolean containsKey = false; synchronized (mapShift2DFN) { containsKey = mapShift2DFN.containsKey(shift); } if (containsKey) { if (shift == DFNTools.SHIFT_EARLY) { final CollapsiblePane morning = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.morning.long") + "</font></html>", null); morning.setSlidingDirection(SwingConstants.SOUTH); morning.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); morning.setForeground(Color.white); morning.setOpaque(false); JPanel pnlMorning = new JPanel(); pnlMorning.setLayout(new VerticalLayout()); morning.setContentPane(pnlMorning); final CollapsiblePane noon = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.noon.long") + "</font></html>", null); noon.setSlidingDirection(SwingConstants.SOUTH); noon.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); noon.setForeground(Color.white); noon.setOpaque(false); JPanel pnlNoon = new JPanel(); pnlNoon.setLayout(new VerticalLayout()); noon.setContentPane(pnlNoon); final CollapsiblePane clock = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.Time.long") + "</font></html>", null); clock.setSlidingDirection(SwingConstants.SOUTH); clock.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); clock.setForeground(Color.white); clock.setOpaque(false); JPanel pnlClock = new JPanel(); pnlClock.setLayout(new VerticalLayout()); clock.setContentPane(pnlClock); ArrayList<DFN> listDFN = null; synchronized (mapShift2DFN) { listDFN = mapShift2DFN.get(shift); } for (DFN dfn : listDFN) { npPanel.setBackground(dfn.getBG()); CollapsiblePane cp1 = createCP4(dfn); synchronized (mapDFN2Pane) { mapDFN2Pane.put(dfn, cp1); if (dfn.getSollZeit() == DFNTools.BYTE_MORNING) { pnlMorning.add(mapDFN2Pane.get(dfn)); } else if (dfn.getSollZeit() == DFNTools.BYTE_NOON) { pnlNoon.add(mapDFN2Pane.get(dfn)); } else { pnlClock.add(mapDFN2Pane.get(dfn)); } } } if (pnlClock.getComponentCount() > 0) { npPanel.add(clock); } if (pnlMorning.getComponentCount() > 0) { npPanel.add(morning); } if (pnlNoon.getComponentCount() > 0) { npPanel.add(noon); } } else if (shift == DFNTools.SHIFT_LATE) { final CollapsiblePane afternoon = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.afternoon.long") + "</font></html>", null); afternoon.setSlidingDirection(SwingConstants.SOUTH); afternoon.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); afternoon.setForeground(Color.white); afternoon.setOpaque(false); JPanel pnlAfternoon = new JPanel(); pnlAfternoon.setLayout(new VerticalLayout()); afternoon.setContentPane(pnlAfternoon); final CollapsiblePane evening = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.evening.long") + "</font></html>", null); evening.setSlidingDirection(SwingConstants.SOUTH); evening.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); evening.setForeground(Color.white); evening.setOpaque(false); JPanel pnlEvening = new JPanel(); pnlEvening.setLayout(new VerticalLayout()); evening.setContentPane(pnlEvening); final CollapsiblePane clock = new CollapsiblePane( "<html><font size=+1>" + SYSTools.xx("misc.msg.Time.long") + "</font></html>", null); clock.setSlidingDirection(SwingConstants.SOUTH); clock.setBackground(SYSCalendar.getBGSHIFT(shift).darker()); clock.setForeground(Color.white); clock.setOpaque(false); JPanel pnlClock = new JPanel(); pnlClock.setLayout(new VerticalLayout()); clock.setContentPane(pnlClock); ArrayList<DFN> listDFN = null; synchronized (mapShift2DFN) { listDFN = mapShift2DFN.get(shift); } for (DFN dfn : listDFN) { npPanel.setBackground(dfn.getBG()); CollapsiblePane cp1 = createCP4(dfn); synchronized (mapDFN2Pane) { mapDFN2Pane.put(dfn, cp1); if (dfn.getSollZeit() == DFNTools.BYTE_AFTERNOON) { pnlAfternoon.add(mapDFN2Pane.get(dfn)); } else if (dfn.getSollZeit() == DFNTools.BYTE_EVENING) { pnlEvening.add(mapDFN2Pane.get(dfn)); } else { pnlClock.add(mapDFN2Pane.get(dfn)); } } } if (pnlClock.getComponentCount() > 0) { npPanel.add(clock); } if (pnlAfternoon.getComponentCount() > 0) { npPanel.add(afternoon); } if (pnlEvening.getComponentCount() > 0) { npPanel.add(evening); } } else { ArrayList<DFN> listDFN = null; synchronized (mapShift2DFN) { listDFN = mapShift2DFN.get(shift); } for (DFN dfn : listDFN) { npPanel.setBackground(dfn.getBG()); CollapsiblePane cp1 = createCP4(dfn); synchronized (mapDFN2Pane) { mapDFN2Pane.put(dfn, cp1); npPanel.add(mapDFN2Pane.get(dfn)); } } } mainPane.setContentPane(npPanel); mainPane.setCollapsible(true); } else { mainPane.setContentPane(npPanel); mainPane.setCollapsible(false); } return mainPane; }
From source file:op.care.dfn.PnlDFN.java
private CollapsiblePane createCP4OnDemand() { /***/*from w w w. ja va 2s . c om*/ * _ ____ ____ _ _ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_ * | (__| | | __/ (_| | || __/ |___| __/|__ _| * \___|_| \___|\__,_|\__\___|\____|_| |_| * */ String title = "<html><font size=+1><b>" + SYSTools.xx("nursingrecords.dfn.ondemand") + "</b></font></html>"; final CollapsiblePane npPane = new CollapsiblePane(title); npPane.setSlidingDirection(SwingConstants.SOUTH); npPane.setBackground(SYSCalendar.getBGSHIFT(DFNTools.SHIFT_ON_DEMAND)); npPane.setForeground(SYSCalendar.getFGSHIFT(DFNTools.SHIFT_ON_DEMAND)); npPane.setOpaque(false); JPanel npPanel = new JPanel(); npPanel.setLayout(new VerticalLayout()); ArrayList<DFN> list = null; synchronized (mapShift2DFN) { list = mapShift2DFN.containsKey(DFNTools.SHIFT_ON_DEMAND) ? mapShift2DFN.get(DFNTools.SHIFT_ON_DEMAND) : null; } if (list != null && !list.isEmpty()) { for (DFN dfn : list) { npPanel.setBackground(dfn.getBG()); CollapsiblePane cp = createCP4(dfn); synchronized (mapDFN2Pane) { mapDFN2Pane.put(dfn, cp); npPanel.add(mapDFN2Pane.get(dfn)); } } npPane.setContentPane(npPanel); npPane.setCollapsible(true); } else { npPane.setContentPane(npPanel); npPane.setCollapsible(false); } return npPane; }
From source file:op.care.dfn.PnlDFN.java
private void prepareSearchArea() { searchPanes = new CollapsiblePanes(); searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS)); jspSearch.setViewportView(searchPanes); JPanel mypanel = new JPanel(); mypanel.setLayout(new VerticalLayout()); mypanel.setBackground(Color.WHITE); CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID)); searchPane.setStyle(CollapsiblePane.PLAIN_STYLE); searchPane.setCollapsible(false);/*from ww w . j a v a 2 s . c om*/ try { searchPane.setCollapsed(false); } catch (PropertyVetoException e) { OPDE.error(e); } GUITools.addAllComponents(mypanel, addCommands()); GUITools.addAllComponents(mypanel, addFilters()); GUITools.addAllComponents(mypanel, addKey()); searchPane.setContentPane(mypanel); searchPanes.add(searchPane); searchPanes.addExpansion(); }
From source file:op.care.dfn.PnlDFN.java
private List<Component> addFilters() { List<Component> list = new ArrayList<Component>(); jdcDate = new JDateChooser(new Date()); jdcDate.setFont(new Font("Arial", Font.PLAIN, 14)); jdcDate.setBackground(Color.WHITE); list.add(jdcDate);/*from w ww . j a v a2 s . c o m*/ JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.setLayout(new HorizontalLayout(5)); buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); final JButton homeButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png"))); homeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDate.setDate(jdcDate.getMinSelectableDate()); } }); homeButton.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png"))); homeButton.setBorder(null); homeButton.setBorderPainted(false); homeButton.setOpaque(false); homeButton.setContentAreaFilled(false); homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton backButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png"))); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDate.getDate()); DateMidnight min = new DateMidnight(jdcDate.getMinSelectableDate()); if (current.equals(min)) { return; } jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), -1)); } }); backButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png"))); backButton.setBorder(null); backButton.setBorderPainted(false); backButton.setOpaque(false); backButton.setContentAreaFilled(false); backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton fwdButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png"))); fwdButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDate.getDate()); if (current.equals(new DateMidnight())) { return; } jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), 1)); } }); fwdButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png"))); fwdButton.setBorder(null); fwdButton.setBorderPainted(false); fwdButton.setOpaque(false); fwdButton.setContentAreaFilled(false); fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton endButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png"))); endButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDate.setDate(new Date()); } }); endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png"))); endButton.setBorder(null); endButton.setBorderPainted(false); endButton.setOpaque(false); endButton.setContentAreaFilled(false); endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); buttonPanel.add(homeButton); buttonPanel.add(backButton); buttonPanel.add(fwdButton); buttonPanel.add(endButton); list.add(buttonPanel); jdcDate.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (initPhase) { return; } if (evt.getPropertyName().equals("date")) { reloadDisplay(); } } }); return list; }
From source file:op.care.med.inventory.PnlInventory.java
private void prepareSearchArea() { searchPanes = new CollapsiblePanes(); searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS)); jspSearch.setViewportView(searchPanes); JPanel mypanel = new JPanel(); mypanel.setLayout(new VerticalLayout(3)); mypanel.setBackground(Color.WHITE); CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx("nursingrecords.inventory")); searchPane.setStyle(CollapsiblePane.PLAIN_STYLE); searchPane.setCollapsible(false);/*from w w w . j a v a 2 s. c om*/ try { searchPane.setCollapsed(false); } catch (PropertyVetoException e) { OPDE.error(e); } GUITools.addAllComponents(mypanel, addCommands()); GUITools.addAllComponents(mypanel, addFilters()); GUITools.addAllComponents(mypanel, addKey()); searchPane.setContentPane(mypanel); searchPanes.add(searchPane); searchPanes.addExpansion(); }
From source file:op.care.med.inventory.PnlInventory.java
private JPanel createContentPanel4(final MedStock stock) { // final String key = stock.getID() + ".xstock"; // if (!contentmap.containsKey(key)) { final JPanel pnlTX = new JPanel(new VerticalLayout()); // pnlTX.setLayout(new BoxLayout(pnlTX, BoxLayout.PAGE_AXIS)); pnlTX.setOpaque(true);/*from w w w . j a va 2 s . co m*/ // pnlTX.setBackground(Color.white); synchronized (lstInventories) { pnlTX.setBackground(getColor(SYSConst.light2, lstInventories.indexOf(stock.getInventory()) % 2 != 0)); } /*** * _ _ _ _______ __ * / \ __| | __| |_ _\ \/ / * / _ \ / _` |/ _` | | | \ / * / ___ \ (_| | (_| | | | / \ * /_/ \_\__,_|\__,_| |_| /_/\_\ * */ JideButton btnAddTX = GUITools.createHyperlinkButton("nursingrecords.inventory.newmedstocktx", SYSConst.icon22add, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new DlgTX(new MedStockTransaction(stock, BigDecimal.ONE, MedStockTransactionTools.STATE_EDIT_MANUAL), new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); final MedStockTransaction myTX = (MedStockTransaction) em.merge(o); MedStock myStock = em.merge(stock); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.lock(em.merge(myTX.getStock().getInventory().getResident()), LockModeType.OPTIMISTIC); em.getTransaction().commit(); createCP4(myStock.getInventory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnAddTX.setEnabled(!stock.isClosed()); pnlTX.add(btnAddTX); /*** * ____ _ _ _ _______ __ * / ___|| |__ _____ __ __ _| | | |_ _\ \/ /___ * \___ \| '_ \ / _ \ \ /\ / / / _` | | | | | \ // __| * ___) | | | | (_) \ V V / | (_| | | | | | / \\__ \ * |____/|_| |_|\___/ \_/\_/ \__,_|_|_| |_| /_/\_\___/ * */ OPDE.getMainframe().setBlocked(true); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { int progress = 0; List<MedStockTransaction> listTX = MedStockTransactionTools.getAll(stock); OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, listTX.size())); BigDecimal rowsum = MedStockTools.getSum(stock); // BigDecimal rowsum = MedStockTools.getSum(stock); // Collections.sort(stock.getStockTransaction()); for (final MedStockTransaction tx : listTX) { progress++; OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), progress, listTX.size())); String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(tx.getPit()) + "<br/>[" + tx.getID() + "]" + "</td>" + "<td width=\"200\" align=\"center\">" + SYSTools.catchNull(tx.getText(), "--") + "</td>" + "<td width=\"100\" align=\"right\">" + NumberFormat.getNumberInstance().format(tx.getAmount()) + "</td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + NumberFormat.getNumberInstance().format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + (stock.getTradeForm().isWeightControlled() ? "<td width=\"100\" align=\"right\">" + NumberFormat.getNumberInstance().format(tx.getWeight()) + "g" + "</td>" : "") + "<td width=\"100\" align=\"left\">" + SYSTools.anonymizeUser(tx.getUser().getUID()) + "</td>" + "</tr>" + "</table>" + "</font></html>"; rowsum = rowsum.subtract(tx.getAmount()); final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); // pnlTitle.getLeft().addMouseListener(); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, "nursingrecords.inventory")) { /*** * ____ _ _______ __ * | _ \ ___| |_ _\ \/ / * | | | |/ _ \ | | | \ / * | |_| | __/ | | | / \ * |____/ \___|_| |_| /_/\_\ * */ final JButton btnDelTX = new JButton(SYSConst.icon22delete); btnDelTX.setPressedIcon(SYSConst.icon22deletePressed); btnDelTX.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnDelTX.setContentAreaFilled(false); btnDelTX.setBorder(null); btnDelTX.setToolTipText(SYSTools.xx("nursingrecords.inventory.tx.btndelete.tooltip")); btnDelTX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(tx.getPit()) + " " + tx.getUser().getUID() + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStockTransaction myTX = em.merge(tx); MedStock myStock = em.merge(stock); em.lock(em.merge( myTX.getStock().getInventory().getResident()), LockModeType.OPTIMISTIC); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.remove(myTX); // myStock.getStockTransaction().remove(myTX); em.getTransaction().commit(); // synchronized (lstInventories) { // int indexInventory = lstInventories.indexOf(stock.getInventory()); // int indexStock = lstInventories.get(indexInventory).getMedStocks().indexOf(stock); // lstInventories.get(indexInventory).getMedStocks().remove(stock); // lstInventories.get(indexInventory).getMedStocks().add(indexStock, myStock); // } // synchronized (linemap) { // linemap.remove(myTX); // } createCP4(myStock.getInventory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage() .indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelTX.setEnabled( !stock.isClosed() && (tx.getState() == MedStockTransactionTools.STATE_DEBIT || tx.getState() == MedStockTransactionTools.STATE_EDIT_MANUAL)); pnlTitle.getRight().add(btnDelTX); } /*** * _ _ _ _______ __ * | | | |_ __ __| | ___ |_ _\ \/ / * | | | | '_ \ / _` |/ _ \ | | \ / * | |_| | | | | (_| | (_) | | | / \ * \___/|_| |_|\__,_|\___/ |_| /_/\_\ * */ final JButton btnUndoTX = new JButton(SYSConst.icon22undo); btnUndoTX.setPressedIcon(SYSConst.icon22Pressed); btnUndoTX.setAlignmentX(Component.RIGHT_ALIGNMENT); btnUndoTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnUndoTX.setContentAreaFilled(false); btnUndoTX.setBorder(null); btnUndoTX.setToolTipText(SYSTools.xx("nursingrecords.inventory.tx.btnUndoTX.tooltip")); btnUndoTX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.undo1") + "<br/><i>" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(tx.getPit()) + " " + tx.getUser().getUID() + "</i><br/>" + SYSTools.xx("misc.questions.undo2"), SYSConst.icon48undo, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStock myStock = em.merge(stock); final MedStockTransaction myOldTX = em.merge(tx); myOldTX.setState(MedStockTransactionTools.STATE_CANCELLED); final MedStockTransaction myNewTX = em .merge(new MedStockTransaction(myStock, myOldTX.getAmount().negate(), MedStockTransactionTools.STATE_CANCEL_REC)); myOldTX.setText(SYSTools.xx("misc.msg.reversedBy") + ": " + DateFormat .getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(myNewTX.getPit())); myNewTX.setText(SYSTools.xx("misc.msg.reversalFor") + ": " + DateFormat .getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT) .format(myOldTX.getPit())); // myStock.getStockTransaction().add(myNewTX); // myStock.getStockTransaction().remove(tx); // myStock.getStockTransaction().add(myOldTX); em.lock(em .merge(myNewTX.getStock().getInventory().getResident()), LockModeType.OPTIMISTIC); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.getTransaction().commit(); // synchronized (lstInventories) { // int indexInventory = lstInventories.indexOf(stock.getInventory()); // int indexStock = lstInventories.get(indexInventory).getMedStocks().indexOf(stock); // lstInventories.get(indexInventory).getMedStocks().remove(stock); // lstInventories.get(indexInventory).getMedStocks().add(indexStock, myStock); // } // synchronized (linemap) { // linemap.remove(tx); // } createCP4(myStock.getInventory()); buildPanel(); // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // synchronized (linemap) { // GUITools.flashBackground(linemap.get(myOldTX), Color.RED, 2); // GUITools.flashBackground(linemap.get(myNewTX), Color.YELLOW, 2); // } // } // }); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage() .indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnUndoTX.setEnabled(!stock.isClosed() && (tx.getState() == MedStockTransactionTools.STATE_DEBIT || tx.getState() == MedStockTransactionTools.STATE_EDIT_MANUAL)); pnlTitle.getRight().add(btnUndoTX); if (stock.getTradeForm().isWeightControlled() && OPDE.getAppInfo() .isAllowedTo(InternalClassACL.MANAGER, "nursingrecords.inventory")) { /*** * _ __ __ _ _ _ * ___ ___| |\ \ / /__(_) __ _| |__ | |_ * / __|/ _ \ __\ \ /\ / / _ \ |/ _` | '_ \| __| * \__ \ __/ |_ \ V V / __/ | (_| | | | | |_ * |___/\___|\__| \_/\_/ \___|_|\__, |_| |_|\__| * |___/ */ final JButton btnSetWeight = new JButton(SYSConst.icon22scales); btnSetWeight.setPressedIcon(SYSConst.icon22Pressed); btnSetWeight.setAlignmentX(Component.RIGHT_ALIGNMENT); btnSetWeight.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnSetWeight.setContentAreaFilled(false); btnSetWeight.setBorder(null); btnSetWeight.setToolTipText(SYSTools.xx("nursingrecords.inventory.tx.btnUndoTX.tooltip")); btnSetWeight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { BigDecimal weight; new DlgYesNo(SYSConst.icon48scales, new Closure() { @Override public void execute(Object o) { if (!SYSTools.catchNull(o).isEmpty()) { BigDecimal weight = (BigDecimal) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedStock myStock = em.merge(stock); final MedStockTransaction myTX = em.merge(tx); em.lock(myTX, LockModeType.OPTIMISTIC); myTX.setWeight(weight); em.lock(myStock, LockModeType.OPTIMISTIC); em.lock(myStock.getInventory(), LockModeType.OPTIMISTIC); em.getTransaction().commit(); createCP4(myStock.getInventory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }, "nursingrecords.bhp.weight", NumberFormat.getNumberInstance().format(tx.getWeight()), new Validator<BigDecimal>() { @Override public boolean isValid(String value) { BigDecimal bd = parse(value); return bd != null && bd.compareTo(BigDecimal.ZERO) > 0; } @Override public BigDecimal parse(String text) { return SYSTools.parseDecimal(text); } }); } }); btnSetWeight.setEnabled( !stock.isClosed() && (tx.getState() == MedStockTransactionTools.STATE_DEBIT || tx.getState() == MedStockTransactionTools.STATE_CREDIT || tx.getState() == MedStockTransactionTools.STATE_EDIT_MANUAL)); pnlTitle.getRight().add(btnSetWeight); } pnlTX.add(pnlTitle.getMain()); } return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); return pnlTX; }