List of usage examples for java.awt Color YELLOW
Color YELLOW
To view the source code for java.awt Color YELLOW.
Click Source Link
From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java
JTextPane createErrorPane(String errorMessage, Component component, final JTabbedPane tabbedPane, final int tabIndex) { final JTextPane errorPane = new JTextPane(); errorPane.setEditable(false);/* w ww . j av a 2 s.com*/ errorPane.setText(errorMessage); errorPane.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { errorPane.setBackground(Color.YELLOW); tabbedPane.setSelectedIndex(tabIndex); } @Override public void focusLost(FocusEvent arg0) { errorPane.setBackground(Color.WHITE); } }); component.requestFocusInWindow(); return errorPane; }
From source file:op.allowance.PnlAllowance.java
private PnlTX getPnlTX(Resident resident, final Allowance allowance) { final BigDecimal editAmount = allowance != null ? allowance.getAmount() : null; final Allowance allow = (allowance == null ? new Allowance(resident) : allowance); return new PnlTX(allow, new Closure() { @Override/*www .j a v a 2 s .c o m*/ public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); final Allowance myAllowance = em.merge((Allowance) o); em.lock(em.merge(myAllowance.getResident()), LockModeType.OPTIMISTIC); em.getTransaction().commit(); DateTime txDate = new DateTime(myAllowance.getPit()); final String keyResident = myAllowance.getResident().getRID(); final String keyYear = myAllowance.getResident().getRID() + "-" + txDate.getYear(); final String keyMonth = myAllowance.getResident().getRID() + "-" + txDate.getYear() + "-" + txDate.getMonthOfYear(); if (!lstResidents.contains(myAllowance.getResident())) { lstResidents.add(myAllowance.getResident()); Collections.sort(lstResidents); } if (!cashmap.containsKey(keyMonth)) { cashmap.put(keyMonth, AllowanceTools.getMonth(myAllowance.getResident(), myAllowance.getPit())); } else { if (cashmap.get(keyMonth).contains(myAllowance)) { cashmap.get(keyMonth).remove(myAllowance); } cashmap.get(keyMonth).add(myAllowance); Collections.sort(cashmap.get(keyMonth)); } // little trick to fix the carries if (editAmount != null) { updateCarrySums(myAllowance.getResident(), new LocalDate(myAllowance.getPit()), editAmount.negate()); } // add the new / edited amount updateCarrySums(myAllowance); createCP4(myAllowance.getResident()); try { if (cpMap.get(keyResident).isCollapsed()) cpMap.get(keyResident).setCollapsed(false); if (cpMap.get(keyYear).isCollapsed()) cpMap.get(keyYear).setCollapsed(false); if (cpMap.get(keyMonth).isCollapsed()) cpMap.get(keyMonth).setCollapsed(false); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); GUITools.scroll2show(jspCash, cpMap.get(keyMonth), cpsCash, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(linemap.get(myAllowance), 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(); } } } }); }
From source file:windows.sensorWindow.java
/** * add a value to the second field of a sensor (used for sensors with 2 * measurements)/*w w w . java 2 s . c o m*/ * * @param sensorUID * @param value */ public void add2ndValue(String sensorUID, double value) { // TODO: make this method more elegant by evolving // plotStateMap.get-things if (seriesCollectionMap2.containsKey(sensorUID)) seriesCollectionMap2.get(sensorUID).getSeries(0).addOrUpdate(new Millisecond(), value); // add measurement value if (values2Map.containsKey(sensorUID)) values2Map.get(sensorUID).addValue(value); // check whether the value is below the thresholds if (markerMapMin2Critical.containsKey(sensorUID)) { // critical if ((value < markerMapMin2Critical.get(sensorUID).getValue()) || (value > markerMapMax2Critical.get(sensorUID).getValue())) { plot2StateMap.put(sensorUID, 3); } // warning else if ((value < markerMapMin2Warning.get(sensorUID).getValue()) || (value > markerMapMax2Warning.get(sensorUID).getValue())) { plot2StateMap.put(sensorUID, 2); } // normal level else { plot2StateMap.put(sensorUID, 1); } } // color the plot's background according to it's current state, // but only if the state of the 2nd plot is below the state of the // current plot // a higher state means higher warning level and therefore a higher // priority if (plot1StateMap.get(sensorUID) <= plot2StateMap.get(sensorUID)) { switch (plot2StateMap.get(sensorUID)) { case 1: plotMap.get(sensorUID).setBackgroundPaint(Color.white); break; case 2: plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); break; case 3: plotMap.get(sensorUID).setBackgroundPaint(Color.red); break; } } /* * // check whether the value is below the threshold if * (markerMapMin2Critical.containsKey(sensorUID)) { if ( (value > * markerMapMin2Critical.get(sensorUID).getValue()) && (value <= * (markerMapMin2Warning.get(sensorUID).getValue())) ) { //under warning * level plot1StateMap.put(sensorUID,2); * plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); } else if * (value <= markerMapMin2Critical.get(sensorUID).getValue()) { //under * threshold level plot1StateMap.put(sensorUID,3); * plotMap.get(sensorUID).setBackgroundPaint(Color.pink); } else { * //normal level * //plotMap.get(sensorUID).setBackgroundPaint(Color.white); * * // check whether the value is above the threshold if * (markerMapMax2Critical.containsKey(sensorUID)) { if ( (value < * markerMapMax2Critical.get(sensorUID).getValue()) && (value >= * (markerMapMax2Warning.get(sensorUID).getValue())) ) { //between the * warning and critical plot1StateMap.put(sensorUID,2); * plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); } else if * (value >= markerMapMax2Critical.get(sensorUID).getValue()) { //above * the max threshold level plot1StateMap.put(sensorUID,3); * plotMap.get(sensorUID).setBackgroundPaint(Color.pink); } else { * //normal level if (plot1StateMap.get(sensorUID) != 1) { * plot1StateMap.put(sensorUID,0); * plotMap.get(sensorUID).setBackgroundPaint(Color.white); } } } * * } } */ }
From source file:op.care.values.PnlValues.java
private void addValue(final ResValueTypes vtype) { final String keyType = vtype.getID() + ".xtypes"; new DlgValue(new ResValue(resident, vtype), DlgValue.MODE_NEW, new Closure() { @Override/* w ww.jav a 2 s . c om*/ public void execute(Object o) { ResValue myValue = null; if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); myValue = em.merge((ResValue) o); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); em.getTransaction().commit(); } 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(); } if (myValue != null) { DateTime dt = new DateTime(myValue.getPit()); // final String keyDay = vtype.getID() + ".xtypes." + dt.toLocalDate() + ".day"; final String keyYear = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; // final LocalDate week = SYSCalendar.max(SYSCalendar.bow(dt.toLocalDate()), new LocalDate(dt.getYear(), 1, 1)); // final String keyWeek = vtype.getID() + ".xtypes." + week + ".week"; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYear)) { mapType2Values.put(keyYear, ResValueTools.getResValues(resident, vtype, dt.getYear())); } if (!mapType2Values.get(keyYear).contains(myValue)) { mapType2Values.get(keyYear).add(myValue); Collections.sort(mapType2Values.get(keyYear)); } // } } try { // eh ? synchronized (cpMap) { cpMap.get(keyType).setCollapsible(true); if (cpMap.get(keyType).isCollapsed()) { cpMap.get(keyType).setCollapsed(false); } if (cpMap.containsKey(keyYear) && cpMap.get(keyYear).isCollapsed()) { cpMap.get(keyYear).setCollapsed(false); } } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } createCP4Type(vtype); buildPanel(); final ResValue myValueCopy = myValue; synchronized (linemap) { GUITools.scroll2show(jspValues, linemap.get(myValueCopy), cpsValues, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(linemap.get(myValueCopy), Color.YELLOW, 2); } }); } } } } }); }
From source file:edu.harvard.i2b2.query.ui.MainPanel.java
private void jNameLabelMouseMoved(java.awt.event.MouseEvent evt) { jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.YELLOW)); jNameLabel.paintImmediately(jNameLabel.getVisibleRect()); try {//from w ww. j a va2 s . c om Thread.sleep(500); } catch (InterruptedException e) { } jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.BLACK)); }
From source file:com.att.aro.diagnostics.GraphPanel.java
private static void populateBluetoothPlot(XYPlot plot, TraceData.Analysis analysis) { // create the dataset... final XYIntervalSeriesCollection bluetoothData = new XYIntervalSeriesCollection(); if (analysis != null) { XYIntervalSeries bluetoothConnected = new XYIntervalSeries(BluetoothState.BLUETOOTH_CONNECTED); XYIntervalSeries bluetoothDisconnected = new XYIntervalSeries(BluetoothState.BLUETOOTH_DISCONNECTED); XYIntervalSeries bluetoothOff = new XYIntervalSeries(BluetoothState.BLUETOOTH_TURNED_OFF); bluetoothData.addSeries(bluetoothConnected); bluetoothData.addSeries(bluetoothDisconnected); // bluetoothStateCollection.addSeries(bluetoothOff); // Populate the data set Iterator<BluetoothInfo> iter = analysis.getBluetoothInfos().iterator(); XYIntervalSeries series;//from www . j av a 2s . co m if (iter.hasNext()) { while (iter.hasNext()) { BluetoothInfo btEvent = iter.next(); switch (btEvent.getBluetoothState()) { case BLUETOOTH_CONNECTED: series = bluetoothConnected; break; case BLUETOOTH_DISCONNECTED: series = bluetoothDisconnected; break; default: series = bluetoothOff; break; } series.add(btEvent.getBeginTimeStamp(), btEvent.getBeginTimeStamp(), btEvent.getEndTimeStamp(), 0.5, 0, 1); } } XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(bluetoothData.indexOf(BluetoothState.BLUETOOTH_CONNECTED), new Color(34, 177, 76)); renderer.setSeriesPaint(bluetoothData.indexOf(BluetoothState.BLUETOOTH_DISCONNECTED), Color.YELLOW); // Assign ToolTip to renderer renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { BluetoothState eventType = (BluetoothState) bluetoothData.getSeries(series).getKey(); return MessageFormat.format(rb.getString("bluetooth.tooltip"), dataset.getX(series, item), ResourceBundleManager.getEnumString(eventType)); } }); } plot.setDataset(bluetoothData); }
From source file:knop.psfj.BeadImage.java
/** * Gets the montage./*from w w w .j av a 2 s . c om*/ * * @return the montage */ public ImageProcessor getMontage() { int beadPerCorner = 4; int beadNumber = getBeadFrameList().getWithAlterEgo().size(); if (beadNumber < 4 * 9 * 2) { beadPerCorner = 1; } if (beadNumber < 18) { return getBeadFrameList().getValidBeadFrames().getBeadMontage(); } int enlargementFactor = 3; int cornerWidth = MathUtils.round(Math.sqrt(beadPerCorner)) * getBeadFrame(0).getWidth() * enlargementFactor; int cornerHeight = MathUtils.round(Math.sqrt(beadPerCorner)) * getBeadFrame(0).getHeight() * enlargementFactor; int mw = cornerWidth * 3; int mh = cornerHeight * 3; ColorProcessor finalMontage = new ColorProcessor(mw, mh); for (int x = -1; x != 2; x++) { for (int y = -1; y != 2; y++) { int xf = (x + 1) * cornerWidth; int yf = (y + 1) * cornerHeight; ImageProcessor beadMontage = getBeadFrameList().getWithAlterEgo() .getSampleFromCorner(getZone(x, y, 4), beadPerCorner).getBeadMontage(); beadMontage = beadMontage.resize(beadMontage.getWidth() * enlargementFactor, beadMontage.getHeight() * enlargementFactor, true); finalMontage.copyBits(beadMontage, xf, yf, Blitter.COPY); finalMontage.setColor(Color.white.darker().darker()); finalMontage.setFont(new Font(java.awt.Font.SANS_SERIF, java.awt.Font.CENTER_BASELINE, 10)); finalMontage.drawString(getCornerName(x, y), xf + 5, yf + 16); finalMontage.setColor(Color.yellow.darker()); finalMontage.drawRect((x + 1) * cornerWidth, (y + 1) * cornerHeight, cornerWidth, cornerHeight); } } return finalMontage; }
From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
public static Color parseColor(String color) { if (color != null) { if (color.trim().startsWith("#")) { // HTML colors (#FFFFFF format) return new Color(Integer.parseInt(color.substring(1), 16)); } else if (color.trim().startsWith("rgb")) { // HTML colors (rgb(255, 255, 255) format) String values = color.substring(color.indexOf("(") + 1, color.indexOf(")")); String rgb[] = values.split(","); return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()), Integer.parseInt(rgb[2].trim())); } else {/* w w w . j av a2 s .c om*/ // Colors by name if (color.equalsIgnoreCase("black")) return Color.black; if (color.equalsIgnoreCase("grey")) return Color.gray; if (color.equalsIgnoreCase("yellow")) return Color.yellow; if (color.equalsIgnoreCase("green")) return Color.green; if (color.equalsIgnoreCase("blue")) return Color.blue; if (color.equalsIgnoreCase("red")) return Color.red; if (color.equalsIgnoreCase("orange")) return Color.orange; if (color.equalsIgnoreCase("cyan")) return Color.cyan; if (color.equalsIgnoreCase("magenta")) return Color.magenta; if (color.equalsIgnoreCase("darkgray")) return Color.darkGray; if (color.equalsIgnoreCase("lightgray")) return Color.lightGray; if (color.equalsIgnoreCase("pink")) return Color.pink; if (color.equalsIgnoreCase("white")) return Color.white; } } log.info("Unable to parse body background-color (color:" + color + "). Assuming white."); return Color.white; }
From source file:com.att.aro.diagnostics.GraphPanel.java
private static void populateWifiPlot(XYPlot plot, TraceData.Analysis analysis) { // create the dataset... final XYIntervalSeriesCollection wifiData = new XYIntervalSeriesCollection(); if (analysis != null) { Map<WifiState, XYIntervalSeries> seriesMap = new EnumMap<WifiState, XYIntervalSeries>(WifiState.class); for (WifiState eventType : WifiState.values()) { XYIntervalSeries series = new XYIntervalSeries(eventType); seriesMap.put(eventType, series); switch (eventType) { case WIFI_UNKNOWN: case WIFI_DISABLED: // Don't chart these break; default: wifiData.addSeries(series); break; }//from w w w . j a v a 2 s .c o m } // Populate the data set List<WifiInfo> wifiInfos = analysis.getWifiInfos(); final Map<Double, WifiInfo> eventMap = new HashMap<Double, WifiInfo>(wifiInfos.size()); Iterator<WifiInfo> iter = wifiInfos.iterator(); if (iter.hasNext()) { while (iter.hasNext()) { WifiInfo wifiEvent = iter.next(); seriesMap.get(wifiEvent.getWifiState()).add(wifiEvent.getBeginTimeStamp(), wifiEvent.getBeginTimeStamp(), wifiEvent.getEndTimeStamp(), 0.5, 0, 1); eventMap.put(wifiEvent.getBeginTimeStamp(), wifiEvent); } } XYItemRenderer renderer = plot.getRenderer(); for (WifiState eventType : WifiState.values()) { Color paint; switch (eventType) { case WIFI_CONNECTED: case WIFI_CONNECTING: case WIFI_DISCONNECTING: paint = new Color(34, 177, 76); break; case WIFI_DISCONNECTED: case WIFI_SUSPENDED: paint = Color.YELLOW; break; default: paint = Color.WHITE; break; } int index = wifiData.indexOf(eventType); if (index >= 0) { renderer.setSeriesPaint(index, paint); } } // Assign ToolTip to renderer renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { WifiState eventType = (WifiState) wifiData.getSeries(series).getKey(); StringBuffer message = new StringBuffer(rb.getString("wifi.tooltip.prefix")); message.append(MessageFormat.format(rb.getString("wifi.tooltip"), dataset.getX(series, item), ResourceBundleManager.getEnumString(eventType))); switch (eventType) { case WIFI_CONNECTED: WifiInfo info = eventMap.get(dataset.getX(series, item)); if (info != null && info.getWifiState() == WifiState.WIFI_CONNECTED) { message.append(MessageFormat.format(rb.getString("wifi.connTooltip"), info.getWifiMacAddress(), info.getWifiRSSI(), info.getWifiSSID())); } break; default: break; } message.append(rb.getString("wifi.tooltip.suffix")); return message.toString(); } }); } plot.setDataset(wifiData); }
From source file:op.care.reports.PnlReport.java
private JPanel getMenu(final NReport nreport) { JPanel pnlMenu = new JPanel(new VerticalLayout()); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /***/*ww w. j a v a 2 s .c o m*/ * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.reports.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgReport(nreport.clone(), new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport newReport = em.merge((NReport) o); NReport oldReport = em.merge(nreport); em.lock(oldReport, LockModeType.OPTIMISTIC); newReport.setReplacementFor(oldReport); for (SYSNR2FILE oldAssignment : oldReport.getAttachedFilesConnections()) { em.remove(oldAssignment); } oldReport.getAttachedFilesConnections().clear(); for (SYSNR2PROCESS oldAssignment : oldReport.getAttachedQProcessConnections()) { em.remove(oldAssignment); } oldReport.getAttachedQProcessConnections().clear(); oldReport.setEditedBy(em.merge(OPDE.getLogin().getUser())); oldReport.setEditDate(new Date()); oldReport.setReplacedBy(newReport); em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance() .format(newReport.getPit()); final String keyOldDay = DateFormat.getDateInstance() .format(oldReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); contentmap.remove(keyOldDay); } synchronized (linemap) { linemap.remove(oldReport); } synchronized (valuecache) { valuecache.get(keyOldDay).remove(nreport); valuecache.get(keyOldDay).add(oldReport); Collections.sort(valuecache.get(keyOldDay)); if (valuecache.containsKey(keyNewDay)) { valuecache.get(keyNewDay).add(newReport); Collections.sort(valuecache.get(keyNewDay)); } } synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : newReport.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } if (minmax.isAfter(new DateTime(newReport.getPit()))) { minmax.setStart(new DateTime(newReport.getPit())); } if (minmax.isBefore(new DateTime(newReport.getPit()))) { minmax.setEnd(new DateTime(newReport.getPit())); } createCP4Day(new LocalDate(oldReport.getPit())); createCP4Day(new LocalDate(newReport.getPit())); buildPanel(); GUITools.scroll2show(jspReports, cpMap.get(keyNewDay), cpsReports, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(linemap.get(newReport), Color.YELLOW, 2); } }); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnEdit.setEnabled(NReportTools.isChangeable(nreport)); pnlMenu.add(btnEdit); /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton("nursingrecords.reports.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format( nreport.getPit()) + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport delReport = em.merge(nreport); em.lock(delReport, LockModeType.OPTIMISTIC); delReport.setDeletedBy(em.merge(OPDE.getLogin().getUser())); for (SYSNR2FILE oldAssignment : delReport .getAttachedFilesConnections()) { em.remove(oldAssignment); } delReport.getAttachedFilesConnections().clear(); for (SYSNR2PROCESS oldAssignment : delReport .getAttachedQProcessConnections()) { em.remove(oldAssignment); } delReport.getAttachedQProcessConnections().clear(); em.getTransaction().commit(); final String keyDay = DateFormat.getDateInstance() .format(delReport.getPit()); synchronized (contentmap) { contentmap.remove(keyDay); } synchronized (linemap) { linemap.remove(delReport); } synchronized (valuecache) { valuecache.get(keyDay).remove(nreport); valuecache.get(keyDay).add(delReport); Collections.sort(valuecache.get(keyDay)); } createCP4Day(new LocalDate(delReport.getPit())); buildPanel(); if (tbShowReplaced.isSelected()) { GUITools.flashBackground(linemap.get(delReport), Color.YELLOW, 2); } } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelete.setEnabled(NReportTools.isChangeable(nreport)); pnlMenu.add(btnDelete); /*** * _ _ _____ _ ____ * | |__ | |_ _ _|_ _|/ \ / ___|___ * | '_ \| __| '_ \| | / _ \| | _/ __| * | |_) | |_| | | | |/ ___ \ |_| \__ \ * |_.__/ \__|_| |_|_/_/ \_\____|___/ * */ final JButton btnTAGs = GUITools.createHyperlinkButton("misc.msg.editTags", SYSConst.icon22tagPurple, null); btnTAGs.setAlignmentX(Component.RIGHT_ALIGNMENT); btnTAGs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popup = new JidePopup(); final JPanel pnl = new JPanel(new BorderLayout(5, 5)); final PnlCommonTags pnlCommonTags = new PnlCommonTags(nreport.getCommontags(), true, 3); pnl.add(new JScrollPane(pnlCommonTags), BorderLayout.CENTER); JButton btnApply = new JButton(SYSConst.icon22apply); pnl.add(btnApply, BorderLayout.SOUTH); btnApply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT); myReport.getCommontags().clear(); for (Commontags commontag : pnlCommonTags.getListSelectedTags()) { myReport.getCommontags().add(em.merge(commontag)); } em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance().format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myReport.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnTAGs); popup.removeExcludedComponent(btnTAGs); pnl.setPreferredSize(new Dimension(350, 150)); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnTAGs.setEnabled(NReportTools.isChangeable(nreport) && NReportTools.isMine(nreport)); pnlMenu.add(btnTAGs); /*** * _ _ __ __ _ _ * | |__ | |_ _ __ | \/ (_)_ __ _ _| |_ ___ ___ * | '_ \| __| '_ \| |\/| | | '_ \| | | | __/ _ \/ __| * | |_) | |_| | | | | | | | | | | |_| | || __/\__ \ * |_.__/ \__|_| |_|_| |_|_|_| |_|\__,_|\__\___||___/ * */ final JButton btnMinutes = GUITools.createHyperlinkButton("nursingrecords.reports.btnminutes.tooltip", SYSConst.icon22clock, null); btnMinutes.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMinutes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JPopupMenu menu = SYSCalendar.getMinutesMenu( new int[] { 1, 2, 3, 4, 5, 10, 15, 20, 30, 45, 60, 120, 240, 360 }, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC); myReport.setMinutes((Integer) o); myReport.setEditDate(new Date()); em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); menu.show(btnMinutes, 0, btnMinutes.getHeight()); } }); btnMinutes.setEnabled(!nreport.isObsolete() && NReportTools.isMine(nreport)); pnlMenu.add(btnMinutes); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = nreport.isObsolete() ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final NReport myReport = em.find(NReport.class, nreport.getID()); em.close(); final String keyNewDay = DateFormat.getDateInstance().format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } }; new DlgFiles(nreport, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(nreport, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSNR2PROCESS> attached = new ArrayList<SYSNR2PROCESS>( myReport.getAttachedQProcessConnections()); for (SYSNR2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getNReport().getAttachedQProcessConnections().remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myReport)) { QProcess myQProcess = em.merge(qProcess); SYSNR2PROCESS myLinkObject = em .merge(new SYSNR2PROCESS(myQProcess, myReport)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedNReportConnections().add(myLinkObject); myReport.getAttachedQProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance().format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); pnlMenu.add(btnProcess); } return pnlMenu; }