コード例 #1
0
ファイル: MiscUtilities.java プロジェクト: zukov/Jpicedt
  /** store the given RenderingHints to a Properties object */
  public static void formatRenderingHints(RenderingHints rh, Properties preferences) {

    if (rh.get(RenderingHints.KEY_ANTIALIASING).equals(RenderingHints.VALUE_ANTIALIAS_ON))
      preferences.put("rendering.antialiasing", "on");
    else if (rh.get(RenderingHints.KEY_ANTIALIASING).equals(RenderingHints.VALUE_ANTIALIAS_OFF))
      preferences.put("rendering.antialiasing", "off");

    if (rh.get(RenderingHints.KEY_TEXT_ANTIALIASING).equals(RenderingHints.VALUE_TEXT_ANTIALIAS_ON))
      preferences.put("rendering.text-antialiasing", "on");
    else if (rh.get(RenderingHints.KEY_TEXT_ANTIALIASING)
        .equals(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF))
      preferences.put("rendering.text-antialiasing", "off");

    if (rh.get(RenderingHints.KEY_RENDERING).equals(RenderingHints.VALUE_RENDER_SPEED))
      preferences.put("rendering.render", "speed");
    else if (rh.get(RenderingHints.KEY_RENDERING).equals(RenderingHints.VALUE_RENDER_QUALITY))
      preferences.put("rendering.render", "quality");

    if (rh.get(RenderingHints.KEY_DITHERING).equals(RenderingHints.VALUE_DITHER_ENABLE))
      preferences.put("rendering.dither", "on");
    else if (rh.get(RenderingHints.KEY_DITHERING).equals(RenderingHints.VALUE_DITHER_DISABLE))
      preferences.put("rendering.dither", "off");

    if (rh.get(RenderingHints.KEY_FRACTIONALMETRICS)
        .equals(RenderingHints.VALUE_FRACTIONALMETRICS_ON))
      preferences.put("rendering.fractional-metrics", "on");
    else if (rh.get(RenderingHints.KEY_FRACTIONALMETRICS)
        .equals(RenderingHints.VALUE_FRACTIONALMETRICS_OFF))
      preferences.put("rendering.fractional-metrics", "off");
  }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: proses_Login.java プロジェクト: muhlik/overtimeapps
 public void koneksiDatabase() {
   try {
     String url = "jdbc:mysql://localhost:3306/payroll_db";
     Properties prop = new Properties();
     prop.put("user", "root");
     prop.put("password", "admin");
     konek = DriverManager.getConnection(url, prop);
     status_Proses(true, "Sukses!!!Berhasil Terhubung dengan Database...", 20);
   } catch (SQLException se) {
     status_Proses(false, "Gagal!!!Tidak terhubung \nKarena : " + se, 20);
   }
 }
コード例 #4
0
  public Properties getProperties() {
    Properties prop = new Properties();
    String name = saName.getText();
    String interval = saInt.getText();
    boolean opt = saYes.isSelected();

    prop.put("name", name);
    prop.put("suppressInt", interval);
    prop.put("suppressAll", opt + "");

    return prop;
  }
コード例 #5
0
ファイル: Installer.java プロジェクト: suever/CTP
  private void updateLinuxServiceInstaller() {
    try {
      File dir = new File(directory, "CTP");
      if (suppressFirstPathElement) dir = dir.getParentFile();
      Properties props = new Properties();
      String ctpHome = dir.getAbsolutePath();
      cp.appendln(Color.black, "...CTP_HOME: " + ctpHome);
      ctpHome = ctpHome.replaceAll("\\\\", "\\\\\\\\");
      props.put("CTP_HOME", ctpHome);
      File javaHome = new File(System.getProperty("java.home"));
      String javaBin = (new File(javaHome, "bin")).getAbsolutePath();
      cp.appendln(Color.black, "...JAVA_BIN: " + javaBin);
      javaBin = javaBin.replaceAll("\\\\", "\\\\\\\\");
      props.put("JAVA_BIN", javaBin);

      File linux = new File(dir, "linux");
      File install = new File(linux, "ctpService-ubuntu.sh");
      cp.appendln(Color.black, "Linux service installer:");
      cp.appendln(Color.black, "...file: " + install.getAbsolutePath());
      String bat = getFileText(install);
      bat = replace(bat, props); // do the substitutions
      bat = bat.replace("\r", "");
      setFileText(install, bat);

      // If this is an ISN installation, put the script in the correct place.
      String osName = System.getProperty("os.name").toLowerCase();
      if (programName.equals("ISN") && !osName.contains("windows")) {
        install = new File(linux, "ctpService-red.sh");
        cp.appendln(Color.black, "ISN service installer:");
        cp.appendln(Color.black, "...file: " + install.getAbsolutePath());
        bat = getFileText(install);
        bat = replace(bat, props); // do the substitutions
        bat = bat.replace("\r", "");
        File initDir = new File("/etc/init.d");
        File initFile = new File(initDir, "ctpService");
        if (initDir.exists()) {
          setOwnership(initDir, "edge", "edge");
          setFileText(initFile, bat);
          initFile.setReadable(true, false); // everybody can read //Java 1.6
          initFile.setWritable(true); // only the owner can write //Java 1.6
          initFile.setExecutable(true, false); // everybody can execute //Java 1.6
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      System.err.println("Unable to update the Linux service ctpService.sh file");
    }
  }
コード例 #6
0
ファイル: Outline.java プロジェクト: ShifuCifuentes/ridixcr
  /**
   * Creates a new Outline object.
   *
   * @param djvuBean the DjVuBean to navigate.
   * @throws ArrayIndexOutOfBoundsException if the document has less than 2 pages.
   */
  public Outline(final DjVuBean djvuBean) {
    this.djvuBean = djvuBean;

    if (djvuBean.getDocument().size() < 2) {
      throw new ArrayIndexOutOfBoundsException("Can not navigate documents with only one page.");
    }

    final MouseListener mouseListener =
        new MouseAdapter() {
          public void mouseClicked(final MouseEvent e) {
            try {
              clickLocation(e.getX(), e.getY());
            } catch (final Throwable exp) {
              exp.printStackTrace(DjVuOptions.err);
              System.gc();
            }
          }
        };

    addMouseListener(mouseListener);

    final Document document = djvuBean.getDocument();
    final Bookmark bookmark = (Bookmark) document.getBookmark();
    bookmark.setDjVmDir(document.getDjVmDir());
    setFirstBookmark(bookmark);

    final Properties properties = djvuBean.properties;
    properties.put("addOn.NavPane", "Outline," + properties.getProperty("addOn.NavPane", "None"));
    djvuBean.addPropertyChangeListener(this);
  }
コード例 #7
0
ファイル: ImageJ.java プロジェクト: chrisp87/ImageJA
 /** Called once when ImageJ quits. */
 public void savePreferences(Properties prefs) {
   Point loc = getLocation();
   prefs.put(IJ_X, Integer.toString(loc.x));
   prefs.put(IJ_Y, Integer.toString(loc.y));
   // prefs.put(IJ_WIDTH, Integer.toString(size.width));
   // prefs.put(IJ_HEIGHT, Integer.toString(size.height));
 }
コード例 #8
0
ファイル: ImageJ.java プロジェクト: chrisp87/ImageJA
 void configureProxy() {
   if (Prefs.useSystemProxies) {
     try {
       System.setProperty("java.net.useSystemProxies", "true");
     } catch (Exception e) {
     }
   } else {
     String server = Prefs.get("proxy.server", null);
     if (server == null || server.equals("")) return;
     int port = (int) Prefs.get("proxy.port", 0);
     if (port == 0) return;
     Properties props = System.getProperties();
     props.put("proxySet", "true");
     props.put("http.proxyHost", server);
     props.put("http.proxyPort", "" + port);
   }
   // new ProxySettings().logProperties();
 }
コード例 #9
0
 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;
 }
コード例 #10
0
ファイル: slsb.java プロジェクト: navssurtani/JBossAS51
  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();
    }
  }
コード例 #11
0
  private Properties writeDefaultDesktopAgentPropertiesFile(File objPropertiesFile)
      throws InvalidPropertiesFormatException, IOException {
    Properties tempProps = new Properties();
    FileOutputStream fos = new FileOutputStream(objPropertiesFile);

    tempProps.put("desktop_agent_left", "0");
    tempProps.put("desktop_agent_top", "0");
    tempProps.put("desktop_agent_width", "300");
    tempProps.put("desktop_agent_height", "450");
    tempProps.put("desktop_agent_use_custom_window_controls", "false");
    tempProps.put("desktop_agent_background_color", "808080");
    tempProps.put("desktop_agent_buttons_background_color", "808080");

    tempProps.put("agents_directory", "Desktop Agent Agents");
    tempProps.put("number_of_agents", "1");
    tempProps.put("agent_files", "GreetingAgent.agent");

    tempProps.storeToXML(fos, "Desktop Agent Properties File", "UTF-8");

    return tempProps;
  }
コード例 #12
0
  public static void sfSendEmail(String subject, String message) throws Exception {

    String SMTP_HOST_NAME = "smtp.gmail.com";
    String SMTP_PORT = "465";
    // message = "Test Email Notification From Monitor";
    // subject = "Test Email Notification From Monitor";
    String from = "*****@*****.**";
    String[] recipients = {
      "*****@*****.**", "*****@*****.**", "*****@*****.**"
    };
    String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
    // String[] recipients = { "*****@*****.**"};
    // String[] recipients = { "*****@*****.**", "*****@*****.**",
    // "*****@*****.**", "*****@*****.**", "*****@*****.**",
    // "*****@*****.**", "*****@*****.**"};
    // String[] recipients = {"*****@*****.**"};

    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    boolean debug = true;

    Properties props = new Properties();
    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.auth", "true");
    // props.put("mail.debug", "true");
    props.put("mail.smtp.port", SMTP_PORT);
    props.put("mail.smtp.socketFactory.port", SMTP_PORT);
    props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
    props.put("mail.smtp.socketFactory.fallback", "false");

    Session session =
        Session.getDefaultInstance(
            props,
            new Authenticator() {

              protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(
                    "*****@*****.**", "els102sensorweb");
              }
            });

    // session.setDebug(debug);

    Message msg = new MimeMessage(session);
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);

    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
      addressTo[i] = new InternetAddress(recipients[i]);
    }
    msg.setRecipients(Message.RecipientType.TO, addressTo);

    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);

    System.out.println("Sucessfully Sent mail to All Users");
  }
コード例 #13
0
 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;
 }
コード例 #14
0
 public static Properties getEnvironmentVariables() {
   synchronized (cygstartPath) {
     if (envVars != null) return envVars;
     envVars = new Properties();
     try (BufferedReader br =
         new BufferedReader(
             new InputStreamReader(RUNTIME.exec(comSpec + "env").getInputStream()))) {
       for (String line = null; (line = br.readLine()) != null; ) {
         // if (debug) System.out.println("getEnvironmentVariables(): line=" + line);
         int idx = line.indexOf('=');
         if (idx > 0) envVars.put(line.substring(0, idx), line.substring(idx + 1));
       }
     } catch (IOException e) {
       e.printStackTrace();
     }
     return envVars;
   }
 }
コード例 #15
0
ファイル: Installer.java プロジェクト: suever/CTP
  private void updateWindowsServiceInstaller() {
    try {
      File dir = new File(directory, "CTP");
      if (suppressFirstPathElement) dir = dir.getParentFile();
      File windows = new File(dir, "windows");
      File install = new File(windows, "install.bat");
      cp.appendln(Color.black, "Windows service installer:");
      cp.appendln(Color.black, "...file: " + install.getAbsolutePath());
      String bat = getFileText(install);
      Properties props = new Properties();
      String home = dir.getAbsolutePath();
      cp.appendln(Color.black, "...home: " + home);
      home = home.replaceAll("\\\\", "\\\\\\\\");
      props.put("home", home);

      bat = replace(bat, props);
      setFileText(install, bat);
    } catch (Exception ex) {
      ex.printStackTrace();
      System.err.println("Unable to update the windows service install.barfile.");
    }
  }
コード例 #16
0
 /** 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();
 }
コード例 #17
0
  public static void sendEmail(String subject, String message) throws Exception {
    /*
    String mailhost = "mail.vancouver.wsu.edu";
    String cc = null;
    String bcc = null;
    boolean debug = false;
    String file = null;
    String mailer = "msgsend";
    String sender = "mail.vancouver.wsu.edu";


       Properties props = System.getProperties();

       if (mailhost != null)
    props.put("mail.smtp.host", mailhost);

       // Get a Session object
       Session session = Session.getInstance(props, null);

    if (debug)
    session.setDebug(true);

       // construct the message
       Message msg = new MimeMessage(session);
       if (sender != null)
    msg.setFrom(new InternetAddress(sender));
       else
    msg.setFrom();

       msg.setRecipients(Message.RecipientType.TO,
    			InternetAddress.parse(receivers[0], false));

       if (cc != null)
    msg.setRecipients(Message.RecipientType.CC,
    			InternetAddress.parse(cc, false));
       if (bcc != null)
    msg.setRecipients(Message.RecipientType.BCC,
    			InternetAddress.parse(bcc, false));

       msg.setSubject(subject);

       String text = content;

       if (file != null) {
    // Attach the specified file.
    // We need a multipart message to hold the attachment.
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText(text);
    MimeBodyPart mbp2 = new MimeBodyPart();
    mbp2.attachFile(file);
    MimeMultipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    msg.setContent(mp);
       } else {
    // If the desired charset is known, you can use
    // setText(text, charset)
    msg.setText(text);
       }

       msg.setHeader("X-Mailer", mailer);
       msg.setSentDate(new Date());

       // send the thing off
       Transport.send(msg);

       System.out.println("\nMail was sent successfully.");
    */

    // Xiaogang: checkbox
    // System.out.println("sendemail"+MainFrame.EMAIL_ENABLE);
    if (MainFrame.EMAIL_ENABLE == false) return;

    String SMTP_HOST_NAME = "smtp.gmail.com";
    String SMTP_PORT = "465";
    // message = "Test Email Notification From Monitor";
    // subject = "Test Email Notification From Monitor";
    String from = "*****@*****.**";
    String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
    String[] recipients = {
      "*****@*****.**", "*****@*****.**", "*****@*****.**"
    };
    // String[] recipients = { "*****@*****.**"};
    // String[] recipients = { , "*****@*****.**", "*****@*****.**",
    // "*****@*****.**", "*****@*****.**"};
    // String[] recipients = {"*****@*****.**"};

    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    boolean debug = true;

    Properties props = new Properties();
    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.auth", "true");
    // props.put("mail.debug", "true");
    props.put("mail.smtp.port", SMTP_PORT);
    props.put("mail.smtp.socketFactory.port", SMTP_PORT);
    props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
    props.put("mail.smtp.socketFactory.fallback", "false");

    Session session =
        Session.getDefaultInstance(
            props,
            new Authenticator() {

              protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(
                    "*****@*****.**", "els102sensorweb");
              }
            });

    // session.setDebug(debug);

    Message msg = new MimeMessage(session);
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);

    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
      addressTo[i] = new InternetAddress(recipients[i]);
    }
    msg.setRecipients(Message.RecipientType.TO, addressTo);

    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);

    System.out.println("Sucessfully Sent mail to All Users");
  }
コード例 #18
0
  protected synchronized SessionPanel newSession(String sel, String[] args) {

    Properties sesProps = new Properties();

    String propFileName = null;
    String session = args[0];

    // Start loading properties
    sesProps.put(TN5250jConstants.SESSION_HOST, session);

    if (isSpecified("-e", args)) sesProps.put(TN5250jConstants.SESSION_TN_ENHANCED, "1");

    if (isSpecified("-p", args)) {
      sesProps.put(TN5250jConstants.SESSION_HOST_PORT, getParm("-p", args));
    }

    if (isSpecified("-f", args)) propFileName = getParm("-f", args);

    //  TODO: remove default codepage behavior and replace it with 870

    if (isSpecified("-cp", args))
      sesProps.put(TN5250jConstants.SESSION_CODE_PAGE, getParm("-cp", args));

    sesProps.put(TN5250jConstants.SESSION_USE_GUI, "1");

    if (isSpecified("-t", args)) sesProps.put(TN5250jConstants.SESSION_TERM_NAME_SYSTEM, "1");

    sesProps.put(TN5250jConstants.SESSION_SCREEN_SIZE, TN5250jConstants.SCREEN_SIZE_24X80_STR);

    //  TODO: are we to use a ssl and if we are what type
    sesProps.put(TN5250jConstants.SSL_TYPE, TN5250jConstants.SSL_TYPE_TLS);

    // check if device name is specified
    if (isSpecified("-dn=hostname", args)) {
      String dnParam;

      // use IP address as device name
      try {
        dnParam = InetAddress.getLocalHost().getHostName();
      } catch (UnknownHostException uhe) {
        dnParam = "UNKNOWN_HOST";
      }

      sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, dnParam);
    } else if (isSpecified("-dn", args)) {

      sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, getParm("-dn", args));
    }

    if (isSpecified("-hb", args)) sesProps.put(TN5250jConstants.SESSION_HEART_BEAT, "1");

    int sessionCount = manager.getSessions().getCount();

    // here we open a new 5250 session on the current session manager
    Session5250 s2 = manager.openSession(sesProps, propFileName, sel);
    // ... and a panel containing it
    SessionPanel s = new SessionPanel(s2);

    newView();
    frame.setVisible(true);
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    if (isSpecified("-t", args)) frame.addSessionView(sel, s);
    else frame.addSessionView(session, s);

    s.connect();

    s.addEmulatorActionListener(this);

    return s;
  }
コード例 #19
0
 public void set(String key, String value) {
   properties.put(key, value);
 }