List of usage examples for java.text NumberFormat getNumberInstance
public static final NumberFormat getNumberInstance()
From source file:op.care.prescription.DlgOnDemand.java
public void initDialog() { fillComboBoxes();//from w ww .j a v a2 s. c om ignoreEvent = true; lblCheckResultAfter.setText(SYSTools.xx("nursingrecords.prescription.dlgOnDemand.outcomeCheck") + ":"); rbActive.setText(SYSTools.xx("nursingrecords.prescription.dlgOnDemand.rbActive")); txtMed.setText(""); cmbMed.setRenderer(TradeFormTools.getRenderer(TradeFormTools.LONG)); cmbMed.setModel(new DefaultComboBoxModel()); cmbDocON.setSelectedItem(prescription.getDocON()); cmbHospitalON.setSelectedItem(prescription.getHospitalON()); txtBemerkung.setText(SYSTools.catchNull(prescription.getText())); if (prescription.hasMed()) { cmbMed.setModel(new DefaultComboBoxModel(new TradeForm[] { prescription.getTradeForm() })); } cmbIntervention.setModel( new DefaultComboBoxModel(InterventionTools.findBy(InterventionTools.TYPE_PRESCRIPTION).toArray())); cmbIntervention.setRenderer(InterventionTools.getRenderer()); cmbIntervention.setEnabled(cmbMed.getModel().getSize() == 0); txtIntervention.setEnabled(cmbIntervention.isEnabled()); cmbIntervention.setSelectedItem(prescription.getIntervention()); cmbCheckAfter.setSelectedItem(schedule.getCheckAfterHours()); cmbSit.setRenderer(SituationsTools.getSituationenRenderer()); cmbSit.setModel(new DefaultComboBoxModel(new Situations[] { prescription.getSituation() })); txtSit.setText(""); txtMaxTimes.setText(NumberFormat.getNumberInstance().format(schedule.getMaxAnzahl())); txtEDosis.setText(schedule.getMaxEDosis().setScale(2, RoundingMode.HALF_UP).toString()); pnlCommonTags = new PnlCommonTags(prescription.getCommontags(), true, 3); jPanel1.add(new JScrollPane(pnlCommonTags), CC.xyw(1, 11, 5)); ignoreEvent = false; txtMed.requestFocus(); }
From source file:org.fao.geonet.kernel.csw.services.getrecords.CatalogSearcher.java
/** * Creates a lucene Query object from a lucene query string using Lucene query syntax. * * @param cswServiceSpecificConstraint/*from www . ja v a 2 s.c om*/ * @return * @throws ParseException * @throws QueryNodeException */ public static Query getCswServiceSpecificConstraintQuery(String cswServiceSpecificConstraint, LuceneConfig _luceneConfig) throws ParseException, QueryNodeException { // MultiFieldQueryParser parser = new MultiFieldQueryParser(Geonet.LUCENE_VERSION, fields , SearchManager.getAnalyzer()); StandardQueryParser parser = new StandardQueryParser(SearchManager.getAnalyzer()); Map<String, NumericConfig> numericMap = new HashMap<String, NumericConfig>(); for (LuceneConfigNumericField field : _luceneConfig.getNumericFields().values()) { String name = field.getName(); int precisionStep = field.getPrecisionStep(); NumberFormat format = NumberFormat.getNumberInstance(); NumericType type = NumericType.valueOf(field.getType().toUpperCase()); NumericConfig config = new NumericConfig(precisionStep, format, type); numericMap.put(name, config); } parser.setNumericConfigMap(numericMap); Query q = parser.parse(cswServiceSpecificConstraint, "title"); // List of lucene fields which MUST not be control by user, to be removed from the CSW service specific constraint List<String> SECURITY_FIELDS = Arrays.asList(LuceneIndexField.OWNER, LuceneIndexField.GROUP_OWNER); BooleanQuery bq; if (q instanceof BooleanQuery) { bq = (BooleanQuery) q; List<BooleanClause> clauses = bq.clauses(); Iterator<BooleanClause> it = clauses.iterator(); while (it.hasNext()) { BooleanClause bc = it.next(); for (String fieldName : SECURITY_FIELDS) { if (bc.getQuery().toString().contains(fieldName + ":")) { if (Log.isDebugEnabled(Geonet.CSW_SEARCH)) Log.debug(Geonet.CSW_SEARCH, "LuceneSearcher getCswServiceSpecificConstraintQuery removed security field: " + fieldName); it.remove(); break; } } } } return q; }
From source file:hudson.Util.java
/** * Returns the parsed string if parsed successful; otherwise returns the default number. * If the string is null, empty or a ParseException is thrown then the defaultNumber * is returned./*from w ww .ja v a 2s . c om*/ * @param numberStr string to parse * @param defaultNumber number to return if the string can not be parsed * @return returns the parsed string; otherwise the default number */ public static Number tryParseNumber(String numberStr, Number defaultNumber) { if ((numberStr == null) || (numberStr.length() == 0)) { return defaultNumber; } try { return NumberFormat.getNumberInstance().parse(numberStr); } catch (ParseException e) { return defaultNumber; } }
From source file:com.clustercontrol.http.factory.RunMonitorHttpScenario.java
/** * HTTP ?/*from w w w .ja v a 2 s . c o m*/ * * @param facilityId ID * @return ???????true */ public List<MonitorRunResultInfo> collectList(String facilityId) { // ??????? if (!m_isMonitorJob && (!m_httpScenarioCheckInfo.getMonitorInfo().getMonitorFlg() && !m_httpScenarioCheckInfo.getMonitorInfo().getCollectorFlg())) { if (m_log.isDebugEnabled()) { m_log.debug("http scenario monitor " + m_httpScenarioCheckInfo.getMonitorId() + " is not enabled, skip filtering."); } return Collections.emptyList(); } if (m_now != null) { m_nodeDate = m_now.getTime(); } m_value = 0; GetHttpResponse.GetHttpResponseBuilder builder = null; try { builder = GetHttpResponse.custom() .setAuthType(m_httpScenarioCheckInfo.getAuthType() == null ? GetHttpResponse.AuthType.NONE : AuthType.valueOf(m_httpScenarioCheckInfo.getAuthType())) .setAuthUser(m_httpScenarioCheckInfo.getAuthUser()) .setAuthPassword(m_httpScenarioCheckInfo.getAuthPassword()) .setUserAgent(m_httpScenarioCheckInfo.getUserAgent()) .setConnectTimeout(m_httpScenarioCheckInfo.getConnectTimeout() == null ? 0 : m_httpScenarioCheckInfo.getConnectTimeout()) .setRequestTimeout(m_httpScenarioCheckInfo.getRequestTimeout() == null ? 0 : m_httpScenarioCheckInfo.getRequestTimeout()) .setCancelProxyCache(HinemosPropertyUtil .getHinemosPropertyBool("monitor.http.scenario.disable.proxy.cache", true)) .setKeepAlive(true).setNeedAuthSSLCert( !HinemosPropertyUtil.getHinemosPropertyBool("monitor.http.ssl.trustall", true)); if (m_httpScenarioCheckInfo.getProxyFlg()) { builder.setProxyURL(m_httpScenarioCheckInfo.getProxyUrl()) .setProxyPort(m_httpScenarioCheckInfo.getProxyPort() == null ? 0 : m_httpScenarioCheckInfo.getProxyPort()) .setProxyUser(m_httpScenarioCheckInfo.getProxyUser()) .setProxyPassword(m_httpScenarioCheckInfo.getProxyPassword()); } } catch (URISyntaxException e) { m_log.warn("fail to initialize GetHttpResponse : " + e.getMessage(), e); MonitorRunResultInfo info = new MonitorRunResultInfo(); info.setFacilityId(facilityId); info.setMonitorFlg(m_httpScenarioCheckInfo.getMonitorInfo().getMonitorFlg()); info.setCollectorFlg(false); info.setCollectorResult(false); info.setCheckResult(-1); info.setPriority(PriorityConstant.TYPE_UNKNOWN); info.setMessage(MessageConstant.MESSAGE_FAIL_TO_ANALYZE_PROXY_URL.getMessage()); StringBuffer messageOrg = new StringBuffer(); messageOrg.append(e.getMessage()); messageOrg.append("\n"); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PROXYURL.getMessage()); messageOrg.append(" : "); messageOrg.append(m_httpScenarioCheckInfo.getProxyUrl()); info.setMessageOrg(messageOrg.toString()); info.setNodeDate(m_nodeDate); info.setProcessType(true); info.setNotifyGroupId(m_httpScenarioCheckInfo.getMonitorInfo().getNotifyGroupId()); return Arrays.asList(info); } int responseTime = 0; ResultType endResultType = ResultType.SUCCESS; MonitorRunResultInfo errorResultInfo = null; List<PageResponse> responses = new ArrayList<PageResponse>(); try (GetHttpResponse m_request = builder.build()) { Map<String, String> variables = RepositoryUtil.createNodeParameter(nodeInfo.get(facilityId)); List<Page> pages = new ArrayList<>(m_httpScenarioCheckInfo.getPages()); Collections.sort(pages, new Comparator<Page>() { @Override public int compare(Page o1, Page o2) { return o1.getId().getPageOrderNo().compareTo(o2.getId().getPageOrderNo()); } }); loopEnd: for (Page page : pages) { ResultType resultType = ResultType.SUCCESS; MonitorRunResultInfo resultInfo = null; StringBinder strbinder = new StringBinder(variables); String url = page.getUrl(); url = strbinder.bindParam(url); String post = page.getPost(); if (post != null && !post.isEmpty()) post = strbinder.bindParam(post); if (m_log.isTraceEnabled()) m_log.trace("http request. (nodeInfo = " + nodeInfo + ", facilityId = " + facilityId + ", url = " + url + ")"); PageResponse response = null; List<String> rurls = new ArrayList<>(); String nextUrl = url; String nextPost = post; while (true) { m_request.execute(nextUrl, nextPost); response = new PageResponse(page, m_request.getResult()); if (response.response.exception == null) { // ?????? if (response.response.statusCode == 301 || response.response.statusCode == 302 || response.response.statusCode == 303 || response.response.statusCode == 307) { for (Header h : response.response.headers) { if (h.getName().equals("Location")) { nextUrl = h.getValue(); nextPost = null; break; } } if (nextUrl != null) { rurls.add(nextUrl); } else { // ????? resultType = ResultType.NOT_FOUND_URL_FOR_REDIRECT; break; } } else { break; } } else { break; } } if (ResultType.NOT_FOUND_URL_FOR_REDIRECT.equals(resultType)) { resultInfo = createNotFoundUrlForRedirectMonitorRunResultInfo(page, response.response, url, rurls); resultInfo.setFacilityId(facilityId); } if (ResultType.SUCCESS.equals(resultType) && response.response.exception != null) { if (SocketTimeoutException.class.equals(response.response.exception.getClass())) { resultType = ResultType.TIMEOUT; resultInfo = createTimeoutMonitorRunResultInfo(page, response.response, url, rurls); resultInfo.setFacilityId(facilityId); } else { resultType = ResultType.UNEXPECTED; resultInfo = createUnexpectedMonitorRunResultInfo(page, response.response, url, rurls); resultInfo.setFacilityId(facilityId); } } if (ResultType.SUCCESS.equals(resultType) && !(page.getStatusCode() == null || Pattern.matches("(\\s*|.*,\\s*)" + response.response.statusCode + "(\\s*,.*|\\s*)", page.getStatusCode()))) { resultType = ResultType.NOT_MATCH_EXPECTED_STATUS_CODES; resultInfo = createUnmatchedStatusCodeMonitorRunResultInfo(page, m_request.getResult(), url); resultInfo.setFacilityId(facilityId); } if (ResultType.SUCCESS.equals(resultType) && !page.getPatterns().isEmpty()) { List<com.clustercontrol.http.model.Pattern> patterns = new ArrayList<>(page.getPatterns()); Collections.sort(patterns, new Comparator<com.clustercontrol.http.model.Pattern>() { @Override public int compare(com.clustercontrol.http.model.Pattern o1, com.clustercontrol.http.model.Pattern o2) { return o1.getId().getPatternOrderNo().compareTo(o2.getId().getPatternOrderNo()); } }); com.clustercontrol.http.model.Pattern matchedPattern = null; Boolean exceptionProcessType = null; for (int i = 0; i < patterns.size(); ++i) { com.clustercontrol.http.model.Pattern pe = patterns.get(i); if (!pe.getValidFlg() || pe.getPattern() == null) continue; try { // ????? Pattern pattern = null; if (pe.getCaseSensitivityFlg()) { pattern = Pattern.compile(pe.getPattern(), Pattern.DOTALL | Pattern.CASE_INSENSITIVE); } // ??? else { pattern = Pattern.compile(pe.getPattern(), Pattern.DOTALL); } // ???? String body = response.response.responseBody; if (body == null) { body = ""; } ; // 404?????body?null??????? Matcher matcher = pattern.matcher(body); if (matcher.matches()) { matchedPattern = pe; break; } } catch (PatternSyntaxException e) { m_log.info("collectList(): PatternSyntax is not valid." + " description=" + pe.getDescription() + ", patternSyntax=" + pe.getPattern() + ", value=" + response.response.responseBody + " : " + e.getClass().getSimpleName() + ", " + e.getMessage()); exceptionProcessType = pe.getProcessType(); } catch (Exception e) { m_log.warn("collectList(): PatternSyntax is not valid." + " description=" + pe.getDescription() + ", patternSyntax=" + pe.getPattern() + ", value=" + response.response.responseBody + " : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); exceptionProcessType = pe.getProcessType(); } } if (matchedPattern != null) { resultType = ResultType.MATCH_PATTERN; resultInfo = createMatchedPatternMonitorRunResultInfo(page, matchedPattern, response.response, url); resultInfo.setFacilityId(facilityId); } else { resultType = ResultType.NOT_MATCH_PATTERNS; resultInfo = createNotmatchedPatternsMonitorRunResultInfo(page, response.response, url, exceptionProcessType); resultInfo.setFacilityId(facilityId); } } // ??? switch (resultType) { case NOT_MATCH_EXPECTED_STATUS_CODES: case NOT_MATCH_PATTERNS: case TIMEOUT: case UNEXPECTED: case NOT_FOUND_URL_FOR_REDIRECT: errorResultInfo = resultInfo; endResultType = resultType; break loopEnd; case MATCH_PATTERN: if (resultInfo.getProcessType().booleanValue()) { endResultType = resultType; errorResultInfo = resultInfo; break loopEnd; } break; default: // SUCCESS break; } // ?? for (Variable variable : page.getVariables()) { String value = null; if (variable.getMatchingWithResponseFlg()) { if (response.response.responseBody != null) { Matcher m = Pattern.compile(variable.getValue(), Pattern.DOTALL) .matcher(response.response.responseBody); if (m.matches()) { try { value = m.group(1); } catch (IndexOutOfBoundsException e) { m_log.warn(String.format( "not contain group paragraph in pattern for variable. facilityId=%s, monitorId=%s, pageNo=%d, variableName=%s, value=%s", facilityId, m_httpScenarioCheckInfo.getMonitorId(), page.getId().getPageOrderNo(), variable.getId().getName(), variable.getValue())); } } else { // ???? m_log.debug(String.format( "variable not match. facilityId=%s, monitorId=%s, pageNo=%d, variableName=%s, value=%s", facilityId, m_httpScenarioCheckInfo.getMonitorId(), page.getId().getPageOrderNo(), variable.getId().getName(), variable.getValue())); } } else { // ???? m_log.warn(String.format( "Not foudnd previous post. facilityId=%s, monitorId=%s, pageNo=%d, variableName=%s, value=%s", facilityId, m_httpScenarioCheckInfo.getMonitorId(), page.getId().getPageOrderNo(), variable.getId().getName(), variable.getValue())); } } else { value = variable.getValue(); } if (value != null) { variables.put(variable.getId().getName(), value); } } responses.add(response); responseTime += m_request.getResult().responseTime; } } catch (IOException e) { m_log.warn("fail to close HttpClient : " + e.getMessage(), e); } List<MonitorRunResultInfo> resultInfos = new ArrayList<>(); if (ResultType.SUCCESS.equals(endResultType)) { MonitorRunResultInfo info = new MonitorRunResultInfo(); info.setFacilityId(facilityId); info.setMonitorFlg(m_httpScenarioCheckInfo.getMonitorInfo().getMonitorFlg()); info.setCollectorFlg(m_httpScenarioCheckInfo.getMonitorInfo().getCollectorFlg()); info.setCollectorResult(true); info.setCheckResult(0); info.setItemCode("0"); info.setItemName(m_httpScenarioCheckInfo.getMonitorInfo().getItemName()); info.setDisplayName(""); info.setPriority(PriorityConstant.TYPE_INFO); info.setMessage(String.format("%s : %s", MessageConstant.MONITOR_HTTP_SCENARIO_TOTAL_RESPONSETIME_MS.getMessage(), NumberFormat.getNumberInstance().format(responseTime))); int pageOrderNo = 1; StringBuffer messageOrg = new StringBuffer(); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_TOTAL_RESPONSETIME.getMessage()); messageOrg.append(" : "); messageOrg.append(responseTime); messageOrg.append("\n"); for (PageResponse pr : responses) { messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PAGE_ORDERNO.getMessage()); messageOrg.append(" : "); messageOrg.append(pageOrderNo++); messageOrg.append("\n"); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PAGE_URL.getMessage()); messageOrg.append(" : "); messageOrg.append(pr.response.url); messageOrg.append("\n"); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PAGE_STATUSCODE.getMessage()); messageOrg.append(" : "); messageOrg.append(pr.response.statusCode); messageOrg.append("\n"); messageOrg.append(MessageConstant.RESPONSE_TIME_MILLI_SEC.getMessage()); messageOrg.append(" : "); messageOrg.append(pr.response.responseTime); messageOrg.append("\n"); } info.setMessageOrg(messageOrg.toString()); info.setNodeDate(m_nodeDate); info.setValue((double) responseTime); info.setProcessType(true); info.setNotifyGroupId(m_httpScenarioCheckInfo.getMonitorInfo().getNotifyGroupId()); resultInfos.add(info); // ??? if (!m_isMonitorJob && m_httpScenarioCheckInfo.getMonitoringPerPageFlg() && m_httpScenarioCheckInfo.getMonitorInfo().getCollectorFlg()) { Map<String, Integer> map = new HashMap<String, Integer>(); for (PageResponse pr : responses) { Integer count = map.get(pr.page.getUrl()); if (count == null) { count = 1; map.put(pr.page.getUrl(), count); } else { map.put(pr.page.getUrl(), ++count); } MonitorRunResultInfo pagetResultInfo = new MonitorRunResultInfo(); pagetResultInfo.setFacilityId(facilityId); pagetResultInfo.setMonitorFlg(false); pagetResultInfo.setCollectorFlg(true); pagetResultInfo.setCollectorResult(true); pagetResultInfo.setItemCode(Integer.toString(pr.page.getId().getPageOrderNo() + 1)); pagetResultInfo.setDisplayName(pr.page.getUrl() + " (" + count + ")"); pagetResultInfo.setPriority(pr.page.getPriority()); pagetResultInfo.setNodeDate(m_nodeDate); pagetResultInfo.setValue((double) pr.response.responseTime); pagetResultInfo.setNotifyGroupId(m_httpScenarioCheckInfo.getMonitorInfo().getNotifyGroupId()); resultInfos.add(pagetResultInfo); } } } else { resultInfos.add(errorResultInfo); } return resultInfos; }
From source file:op.care.med.inventory.PnlInventory.java
private CollapsiblePane createCP4(final MedStock stock) { /***/*from w w w. j a v a2 s . c o m*/ * _ ____ ____ _ _ __ _ _ __ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | / /__| |_ ___ ___| | _\ \ * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_| / __| __/ _ \ / __| |/ /| | * | (__| | | __/ (_| | || __/ |___| __/|__ _| \__ \ || (_) | (__| < | | * \___|_| \___|\__,_|\__\___|\____|_| |_| | |___/\__\___/ \___|_|\_\| | * \_\ /_/ */ final String key = stock.getID() + ".xstock"; synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } cpMap.get(key).setName("stock"); BigDecimal sumStock = BigDecimal.ZERO; try { EntityManager em = OPDE.createEM(); sumStock = MedStockTools.getSum(em, stock); em.close(); } catch (Exception e) { OPDE.fatal(e); } String title = "<html><table border=\"0\">" + "<tr>" + (stock.isClosed() ? "<s>" : "") + "<td width=\"600\" align=\"left\">" + MedStockTools.getAsHTML(stock) + "</td>" + "<td width=\"200\" align=\"right\">" + NumberFormat.getNumberInstance().format(sumStock) + " " + DosageFormTools.getPackageText(MedInventoryTools.getForm(stock.getInventory())) + "</td>" + (stock.isClosed() ? "</s>" : "") + "</tr>" + "</table>" + "</html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpMap.get(key).setCollapsed(!cpMap.get(key).isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); cpMap.get(key).setTitleLabelComponent(cptitle.getMain()); cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH); cptitle.getRight().add(new StockPanel(stock)); if (!stock.getInventory().isClosed()) { /*** * ____ _ _ _ _ _ * | _ \ _ __(_)_ __ | |_| | __ _| |__ ___| | * | |_) | '__| | '_ \| __| | / _` | '_ \ / _ \ | * | __/| | | | | | | |_| |__| (_| | |_) | __/ | * |_| |_| |_|_| |_|\__|_____\__,_|_.__/ \___|_| * */ final JButton btnPrintLabel = new JButton(SYSConst.icon22print2); btnPrintLabel.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnPrintLabel.setContentAreaFilled(false); btnPrintLabel.setBorder(null); btnPrintLabel.setToolTipText(SYSTools.xx("nursingrecords.inventory.stock.btnprintlabel.tooltip")); btnPrintLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { LogicalPrinter logicalPrinter = OPDE.getLogicalPrinters().getMapName2LogicalPrinter() .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_LOGICAL_PRINTER)); PrinterForm printerForm1 = logicalPrinter.getForms() .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_MEDSTOCK_LABEL)); OPDE.getPrintProcessor().addPrintJob(new PrintListElement(stock, logicalPrinter, printerForm1, OPDE.getProps().getProperty(SYSPropsTools.KEY_PHYSICAL_PRINTER))); } }); btnPrintLabel.setEnabled(OPDE.getPrintProcessor().isWorking()); cptitle.getRight().add(btnPrintLabel); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); // btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(stock); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); cptitle.getRight().add(btnMenu); CollapsiblePaneAdapter adapter = new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpMap.get(key).setContentPane(createContentPanel4(stock)); } }; synchronized (cpListener) { if (cpListener.containsKey(key)) { cpMap.get(key).removeCollapsiblePaneListener(cpListener.get(key)); } cpListener.put(key, adapter); cpMap.get(key).addCollapsiblePaneListener(adapter); } if (!cpMap.get(key).isCollapsed()) { JPanel contentPane = createContentPanel4(stock); cpMap.get(key).setContentPane(contentPane); } cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING); cpMap.get(key).setOpaque(false); cpMap.get(key).setBackground( getColor(SYSConst.light3, lstInventories.indexOf(stock.getInventory()) % 2 != 0)); return cpMap.get(key); } }
From source file:com.clustercontrol.performance.monitor.factory.RunMonitorPerformance.java
/** * ????/*from www .j a v a 2 s . c o m*/ */ @Override public String getMessage(int result) { String valueString; if (Double.isNaN(m_value)) { valueString = MessageConstant.MESSAGE_COULD_NOT_GET_VALUE_PERFORMANCE.getMessage(); } else { valueString = NumberFormat.getNumberInstance().format(m_value); } return m_itemName + " : " + valueString; }
From source file:com.clustercontrol.performance.monitor.factory.RunMonitorPerformance.java
/** * ????/*w w w. j av a 2s. c om*/ */ @Override protected String getMessageForScope(int result) { String valueString; if (Double.isNaN(m_value)) { valueString = MessageConstant.TIME_OUT.getMessage(); } else { valueString = NumberFormat.getNumberInstance().format(m_value); } return m_itemName + " : " + valueString; }
From source file:com.clustercontrol.performance.monitor.factory.RunMonitorPerformance.java
/** * ????/* w ww.j ava2s. c o m*/ */ @Override public String getMessageOrg(int result) { String valueString; if (Double.isNaN(m_value)) { valueString = "NaN"; if (m_errorMessage != null) { valueString = valueString + "\n" + m_errorMessage; } } else { valueString = NumberFormat.getNumberInstance().format(m_value); m_log.debug("RunMonitorPerf messageOrg : " + valueString); // ? if (m_deviceData != null) { valueString = valueString + "\n" + MessageConstant.DEVICE_NAME.getMessage() + " : " + m_deviceData.getDeviceName() + "\n" + MessageConstant.DEVICE_INDEX.getMessage() + " : " + m_deviceData.getDeviceIndex(); m_log.debug("RunMonitorPerf add DeviceInfo : " + valueString); } } return m_itemName + " : " + valueString; }
From source file:net.massbank.validator.RecordValidator.java
/** * ???// w w w .j av a 2 s . c o m * * @param op * PrintWriter? * @param resultMap * ?? * @return ? * @throws IOException */ private static boolean dispResult(PrintStream op, TreeMap<String, String> resultMap) throws IOException { // ---------------------------------------------------- // // ---------------------------------------------------- NumberFormat nf = NumberFormat.getNumberInstance(); int okCnt = 0; int warnCnt = 0; int errCnt = 0; for (Map.Entry<String, String> e : resultMap.entrySet()) { String statusStr = e.getValue().split("\t")[0]; if (statusStr.equals(STATUS_OK)) { okCnt++; } else if (statusStr.equals(STATUS_WARN)) { warnCnt++; } else if (statusStr.equals(STATUS_ERR)) { errCnt++; } } op.println(nf.format(okCnt) + " ok"); op.println(nf.format(warnCnt) + " warn"); op.println(nf.format(errCnt) + " error / " + nf.format(resultMap.size()) + " files"); op.println("Status"); op.println("Details"); // ---------------------------------------------------- // // ---------------------------------------------------- for (Map.Entry<String, String> e : resultMap.entrySet()) { String nameStr = e.getKey(); String statusStr = e.getValue().split("\t")[0]; String detailsStr = e.getValue().split("\t")[1].trim(); op.println(nameStr + " "); op.println(statusStr + ""); op.println(detailsStr + ""); } return true; }
From source file:com.clustercontrol.performance.monitor.factory.RunMonitorPerformance.java
/** * ????//from w w w .j a v a2s . c o m */ @Override protected String getMessageOrgForScope(int result) { String valueString; if (Double.isNaN(m_value)) { valueString = "NaN"; } else { valueString = NumberFormat.getNumberInstance().format(m_value); } return m_itemName + " : " + valueString; }