PropertyChange progress value

Hello,
I'm trying to create a progress bar in my program when a user uploads a File.
I've created a class that extends SwingWorker to upload a file using FTP. I'm creating an instance of the class and adding a propertychange listener to it. But when I run it the only calls im getting from the propertyChange method are two states that tell me when the file upload has started and when its finished. The file upload works fine. I've been reading this tutorial http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html and it looks like I should be getting the progress aswell, so I can use it in a progress bar.
Any pointers greatly appreciated.

Hi Benny,
it depends on the setting for the EV basis, which is done in the customizing for the Progress Version. There you can choose between:
- cost plan (annual values, per periods) e.g. via transaction CJR2
- cost plan (overall values) e.g. via transaction CJ40
- budget (annual values)
- budget (overall values)
The calculation of the BCWS and BCWP is done for each object. This means that the budget/planned costs from the relevant object are used for the calculation of the Earned Value. So if there is a POC for this object, but no budget or planned costs, then the EVs will be zero.
Besides this you should check whether this is just a reporting problem. Therefore you should check whether there are entries in table COSB with value type 'P1' and/or 'P2' for the relevant objects. If there are entries then check whether there are corresponding entries in table RPSCO (Project Info Database) with the same value types.
If these entries are missing, check the assignment to value categories of the cost elements that you have maintained for the Progress Analysis (cost elements can be found in IMG Project System -> Progress -> Progress Analysis -> Maintain Assignment Of Cost Element Group).
The assignment of cost elements to value categories can be done via transaction OPI2.
I hope that these informations will help you.
Kind regards,
Dirk

Similar Messages

  • Migration of Cost Transaction Work In Progress Values into the Projects

    Hi,
    Can anyone kindly help me out in the approach to adopt for the Open Work in progress value migration into the projects applications of Oracle Applications.
    Thanks in Advance,
    Lavanya
    Edited by: Lavan ya on Nov 15, 2009 12:54 AM

    Hi
    The migration strategy depends on the way the company will for forward with its accounting procedure.
    I assume the project is incurring costs as work occurs, and supplier invoices are entered. At the end of the period the company need to move the value of costs which has not matched to the period revenue into a GL account representing the Work in Progress. If the model is calculating the figures on the marginal period, and not accumulated ITD amount, then your approach may be valid.
    The question regarding converting the project invoices (sent to customer) also depends on the method you accrue revenue. If Revenue and Invoice is always taken on the same time for the same value, you don't need to maintain UBR&UER balances. However, if those are generated separately, you might need to convert into Projects also the old revenue and old invoiced amount per project.
    Converting historic data also depends on the requirements for future reporting. If you only convert the balance of WIP, you might be missing information for reporting actual cost versus cost budgets, etc.
    Dina

  • TFS 2012 - How to Import bulk of historical WI's via EXCEL, with already progressed values in State field within the excel

    A user wants to import into TFS, ~ 500 historical bugs that were created and maintained in an excel template outside TFS. While they were maintained outside TFS, the user changed among others, the value of their Status field as well, i.e. there are bugs
    in a progressed state e.g. already in status Closed.
    Since normally in TFS, one could not directly create a new bug in State = Closed, an error would be yielded when trying to import them as is into regular Team Project. Can u please advise how to easily solve this, without hindering the state diagram of the
    model in TFS, and as possible by utilizing GUI of Excel / TFS / other available tool for this purpose ?
    Kind thx,

    Hi!
    You may use excel features for this. Simply copy & paste the state column:
    Publish 500 new bugs.
    Copy & paste the state column from your source table and publish.
    But the reason for state may not be correct. So you may use the more difficult way:
    For Source table create the custom state columns (for the cmmi template states Proposed->Active->Resolved->Closed) by this rules:
    (Active state column) if (source state == "Active" || source state == "Resolved" || source state == "Closed") { value = Active } else { value = source state }
    (Resolved state column) if (source state == "Resolved" || source state == "Closed") { value = Resolved } else { value = source state }
    (Closed state column) if (source state == "Closed") { value = Closed } else { value = source state }
    Then Publish new bugs.
    Copy&paste (Active state column) values and publish.
    Copy&paste (Resolved state column) values and publish.
    Copy&paste (Closed state column) values and publish.

  • WIP, RA with Method 07-POC Method on Basis of Project Progress value

    Hello, we are currently using RA under a Basis of work completed method, and this works well in our system. We are using the standard SAP functionality, and within our system this means revenue is recognised based on Earned Revenue = actual cost/planned cost x planned revenue. The system automatically processes accruals/deferrals on our projects taking into account the invoiced values also, as part of the RA & settlement process.
    I need to find some information describing this process specific to this selection of method 07, and can't seem to find anything. I have tried saying it is Standard functionality but need to be able to explain alittle more about how this works.
    Can anyone help with this, have they also produced something similar.
    Points always awarded

    Hi Wndy
    I have send a mail to you.
    The RA, I was doing is POC based on Plan over Plan method using 07
    As of now it's working. Still doing some testing.. Once it's complete I am happy to share the same here.
    psconsultant

  • Progress Bar Never 100%

    Ok, kind of an odd issue, but I've got a script that can take a considerable amount of time to run due to all the sub-scripts.  Anyway, I've setup a progress bar to work with it so I can tell how far it is.  The only problem is, unless there is an alert or something that pauses the script (like a pop-up), the bar NEVER shows 100% full; even if I use an in-script pause such as the sleep command.  Any ideas how to fix this?  An example script is below and also never reaches 100% filled bar.
    #target photoshop
    var list = ["one", "two", "three", "four", "five", "six"];
    var w = new Window ("palette");
    var progress = progress_bar (w, list.length);
    for (var i = 0; i < list.length; i++) {
        progress.value = i+1;
        // user functions
        $.sleep (400);
    progress.parent.close();
    function progress_bar (w, stop) {
        var pbar = w.add ("progressbar", undefined, 1, stop);
        pbar.preferredSize = [300,20];
        w.show ();
        return pbar;
    I've also tried adding "w.show();" immediately after the "progress.value = i+1;" and still nothing; but like I said, if an alert pauses the script, it will work right.  Any ideas?
    Thanks for any help!

    Lol, ok, now I feel stupid.  I actually found the fix for the issue on my own.  To fix it, simply replace the $.sleep(400); with w.update(); (the sleep is pointless and pretty much just slows down your script).

  • Implements the progress bar in user defined form

    Hi Experts,
    As i am new to SAP B1 add on development field so i wants  to set the progress bar in user defined screen through sdk code. Can you guide me?
    Regards,
    silambu

    Rahul,
             It is really helped to me. But progress bar only showed.I need  Loading part  mention by some color or something..
    my coding...
    Dim progress As SAPbouiCOM.ProgressBar
    progress = oApplication.StatusBar.CreateProgressBar("Importing Data From Excel", oMatrixTml.VisualRowCount, True)
               progress.Value = 0
                For i As Integer = 0 To dataset.Tables(0).Rows.Count - 1
                    If i <> 0 Then
                        oGFun.SetNewLine(oMatrixTml, oDBDSDetail, 0, "")
                        oDBDSDetail.SetValue("U_Check", i - 1, "Y")
                        oDBDSDetail.SetValue("U_DelrCode", i - 1, dataset.Tables(0).Rows(i)("F3").ToString)
                        oDBDSDetail.SetValue("U_OrdrType", i - 1, dataset.Tables(0).Rows(i)("F4").ToString)
                        oDBDSDetail.SetValue("U_OrderNo", i - 1, dataset.Tables(0).Rows(i)("F6").ToString)
                        oMatrixTml.LoadFromDataSource()
                        progress.Value += 1
                    End If
                Next
               progress.Stop()   // stop the progress bar
                progress = Nothing
    Thanks,
    Silambu

  • Php redirect based on value not working?

    Hello, i have a signup page, a login page, failed.php and a landing page once they have signed up.
    the user signs up (application-formP1.php) then once they have done this they are redirected to the next page (application-formP2.php) they then have other information to add.
    on application-formP1.php there is a redirect that if the user has finished with the page (completed it) they are directed to application-formP2.php
    if($status == "P1complete")
              header("location: application-formP2.php");
    the trouble i am having is if i just try to access application-formP1.php ( which is the signup page) it is automatically sending the user to application-formP2.php even if they are not signed in then because they are not signed in it is sending the user to the failed page (obiously because the retstrict user is working)
    i have included the code below for application-formP1.php
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO LettingsTenApp (tenID, progress, tenTitle, tenUsername, tenPassword, tenSex, tenEmail, tenDobDD, tenDobMM, tenDobYY, tenDepend, tenMarital, tenPrevSurn, tenEmployTyp, tenNINumber) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['tenID'], "int"),
                                                         GetSQLValueString($_POST['progress'], "text"),
                           GetSQLValueString($_POST['tenTitle'], "text"),
                           GetSQLValueString($_POST['tenUsername'], "text"),
                           GetSQLValueString($_POST['tenPassword'], "text"),
                           GetSQLValueString($_POST['tenSex'], "text"),
                           GetSQLValueString($_POST['tenEmail'], "text"),
                           GetSQLValueString($_POST['tenDobDD'], "text"),
                           GetSQLValueString($_POST['tenDobMM'], "text"),
                           GetSQLValueString($_POST['tenDobYY'], "text"),
                           GetSQLValueString($_POST['tenDepend'], "text"),
                           GetSQLValueString($_POST['tenMarital'], "text"),
                           GetSQLValueString($_POST['tenPrevSurn'], "text"),
                           GetSQLValueString($_POST['tenEmployTyp'], "text"),
                           GetSQLValueString($_POST['tenNINumber'], "text"));
      mysql_select_db($database_Letting, $Letting);
      $Result1 = mysql_query($insertSQL, $Letting) or die(mysql_error());
      $insertGoTo = "application-formP2.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    mysql_select_db($database_Letting, $Letting);
    $query_rsTenant = "SELECT * FROM LettingsTenApp";
    $rsTenant = mysql_query($query_rsTenant, $Letting) or die(mysql_error());
    $row_rsTenant = mysql_fetch_assoc($rsTenant);
    $totalRows_rsTenant = mysql_num_rows($rsTenant);
    $status = $row_rsTenant['progress'];
    // Redirect user if thier application is completed
    if($status == "P1complete")
              header("location: application-formP2.php");
    and the form
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" >
            <input type="submit" value="Save &amp; continue" />
            <input type="hidden" name="progress" value="P1complete" />
            <input type="hidden" name="MM_insert" value="form1" />
    </form>
    thanks

    i noticed i dint have the session variable on the form i have now included this
    <?php
    if (!isset($_SESSION)) {
      session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
      // For security, start by assuming the visitor is NOT authorized.
      $isValid = False;
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
      // Therefore, we know that a user is NOT logged in if that Session variable is blank.
      if (!empty($UserName)) {
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
        // Parse the strings into arrays.
        $arrUsers = Explode(",", $strUsers);
        $arrGroups = Explode(",", $strGroups);
        if (in_array($UserName, $arrUsers)) {
          $isValid = true;
        // Or, you may restrict access to only certain users based on their username.
        if (in_array($UserGroup, $arrGroups)) {
          $isValid = true;
        if (($strUsers == "") && true) {
          $isValid = true;
      return $isValid;
    $MM_restrictGoTo = "failed.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
      $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO hostLettingsTenApp (tenID, progress, tenTitle, tenUsername, tenPassword, tenSex, tenEmail, tenDobDD, tenDobMM, tenDobYY, tenDepend, tenMarital, tenPrevSurn, tenEmployTyp, tenNINumber) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['tenID'], "int"),
                                                         GetSQLValueString($_POST['progress'], "text"),
                           GetSQLValueString($_POST['tenTitle'], "text"),
                           GetSQLValueString($_POST['tenUsername'], "text"),
                           GetSQLValueString($_POST['tenPassword'], "text"),
                           GetSQLValueString($_POST['tenSex'], "text"),
                           GetSQLValueString($_POST['tenEmail'], "text"),
                           GetSQLValueString($_POST['tenDobDD'], "text"),
                           GetSQLValueString($_POST['tenDobMM'], "text"),
                           GetSQLValueString($_POST['tenDobYY'], "text"),
                           GetSQLValueString($_POST['tenDepend'], "text"),
                           GetSQLValueString($_POST['tenMarital'], "text"),
                           GetSQLValueString($_POST['tenPrevSurn'], "text"),
                           GetSQLValueString($_POST['tenEmployTyp'], "text"),
                           GetSQLValueString($_POST['tenNINumber'], "text"));
      mysql_select_db($database_hostLetting, $hostLetting);
      $Result1 = mysql_query($insertSQL, $hostLetting) or die(mysql_error());
      $insertGoTo = "application-formP2.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    $colname_rsTenant = "-1";
    if (isset($_POST['P1complete'])) {
      $colname_rsTenant = $_POST['P1complete'];
    mysql_select_db($database_hostLetting, $hostLetting);
    $query_rsTenant = sprintf("SELECT progress FROM hostLettingsTenApp WHERE tenID = %s", GetSQLValueString($colname_rsTenant, "int"));
    $rsTenant = mysql_query($query_rsTenant, $hostLetting) or die(mysql_error());
    $row_rsTenant = mysql_fetch_assoc($rsTenant);
    $totalRows_rsTenant = mysql_num_rows($rsTenant);
    $status = $row_rsTenant['progress'];
    // Redirect user if thier application is completed
    if($status == "P1complete")
              header("location: application-formP2.php");
    ?>
    but it still is staying on this page if the column "progress" has "P1complete " in it

  • Progress dialogs for (eager and lazy) downloads

    <resources progress="all-downloads">
    </resources>
    Where 'progress' values are
    "standard" - default behaviour if omitted - progress
       dialog for eager downloads only
    "all-downloads" - progress dialog supplied for all
       downloads, eager or lazy.
    "none" - (suggest) no progress dialogsThe 'progress' attribute is not something in the
    web start API, but I would like to see it added.
    The intent is to allow the JNLP file to suggest a
    behaviour for progress dialogs during the download
    of both eager and lazy resources.
    Currently (web start in 1.5), there is no progress
    dialog, or message of any kind, during the download
    of 'lazy' resources.
    My questions.
    Is it technically feasible to provide this ability?
    Does it conform to the web start ..framework?
    Would an RFE to add support for this 'progress'
    attribute (call it what you like) be well received
    (or disappear into the abyss as some other
    requests assigned an ..'internal review ID'
    sometimes seem to)?
    More generally to other forum members, is
    this something that is important to you?
    Would you vote for an RFE to support the
    progress dialog attribute?

    ScheduleWorld used to use around 40 jars and I noticed a big speedup when I started using the version protocol. Now, my httpd logs only report a HTTP HEAD request on the jnlp file (sometimes icon image too?) and the app starts quite fast. I use less jars now but I am sure the main thing is the switch to the version protocol.
    With the version protocol, the client can determine if it has all of the right versions without making network connections. If you have a slow network connection (like a modem) and/or your server has keepalive disabled and is rate-limited to the number of new connections/second to the same IP you could see exactly what you are describing.

  • Default progress version in project objects

    hi all,
    is it possible to have a default progress version in projects.. note, i am referring to progress version, not measurement method...
    my main requirement is to have progress values but no need to maintain progress version in progress tab of WBS and activities...
    is this possible using substitution or user exit or is it possible no need to maintain prog version in wbs but still have poc values..
    thanks.

    no replies..

  • NPE on updating components

    Hello.
    I'm doing an applet using Swing. I've set Nimbus LAF first think in init() and called SwingUtilities.updateComponentTreeUI() just in case.
    I have a JProgressBar that I update during a long calculation. My long calculation is done on the doBackground() of the SwingWorker. I call a method to set the JProgressBar indeterminate, maximum, minimum and progress values. All those methods are called using SwingUtilities.invokeLater(). All of them work fine EXCEPT setIndeterminate(), that throws the following NPE.
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at javax.swing.plaf.synth.SynthLookAndFeel.getStyle(SynthLookAndFeel.java:210)
         at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:266)
         at javax.swing.plaf.synth.SynthProgressBarUI.updateStyle(SynthProgressBarUI.java:59)
         at javax.swing.plaf.synth.SynthProgressBarUI.propertyChange(SynthProgressBarUI.java:318)
         at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
         at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
         at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:318)
         at java.awt.Component.firePropertyChange(Component.java:8237)
         at javax.swing.JComponent.firePropertyChange(JComponent.java:4440)
         at javax.swing.JProgressBar.setIndeterminate(JProgressBar.java:918)
         at my.code.NotificationBar$3.run(NotificationBar.java:120)  // My own runnable that calls invokeLater() if we're not on EDT and only has the line bar.setIndeterminate(true/false)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)Change really occurs, and I can see the bar turning indeterminate, but I don't like having unknowns exceptions being thrown in my code.
    Anyone have any idea?
    Thanks a lot in advance!

    Of course, I set the LAF in the EDT. I've modified it and added the code to run on the EDT to my constructor just in case something is calling first a Swing component and the LAF is being set before I set the LAF (but that's what SwingUtilities.updateComponentTreeUI() is for, isn't it?) but it made no differences.
    Thanks a lot for your response, I'll be testing a little bit more and I'll try to make a standalone app that reproduces the problem.

  • Error in reading the XML file

    Hi,
    I am trying to read the values of the node of XML file. The structure of the XML file is:
    <?xml version = "1.0"?>
    <DOCUMENT>
    <LANGUAGE_TRANS>
    <TRANSLATION>
    <CODE>3</CODE>
    <VALUE>Please select a number</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>5</CODE>
    <VALUE>Patni</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>6</CODE>
    <VALUE>Status Messages</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>7</CODE>
    <VALUE>Progress</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>8</CODE>
    <VALUE>Create Data Files...</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>9</CODE>
    <VALUE>OK</VALUE>
    </TRANSLATION>
    </LANGUAGE_TRANS>
    </DOCUMENT>
    I have written the code to read the value of the code from the XML file. When I run the code as written below. It doesnot give any error or exception. The node name returned is CODE as desired but the Node value returned is null which is not the desired result. Can anyone please help me to find where I am going wrong. Thanks a lot.
    Regards,
    Shweta
    import java.net.*;
    import java.util.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    public class MergeXMLTest
    private static XMLDocument mDoc;
    public MergeXMLTest () {
    try {
    // Get an instance of the parser
    DOMParser lParser = new DOMParser();
    // Generate a URL from the filename for UPDATE.XML file.
    URL lUrl = createURL("mot.xml");
    System.out.println("after creating the URL object ");
    lParser.setErrorStream(System.out);
    lParser.showWarnings(true);
    lParser.parse(lUrl);
    mDoc = lParser.getDocument();
    System.out.println("after creating the URL object "+mDoc);
    lParser.reset();
    } catch (Exception e) {
    e.printStackTrace();
    } // end catch block
    } // End of constructor
    public void merge() throws DOMException {
    try {
         NodeList lTrans1 = this.mDoc.getElementsByTagName("CODE");
         if(lTrans1.getLength()>0) {
              Node lTransTag1 = lTrans1.item(0);
              System.out.println("lTrans1.item(0).getNodeName : " + lTrans1.item(0).getNodeName());
              System.out.println("lTrans1.item(0).getNodeValue : " + lTrans1.item(0).getNodeValue());
         } catch (Exception e) {
         System.out.println("Exception "+e);
         e.printStackTrace();
         } catch (Throwable t) {
              System.out.println("Exception "+t);
    public static URL createURL(String pFileName) throws MalformedURLException {
    URL url = null;
    Block of code to create a URL object from the file name
    that is passed as parameter.
    try {
    url = new URL(pFileName);
    } catch (MalformedURLException ex) {
    File f = new File(pFileName);
    String path = f.getAbsolutePath();
    String fs = System.getProperty("file.separator");
    System.out.println(" path of file : "+path +"separator " +fs);
    if (fs.length() == 1) {
    char sep = fs.charAt(0);
    if (sep != '/')
    path = path.replace(sep, '/');
    if (path.charAt(0) != '/')
    path = '/' + path;
    path = "file://" + path;
    System.out.println("path is : "+path);
    // Try again, if this throws an exception we just raise it up
    url = new URL(path);
    } // End catch block
    return url;
    } // end method create URL
    public static void main (String args[]) {
         MergeXMLTest mXML = new MergeXMLTest();
         mXML.merge();
    }

    see my answer here: http://forum.java.sun.com/thread.jsp?forum=34&thread=304647
    ps. if you know a little of XPath, this is why text() is a special kind of node()...

  • Reading from XML file using DOM parser.

    Hi,
    I have written the following java code to read the XML file and print the values. It reads the XML file. It gets the node NAME and prints it. But it returns null when trying to get the node VALUE. I am unable to figure out why.
    Can anyone please help me with this.
    Thanks and Regards,
    Shweta
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    public class ReadNodes
    private static XMLDocument mDoc;
    public ReadNodes () {
         try {
    DOMParser lParser = new DOMParser();
    URL lUrl = createURL("mot.xml");
    System.out.println("after creating the URL object ");
    lParser.setErrorStream(System.out);
    lParser.showWarnings(true);
    lParser.parse(lUrl);
    mDoc = lParser.getDocument();
         System.out.println("after creating the URL object "+mDoc);
    lParser.reset();
    } catch (Exception e) {
    e.printStackTrace();
    } // end catch block
    } // End of constructor
    public void read() throws DOMException {
    try {
         NodeList lTrans = this.mDoc.getElementsByTagName("TRANSLATION");
         for(int i=0;i<lTrans.getLength();i++) {
              NodeList lTrans1 = lTrans.item(i).getChildNodes();
              System.out.println("lTrans1.item(0).getNodeName : " + lTrans1.item(0).getNodeName());
              System.out.println("lTrans1.item(0).getNodeValue : " + lTrans1.item(0).getNodeValue());
              System.out.println("lTrans1.item(1).getNodeName : " + lTrans1.item(1).getNodeName());
              System.out.println("lTrans1.item(1).getNodeValue : " + lTrans1.item(1).getNodeValue());
         } catch (Exception e) {
         System.out.println("Exception "+e);
         e.printStackTrace();
         } catch (Throwable t) {
              System.out.println("Exception "+t);
    public static URL createURL(String pFileName) throws MalformedURLException {
    URL url = null;
    try {
    url = new URL(pFileName);
    } catch (MalformedURLException ex) {
    File f = new File(pFileName);
    String path = f.getAbsolutePath();
    String fs = System.getProperty("file.separator");
    System.out.println(" path of file : "+path +"separator " +fs);
    if (fs.length() == 1) {
    char sep = fs.charAt(0);
    if (sep != '/')
    path = path.replace(sep, '/');
    if (path.charAt(0) != '/')
    path = '/' + path;
    path = "file://" + path;
    System.out.println("path is : "+path);
    // Try again, if this throws an exception we just raise it up
    url = new URL(path);
    } // End catch block
    return url;
    } // end method create URL
    public static void main (String args[]) {
         ReadNodes mXML = new ReadNodes();
         mXML.read();
    The XML file that I am using is
    <?xml version = "1.0"?>
    <DOCUMENT>
    <LANGUAGE_TRANS>
    <TRANSLATION>
    <CODE>3</CODE>
    <VALUE>Please select a number</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>5</CODE>
    <VALUE>Patni</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>6</CODE>
    <VALUE>Status Messages</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>7</CODE>
    <VALUE>Progress</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>8</CODE>
    <VALUE>Create Data Files...</VALUE>
    </TRANSLATION>
    <TRANSLATION>
    <CODE>9</CODE>
    <VALUE>OK</VALUE>
    </TRANSLATION>
    </LANGUAGE_TRANS>
    </DOCUMENT>

    because what you want is not the node value of CODE but the node value of the text nodes into it!
    assuming only one text node into it, try this:
    System.out.println("lTrans1.item(0).getNodeName : " + lTrans1.item(0).getFirstChild().getNodeValue());

  • How to 'import xml' in my script

    Hi All,
    Below "Script 1" is working fine, now I want to call the '.xml' file which was placed in Template folder(see script code).
    How to import xml in 'New.indd' file("Line 27:-->var source = File(path + '/New.indd')".
    Please add import xml code in 'Script 1"
    Script 1:
    var path = Folder.selectDialog ("Select folder");
    if(path==null)
    exit();
    var files = path.getFiles(/\.(indd?|indt?)$/i);
    if(files==0)  
      alert("There is no 'indd'/'indt' file in your folder");
      exit();
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
    try
    myDocument = app.open(new File(files));
    MasterpageScriptLabel();
    TableCellStyleCreation();
    myDocument.save(new File(path + "/New.indd"));
    var folder = new Folder(path + '/Updated_Folder');
    folder.create();
    myDocument.close();
    var source = File(path + '/New.indd');
    var dest = new File(folder + '/New.indd');
    source.copy(dest);
    source.remove();
    catch(e)
    alert ("Your folder permissible only one file of 'INDD' or 'INDT' file");
    exit();
    function MasterpageScriptLabel()
    var myDoc=app.activeDocument;
    var myXMLElement=myDoc.xmlElements[0];
    if(myXMLElement.isValid)
        var myParentStory=myXMLElement.parentStory;
        var myTextContainers=myParentStory.textContainers;
        for(var i=0;i<myTextContainers.length;i++)
            myTextContainers[i].label="S_TF";
    var myDoc=app.activeDocument;
    var mspreads=myDoc.masterSpreads;
    for (i=0;i<mspreads.length;i++)
    if(mspreads[i].textFrames.length>1)
        var txfmlength=mspreads[i].textFrames;
        for (j=0;j<txfmlength.length;j++)
            if(txfmlength[j].nextTextFrame!=null)
            {txfmlength[j].label="S_TF";}
            if(txfmlength[j].previousTextFrame!=null)
            {txfmlength[j].label="S_TF";}
    function TableCellStyleCreation()
        var cestyle = myDocument.cellStyles;
        var array = ["TBL_COLH", "TBL_BODY"];
        var i = array.length;
        while(i--)
                try{
                    var style = myDocument.cellStyles.add();
                    style.name = array[i++];
                catch(e)
                    style.remove();
                    alert("'" + array[i-1] + "'"+ " Already exists in the document.")
                i--;
    main();
    function main(){
          var progress_win = new Window ("palette");
    var progress = progress_bar(progress_win, 2, 'Processing ... Completed');
        delay(1);
          progress.value = progress.value+1;
        delay(1);
        progress.parent.close();
    // delay function found here
    //found here http://www.wer-weiss-was.de/theme157/article1143593.html
      function delay(prmSec){
      prmSec *= 1000;
      var eDate = null;
      var eMsec = 0;
      var sDate = new Date();
      var sMsec = sDate.getTime();
      do {
      eDate = new Date();
      eMsec = eDate.getTime();
      } while ((eMsec-sMsec)<prmSec);
    * Taken from ScriptUI by Peter Kahrel
    * @param  {Palette} w    the palette the progress is shown on
    * @param  {[type]} stop [description]
    * @return {[type]}      [description]
    function progress_bar (w, stop, labeltext) {
    var txt = w.add('statictext',undefined,labeltext);
    var pbar = w.add ("progressbar", undefined, 1, stop);
    pbar.preferredSize = [300,20];
    w.show ();
    return pbar;
    by
    hasvi

    DECLARE @x xml=N'
    <Jobs>
    <Job>
    <JobCode>123</JobCode>
    <JobTitle>Years</JobTitle>
    <JobSubCode>
    <div>
    <Ol>
    <li>2001</li>
    <li>2002e</li>
    <li>2003</li>
    <li>2004</li>
    </Ol>
    </div>
    </JobSubCode>
    </Job>
    </Jobs>'
    SELECT J.c.value('(JobCode/text())[1]', 'varchar(10)') AS JobCode,
           J.c.value('(JobTitle/text())[1]', 'nvarchar(40)') AS JobTitle,
           L.c.value('.', 'varchar(10)') AS Years
    FROM   @x.nodes('/Jobs/Job') AS J(c)
    CROSS  APPLY J.c.nodes('JobSubCode/div/Ol/li') AS L(c)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Batch HDR Merging/Toning Script

    I've seen a number of different posts on these forums about trying to do this and I never really found a complete and suitable solution. It also has really annoyed me that adobe never implemented this (and it's not possible to do with actions because the action just runs a script and you can't record the HDR toning settings, the dialog always pops up, its in the script). So I finally had some time to get my hands dirty with ExtendScript and I have created a fully featured script complete with UI that allows batch creation of HDR tonned images in photoshop.
    The code I got working from various snipets of code I found around the 'net and single stepping through the MergeToHDR.jsx script that is built into photoshop.
    This has only been partially tested on photoshop CC on a mac. Hopefully I made it portable enough and it will work on windows and older versions. I don't think the MergeToHDR script has changed much in the last several versions (and that is mainly what I call to do the work) so I think it should work. If you have issues please let me know.
    My motivation for this script was coming up with a way to do batch HDR toning for timelapse and so this script's features lean toward using it for that end. I really didn't want to buy another separate program for doing this like photomatix, when I knew it should at least be possible to do in photoshop.
    I uploaded the script to github:
    https://github.com/davidmilligan/PhotoshopBatchHDR/blob/master/Batch%20HDR.jsx
    How to use:
    Drop the script in the '[photoshop folder]/presets/scripts' folder and restart photoshop if it is already running.
    The script should appear as a menu item under File>Automate>Batch HDR...
    A dialog will appear where you specify all the settings for the batch
    Input Section:
    Click browse and select the source folder that contains the images to be merged/toned
    Specify "Number of Brackets" this is how many separate images to group into a single HDR output image (the script will group the images in the source folder in order based on this parameter). You can use a value of 1, which means each image in the source folder is separate and will be toned and output. (I find that many times when shooting RAW, 14 bits is ample to capture the full dynamic of the scene, so I do not waste storage space and shutter acutations using more than one exposure, just make sure to ETTR, also post-processing with this script will be faster)
    If there are other files in your source folder (for example .xmp files) that you need to exclude you can specify a filte. For example: *.cr2
    Typically for timelapse you are using a tripod and do not need to have photoshop align the images, but I provided that capability for anyone who might need it b/c it was easy to enable. Note that enabling this will make the process MUCH slower.
    Toning Section:
    These settings are all the same as the photoshop HDR toning dialog for "Local Adaptation"
    To preview what your toning settings will look like you can select any file(s) in your sequence by clicking "Select File(s)..." under "Preview". The file(s) you select will open and merge (if more than one file). When that's finished you can click the "Update Preview" button to apply the current toning settings and see what they will look like (I can't do the fast, automatic previews like the builtin dialog, sorry - somebody from adobe want to show me how to do this?)
    You can see what the settings will look like at another point in your sequence by clicking the "Select File(s).." button again. (I recommend previewing a shot near the beginning, middle, and end of your sequence)
    The dialog prevents you from using anything in photoshop while its open so I provided a zoom to allow you to zoom in on the preview
    The tone curve you must enter as a comma separated list of points (sorry, ScriptUI is not really adequate to create the graphical histogram overlay for the curves like in the builtin dialog). The points are grouped into x,y pairs so for example: x1,y1,x2,y2,etc. Typically you will start with 0,0 and end with 255,255 (note that 255 is the max, full white). Like the curves tool, x represents the input and y represents the output
    Output Section:
    Click browse and select a folder for the script to save the output files to
    The rest of this section should be self explanitory. NOTE: If you select to output 32bit files, the toning will not be applied, the files will simply be merged into a 32bit HDR image and saved.
    Once you have specified the input and output folders the OK button should be enabled, when you are ready, click OK to start the process
    Go watch a movie or take a nap, this is going to take a while. The script will display a progress window showing you how far along the proces is (the photoshop progress windows may occasionally appear on top of it, I usually just move them up a little so I can see both)
    Limitations:
    Only the local adaptation method is supported. It's really the only one I ever use, and I didn't really feel like implementing the other ones, but feel free to modify the script yourself to add this support
    You canot load or save presets from the builtin toning dialog. The format of the preset files is binary and would require reverse engineering of the format and it would be very difficult to read to the files in javascript anyway. If it were xml, it would be much easier, alas it is not. Feel free to grab a hex editor and do this yourself. For now you'll just have to copy all of the values of a preset by hand into the dialog if you want to use a preset. If I have more time this is something I might work on.
    Preview is slow because it has to do the actual full toning, I don't know a way to do the fast real time previews like the builtin dialog.
    I don't think the "Cancel" button on the progress window really works, once running, the script is too busy to register a click, anybody know how I might fix this?
    There may potentially be some ways to improve performance of this script in certain scenarios, IDK, but I'm just glad it works
    You're welcome Adobe, you can send me a check at:
    [REDACTED]
    [REDACTED]
    [REDACTED]
    Please hit me up with comments/suggestions,
    David

    Thank you for your script, it's very useful.
    I just changed a few things :
    The Checkboxes didn't work so I changed them :
    alignCheckBox.onChanged by alignCheckBox.onClick
    deghostCheckBox.onChanged by deghostCheckBox.onClick
    smoothEdgesBox.onChange by smoothEdgesBox.onClick
    And for best alignment, I changed :
    mergeToHDR.mergeFilesToHDR( currentFileList, false, hdrDeghosting ? kMergeToHDRDeghostBest : kMergeToHDRDeghostOff );
    by :
    mergeToHDR.mergeFilesToHDR( currentFileList, mergeToHDR.useAlignment, hdrDeghosting ? kMergeToHDRDeghostBest : kMergeToHDRDeghostOff );
    And lastly :
    My language is french so I had to modify loadPreset function because my own preset file contains the string "P a r   d é f a u t" in place of "D e f a u l t" so that the data is shifted.
    Here is the code :
    #target photoshop
    Batch HDR Script by David Milligan
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    // BEGIN__HARVEST_EXCEPTION_ZSTRING
    <javascriptresource>
    <name>Batch HDR...</name>
    <menu>automate</menu>
    </javascriptresource>
    // END__HARVEST_EXCEPTION_ZSTRING
    //these lines import the 'Merge To HDR.jsx' script that is built in to photoshop, we will make calls to that script and some of the scripts that it includes
    var runMergeToHDRFromScript = true;
    var g_ScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
    var g_ScriptPath = File( g_ScriptFolderPath+'/Merge To HDR.jsx' );
    $.evalFile( g_ScriptPath );
    //$.level = 2;
    //default settings:
    mergeToHDR.useAlignment = false;
    mergeToHDR.useACRToning = false;
    var numberOfBrackets = 3;
    var userCanceled = false;
    var sourceFolder;
    var outputFolder;
    var saveType = "JPEG";
    var jpegQuality = 10;
    var progress;
    var statusText;
    var progressWindow;
    var fileMask = "*";
    var outputFilename = "hdr_output_";
    var hdrRadius = 100;
    var hdrStrength = 0.5;
    var hdrGamma = 1.0;
    var hdrExposure = 0.0;
    var hdrDetail = 100;
    var hdrShadow = 0;
    var hdrHighlights = 0;
    var hdrVibrance = 20;
    var hdrSaturation = 30;
    var hdrSmooth = false;
    var hdrDeghosting = true;
    var hdrCurve = "0,0,255,255";
    var estTimeRemaining = "";
    var previewDoc;
    var originalDoc;
    function main()
        promptUser();
        //make sure user didn't cancel
        if(sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists && numberOfBrackets > 0)
            initializeProgress();
            var files =  sourceFolder.getFiles(fileMask);
            var currentFileList = new Array();
            for(var index = 0;  index < files.length; index++)
                if((index % numberOfBrackets) == numberOfBrackets - 1)
                    var start = new Date();
                    progress.value = 100 * index / files.length;
                    currentFileList.push(files[index]);
                    if(userCanceled) break;
                    if(numberOfBrackets > 1)
                        statusText.text = "Merging files "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+files.length + estTimeRemaining;
                        //for braketed exposures use the mergeToHDR script to merge the files into a single 32 bit image
                        mergeToHDR.outputBitDepth= 32;
                        mergeToHDR.mergeFilesToHDR( currentFileList, mergeToHDR.useAlignment, hdrDeghosting ? kMergeToHDRDeghostBest : kMergeToHDRDeghostOff );
                        statusText.text = "Toning files "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+files.length+ estTimeRemaining;
                    else
                        statusText.text = "Loading file "+(index+1)+" of "+files.length+ estTimeRemaining;
                        //otherwise just open the file
                        doOpenFile(files[index]);
                        statusText.text = "Toning file "+(index+1)+" of "+files.length+ estTimeRemaining;
                    progress.value = 100 * (index + numberOfBrackets / 2 ) / files.length;
                    if(userCanceled) break;
                    if(app.activeDocument != null)
                        //apply the actual tone mapping to the HDR image to get it back down to 8 bits
                        doHDRToning();
                    //save the result and close
                    //TODO: add leading zeros to index in filename
                    if(numberOfBrackets > 1)
                        statusText.text = "Saving result "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+files.length+ estTimeRemaining;
                    else
                        statusText.text = "Saving result "+(index+1)+" of "+files.length+ estTimeRemaining;
                    if(userCanceled) break;
                    doSaveFile(outputFolder.absoluteURI + "/" + outputFilename + ZeroPad(Math.round((index + 1)/numberOfBrackets), 5) );
                    activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                    //reset our file list
                    currentFileList = new Array();
                    //calculate time remaining
                    var end = new Date();
                    var timeElapsed = end.getTime() - start.getTime();
                    var mins = timeElapsed / 60000 * ((files.length - index - 1) / numberOfBrackets);
                    estTimeRemaining = " | Remaining: " + ZeroPad((mins / 60).toFixed(0),2) + ":" + ZeroPad((mins % 60).toFixed(0),2);
                else
                    currentFileList.push(files[index]);
            progressWindow.hide();
    function doOpenFile(filename)
        const eventOpen = app.charIDToTypeID('Opn ');
        var desc = new ActionDescriptor();
        desc.putPath( typeNULL, new File( filename ) );
        desc.putBoolean( kpreferXMPFromACRStr, true ); //not sure what this does or if it is needed
        executeAction( eventOpen, desc, DialogModes.NO );
        //if we don't convert the image to 32bit the mergeToHDR script will not tone our image when we call it, it will simply downconvert it to 8 bit
        convertTo32Bit ();
    function convertTo32Bit()
        var idCnvM = charIDToTypeID( "CnvM" );
        var desc6 = new ActionDescriptor();
        var idDpth = charIDToTypeID( "Dpth" );
        desc6.putInteger( idDpth, 32 );
        var idMrge = charIDToTypeID( "Mrge" );
        desc6.putBoolean( idMrge, false );
        var idRstr = charIDToTypeID( "Rstr" );
        desc6.putBoolean( idRstr, false );
        executeAction( idCnvM, desc6, DialogModes.NO );
    function doSaveFile(filename)
        if(saveType == "JPEG")
            var jpgSaveOptions = new JPEGSaveOptions();
            jpgSaveOptions.embedColorProfile = true;
            jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            jpgSaveOptions.matte = MatteType.NONE;
            jpgSaveOptions.quality = jpegQuality;
            activeDocument.saveAs(new File(filename), jpgSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else if(saveType == "TIFF")
            var tifSaveOptions = new TiffSaveOptions();
            tifSaveOptions.embedColorProfile = true;
            activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else if(saveType == "TIFF LZW")
            var tifSaveOptions = new TiffSaveOptions();
            tifSaveOptions.embedColorProfile = true;
            tifSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
            activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else if(saveType == "TIFF ZIP")
            var tifSaveOptions = new TiffSaveOptions();
            tifSaveOptions.embedColorProfile = true;
            tifSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
            activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else
            activeDocument.saveAs(new File(filename), undefined, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
    function doHDRToning()
        //TODO: Reverse engineer the HDR Preset file format and allow user to select a preset file and create the ActionDescriptor from the file
        //create the ActionDescriptor that describes the HDR toning settings to use
        var hdDesc = new ActionDescriptor;
        hdDesc.putInteger( stringIDToTypeID( 'version' ), 6 );//I'm not sure what this does
        hdDesc.putInteger(  kmethodStr, 3 );// the toning method to use, 3 = local adaptation
        hdDesc.putDouble( stringIDToTypeID( 'radius' ), hdrRadius );
        hdDesc.putDouble( stringIDToTypeID( 'threshold' ), hdrStrength );// strength
        hdDesc.putDouble( stringIDToTypeID( 'center' ), hdrGamma );// gamma
        hdDesc.putDouble( stringIDToTypeID( 'brightness' ), hdrExposure );// exposure
        hdDesc.putDouble( stringIDToTypeID( 'detail' ), hdrDetail );
        hdDesc.putDouble( stringIDToTypeID( 'shallow' ), hdrShadow );
        hdDesc.putDouble( stringIDToTypeID( 'highlights' ), hdrHighlights );
        hdDesc.putDouble( stringIDToTypeID( 'vibrance' ), hdrVibrance );
        hdDesc.putDouble( stringIDToTypeID( 'saturation' ), hdrSaturation);
        hdDesc.putBoolean( stringIDToTypeID( 'smooth' ), hdrSmooth );
        hdDesc.putBoolean( stringIDToTypeID( 'deghosting' ), hdrDeghosting );
        //create the tone curve
        var cDesc = new ActionDescriptor;
        cDesc.putString( stringIDToTypeID( 'name' ), 'Default');
        var cList = new ActionList;
        var points = hdrCurve.split(',');
        for(var i = 0; i < points.length; i++)
            if(i % 2 == 1)
                var pDesc = new ActionDescriptor;
                pDesc.putDouble( stringIDToTypeID( 'horizontal' ), points[i-1] );
                pDesc.putDouble( stringIDToTypeID( 'vertical' ), points[i] );
                pDesc.putBoolean( keyContinuity , false );// ?????
                cList.putObject( charIDToTypeID( 'Pnt ' ), pDesc );
        cDesc.putList( stringIDToTypeID( 'curve' ), cList );
        hdDesc.putObject( kclassContour, classShapingCurve, cDesc );
        //call the script that actually invokes the toning plugin
        convertFromHDRNoDialog( outputBitDepth, hdDesc );
    function initializeProgress()
        progressWindow = new Window("palette { text:'Batch HDR Progress', \
            statusText: StaticText { text: 'Processing Images...', preferredSize: [350,20] }, \
            progressGroup: Group { \
                progress: Progressbar { minvalue: 0, maxvalue: 100, value: 0, preferredSize: [300,20] }, \
                cancelButton: Button { text: 'Cancel' } \
        statusText = progressWindow.statusText;
        progress = progressWindow.progressGroup.progress;
        progressWindow.progressGroup.cancelButton.onClick = function() { userCanceled = true; }
        progressWindow.show();
    function promptUser()
        var setupWindow = new Window("dialog { orientation: 'row', text: 'Batch HDR', alignChildren:'top', \
            leftGroup: Group { orientation: 'column', alignChildren:'fill', \
                inputPanel: Panel { text: 'Input', \
                    sourceGroup: Group { \
                        sourceBox: EditText { characters: 40, text: '' }, \
                        sourceBrowse: Button { text: 'Browse' } \
                    bracketGroup: Group{ \
                        bracketLabel: StaticText { text: 'Number of Brackets: ' }, \
                        bracketBox: EditText { characters: 2 }, \
                        filterLabel: StaticText { text: 'File Filter: ' }, \
                        filterText: EditText { characters: 5 }, \
                        alignCheckBox: Checkbox { text: 'Align' }\
                        deghostCheckBox: Checkbox { text: 'Deghost' }\
                toningPanel: Panel { text: 'Toning', orientation:'row', alignChildren:'top' } ,\
                outputPanel: Panel { text: 'Output', \
                    outputGroup: Group { \
                        outputBox: EditText { characters: 40, text: '' }, \
                        outputBrowse: Button { text: 'Browse' } \
                    outputOptionsGroup: Group { \
                        outputFilenameLabel: StaticText { text: 'Filename Format: ' }, \
                        outputFilenameText: EditText { characters: 10 }, \
                        outputFilenamePost: StaticText { text: '00001.jpg' }, \
                    saveSettingsGroup: Group { \
                        saveTypeLabel: StaticText { text: 'Save As: ' }, \
                        saveDropDown: DropDownList { }, \
                        jpegQualityLabel: StaticText { text: 'JPEG Quality (1-10): ' }, \
                        jpegQualityText: EditText { characters: 2}, \
                        outputBitDepthLabel: StaticText { text: 'Bit Depth', enabled:false }, \
                        outputBitDepthDropDown: DropDownList { enabled:false }, \
            rightGroup: Group { orientation: 'column', alignChildren:'fill', \
                okButton: Button { text: 'OK', enabled: false } \
                cancelButton: Button { text: 'Cancel' } \
        generateToningPanel(setupWindow.leftGroup.toningPanel);
        //shortcut variables
        var sourceBox = setupWindow.leftGroup.inputPanel.sourceGroup.sourceBox;
        var sourceBrowse = setupWindow.leftGroup.inputPanel.sourceGroup.sourceBrowse;
        var bracketBox = setupWindow.leftGroup.inputPanel.bracketGroup.bracketBox;
        var filterText = setupWindow.leftGroup.inputPanel.bracketGroup.filterText;
        var alignCheckBox = setupWindow.leftGroup.inputPanel.bracketGroup.alignCheckBox;
        var outputBox = setupWindow.leftGroup.outputPanel.outputGroup.outputBox;
        var outputBrowse = setupWindow.leftGroup.outputPanel.outputGroup.outputBrowse;
        var outputFilenameText = setupWindow.leftGroup.outputPanel.outputOptionsGroup.outputFilenameText;
        var saveDropDown = setupWindow.leftGroup.outputPanel.saveSettingsGroup.saveDropDown;
        var jpegQualityText = setupWindow.leftGroup.outputPanel.saveSettingsGroup.jpegQualityText;
        var jpegQualityLabel = setupWindow.leftGroup.outputPanel.saveSettingsGroup.jpegQualityLabel;
        var outputBitDepthDropDown = setupWindow.leftGroup.outputPanel.saveSettingsGroup.outputBitDepthDropDown;
        var outputBitDepthLabel = setupWindow.leftGroup.outputPanel.saveSettingsGroup.outputBitDepthLabel;
        var okButton = setupWindow.rightGroup.okButton;
        var cancelButton = setupWindow.rightGroup.cancelButton;
        var toningPanel = setupWindow.leftGroup.toningPanel;
        var deghostCheckBox = setupWindow.leftGroup.inputPanel.bracketGroup.deghostCheckBox;
        //set default values
        bracketBox.text = numberOfBrackets;
        filterText.text = fileMask;
        //mergeToHDR.useAlignment = true;
        alignCheckBox.value = mergeToHDR.useAlignment;
        deghostCheckBox.value = hdrDeghosting;
        outputFilenameText.text = outputFilename;
        jpegQualityText.text = jpegQuality;
        saveDropDown.add("item", "JPEG");
        saveDropDown.add("item", "TIFF");
        saveDropDown.add("item", "TIFF LZW");
        saveDropDown.add("item", "TIFF ZIP");
        saveDropDown.add("item", "PSD");
        saveDropDown.selection = 0;
        outputBitDepthDropDown.add("item", "8");
        outputBitDepthDropDown.add("item", "16");
        outputBitDepthDropDown.add("item", "32");
        outputBitDepthDropDown.selection = 0;
        //event handlers
        sourceBox.onChange = function()
            sourceFolder = new Folder(sourceBox.text);
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        sourceBrowse.onClick = function()
            sourceFolder = Folder.selectDialog ("Select the source folder");
            if(sourceFolder != null)
                sourceBox.text = sourceFolder.fullName;
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        bracketBox.onChange = function() { numberOfBrackets = bracketBox.text; };
        filterText.onChange = function() { fileMask = filterText.text; };
        alignCheckBox.onClick = function() { mergeToHDR.useAlignment = alignCheckBox.value; };
        deghostCheckBox.onClick = function() { hdrDeghosting = deghostCheckBox.value; };
        outputBox.onChange = function()
            outputFolder = new Folder(outputBox.text);
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        outputBrowse.onClick = function()
            outputFolder = Folder.selectDialog ("Select the output folder");
            if(outputFolder != null)
                outputBox.text = outputFolder.fullName;
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        outputFilenameText.onChange = function() { outputFilename = outputFilenameText.text; };
        saveDropDown.onChange = function()
            saveType = saveDropDown.selection.text;
            jpegQualityText.enabled = saveDropDown.selection.text == "JPEG";
            jpegQualityLabel.enabled = saveDropDown.selection.text == "JPEG";
            if(saveDropDown.selection.text == "JPEG")
                outputBitDepthDropDown.selection = 0;
            outputBitDepthDropDown.enabled = saveDropDown.selection.text != "JPEG";
            outputBitDepthLabel.enabled = saveDropDown.selection.text != "JPEG";
        jpegQualityText.onChange = function() { jpegQuality = jpegQualityText.text; };
        outputBitDepthDropDown.onChange = function()
            outputBitDepth = outputBitDepthDropDown.selection.text;
            toningPanel.enabled = outputBitDepth != 32;
        okButton.onClick = function() { setupWindow.hide(); cleanUpPreviews(); };
        cancelButton.onClick = function() { sourceFolder = null, setupWindow.hide(); cleanUpPreviews(); };
        saveDropDown.onChange();
        outputBitDepthDropDown.onChange();
        setupWindow.show();
    function cleanUpPreviews()
        if(originalDoc != null)
            originalDoc.close(SaveOptions.DONOTSAVECHANGES);
            originalDoc = null;
        if(previewDoc != null)
            previewDoc.close(SaveOptions.DONOTSAVECHANGES);
            previewDoc = null;
    function generateToningPanel(toningPanel)
        var leftToningGroup = toningPanel.add("group{orientation:'column',alignChildren:'fill'}");
        var rightToningGroup = toningPanel.add("group{orientation:'column',alignChildren:'fill'}");
        var presetGroup = leftToningGroup.add("group{orientation:'row'}");
        var presetDropDown = presetGroup.add("dropdownlist");
        var loadPresetButton = presetGroup.add("button", undefined, "Load Preset");
        var edgePanel = leftToningGroup.add("panel",undefined,"Edge Glow");
        var radiusSlider = createSliderControl(edgePanel.add("group"), "  Radius: ", "px", 0, 500, 0, hdrRadius, function(newValue){ hdrRadius = newValue; });
        var strengthSlider = createSliderControl(edgePanel.add("group"), "Strength: ", "", 0, 4.0, 2, hdrStrength, function(newValue){ hdrStrength = newValue; });
        var edgeGroup = edgePanel.add("group");
        var smoothEdgesBox = edgeGroup.add("checkbox",undefined, "Smooth Edges");
        var detailPanel = leftToningGroup.add("panel",undefined,"Tone and Detail");
        var gammaSlider = createSliderControl(detailPanel.add("group"), "  Gamma: ", "", 0.1, 2.0, 2, hdrGamma, function(newValue){ hdrGamma = newValue; });
        var exposureSlider = createSliderControl(detailPanel.add("group"), "Exposure: ", "", -5.0, 5.0, 2, hdrExposure, function(newValue){ hdrExposure = newValue; });
        var detailSlider = createSliderControl(detailPanel.add("group"), "     Detail: ", "%", -300, 300, 0, hdrDetail, function(newValue){ hdrDetail = newValue; });
        var advancedPanel = leftToningGroup.add("panel",undefined,"Advanced");
        var shadowSlider = createSliderControl(advancedPanel.add("group"), "  Shadow: ", "%", -100, 100, 0, hdrShadow, function(newValue){ hdrShadow = newValue; });
        var highlightSlider = createSliderControl(advancedPanel.add("group"), " Highlight: ", "%",  -100, 100, 0, hdrHighlights, function(newValue){ hdrHighlights = newValue; });
        var vibranceSlider = createSliderControl(advancedPanel.add("group"), "  Vibrance: ", "%",  -100, 100, 0, hdrVibrance, function(newValue){ hdrVibrance = newValue; });
        var saturationSlider = createSliderControl(advancedPanel.add("group"), "Saturation: ", "%",  -100, 100, 0, hdrSaturation, function(newValue){ hdrSaturation = newValue; });
        var toningCurvePanel = leftToningGroup.add("panel{text:'Toning Curve',alignChildren:'fill'}");
        var curveBox = toningCurvePanel.add("edittext", undefined, hdrCurve);
        //right side (preview panel)
        var previewGroup = rightToningGroup.add("panel", undefined, "Preview");
        var selectPreviewButton = previewGroup.add("button",undefined,"Select File(s)...");
        var previewButton = previewGroup.add("button",undefined,"Update Preview");
        var zoomGroup = previewGroup.add("group");
        zoomGroup.add("statictext",undefined, "zoom");
        var zoomBox = zoomGroup.add("edittext { text: '100', characters: 3, enabled: false } ");
        var previewZoomSlider = previewGroup.add("slider { minvalue: 10, maxvalue: 200, value: 100, enabled: false }");
        //default values
        smoothEdgesBox.value = hdrSmooth;
        previewButton.enabled = app.documents.length > 0;
        var presetFiles = getPresetFiles();
        var updateSliders = function()
            radiusSlider(hdrRadius);
            strengthSlider(hdrStrength);
            smoothEdgesBox.value = hdrSmooth;
            exposureSlider(hdrExposure);
            gammaSlider(hdrGamma);
            detailSlider(hdrDetail);
            shadowSlider(hdrShadow);
            highlightSlider(hdrHighlights);
            vibranceSlider(hdrVibrance);
            saturationSlider(hdrSaturation);
            curveBox.text = hdrCurve;
        if(presetFiles.length > 0)
            for(var f in presetFiles)
                presetDropDown.add("item", presetFiles[f].displayName.replace(".hdt",""));
            presetDropDown.selection = 0;
            loadPreset(presetFiles[0]);
            presetDropDown.onChange = function()
                loadPreset(presetFiles[presetDropDown.selection.index]);
                updateSliders();
        //event handlers
        loadPresetButton.onClick = function()
            loadPreset(null);
            updateSliders();
        smoothEdgesBox.onClick = function () { hdrSmooth = smoothEdgesBox.value; };
        curveBox.onChange = function () { hdrCurve = curveBox.text; };
        selectPreviewButton.onClick = function()
            var selectedFiles = File.openDialog("Select file(s) to load for preview", function(){return true;}, true);
            if(selectedFiles != null)
                cleanUpPreviews();
                if(selectedFiles instanceof Array)
                    if(selectedFiles.length > 1)
                        mergeToHDR.outputBitDepth= 32;
                        mergeToHDR.mergeFilesToHDR( selectedFiles, false, -2 );
                    else
                        doOpenFile(selectedFiles[0].fullName);
                else
                    doOpenFile(selectedFiles.fullName);
                originalDoc = app.activeDocument;
                previewButton.enabled = originalDoc != null;
                zoomBox.text = getZoomLevel();
                previewZoomSlider.value = getZoomLevel();
        previewButton.onClick = function()
            if(originalDoc != null)
                var tempOutputBitDepth = outputBitDepth;
                outputBitDepth = 16;
                if(previewDoc != null)
                    previewDoc.close(SaveOptions.DONOTSAVECHANGES);
                previewDoc = originalDoc.duplicate("HDR Preview");
                app.activeDocument = previewDoc;
                setZoomLevel(previewZoomSlider.value);
                convertTo32Bit();
                doHDRToning();
                outputBitDepth = tempOutputBitDepth;
                waitForRedraw();
                zoomBox.enabled = previewDoc != null;
                previewZoomSlider.enabled = previewDoc != null;
        zoomBox.onChange = function()
            if(previewDoc != null)
                previewZoomSlider.value = zoomBox.text;
                setZoomLevel(previewZoomSlider.value);
        previewZoomSlider.onChange = function()
            if(previewDoc != null)
                zoomBox.text = previewZoomSlider.value.toFixed(0);
                setZoomLevel(previewZoomSlider.value);
        updateSliders();
    function createSliderControl(group,label,postLabel,min,max,round,value,onValueChanged)
        var ignoreChange = false;
        group.add("statictext", undefined, label);
        var slider = group.add("slider",undefined,value,min,max);
        slider.alignment = "fill";
        var box = group.add("edittext",undefined,value);
        box.characters = 6;
        group.add("statictext", undefined, postLabel);
        slider.onChange = function()
            if(!ignoreChange)
                ignoreChange = true;
                box.text = slider.value.toFixed(round);
                onValueChanged(slider.value);
                ignoreChange = false;
        box.onChange = function()
            if(!ignoreChange)
                ignoreChange = true;
                slider.value = box.text;
                onValueChanged(box.text);
                ignoreChange = false;
        return function(newValue)
            slider.value = newValue;
            box.text = newValue.toFixed(round);
    //forces a redraw while a script dialog is active (for preview)
    var waitForRedraw = function()
        var desc = new ActionDescriptor();
        desc.putEnumerated(charIDToTypeID("Stte"), charIDToTypeID("Stte"), charIDToTypeID("RdCm"));
        executeAction(charIDToTypeID("Wait"), desc, DialogModes.NO);
    function getZoomLevel()
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        var desc = executeActionGet(ref);
        return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1);
    function setZoomLevel( zoom )
        if(zoom < 1 ) zoom =1;
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(s tringIDToTypeID('newDocPresetScreenResolution'))/72;
        var docRes = activeDocument.resolution;
        activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE );
        var desc = new ActionDescriptor();
        ref = null;
        ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) );
        desc.putReference( charIDToTypeID( "null" ), ref );
        executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
        activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );
    function ZeroPad(number,numZeros)
        var result = number.toString();
        while(result.length < numZeros)
            result = "0" + result;
        return result;
    var getPresetFiles = function()
        var presetFolder = new Folder(app.path + "/Presets/HDR Toning");
        return presetFolder.getFiles("*.hdt");
    var loadPreset = function(presetFile)
        if(presetFile == null)
            presetFile = File.openDialog("Select Preset","*.hdt");
        if(presetFile != null)
            var tmpStr = new String();
            var binaryData = new Array();
            presetFile.encoding = "BINARY";
            presetFile.open('r');
            while(!presetFile.eof)
                var ch = presetFile.readch();
                if ( ch.charCodeAt(0) == 0 ){
                    tmpStr += ' ';
                else {
                    tmpStr += ch;
                binaryData.push(ch.charCodeAt(0));
            presetFile.close();
            if(binaryData.length >= 40)
                // init start position for reading datas
                // start position for english version ( string "D e f a u l t" is in the preset file )
                var startPos = 38;
                if ( tmpStr.search ("P a r   d é f a u t") > -1 ){
                    // start position for french preset file version ( string "P a r   d é f a u t" is in the preset file ) (==> + 6 bytes)
                    startPos = 44;
                // if your preset file can't be read, try this : open it in notepad to see the string "D e f a u l t" in your language and add the code here to set startPos to 38 + diff between the length of ("D e f a u l t") and length of ("D e f a u l t" in your language)
                var curvePointCount = getUInt16(binaryData, startPos);
                if(binaryData.length >= 104 + curvePointCount * 4)
                    var curvePointStr = "";
                    for(var i = 0; i < curvePointCount; i++)
                        curvePointStr += getUInt16(binaryData, startPos + 4 + i * 4) + "," + getUInt16(binaryData, startPos + 2 + i * 4) + ((i < curvePointCount - 1) ? "," : "");
                    hdrCurve = curvePointStr;
                    hdrStrength =  getFloat32(binaryData,8);
                    hdrRadius = getFloat32(binaryData, startPos + 10 + 5 * curvePointCount);
                    hdrExposure = getFloat32(binaryData, startPos + 34 + 5 * curvePointCount);
                    hdrSaturation = getFloat32(binaryData, startPos + 38 + 5 * curvePointCount);
                    hdrDetail = getFloat32(binaryData, startPos + 42 + 5 * curvePointCount);
                    hdrShadow = getFloat32(binaryData, startPos + 46 + 5 * curvePointCount);
                    hdrHighlights = getFloat32(binaryData, startPos + 50 + 5 * curvePointCount);
                    hdrGamma = getFloat32(binaryData, startPos + 54 + 5 * curvePointCount);
                    hdrVibrance = getFloat32(binaryData, startPos + 58 + 5 * curvePointCount);
                    hdrSmooth = getUInt16(binaryData, startPos + 62 + 5 * curvePointCount) != 0;
                else
                    alert("Error Loading File", "Error", true);
            else
                alert("Error Loading File", "Error", true);
    function getUInt16(byteArray,offset)
        return byteArray[offset] * 0x100 + byteArray[offset + 1];
    function getUInt32(byteArray,offset)
        return byteArray[offset] * 0x1000000 + byteArray[offset + 1] * 0x10000 + byteArray[offset + 2] * 0x100 + byteArray[offset + 3];
    function getFloat32(byteArray,offset)
        var bytes = getUInt32(byteArray,offset);
        var sign = (bytes & 0x80000000) ? -1 : 1;
        var exponent = ((bytes >> 23) & 0xFF) - 127;
        var significand = (bytes & ~(-1 << 23));
        if (exponent == 128)
            return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);
        if (exponent == -127) {
            if (significand == 0) return sign * 0.0;
            exponent = -126;
            significand /= (1 << 22);
        } else significand = (significand | (1 << 23)) / (1 << 23);
        return sign * significand * Math.pow(2, exponent);
    main();

  • Combining CFChartSeries in one graph

    I have a chart that has four vertical bar graphs. The results
    show how much percentage of a goal has been reached. If/when any
    bar exceeds the 100% of goal mark, I bump the scaleTo up to 200 and
    show a horizontal line at the 100% mark. Everything works as
    expected, except when the horizontal line is displayed - the colors
    set for my bars are ignored and all are changed to a pea green (the
    horizontal line remains black as set). Any thoughts?
    <cfchart format="swf"
    chartWidth="650"
    scaleTo="#goal#"
    showXGridlines="no"
    showYGridlines="yes"
    gridlines="11"
    show3d="no"
    showmarkers="no"
    xAxisTitle="Category"
    yAxisTitle="Percent of Goal"
    fontsize="12">
    <cfif goal IS 200>
    <cfchartseries type="line" seriescolor="000000">
    <cfchartdata item="Monthly Progress" value="100">
    <cfchartdata item="Delivered to Shipping" value="100">
    <cfchartdata item="Invoiced" value="100">
    <cfchartdata item="Bookings" value="100">
    </cfchartseries>
    </cfif>
    <cfchartseries type="bar" colorlist="999999, cc0000,
    00cc00, 0000cc">
    <cfchartdata item="Monthly Progress" value="#gone#">
    <cfchartdata item="Delivered to Shipping"
    value='#del#'>
    <cfchartdata item="Invoiced" value='#inv#'>
    <cfchartdata item="Bookings" value='#book#'>
    </cfchartseries>
    </cfchart>

    This is a bug in cfcharts with more than one series.
    Either the entire column (for all series) has the same color
    or the entire series has the same color.
    Attached is a work-around that may work for your specific
    example.

Maybe you are looking for

  • Itunes for WIN7: attempting to copy to disk "..." failed.  The file name was invalid or too long

    itunes for WIN7: attempting to copy to disk "..." failed.  The file name was invalid or too long help!!

  • Use of contextmenu will crash in new flashplayer

    hi all, i am using flex 2.0 final addition to create context menu support in my application i am sucessfully able to create context menu but when i am trying to select any item from contextmenu in flash player 9.0 final release it will crash the apli

  • Urgent Hotspot question

    Hi, So, I have managed to figure out how to use Lightbox (I dont really know any coding so it was not incredibly easy razz ) So, there is this feature in dreamweaver thats called "Hotspot" which means you draw an area in an image and when someone cli

  • Linux on Sparc

    If I load Redhat 6.1 on a sparc machine, will the Linux version of the Oracle 8i server run on it, or will it only run on a Linux/intel machine. TIA

  • Facebook plugin publishing error

    Every time I try to upload a photo I get a error message "Can't upload to the Facebook album named "xxx". Please make sure the 'Adobe photoshop lightroom" app has permission to upload to albums with the privacy level of this album." I've already trie