XML and Tree Model !!!
I am wanting to implement the tree model from xml data.
I am new to this so would appreicate any help filling in the gaps. My aim is to reflect this xml file in a JTreeTable format (I have left out the table model implementation.)
A sample xml file looks like this :
<?xml version="1.0" ?>
<exam>
<Column class="xTableModel">Attribute</Column>
<Column class="String">Value</Column>
<Question>
<Id>1</Id>
<Type>TF></Type>
<Text>Napolean was french ?></Text>
<Answer>True</Answer>
<Mark>3</Mark>
</Question>
</exam>
How I am Reading the file:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
doc = parser.parse(xmlfile);
Tree Model Methods. //Not really sure what i am doing here.
public Object getChild(Object node, int i)
Node parent = ((Node) node);
Object child = parent.getChildNodes().item(i);
return child;
public int getChildCount(Object node)
Node parent = ((Node) node);
// int child = parent.getChildNodes().getLength();
return 1;
public boolean isleaf(Object node)
Node parent = ((Node)node);
Node child = parent.getFirstChild();
return (child == null);
}
you can use a adapter pattern to convert the xml element to a TreeModel, this can be used by JTree
Similar Messages
-
XML Populating Tree Map and JMenu
Hey I am looking for a way to populate a JMenu and A JTreeMap from an XML file.
The Layout is like
<node name="top">
<node name="Main" selected="true">
<node name="ChildOfMain1" selected="true">
<node name="ChildOfMain2" selected="true"/>
</node>
</node>
It is in this format due to the application I am tryingt o build has to import files from an old system we are using
Thanksis there a class that will magically interpret your XML and create Swing components from it? no. are there libraries around that allow you to describe UIs in XML and have Swing generated from that XML? yes. loads. google "java XUL" and "swing xml" for an insight. can I tell you how to use them? no
incidentally, are you really constrained to that format? I ask because making the decision that "ChildOfMain" should be a sub-menu of "Main" isn't going to be easy. something like the following would be nicer
<menu name="top">
<menu_item name="Main">
<menu_item name="ChildOfMain1" />
<menu_item name="ChildOfMain2" />
</menu_item>
<!-- etc -->
</menu> -
Just trying to clarify some issues as I try and learn about XML, and specifically how it integrates into the DB.
1 - Is there a way with Oracle tools for me to get an XSD of an existing 9i relational schema? We are not currently using the XML DB, but our middleware developers would like to have an up to date XSD to use for their internal mapping.
2 - Is there any way that I can keep that XSD up-to-date automatically, so I get a new one whenever the schema gets updated?
3 - If I wanted to investigate storing XML docs within the DB in native XML format, I need to have an XML DB, correct? Is this DB construct maintained seperatelly from my "normal" relational schema? or are they kept in sync by Oracle?
I know these may all be real basic questions, but as I said, I'm new to XML and Oracle. I am reading as much as I can, but there are a lot of docs out there.
Thanks,
MikeHi
1. On my opinion such a tool doesn't exists. Some parts can be implemented elsewhere, but not as described by you... e.g. with XSU if you specify the parameter "withschema" the XSD of the executed statement is generated. Another example is to use DBMS_METADATA to dump the data dictionary in XML (but not XSD, of course you could write your own XSLT to do this transformation...).
2. -
3. If you use XSD-based tables the XSD and the relational model are stored separately in the data dictionary. Therefore if you change the XSD you have to drop/create the XSD-based table... no schema evolution yet.
Chris -
Report locale, subtemplates and Data Model
Hi,
I have the following situation:
We have 4 templates according to language, with french the default language:
- FR: template.rtf
- NL: template_nl.rtf
- DE: template_de.rtf
- EN: template_en.rtf
The report locale is enough for BI Publisher to select the correct template, so that's OK.
Some data from our database is also based on locale (eg street names and cities).
Question 1: is it possible to use the current locale as parameter for the (sql) data model in some way (eg by using a specific parameter name)? For now we set the report locale to the correct language AND we send that same value through as a parameter. It would be cleaner to just set the report locale and be able to use that value in some way.
Question 2: all of the above templates have a footer that's being reused, each also share the same data model, but the data is again based on the current locale.
so: footer.rtf, footer_nl.rtf, footer_de.rtf and footer_en.rtf. Do I need to import all of these in their respective files or will localisation work (I doubt it)?
Question 3: Is there a way to implicitly pass all parameters that were passed to the main template, also pass to the subtemplates? (eg LANG parameter is passed to template_nl.rtf, who can use it in his data model, is there a way to automatically make LANG available for footer_nl.rtf's data model or do I need to explicitly pass it as a parameter in the <?call-template: footer?>) - again if the report locale is available in some way to the data model, it would be easy.
Thanks in advanceHello,
Probably the easiest would be to use an OnDemand Process and some AJAX to pull your data into the extjs object.
Here's an example of an OnDemand Process.
http://apex.oracle.com/pls/otn/f?p=11933:11
For data the easiest at the moment would be probably to use the Oracle XML functions to generate your data in XML and use that as your data feed.
You might want to take a look the new Interactive Reports included in APEX 3.1, while extjs has alot of functions there is a bit of setup involved , while the Interactive Reports all you need is a SQL query http://www.oracle.com/technology/products/database/application_express/html/irrs.html
You should search the forum for extjs as there has been quite a few successful integrations of APEX and extjs / YUI / jQuery etc.
Regards,
Carl
blog : http://carlback.blogspot.com/
apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5 -
Hi guys, first time poster so I apologize if this is a basic
question! I am creating a Media cataloging application to run as a
desktop application through Air, I initially built this as a Flex
web app but have decided I want it as a standalone. Anyway my
problem is this, in the web version I was using the following code:
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="srv.send()"
xmlns:ns1="com.dougmccune.containers.*"
backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #2CE1AC]" width="1281">
<mx:HTTPService id="srv" url="dvdLibrary.xml"/>
<mx:DataGrid x="336" y="57"
dataProvider="{srv.lastResult.dvdList.dvd}" id="dg" width="935"
height="354">
<mx:columns>
<mx:DataGridColumn headerText="Title"
dataField="title"/>
<mx:DataGridColumn headerText="Studio"
dataField="studio"/>
<mx:DataGridColumn headerText="Released"
dataField="releaseDate"/>
<mx:DataGridColumn headerText="Runtime"
dataField="runtime"/>
<mx:DataGridColumn headerText="Colour"
dataField="color"/>
<mx:DataGridColumn headerText="Aspect Ratio"
dataField="aspectRatio"/>
</mx:columns>
</mx:DataGrid>
The above code uses the XML file to populate the dataGrid
(which I am sure you know already! :) ), however when I port this
to an Air app, it no longer works. I have tried changing the
<mx:HTTPService> tag and attributes to the <mx:XML
source="pathtoXML.xml" id="srv"/> and <mx:Model
source="pathtoXML.xml" id="srv"/> but neither works.
Can anyone shed any light? I also get and error saying
something about creationComplete send() is not a function?
Is there a very different way of achieving this in Air?
Thanks in advance!Hi guys, first time poster so I apologize if this is a basic
question! I am creating a Media cataloging application to run as a
desktop application through Air, I initially built this as a Flex
web app but have decided I want it as a standalone. Anyway my
problem is this, in the web version I was using the following code:
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="srv.send()"
xmlns:ns1="com.dougmccune.containers.*"
backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #2CE1AC]" width="1281">
<mx:HTTPService id="srv" url="dvdLibrary.xml"/>
<mx:DataGrid x="336" y="57"
dataProvider="{srv.lastResult.dvdList.dvd}" id="dg" width="935"
height="354">
<mx:columns>
<mx:DataGridColumn headerText="Title"
dataField="title"/>
<mx:DataGridColumn headerText="Studio"
dataField="studio"/>
<mx:DataGridColumn headerText="Released"
dataField="releaseDate"/>
<mx:DataGridColumn headerText="Runtime"
dataField="runtime"/>
<mx:DataGridColumn headerText="Colour"
dataField="color"/>
<mx:DataGridColumn headerText="Aspect Ratio"
dataField="aspectRatio"/>
</mx:columns>
</mx:DataGrid>
The above code uses the XML file to populate the dataGrid
(which I am sure you know already! :) ), however when I port this
to an Air app, it no longer works. I have tried changing the
<mx:HTTPService> tag and attributes to the <mx:XML
source="pathtoXML.xml" id="srv"/> and <mx:Model
source="pathtoXML.xml" id="srv"/> but neither works.
Can anyone shed any light? I also get and error saying
something about creationComplete send() is not a function?
Is there a very different way of achieving this in Air?
Thanks in advance! -
XML and its influence over program design (2 issues)
I have 2 open questions about XML and Java. I apologise if they are not clear-cut or specific enough, but really I am fishing for sound advice.
I am trying to develop a J2EE application but find myself stuttering at an early stage because I cannot decide on the best design for my application. Part of my problem is a lack of experience with the different J2EE technologies/API (especially XML APIs), and the realisation that there is 101 ways to do what I want to do.
A major issue is this: my application basically is concerned with representing conversations between the server and a user, e.g. a simple sequence of yes/no questions asked by the server to the user, which the user replies to in turn. I believe that the XML format would be a very suitable way to represent these conversations. My first question is:
* Should the decision to use XML as a storage format influence the design of the rest of the program? I feel that in choosing XML to represent the conversation data, I am stuck thinking about the rest of my program in a XML way (i.e. doing everything using a DOM etc.). Am I right in thinking that my program should be designed in such a way that an XML-based storage system could be easily interchanged with, say, a relational flat-tabled database?
My second question is:
* Imagine that each conversation contains one or more questions, and there are, say, 4 different types of question (e.g. yes/no, multiple choice, etc.). Each of these needs to be handled in a different way. Is there a good pattern or recommended way of handling this sort of situation in code, ideally avoiding a big 'if' or switch statement (e.g. if the node is of "ABC" type do this, else if it is "yes/no"...). It would be great if one could easily add new types of question to the XML and then similarly one can make easy additions to the code to cope with these new cases.
Thank you very much indeed for any advice.
GregI am trying to develop a J2EE application but find
myself stuttering at an early stage because I cannot
decide on the best design for my application. Part of
my problem is a lack of experience with the different
J2EE technologies/API (especially XML APIs), and theThat's nothing to be ashamed of. And realising that you lack experience and trying to remedy that is a good sign.
A major issue is this: my application basically is
concerned with representing conversations between the
server and a user, e.g. a simple sequence of yes/no
questions asked by the server to the user, which the
user replies to in turn. I believe that the XML
format would be a very suitable way to represent
these conversations. My first question is:
XML might be overkill if it's just a question followed by an answer and neither contains complex hierarchical data structures.
* Should the decision to use XML as a storage format
influence the design of the rest of the program? ICertainly not.
XML should represent data structures that are natural to your program, thus becoming a tool rather than forcing its structure upon you.
feel that in choosing XML to represent the
conversation data, I am stuck thinking about the rest
of my program in a XML way (i.e. doing everything
using a DOM etc.). Am I right in thinking that my
program should be designed in such a way that an
XML-based storage system could be easily interchanged
with, say, a relational flat-tabled database?
Flexibility is good to keep in mind, but at the moment I'd worry about just getting something to work.
* Imagine that each conversation contains one or more
questions, and there are, say, 4 different types of
question (e.g. yes/no, multiple choice, etc.). Each
of these needs to be handled in a different way. Is
there a good pattern or recommended way of handling
this sort of situation in code, ideally avoiding a
big 'if' or switch statement (e.g. if the node is of
"ABC" type do this, else if it is "yes/no"...). It
would be great if one could easily add new types of
question to the XML and then similarly one can make
easy additions to the code to cope with these new
cases.
Think of a factory that creates the handlers on the fly based on the actual message received.
If the factory makes use of some mapping construct to do so there's no need for any conditionals at all in your decision tree.
I've myself used XML structures successfully to define such mappings (and so have others) on disc, but simple ones can be easily represented using just a properties file. -
Hi,
I am getting null pointer exception , i dont whether it is due to jar mismatch or what ???
I have a stand alone application which created java classes from one schema file and , i construct xml file by
inputting some values. It works fine in my machine. But when i deploy it our product which has tomcat6 it
gives the following exception.
ava.lang.NullPointerException
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName(PropertyInfoImpl.java:287)
at com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName(PropertyInfoImpl.java:260)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl.getTypes(ElementPropertyInfoImpl.java:100)
at com.sun.xml.bind.v2.model.impl.RuntimeElementPropertyInfoImpl.getTypes(RuntimeElementPropertyInfoImpl.java:50)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.size(ElementPropertyInfoImpl.java:42)
at java.util.AbstractList$Itr.hasNext(AbstractList.java:341)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:139)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:204)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$1.run(JAXBContextImpl.java:343)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$1.run(JAXBContextImpl.java:340)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:340)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:204)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:589)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:381)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at com.facetime.rtgsm.extractor.GenerateXml.GenerateXmlForSkypeManagementOnly(Unknown Source)
at com.facetime.rtgsm.extractor.JDBCToXML.getXmlStringForModalities(Unknown Source)
at com.facetime.rtgsm.publisher.MessagePublisherClient.sendMessage(Unknown Source)
at com.facetime.rtgsm.publisher.MessagePublisherJob.execute(Unknown Source)
at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
Any help would be be grately appreciated :)Check whether jaxb-ri.jar is there in your class path
-
How to hide a tree node from the GUI but still keep it in the tree model?
Hi, All
I used a JTree in my project in which I have a DefaultTreeModel to store all the tree structure and a JTree show it on the screen. But for some reason, I want to hide some of the nodes from the user, but I don't want to remove them from the tree model because later on I still need to use them.
I searched on the web, some people suggested method to hide the root node, but that's not appliable to my project because I want to hide some non-root nodes; Some people also suggested to collapse the parent node when there are child to hide, it is not appliable to me either, because there still some other childnodes (sibling of the node to hide) I want to show.
How can I hide some of the tree node from the user? Thanks for any information.
LindaHere's an example using a derivation of DefaultTreeModel that shows (or does not show) two types of Sneech (appologies to the good Dr Zeus) by overiding two methods on the model.
Now, there are many things wrong with this example (using instanceof, for example), but it's pretty tight and shows one way of doing what you want.
Note: to make it useful, you''d have to change the implementation of setShowStarBelliedSneeches() to do something more sophisticated than simply firing a structure change event on the root node. You'd want to find all the star bellied sneech nodes and call fireTreeNodesRemoved(). That way the tree would stay expanded rather than collapse as it does now.
import javax.swing.JTree;
import javax.swing.JScrollPane;
import javax.swing.JOptionPane;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.tree.TreePath;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;
class FilteredTree
private class PlainBelliedSneech {
public String toString() { return "Plain Bellied Sneech"; }
private class StarBelliedSneech {
public String toString() { return "Star Bellied Sneech"; }
private class FilteredTreeModel
extends DefaultTreeModel
private boolean mShowStarBelliedSneeches= true;
private DefaultMutableTreeNode mRoot;
FilteredTreeModel(DefaultMutableTreeNode root)
super(root);
mRoot= root;
public Object getChild(Object parent, int index)
DefaultMutableTreeNode node=
(DefaultMutableTreeNode) parent;
if (mShowStarBelliedSneeches)
return node.getChildAt(index);
int pos= 0;
for (int i= 0, cnt= 0; i< node.getChildCount(); i++) {
if (((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject()
instanceof PlainBelliedSneech)
if (cnt++ == index) {
pos= i;
break;
return node.getChildAt(pos);
public int getChildCount(Object parent)
DefaultMutableTreeNode node=
(DefaultMutableTreeNode) parent;
if (mShowStarBelliedSneeches)
return node.getChildCount();
int childCount= 0;
Enumeration children= node.children();
while (children.hasMoreElements()) {
if (((DefaultMutableTreeNode) children.nextElement()).getUserObject()
instanceof PlainBelliedSneech)
childCount++;
return childCount;
public boolean getShowStarBelliedSneeches() {
return mShowStarBelliedSneeches;
public void setShowStarBelliedSneeches(boolean showStarBelliedSneeches)
if (showStarBelliedSneeches != mShowStarBelliedSneeches) {
mShowStarBelliedSneeches= showStarBelliedSneeches;
Object[] path= { mRoot };
int[] childIndices= new int[root.getChildCount()];
Object[] children= new Object[root.getChildCount()];
for (int i= 0; i< root.getChildCount(); i++) {
childIndices= i;
children[i]= root.getChildAt(i);
fireTreeStructureChanged(this, path, childIndices, children);
private FilteredTree()
final DefaultMutableTreeNode root= new DefaultMutableTreeNode("Root");
DefaultMutableTreeNode parent;
DefaultMutableTreeNode child;
for (int i= 0; i< 2; i++) {
parent= new DefaultMutableTreeNode(new PlainBelliedSneech());
root.add(parent);
for (int j= 0; j< 2; j++) {
child= new DefaultMutableTreeNode(new StarBelliedSneech());
parent.add(child);
for (int k= 0; k< 2; k++)
child.add(new DefaultMutableTreeNode(new PlainBelliedSneech()));
for (int j= 0; j< 2; j++)
parent.add(new DefaultMutableTreeNode(new PlainBelliedSneech()));
parent= new DefaultMutableTreeNode(new StarBelliedSneech());
root.add(parent);
for (int j= 0; j< 2; j++) {
child= new DefaultMutableTreeNode(new PlainBelliedSneech());
parent.add(child);
for (int k= 0; k< 2; k++)
child.add(new DefaultMutableTreeNode(new StarBelliedSneech()));
for (int j= 0; j< 2; j++)
parent.add(new DefaultMutableTreeNode(new StarBelliedSneech()));
final FilteredTreeModel model= new FilteredTreeModel(root);
JTree tree= new JTree(model);
tree.setShowsRootHandles(true);
tree.putClientProperty("JTree.lineStyle", "Angled");
tree.setRootVisible(false);
JScrollPane sp= new JScrollPane(tree);
sp.setPreferredSize(new Dimension(200,400));
final JCheckBox check= new JCheckBox("Show Star Bellied Sneeches");
check.setSelected(model.getShowStarBelliedSneeches());
check.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.setShowStarBelliedSneeches(check.isSelected());
JPanel panel= new JPanel(new BorderLayout());
panel.add(check, BorderLayout.NORTH);
panel.add(sp, BorderLayout.CENTER);
JOptionPane.showOptionDialog(
null, panel, "Sneeches on Beeches",
JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE,
null, new String[0], null
System.exit(0);
public static void main(String[] argv) {
new FilteredTree(); -
Problem in Exploring the Decision Tree Model on Lesson 4 Basic Data Mining SSAS
Hello everyone,
I've tried to follow all the steps mentioned in Basic Data Mining Tutorials, but I've an odd problem in the Lesson 4 - Exploring the Decision Tree Model (http://technet.microsoft.com/en-us/library/cc879269.aspx).
It's stated that "As you view the TM_Decision_Tree model
in the Decision Tree viewer, you can see the most important attributes at the left side of the chart. “Most important” means that these attributes have the greatest influence on the outcome. Attributes further down the tree (to the right of the chart) have
less of an effect. In this example, age is the single most important factor in predicting bike buying. The model
groups customers by age, and then shows the next more important attribute for each age group. For example, in the group of customers aged 34 to 40, the number of cars owned is the strongest predictor after age."
But, I got a different result from what mentioned in the tutorial. I got the number of cars owned as the most important attribute, then followed by the attribute age.
Do you guys know why?
Thanks in advanceHI,
BEGIN
INSERT INTO DT_CA_SETTINGS_TEST (SETTING_NAME, SETTING_VALUE) VALUES
(dbms_data_mining.TREE_TERM_MINPCT_NODE,to_char(1));
END;
That is not "Mode" its "NODE".
Now Execute.
Cheers.. -
Bette way to referenced tree model nodes from UI to perform actions on them
A singleton facade is built.
Its init() method loads several "tree model configs", each of them referenced by a name.
This singleton creates a Project instance for a given "tree model config" calling the facade method -> createProject(String pjrName, String modelConfigName)
When the Project is built a new Model instance is set ( remember the model instance is a tree holding nodes )
The new Project instance built is added to a List that the facade has and then it's returned to the UI part that called ->createProject(prjName,modelconfigName)
Given the Project instance the UI has to build a JTree representation of the model that the project references and the UI will have button actions that should call methods of the Nodes of the model referenced by the Project.
Doing it this way the UI will be able to reference objects directly without going through the facade.
Maybe I should return to the UI something like a ProjectKey instance instead of letting have the UI the Project instance ?
It should be better if I process the possible node actions behind the Facade and not the UI, but how can I do it ?
Having a ProjectKey in my UI I could ask the facade a model tree representation but not having the real nodes, otherwise having some NodeKey instances ?Sounds like you want to represent a tree structure, without a reference to the real tree.
I'll take it further: maybe you don't want the UI to know there's a real tree data-structure with nodes and pointers to children, because maybe you build the tree on the fly from a database.
So use the Builder pattern instead of committing to a specific data structure.
Google results for Builder pattern: http://www.google.com/search?hl=en&q=builder+pattern&btnG=Google+Search
Your UI should know how to construct nodes and children graphically, when told. This means it should have methods like addNode, but related to the domain: addSubProject maybe.
A Project object is the Director, knowing which part goes where, but it doesn't know the real end result (a JPanel or HTML). So it has a method buildProject(Builder e) or exportProject(Exporter e), where all logic of assembling the parts is.
When you have that, write a class JTreeProjectExporter implements Exporter.
Hope this helps. -
I have two types of tree Models that I would like to combine into one tree i did the combination this way:
public CombainedTreeModel(BaseTreeModel firstSubTree,BaseTreeModel secondSubTree) {
super(null);
BaseTreeNode root=new BaseTreeNode("root");
insertNodeInto(firstSubTree.getTreeRoot(),root,GuiConstants.INDEX_ZERO);
insertNodeInto(secondSubTree.getTreeRoot(),root,GuiConstants.INDEX_ONE);
and used the combined model (that is extends of BaseTreeModel -> DefaultTreeModel.) as the input of the tree.
I see that there are elements in the tree but they are not visible.....
what is the problem?I had a bit different interpertation for the MVC in swing:
model - is a pure java class holds the data
control- the treeModel that pass the commands to the model and after the comand was done - remove/add/update node from the tree and commite reload so the view will be refreshed
view - the Jtree
Everything in this model used to be ok until i combined two tree model to a third model so they will be displayed together.
this is how I remove a node:
public void removeContentServer(int contentServerId) throws BitBandGuiRemoveException, BitBandGuiFindException {
if (logger.isDebugEnabled())
logger.debug("ContentTreeModel.removeContentServer");
BaseContentTreeNode contentServerNode = getContentServerNode(contentServerId);
networkModel.removeContentServer(contentServerId);
contentServerNode.removeFromParent();
if (logger.isDebugEnabled()) {
logger.debug("remove content server from the model" + contentServerId);
synchronized (contentServerNode) {
contentServerNode.removeFromParent();
if (logger.isDebugEnabled()) {
logger.debug("remove content server from the tree model");
reload(root);
} -
Hi All,
I'm need to create a JATO tree implementation and need some advice. I
want to modify the JATO sample tree implementation so that:
1) The model is cached within the user's session.
2) The model is created on demand. i.e. The data associated with the
branches are only retrieved when the branches are opened.
In the sample application E0115TreeView (view) creates a
SimpleTreeModelImpl (model) each time it is instantiated and
SimpleTreeModelImpl (model) creates dummy data each time it is
instantiated.
1) Is there a standard JATO technique for associating a model with a
view (unlike the sample)? Does this involve the ModelTypeMapImpl class?
My tree data is stored in LDAP, so I can't use a standard JATO database
Model classes.
2) The comment in the SimpleTreeModelImpl class definition indicates
that it is normal practice to store the model in the user's session. Is
there a standard JATO technique for doing this?
3) What would be the best way to extend the sample so that I can create
the model on-demand?
Regards,
Dennis Parrott.
[Non-text portions of this message have been removed]Thanks Todd,
That makes perfect sense.
Regards,
Dennis parrott.
Todd Fast wrote:
Hi Dennis--
I have now added a SimpleTreeModel interface (which extends TreeModel) andhave added an
mapping in ModelTypeMapImpl static initializer. i.e. To registerSimpleTreeModelImpl with the
ModelManager.This is fine, but you can so without the additional interface if you want.
You don't need to register the model in the ModelTypeMap, and you can
instead just pass the implementation class to ModelManager.
In the tree view constructor instead of creating the SimpleTreeModelImpleach time I use the
ModelManager to retrieve the model, indicating that the model should bestored in the sesssion:
public Treeview(View parent, String name) {
super(parent, name);
RequestContext requestContext = getRequestContext();
ModelManager modelManager = requestContext.getModelManager();
Class clazz = SimpleTreeModel.class;
SimpleTreeModel simpleTreeModel =
(SimpleTreeModel)modelManager.getModel( clazz,clazz.getName(), true, true );
setPrimaryModel( simpleTreeModel );
registerChildren();
}This looks good, EXCEPT for the fact that you shouldn't be able to get the
RequestContext at this point via the class's getRequestContext() method (it
isn't set until after the constructor). However, you can use the static
method RequestManager.getRequestContext() instead.
The final bit I need to implement is the model creation on-demand.Currently the entire model
is constructed on the first access and stored in the session. However,when model is large then
this has a performance impact on constructing it for the first time.Instead I would like to
construct peices of the model as the user accesses them. Any ideas?This is really a function of your model implementation. Nodes that are not
needed in a particular rendering of a TreeModel are never accessed by the
framework in that rendering, so you need to implement your model to lazily
fetch sub-trees of the underlying data structure only as needed. Depending
on the technology you are using, this may or may not be difficult.
I suspect that right now you are fetching the entire tree data structure
when the model is created, and this is the root of the problem. You need to
fetch all nodes that are children of the root on the first request, then
fetch child nodes of the next node the user expands on the next request, ad
infinitum. Otherwise, you will have to settle for a one-time performance
hit per session caused by retrieving the entire tree data structure at once.
If you are using TreeModelBase as your superclass and just implementing the
abstract methods therein, then the implementation of the firstChild() method
is your opportunity to fetch the tree data lazily. This method will be
called on a node to "step down" one level in the tree, and it will only be
called for the nodes that are expanded. You should implement this method to
figure out what node the model is on at the moment, then use that
information to determine if you've already looked up that node's childre in
the backend system, or if you need to go and fetch ONLY the current node's
direct children. As the user descends through the tree, the tree will be
fleshed out and cached lazily, one level at a time, via this mechanism.
Does this make any sense?
Todd
To download the latest version of S1AF (JATO), please visit one of thefollowing locations:
>
Framework + IDE plugin for Sun ONE Studio 4 Update 1, Community Edition:
http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_CE.html
Framework + IDE pluign for Sun ONE Studio 4 Update 1, Enterprise Edition:
http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_EE.html
Previous versions of JATO:
http://www.sun.com/software/download/developer/5102.html
[Non-text portions of this message have been removed] -
Adfm.xml and locating DataBindings
I have some issues with this. This is the situation: Model and ViewController project. DataControls are used, made on a session bean in Model prject, referenced in ViewController project to display on a page etc. So it is standard use of data controls.
Within embedded JDeveloper it works fine. Then I deploy it to Standalone OC4J. Error is:
JBO-26001: XML File not found for the Container model/DataBindings.cpx
So I figured out that the location that points to DataBindings is not correct. In Model project adfm.xml is, naturally, in the META-INF direktory, together with the persistence.xml and ejb-jar.xml.
In the war file for the ViewController these files are also present. I guess that is because of dependency among projects, so the compiled source directory of Model project, together with the META-INF directory is under WEB-INF/classes/
In war project adfm.xml is under WEB-INF/classes/META-INF, also persistence.xml and ejb-jar.xml.
Now, when deployment starts, it just does not find jar files referenced in the persistence.xml. So I removed it, and deployment went on. But, once I get to display the page that uses bindings. I get error that it cannot locate DataBindings. I tried different combinations of paths, but it doesn't work.
Without adfm.xml file, of course, application cannot locate bindings.
So, here are the questions:
1) What is the correct way to assemble this kind of project? Are the files ejb/jar.xml an persistence.xml needed in WEB-INF/classes/META-INF
2) Where should the file adfm.xml be located in war archive and how should it reference the DataBindings?OK, after some trouble I have managed to get things up and running. I'm not sure how, but I have noticed one annoying thing with swtandalone tp4. If I deploy app, then undeploy it and deploy it again, the old version of module I changed with new deploy is not removed if I dont restart the server. So It happend I didnt notice some changes I made, then I made a clean start and it worked.
Thanks anyway, Frank. The way things are going, I think Ill soon be here with more questions :)
Message was edited by:
mishaerror -
Hi,
I have a design problem in my application. It goes on like this:
For every XML Request-Response query, I have a Session Bean which accesses database tables. I have to refer to 4-5 tables to fulfil each request. All the tables follow the parent-child relationship(onto 4-5 levels, depending upon the number of queries) which means for one row in parent table there are multiple rows in child tables and so on.
Now, in my XML response, I need to follow the same schema in form of tags. For example:
<table1Info>
<data1>1212</data1>
<table2Info> (tags could be multiple)
<data2>1212</data2>
<table3Info> (tags could be multiple)
<data3>1212</data3>
<table4Info> (tags could be multiple)
<data4>1212</data3>
</table4Info>
</table3Info>
</table2Info>
</table1Info>
So far, so good! I can happily select data from multiple tables and generate the XML response by serially concatenating the response string. My problem is that I want to write a single query to fetch all the data instead of fetching data corresponding the parent tag and then making another query to fetch data from child table(which corresponds to child tag).
If i do a join of all tables in a single query, I need to do a lot of checking in java code inside the loop and figure out when a parent data has changed and the upcoming values correspond to next parent data(and thereby close all the child tags and open the next parent tag). It can sometimes become quite messy and cumbersome. Is there a cleaner way of doing it? Any ideas wud be welcome...Please let me know if i need to elaborate more ..
Thanks,
PrashantWhat is wrong with issuing the query each time for the child? Performance? It more accurately models what you are trying to do than the approach you mention.
steve - http://www.fdsapi.com - an api used to generate dynamic xml and html -
Simple Tree Model displays the subtree on second click
Hi,
I want to display a simple tree model structure with root "Tableset" and subnodes like "MARA". If i click on Mara it has to display all the fields from that table.
But it takes two clicks till the subtree opens? I suppose it needs something like a "fresh Tree".
SinanHello Sinan,
you have to call the method expand_root_nodes of the tree model:
CALL METHOD model->expand_root_nodes
EXPORTING expand_subtree = expand_subtree
level_count = level_count.
expand_subtree:
If you set this parameter to 'X' , the system expands all subtrees of the root nodes
level_count:
Specifies the depth to which the root nodes should be expanded. Possible values:
0
: Only the root nodes themselves are expanded 1
: The root nodes and their first level of child nodes are expanded n
: The root nodes are expanded down to their nth level of child nodes.
Note: If you set the expand_subtree parameter to 'X' , the value of level_count is ignored.
Maybe you are looking for
-
Newbie:need help to use xml as database
helo experts , i am totally new to Xml/java api i need to develop a application in which my java program interact with a xml file which will contain product inventory of a online seller store(i means what goods they are selling their price and someth
-
How to display long text of info in webdynpro view
Hi all I want to retrive a text of 500 characters in TextEdit UI element from R3,but the attribute through which we have bind this UI element is mapped to model attribute which is coming in the form of table i.e. first row of that table contains fi
-
I cant use my itunes gift card it says error
hello
-
Regarding Mail notification in standard Workflow WS20000075
Hi Experts, I am using the standard workflow to send mail to releaser for PO release. The task TS20000168 sends a mail notification to the PO creator saying that the PO is released after every release done by the concerned persons. Now the user requi
-
Is my macbook capable of harboring this RAM?
So I've visited tons of sites with little to no clue on what I should be looking for for RAM upgrades for my macbook. OWC, new egg, and crucial all seem to be good ones... but I don't know which one has the most desirable RAM upgrades. Plus I'm confu