private XmlUIElement getXmlUIElementFor(String typeArg) { if (typeToClassMappingProp == null) { setUpMappingsHM(); } String clsName = (String) typeToClassMappingProp.get(typeArg); if ((clsName != null) && !(clsName.equals("*NOTFOUND*")) && !(clsName.equals("*EXCEPTION*"))) { try { Class cls = Class.forName(clsName); return (XmlUIElement) cls.newInstance(); } catch (Throwable th) { typeToClassMappingProp.put(typeArg, "*EXCEPTION*"); showErrorMessage( MessageFormat.format( ProvClientUtils.getString( "{0} occurred when trying to get the XmlUIElement for type : {1}"), new Object[] {th.getClass().getName(), typeArg})); th.printStackTrace(); return null; } } else if (clsName == null) { typeToClassMappingProp.put(typeArg, "*NOTFOUND*"); showErrorMessage( MessageFormat.format( ProvClientUtils.getString( "The type {0} does not have the corresponding XMLUIElement specified in the TypeToUIElementMapping.txt file"), new Object[] {typeArg})); } return null; }
/** Sends Emails to Customers who have not submitted their Bears */ public static void BearEmailSendMessage(String msgsubject, String msgText, String msgTo) { try { BearFrom = props.getProperty("BEARFROM"); // To = props.getProperty("TO"); SMTPHost = props.getProperty("SMTPHOST"); Properties mailprops = new Properties(); mailprops.put("mail.smtp.host", SMTPHost); // create some properties and get the default Session Session session = Session.getDefaultInstance(mailprops, null); // create a message Message msg = new MimeMessage(session); // set the from InternetAddress from = new InternetAddress(BearFrom); msg.setFrom(from); InternetAddress[] address = InternetAddress.parse(msgTo); msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject(msgsubject); msg.setContent(msgText, "text/plain"); Transport.send(msg); } // end try catch (MessagingException mex) { USFEnv.getLog().writeCrit("Message not sent", null, null); } catch (Exception ex) { USFEnv.getLog().writeCrit("Message not sent", null, null); } } // end BearEmailSendMessage
public static void basic_putenv(Object name, Object value) { String name_string = SmartEiffelRuntime.NullTerminatedBytesToString(name); String value_string = SmartEiffelRuntime.NullTerminatedBytesToString(value); Properties props = System.getProperties(); props.put(name_string, value_string); System.setProperties(props); return; }
public Properties getUserInputValues() { Properties prop = new Properties(); for (int i = 0; i < uiList.size(); i++) { UserInput ui = (UserInput) uiList.get(i); XmlUIElement el = (XmlUIElement) uiElementsList.get(i); ui.setValue(el.getValue()); prop.put("$UserInput$" + ui.getID(), el.getValue()); } return prop; }
// reads the configuration (breakpoints, window sizes and positions...) for the current index private void restoreConfig() { Breakpoints.reset(); Properties.reset(); try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(idxName + ".config")); Breakpoints.restore(in); Properties.restore(in); in.close(); } catch (IOException exc) { // something went wrong - there probably was no .config file // ignore it } }
public Properties getPropertiesValue() { Properties props = new Properties(); for (int i = 0; i < propKeyList.size(); i++) { String propName = (String) propKeyList.get(i); // Since $Template$Params is being appended (before replacement)in the server side latest code // it is removed here using substring(15). // If not removed, this results in $Template$Params$Template$ParamsSource as the key to be // replaced by the user specified value. // Check to be introduced in server side. // propName = propName.trim().substring(15); XmlUIElement el = (XmlUIElement) propValueList.get(i); props.put(propName, el.getValue()); } return props; }
// saves the current configuration (breakpoints, window sizes and positions...) private void saveConfig() { try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(idxName + ".config")); Breakpoints.save(out); Properties.save(out); out.close(); } catch (IOException exc) { consoleFrame.echoInfo("Could not save settings: " + exc); } }
public static void main(String[] args) { try { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.PROVIDER_URL, "10.10.10.13:1100,10.10.10.14:1100"); // p.put(Context.PROVIDER_URL, "localhost:1100"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); InitialContext ctx = new InitialContext(p); StatelessSessionHome statelessSessionHome = (StatelessSessionHome) ctx.lookup("nextgen.StatelessSession"); EnterpriseEntityHome cmpHome = (EnterpriseEntityHome) ctx.lookup("nextgen.EnterpriseEntity"); StatelessSession statelessSession = statelessSessionHome.create(); EnterpriseEntity cmp = null; try { cmp = cmpHome.findByPrimaryKey("bill"); } catch (Exception ex) { cmp = cmpHome.create("bill"); } int count = 0; while (true) { System.out.println(statelessSession.callBusinessMethodB()); try { cmp.setOtherField(count++); } catch (Exception ex) { System.out.println("exception, trying to create it: " + ex); cmp = cmpHome.create("bill"); cmp.setOtherField(count++); } System.out.println("Entity: " + cmp.getOtherField()); Thread.sleep(2000); } } catch (NamingException nex) { if (nex.getRootCause() != null) { nex.getRootCause().printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } }
public JPanel getPanelForProperties(Properties propsArg) { // clear(); propKeyList = new ArrayList(); propValueList = new ArrayList(); for (Enumeration e = propsArg.propertyNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); String value = (String) propsArg.getProperty(name); XmlUIElement el = getXmlUIElementFor("textfield"); if (el != null) { propKeyList.add(name); el.setValue(value); if (name.endsWith("#")) { el.setLabelName(name.substring(0, name.length() - 1)); } else { el.setLabelName(name); } propValueList.add(el); } } return getPanelFor(propValueList); }
/** This replaces the user input variables in the XML template * */ public String replaceVariablesInString(String xmlStringArg) { String modXmlString = xmlStringArg; Properties prop = new Properties(); for (int i = 0; i < uiList.size(); i++) { UserInput ui = (UserInput) uiList.get(i); XmlUIElement el = (XmlUIElement) uiElementsList.get(i); ui.setValue(el.getValue()); prop.put("$UserInput$" + ui.getID(), el.getValue()); // modXmlString = StringUtil.replaceStringBySpecifiedString(modXmlString,"$UserInput$" + // ui.getID(),el.getValue()); } Template template = null; try { template = new Template(xmlStringArg); // template = PopulateTemplateParams.substituteParams(template, prop, 3); template = PopulateTemplateParams.substituteParams(template, prop); } catch (Exception exc) { exc.printStackTrace(); } // return modXmlString; return template.toString(); }
private void setUpMappingsHM() { typeToClassMappingProp = new Properties(); URL url = UserInputUIHandler.class.getClassLoader().getResource(mappingTxt); if (url == null) { showErrorMessage(ProvClientUtils.getString("TypeToUIElementMapping.txt file is not found")); return; } try { typeToClassMappingProp.load(url.openStream()); } catch (IOException ioe) { ioe.printStackTrace(); } }
@Override public void applyInput(Properties props, boolean selected) throws UserInputException { Component tab = null; try { tab = this.tabModel; String os = "3.1_64x32"; if (this.btnMon31_64x16.isSelected()) { os = "3.1_64x16"; } else if (this.btnMonSCCH80.isSelected()) { os = "SCCH8.0"; } else if (this.btnMonSCCH1088.isSelected()) { os = "SCCH10/88"; } else if (this.btnMon2010.isSelected()) { os = "2010"; } props.setProperty(this.propPrefix + "os.version", os); tab = this.tabRF; this.tabRF.applyInput(props, selected); tab = this.tabGIDE; this.tabGIDE.applyInput(props, selected); tab = this.tabSCCH; this.tabSCCH.applyInput(props, selected); tab = this.tab2010; this.fldAltPio2Rom2010.applyInput(props, selected); this.fldRomBank2010.applyInput(props, selected); tab = this.tabExt; EmuUtil.setProperty(props, this.propPrefix + "color", this.btnColor.isSelected()); EmuUtil.setProperty( props, this.propPrefix + "floppydisk.enabled", this.btnFloppyDisk.isSelected()); EmuUtil.setProperty(props, this.propPrefix + "kcnet.enabled", this.btnKCNet.isSelected()); EmuUtil.setProperty(props, this.propPrefix + "vdip.enabled", this.btnVDIP.isSelected()); EmuUtil.setProperty( props, this.propPrefix + "joystick.enabled", this.btnJoystick.isSelected()); tab = this.tabEtc; EmuUtil.setProperty(props, this.propPrefix + "paste.fast", this.btnPasteFast.isSelected()); this.fldAltOS.applyInput(props, selected); this.fldAltFont.applyInput(props, selected); } catch (UserInputException ex) { if (tab != null) { this.tabbedPane.setSelectedComponent(tab); } throw ex; } }
// resets the configuration (breakpoints, window sizes and positions...) private void resetConfig() { Breakpoints.reset(); Properties.reset(); }
public static String GetFaultDescription(long fault, Locale locale) { if (fault != 0L) { String fmt = "000"; StringBuffer sb = new StringBuffer(); if ((fault & TYPE_MASK) == TYPE_J1708) { int mid = DTOBDFault.DecodeSystem(fault); // MID boolean isSid = DTOBDFault.IsJ1708_SID(fault); int pidSid = DTOBDFault.DecodePidSid(fault); // PID|SID "128/[s]123/1" int fmi = DTOBDFault.DecodeFMI(fault); // FMI Properties p = (j1587DescProvider != null) ? j1587DescProvider.getJ1587Descriptions(fault) : new Properties(); // MID sb.append( NAME_MID + "(" + StringTools.format(mid, fmt) + ") " + p.getProperty(NAME_MID_DESC, "") + "\n"); // PID/SID if (isSid) { sb.append( NAME_SID + "(" + StringTools.format(pidSid, fmt) + ") " + p.getProperty(NAME_SID_DESC, "") + "\n"); } else { sb.append( NAME_PID + "(" + StringTools.format(pidSid, fmt) + ") " + p.getProperty(NAME_PID_DESC, "") + "\n"); } // FMI sb.append( NAME_FMI + "(" + StringTools.format(fmi, fmt) + ") " + p.getProperty(NAME_FMI_DESC, "")); return sb.toString(); } else if ((fault & TYPE_MASK) == TYPE_J1939) { int spn = DTOBDFault.DecodeSystem(fault); // SPN int fmi = DTOBDFault.DecodeFMI(fault); // FMI Properties p = new Properties(); // SPN sb.append( NAME_SPN + "(" + StringTools.format(spn, fmt) + ") " + p.getProperty(NAME_SPN, "") + "\n"); // FMI sb.append( NAME_FMI + "(" + StringTools.format(fmi, fmt) + ") " + p.getProperty(NAME_FMI, "")); return sb.toString(); } else if ((fault & TYPE_MASK) == TYPE_OBDII) { String dtc = DTOBDFault.GetFaultString(fault); // DTC Properties p = new Properties(); // DTC sb.append(NAME_DTC + "(" + dtc + ") " + p.getProperty(NAME_DTC, "")); return sb.toString(); } } return ""; }