Xml in JTree: how to not collpase JTree node, when renaming XML Node.

Hi.
I'm writing some kind of XML editor. I want to view my XML document in JTree and make user able to edit contents of XML. I made my own TreeModel for JTree, which straight accesses XML DOM, produced by Xerces. Using DOM Events, I made good-looking JTree updates without collapsing JTree on inserting or removing XML nodes.
But there is a problem. I need to produce to user some method of renaming nodes. As I know, there is no way to rename node in w3c DOM. So I create new one with new name and copy all children and attributes to it. But in this way I got a new object of XML Node instead of renamed one. And I need to initiate rebuilding (treeStructureChanged event) of JTree structure. Renamed node collapses. If I use treeNodesChanged event (no rebuilding, just changes string view of JTree node), then when I try to operate with renamed node again, exception will be throwed.
Is there some way to rename nodes in my program without collpasing JTree?
I'am new to Java. Maybe there is a method in Xerces DOM implementation to rename nodes without recreating?
Thanks in advance.

I assume that "rename" means to change the element name? Anyway your question seems to be "When I add a node to a JTree, how do I make sure it is expanded?" This is completely concerned with Swing, so it might have been better to post it in the Swing forum, but if it were me I would do this:
1. Copy the XML document into a JTree.
2. Allow the user to edit the document. Don't attempt to keep an XML document or DOM synchronized with the contents of the JTree.
3. On request of the user, copy the JTree back to a new XML document.
This way you can "rename" things to the user's heart's content without having the problem you described.

Similar Messages

  • How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?

    How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
    Hi,
    I do generate XML-Files by using DBMS_XMLGEN with output by UTL_FILE
    but it seems, the xml-Datafile I get on end is not really UTF-8 encoding
    ( f.ex. cannot verifying it correct in xmlspy )
    my dbms is
    NLS_CHARACTERSET          = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET     = AL16UTF16
    NLS_RDBMS_VERSION     = 10.2.0.1.0
    I do generate it in this matter :
    declare
    xmldoc CLOB;
    ctx number ;
    utl_file.file_type;
    begin
    -- generate fom xml-view :
    ctx := DBMS_XMLGEN.newContext('select xml from xml_View');
    DBMS_XMLGEN.setRowSetTag(ctx, null);
    DBMS_XMLGEN.setRowTag(ctx, null );
    DBMS_XMLGEN.SETCONVERTSPECIALCHARS(ctx,TRUE);
    -- create xml-file:
    xmldoc := DBMS_XMLGEN.getXML(ctx);
    -- put data to host-file:
    vblob_len := DBMS_LOB.getlength(xmldoc);
    DBMS_LOB.READ (xmldoc, vblob_len, 1, vBuffer);
    bHandle := utl_file.fopen(vPATH,vFileName,'W',32767);
    UTL_FILE.put_line(bHandle, vbuffer, FALSE);
    UTL_FILE.fclose(bHandle);
    end ;
    maybe while work UTL_FILE there is a change the encoding ?
    How can this solved ?
    Thank you
    Norbert
    Edited by: astramare on Feb 11, 2009 12:39 PM with database charsets

    Marco,
    I tryed to work with dbms_xslprocessor.clob2file,
    that works good,
    but what is in this matter with encoding UTF-8 ?
    in my understandig, the xmltyp created should be UTF8 (16),
    but when open the xml-file in xmlSpy as UTF-8,
    it is not well ( german caracter like Ä, Ö .. ):
    my dbms is
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    NLS_RDBMS_VERSION = 10.2.0.1.0
    -- test:
    create table nh_test ( s0 number, s1 varchar2(20) ) ;
    insert into nh_test (select 1,'hallo' from dual );
    insert into nh_test (select 2,'straße' from dual );
    insert into nh_test (select 3,'mäckie' from dual );
    insert into nh_test (select 4,'euro_€' from dual );
    commit;
    select * from nh_test ;
    S0     S1
    1     hallo
    1     hallo
    2     straße
    3     mäckie
    4     euro_€
    declare
    rc sys_refcursor;
    begin
    open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
    dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
    end;
    ( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
    open in xmlSpy is:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <S0>1</S0>
    <S1>hallo</S1>
    </ROW>
    <ROW>
    <S0>2</S0>
    <S1>straޥ</S1>
    </ROW>
    <ROW>
    <S0>3</S0>
    <S1>m㢫ie</S1>
    </ROW>
    <ROW>
    <S0>4</S0>
    <S1>euro_€</S1>
    </ROW>
    </ROWSET>
    regards
    Norbert

  • JTree: How to set different cell editor for different tree Nodes.

    I have a JTree and I want to set different cell editors for different node depending on some condition. E.g. I want to set ComboBox as editor for leaf node but each leaf node will have its own set of data.
    Any help or pointer?
    Thanks in advance
    Sachin

    take there:
    http://www.mutualinstrument.com/Easy/FAQ/Tree/tree.html

  • How to mention the "dtd" file when loading xml file

    i am using the JAXP parser for parsing and loading my xml file.In the file i have mentioned the dtd like
    <!DOCTYPE screensmanagement SYSTEM "scrReg.dtd">
    But after doing some manipulations, when i save the file through JAXP parser at the same location from where i loaded, then "dtd header" is not saved with my xml File and when i again parse the xml file then parser does not find the "dtd" file coz it is not been saved with xml source.
    How can i get aroud this problem.
    Merry Chrismis

    when serializing the DOM, use this: transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, scrReg.dtd");
    Merry Chrasmas too ;-)

  • Not well defined classpath when using XML-RPC

    Hello,
    im trying to setup a webservice using XML-RPC
    I get real time ClassNotDefined exceptions, and all i can suppose, i haven't set up the classpath correctly.
    I must inform you, that i've allready put the xerces.jar, xmlrpc-1.2-b1.jar (and so on...) at my (JAVA_HOME)\jre\lib and (JAVA_HOME)\jre\lib\ext folders. I use the following statements :
    import java.io.IOException;
    import org.apache.xmlrpc.*;
    import org.apache.xerces.parsers.*; //for the server-side
    import java.io.IOException;
    import java.util.Vector;
    import org.apache.xmlrpc.*;
    import org.apache.xerces.parsers.*; //for the client-side
    I've allready worked with SAXParsers and jdom, but i think that the classes i used there are distributed with the standard jdk-1.4 version i use.
    So, any suggestions? How can i setup my classpath for the XML-RPC programms, if that's the problem?
    Any help would be very very appreciate
    Thank you

    Thanks, I'll have the dev team take a look and put in a fix.

  • JTree how to use different font's color for different node

    Hi all
    This is the first time I am using JTree in my application and I have got some problems with it that I can't work out after reading the Java tutorial. Please help!
    1. For some nodes, the font color need to be different.
    2. One node need to use more than one font type for example "This is a sample " some words need to be bolded.
    Kind regards
    Edmond

    Did you read the section on [url http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display]Customizing a Tree's Display?
    And did you follow the link on renderers?

  • How to not create Lightroom duplicate when editing in Photoshop

    When I choose to Edit in Photoshop from within Lightroom 3, the edited copy is added to Lightroom. This might sometimes be useful, but I want to choose whether or not the edited copy is added to lightroom.
    How can I make this choice?
    David

    That's not my experience - maybe I've got some setting wrong somewhere.
    I have two categories of images in Lightroom: DNG files originating from digital camera Raw files, and files which are PSD that were scanned from old photos.
    Opening the DNG files in Photoshop then selecting "Save As" does not make the duplicate in Lightroom PROVIDED I have "As a copy" checked. But then the copy is not the file that's currently open so I have go find the copy and open it to do any work on it.
    Opening PSD files from Lightroom in Photoshop, the duplicate is created immediately the file opens in Photoshop unless I select the "Edit original" option. But even then, if I subsequently use Save As within Photoshop, the copy appears in Lightroom.
    My version of Lighrtoom is 3.4.1
    My version of Photoshop is CS5.1
    I'm on a Mac running Snow Leopard

  • How to not retriggered output type when changes are made in Purchase Order

    Hi All,
    Could you let me know how can I resolve this one?
    We have a custom output type. Now this output type should NOT be automatically retriggered if a change is made to the document/purchase order. Currently the system automatically repeating the output type for every change made to the document/purchase order. But there is still an option for the user to be able to manually repeat the output.
    TIA

    Hi,
    1.In order to restrict the output type to trigger you need to write the requirement routine in transaction
       VOFM> requirements>output control.
    2. create the requirement routine in application EF and write the required logic and pass the sy-subrc EQ 4 if you not require to trigger the output type and pass sy-subrc equal 0 to trigger the output type.
    3. assign this requirement routine to custom output type.

  • How to not include the path when creating pdf from many html files?

    I use "Merge File into a Single File" to create a pdf file from many html files. However, the generated pdf file have the path information of the html files. I'm wondering how to generate a pdf without the path information.

    Go to CREATE > Create PDF from Web Page > Click the SETTINGS button on the dialog that follows > Uncheck "Place headers and footers on new page".
    Thanks!

  • How to not upgrade clusterware 10203 when upgrading another oracle home

    Hello,
    We have a 4 node rac 10.2.0.3 and 10.2.0.3 clusterware on red hat 4. We want to install a new none-rac home on one of the nodes and patch that new none-rac home to 10.2.0.4. But if we install and patch the new 10.2.0.4, what happen to the clusterware already running on the 4 rac-node? What we want is to avoid upgrading the clusterware 10.2.0.3. We just want to install a new none-rac on one of the nodes and not touch the clusterware that is already running for the rac-node, 10.2.03. My question is, when installing a new separate none-rac oracle home 10.2.0.4 on RAC, does the new none-rac detect the clusterware 10.2.0.3? If so, what to do so the clusterware 10.2.0.3 is untouched when installing a 10.2.0.4 new none-rac oracle home? Thank you.

    As long as you choose a different path name for your new 10.2.0.4 oraclehome, there is no problem. ;)
    does the new none-rac detect the clusterware 10.2.0.3?Not if it's NON RAC!

  • How to show a jtable created when a tree node is selected in a jsplit pane

    hello,
    does anyone know how you would go about updating a jtable you have created in a split pane when the data of the jtable changes?
    i have a jtree that creates a jtable when a node is selected. i want to display this jtable in a split pane that is created when the gui is launched.
    any help appreciated. i know it has something to do with updating a table model but if anyone has any sample code of how to do this, could they post it?
    thank you.

    Hi Laura,
    When you make a selection on your JTree, what data are you send to the JTable? Is it an entirely new TableModel that gets set each time?
    If you don't already have an implementation, consider using one JTable and simply swap the models in and out on JTree selection. It's probably best to contain the JTable in JScrollPane also. Perhaps not necessary, but calls to revalidate and repaint on the JTable after setting whatever data it is you set should update what is displayed.
    Warm regards,
    Darren

  • How to execute custom code only when a specific node is selected in infoset

    Hi,
    We have written a piece of custom code under a node (P1045). Not all users will have access to this Infotype as it is related to Appraisals. So, when users (w/no access to 1045) try to run a Query for other info types data, they are getting error message 'Can not access 1045'. Custom code is getting generated whenever user runs a query. Tried to control custom code with simple IF condition by giving user name. Still generating 1045 code.
    All users use same infoset, where a group of users has access to 1045 and another group does not have access to 1045.
    Appreciate your inputs to get this resolved.
    Thanks,
    Swapna.

    Why don't you try another aproach, instead of adding the infotype to the infoset, create a new table as an alias (with the fields you want to show in regards to infotype 1045) and fill it in the node depending on the authorization check for that infotype in the code ?
    I think that adding the infotype as a node will always get the data from the infotype regardless, that is why it's showing the error.

  • How to display the current name when renaming Finder item

    Is there any way to get Automator to display the current name of a Finder item when renaming an item?
    I want my users to be able to copy and rename a folder template but I want to display the folder template's current name as a default in the renaming dialogue window, so the user follows the correct naming format.

    Since you've already hacked into it, if you've got developer tools installed, it is most likely in the nib file that is in the English project folder in the Resources.
    I don't know what further implications that will have on the app in general, though.
    If you are a little adept at applescript, you may want to create your own Applescript Studio app to do this instead of Automator. Also, take a look at Platypus to make a wrapper around you applescript instead of AS Studio.
    Message was edited by: Barney-15E

  • Org.xml.sax.SAXParseException: Reference is not allowed in prolog

    Hi,
    I have been using DocumentBuilder to parse an xml string in our application but now came up with this exception:
    org.xml.sax.SAXParseException: Reference is not allowed in prolog
    When I looked at the xml data, I found that it does not have a prolog in it. I also found that the data contains end of line character ""&#xD;""
    " in it.
    This the xml to be parsed: (Qutoted them to view the unicodes in xml)
    "<dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:title xml:lang="en">Test metadata</dc:title>
    <dc:language>en</dc:language>
    <dc:description xml:lang="en">Blah</dc:description>
    <dc:creator>BEGIN:vcard
    FN:Jan Austin
    ORG:IBalahblahLtd
    EMAIL:[email protected]
    END:vcard</dc:creator>
    <dc:format>text/html</dc:format>
    <dc:identifier>http://gg.com/</dc:identifier>
    <dc:subject>Medicine and Dentistry</dc:subject>
    </dc:dc>"
    And in the class, I used,
    DocumentBuilderFactory factory =  DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(file);I can not change the xml data to be parsed as the application gets this data from other targets through a web service.
    So, can anyone provide any suggestions to solve this issue please?
    Thanks,
    Shiv.

    I have tried various options by
    1. factory.setIgnoringElementContentWhitespace(true);
    2. factory.setValidation(false);
    But, none of them seems to work.
    Could anyone please giv me atleast a gist abt where to look about?
    Cheers,
    Shiv.

  • XML E4X Select nodes based on child node attribute.

    Hey,
    I am trying to make a selection on following XML.
    I want to retrieve a list of the variable node when its child nodes metadata attribute "name" is not equal to "transient". I have read through the documentation but have not been able to solve this and it should be rather simple. So far I have tried with something like.
    var variables:XMLList = classInfo.variable.(metadata.(@name != "transient"));
    var variables:XMLList = classInfo.variable.(metadata.@name != "transient");
    But it returns all variable nodes.
    <type name="com.sca.dataModel::PresentationDataEntity" base="com.sca.dataModel::BaseEntity" isDynamic="false" isFinal="false" isStatic="false">
      <extendsClass type="com.sca.dataModel::BaseEntity"/>
      <extendsClass type="Object"/>
      <variable name="subtitle" type="String">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/PresentationDataEntity.as"/>
          <arg key="pos" value="128"/>
        </metadata>
      </variable>
      <variable name="id" type="Number">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/BaseEntity.as"/>
          <arg key="pos" value="153"/>
        </metadata>
      </variable>
      <variable name="tableName" type="String">
        <metadata name="transient"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/BaseEntity.as"/>
          <arg key="pos" value="118"/>
        </metadata>
      </variable>
      <variable name="db_SortAsc" type="Boolean">
        <metadata name="transient"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/BaseEntity.as"/>
          <arg key="pos" value="281"/>
        </metadata>
      </variable>
      <variable name="title" type="String">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/PresentationDataEntity.as"/>
          <arg key="pos" value="100"/>
        </metadata>
      </variable>
      <method name="setData" declaredBy="com.sca.dataModel::BaseEntity" returnType="*">
        <parameter index="1" type="Object" optional="false"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/BaseEntity.as"/>
          <arg key="pos" value="330"/>
        </metadata>
      </method>
      <metadata name="__go_to_ctor_definition_help">
        <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/PresentationDataEntity.as"/>
        <arg key="pos" value="167"/>
      </metadata>
      <metadata name="__go_to_definition_help">
        <arg key="file" value="/Users/jonas/projects/SCA-CMS/src/com/sca/dataModel/PresentationDataEntity.as"/>
        <arg key="pos" value="42"/>
      </metadata>
    </type>

    Perfect, that worked!
    Thanks.
    Jonas

Maybe you are looking for

  • I need a plain trumpet sound and having trouble

    I need a plain/pure sound of a trumpet and I'm having trouble with it sounding off. What should my settings be with all the options. I'd greatly appreciate any help - sorry for such a basic question.

  • Upgrading from a Blackberry to iPhone4

    I see all the questions re upgrading from an older iPhone. Can anyone fill me in on what will be involved in upgrading from a Blackberry (I'm so excited & can't wait to upgrade)? Any additional steps? If the phone is sent to my home, can I get it goi

  • Update GL Account number in account assignment PO

    Dear Guru's, I have a requirement to replace proposal gl account in PO after item is entered, this requirement it's because of for several document type they need to map the gl account into other account but didn't want to use config. It's frustating

  • Help please!!  iDVD error...

    Hi I created a small movie in iMovie 08 and I sent it to iDVD but when I click burn dvd it keeps saying: "There were errors during the project validation that have to be fixed before burning the project." I am a computer dummy....lol Also, it does no

  • Why am i getting an error saying administrative privileges are required?

    Why am i getting an error saying administrative privileges are required?