Re: Help for a new user - Working with elements

2002-04-11 Thread Jeremy W. Redmond


Posting the code snippet that you are trying might be helpful.


   

  "Nemesh, Jim"

   <[EMAIL PROTECTED]>  

   cc: 

  04/10/2002 03:21 Subject:  Help for a new user - Working 
with elements   
  PM   

  Please respond to

  "ECS Users List" 

   

   






 Hi there.  I'm hoping someone can help me out with a problem
I've
got...

 I'm trying to "merge" the attributes from two elements
together (I
hope
I've got the terminology correct here.)  For example, I could have two TD
objects,
and I'd like to take the second TD, and overwrite the formatting, etc in
the
first
with the second, but retain any formatting in the first that is not in the
second.

 So, if I had a TD that was instantiated as:
 TD first = new TD ("Foo");

 And a second TD with formatting options:
 TD format = new TD();
 format.setBgColor("#CC");

 I'd like to merge the two so the end result is a TD object
that has
both
the String "Foo" and the backround color.

 Is this possible?  I've been fooling with ECS a bit, and have
tried
calling elements, keys, and attributes for these.  The attributes tag
returns the
bgcolor String for the format object.  I can get the value of the bgcolor
via
getAttribute.

 But I can't seem to create a new Element of some kind and push
it
back
into the first object.  I've tried making a ConcreteElement object with the

addElementToRegistry method, then adding that element to the first object,
but the TD object is not correct when printed:  Foo<>#CC

 Any help someone can give me, or references to on line info
would
be greatly appreciated...

-Jim Nemesh
GCI Scientific Programmer

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 






--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Help for a new user - Working with elements

2002-04-11 Thread Nemesh, Jim



> -Original Message-
> From: Jeremy W. Redmond [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 8:00 AM
> To: ECS Users List
> Subject: Re: Help for a new user - Working with elements
> 
> 
> 
> Posting the code snippet that you are trying might be helpful.

Here's the basic idea:

 TD data = new TD("Foo");
   TD format = new TD();
 format.setBgColor("#CC"); 
 Enumeration formatEKeys = format.attributes();
 while (formatEKeys.hasMoreElements()) {
String o = (String) formatEKeys.nextElement();
System.out.println (o);
String value = format.getAttribute(o);
System.out.println (value);
// do something to create an element with these values and
add it to data.
 }

This should take the format information (backround color) from the
format
TD object, and put it in the first TD object.

The question is, what goes after the comment line?  Should I be
making a
ConcreteElement, or GenericElement?  If so, how would I go about doing this?

Why am I doing this?  I'm building some generic ways to create
tables from other objects
and provide ways to format the cells and rows of the tables after the TD
objects have already 
been created, or provide multiple levels of formatting (for example one test
would say that if
the data included the word "Foo", the backround would be red, and if the
data contained the word
"Bar" as well, it would do something else.)

-Jim Nemesh


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Help for a new user - Working with elements

2002-04-11 Thread Klaus Sonnenleiter

Jim,

You could probably get to where you want to go by looping through the 
attributes and copying them one by one. But it seems unnecessary to me. You 
could also create classes that inherit from TD and set some defaults, like this

class JimsOwnTD extends TD {
 JimsOwnTD() {
 this("default")
 }

 JimsOwnTD(String s) {
 super(s);
 this.setBgColor("#CC");
 }

 //override other methods here
}

Then, instead of creating two separate TDs, you'll create only one JimsOwnTD:

JimsOwnTD jotd = JimsOwnTD("Foo");

and it should inherit what you need.

Klaus

At 10:48 AM 4/11/2002 -0400, Nemesh, Jim wrote:


> > -Original Message-
> > From: Jeremy W. Redmond [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, April 11, 2002 8:00 AM
> > To: ECS Users List
> > Subject: Re: Help for a new user - Working with elements
> >
> >
> >
> > Posting the code snippet that you are trying might be helpful.
>
> Here's the basic idea:
>
> TD data = new TD("Foo");
>TD format = new TD();
> format.setBgColor("#CC");
> Enumeration formatEKeys = format.attributes();
> while (formatEKeys.hasMoreElements()) {
> String o = (String) formatEKeys.nextElement();
> System.out.println (o);
> String value = format.getAttribute(o);
> System.out.println (value);
> // do something to create an element with these values and
>add it to data.
> }
>
> This should take the format information (backround color) from the
>format
>TD object, and put it in the first TD object.
>
> The question is, what goes after the comment line?  Should I be
>making a
>ConcreteElement, or GenericElement?  If so, how would I go about doing this?
>
> Why am I doing this?  I'm building some generic ways to create
>tables from other objects
>and provide ways to format the cells and rows of the tables after the TD
>objects have already
>been created, or provide multiple levels of formatting (for example one test
>would say that if
>the data included the word "Foo", the backround would be red, and if the
>data contained the word
>"Bar" as well, it would do something else.)
>
> -Jim Nemesh
>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Help for a new user - Working with elements

2002-04-11 Thread Nemesh, Jim

Here's the trick:

The attributes will be defined by someone else using the class,
so the attributes will not be static.  Any attributes could be set
in the format class, and I need to copy them.  I want this to be
generic as possible, so I can loop through a set of TD's, set a 
condition to modify a format, then apply that format to only those
records that need it.  I can't just call setBgColor on all the TD's,
unless I do some tricks with reflexion to pass the name of the method
call.  I want this to be simple and easy for a user.  

So, my question still remains:

How do I copy these attributes from one TD to another?

I've tried to create a ConcreteElement and do it like this:

  TD data = new TD("Foo");
TD format = new TD();
format.setBgColor("#CC");

  Enumeration formatEKeys = format.attributes();
ConcreteElement ce = new ConcreteElement();
while (formatEKeys.hasMoreElements()) {
String o = (String) formatEKeys.nextElement();
System.out.println (o);
String value = format.getAttribute(o);
System.out.println (value);
ce.addElementToRegistry (o, value);
System.out.println (ce);
data.addElement (ce);
}
System.out.println (data);

I get the following result:

bgcolor
#CC
<>#CC
Foo<>#CC

Almost, but not quite.  Can someone help me clean up this
code so it produces:

Foo

Thanks yet again.

> -Original Message-
> From: Klaus Sonnenleiter [mailto:[EMAIL PROTECTED]]
>
> 
> Jim,
> 
> You could probably get to where you want to go by looping through the 
> attributes and copying them one by one. But it seems 
> unnecessary to me. You 
> could also create classes that inherit from TD and set some 
> defaults, like this
> 
> class JimsOwnTD extends TD {
>  JimsOwnTD() {
>  this("default")
>  }
> 
>  JimsOwnTD(String s) {
>  super(s);
>  this.setBgColor("#CC");
>  }
> 
>  //override other methods here
> }
> 
> Then, instead of creating two separate TDs, you'll create 
> only one JimsOwnTD:
> 
> JimsOwnTD jotd = JimsOwnTD("Foo");
> 
> and it should inherit what you need.
> 
> Klaus
> 
> At 10:48 AM 4/11/2002 -0400, Nemesh, Jim wrote:
> 
> 
> > > -Original Message-
> > > From: Jeremy W. Redmond [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, April 11, 2002 8:00 AM
> > > To: ECS Users List
> > > Subject: Re: Help for a new user - Working with elements
> > >
> > >
> > >
> > > Posting the code snippet that you are trying might be helpful.
> >
> > Here's the basic idea:
> >
> > TD data = new TD("Foo");
> >TD format = new TD();
> > format.setBgColor("#CC");
> > Enumeration formatEKeys = format.attributes();
> > while (formatEKeys.hasMoreElements()) {
> > String o = (String) formatEKeys.nextElement();
> > System.out.println (o);
> > String value = format.getAttribute(o);
> > System.out.println (value);
> > // do something to create an element with 
> these values and
> >add it to data.
> > }
> >
> > This should take the format information (backround 
> color) from the
> >format
> >TD object, and put it in the first TD object.
> >
> > The question is, what goes after the comment line?  
> Should I be
> >making a
> >ConcreteElement, or GenericElement?  If so, how would I go 
> about doing this?
> >
> > Why am I doing this?  I'm building some generic 
> ways to create
> >tables from other objects
> >and provide ways to format the cells and rows of the tables 
> after the TD
> >objects have already
> >been created, or provide multiple levels of formatting (for 
> example one test
> >would say that if
> >the data included the word "Foo", the backround would be 
> red, and if the
> >data contained the word
> >"Bar" as well, it would do something else.)
> >
> > -Jim Nemesh
> >
> >
> >--
> >To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Help for a new user - Working with elements

2002-04-11 Thread Klaus Sonnenleiter

In that case, your problem is you're going through the elements, not 
through the attributes.

At 11:50 AM 4/11/2002 -0400, you wrote:
>Here's the trick:
>
> The attributes will be defined by someone else using the class,
>so the attributes will not be static.  Any attributes could be set
>in the format class, and I need to copy them.  I want this to be
>generic as possible, so I can loop through a set of TD's, set a
>condition to modify a format, then apply that format to only those
>records that need it.  I can't just call setBgColor on all the TD's,
>unless I do some tricks with reflexion to pass the name of the method
>call.  I want this to be simple and easy for a user.
>
> So, my question still remains:
>
> How do I copy these attributes from one TD to another?
>
> I've tried to create a ConcreteElement and do it like this:
>
>   TD data = new TD("Foo");
> TD format = new TD();
> format.setBgColor("#CC");
>
>   Enumeration formatEKeys = format.attributes();
> ConcreteElement ce = new ConcreteElement();
> while (formatEKeys.hasMoreElements()) {
> String o = (String) formatEKeys.nextElement();
> System.out.println (o);
> String value = format.getAttribute(o);
> System.out.println (value);
> ce.addElementToRegistry (o, value);
> System.out.println (ce);
> data.addElement (ce);
> }
> System.out.println (data);
>
> I get the following result:
>
>bgcolor
>#CC
><>#CC
>Foo<>#CC
>
> Almost, but not quite.  Can someone help me clean up this
>code so it produces:
>
> Foo
>
> Thanks yet again.
>
> > -Original Message-
> > From: Klaus Sonnenleiter [mailto:[EMAIL PROTECTED]]
> >
> >
> > Jim,
> >
> > You could probably get to where you want to go by looping through the
> > attributes and copying them one by one. But it seems
> > unnecessary to me. You
> > could also create classes that inherit from TD and set some
> > defaults, like this
> >
> > class JimsOwnTD extends TD {
> >  JimsOwnTD() {
> >  this("default")
> >  }
> >
> >  JimsOwnTD(String s) {
> >  super(s);
> >  this.setBgColor("#CC");
> >  }
> >
> >  //override other methods here
> > }
> >
> > Then, instead of creating two separate TDs, you'll create
> > only one JimsOwnTD:
> >
> > JimsOwnTD jotd = JimsOwnTD("Foo");
> >
> > and it should inherit what you need.
> >
> > Klaus
> >
> > At 10:48 AM 4/11/2002 -0400, Nemesh, Jim wrote:
> >
> >
> > > > -Original Message-
> > > > From: Jeremy W. Redmond [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, April 11, 2002 8:00 AM
> > > > To: ECS Users List
> > > > Subject: Re: Help for a new user - Working with elements
> > > >
> > > >
> > > >
> > > > Posting the code snippet that you are trying might be helpful.
> > >
> > > Here's the basic idea:
> > >
> > > TD data = new TD("Foo");
> > >TD format = new TD();
> > > format.setBgColor("#CC");
> > > Enumeration formatEKeys = format.attributes();
> > > while (formatEKeys.hasMoreElements()) {
> > > String o = (String) formatEKeys.nextElement();
> > > System.out.println (o);
> > > String value = format.getAttribute(o);
> > > System.out.println (value);
> > > // do something to create an element with
> > these values and
> > >add it to data.
> > > }
> > >
> > > This should take the format information (backround
> > color) from the
> > >format
> > >TD object, and put it in the first TD object.
> > >
> > > The question is, what goes after the comment line?
> > Should I be
> > >making a
> > >ConcreteElement, or GenericElement?  If so, how would I go
> > about doing this?
> > >
> > > Why am I doing this?  I'm building some generic
> > ways to create
> > >tables from other objects
> > >and provide ways to format the cells and rows of the tables
> > after the TD
> > >objects have already
> > >been created, or provide multiple levels of formatting (for
> > example one test
> > >would say that if
> > >the data included the word "Foo", the backround would be
> > red, and if the
> > >data contained the word
> > >"Bar" as well, it would do something else.)
> > >
> > > -Jim Nemesh
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Help for a new user - Working with elements

2002-04-11 Thread Nemesh, Jim

How's that?

Isn't the line:
Enumeration formatEKeys = format.attributes();
getting the attributes?

Then:
while (formatEKeys.hasMoreElements()) {
String o = (String) formatEKeys.nextElement();

Iterating through those attributes?

-Jim


> -Original Message-
> From: Klaus Sonnenleiter [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 12:02 PM
> To: ECS Users List
> Subject: RE: Help for a new user - Working with elements
> 
> 
> In that case, your problem is you're going through the elements, not 
> through the attributes.
> 
> At 11:50 AM 4/11/2002 -0400, you wrote:
> >Here's the trick:
> >
> > The attributes will be defined by someone else 
> using the class,
> >so the attributes will not be static.  Any attributes could be set
> >in the format class, and I need to copy them.  I want this to be
> >generic as possible, so I can loop through a set of TD's, set a
> >condition to modify a format, then apply that format to only those
> >records that need it.  I can't just call setBgColor on all the TD's,
> >unless I do some tricks with reflexion to pass the name of the method
> >call.  I want this to be simple and easy for a user.
> >
> > So, my question still remains:
> >
> > How do I copy these attributes from one TD to another?
> >
> > I've tried to create a ConcreteElement and do it like this:
> >
> >   TD data = new TD("Foo");
> > TD format = new TD();
> > format.setBgColor("#CC");
> >
> >   Enumeration formatEKeys = format.attributes();
> > ConcreteElement ce = new ConcreteElement();
> > while (formatEKeys.hasMoreElements()) {
> > String o = (String) formatEKeys.nextElement();
> > System.out.println (o);
> > String value = format.getAttribute(o);
> > System.out.println (value);
> > ce.addElementToRegistry (o, value);
> > System.out.println (ce);
> > data.addElement (ce);
> > }
> > System.out.println (data);
> >
> > I get the following result:
> >
> >bgcolor
> >#CC
> ><>#CC
> >Foo<>#CC
> >
> > Almost, but not quite.  Can someone help me clean up this
> >code so it produces:
> >
> > Foo
> >
> > Thanks yet again.
> >
> > > -Original Message-
> > > From: Klaus Sonnenleiter [mailto:[EMAIL PROTECTED]]
> > >
> > >
> > > Jim,
> > >
> > > You could probably get to where you want to go by looping 
> through the
> > > attributes and copying them one by one. But it seems
> > > unnecessary to me. You
> > > could also create classes that inherit from TD and set some
> > > defaults, like this
> > >
> > > class JimsOwnTD extends TD {
> > >  JimsOwnTD() {
> > >  this("default")
> > >  }
> > >
> > >  JimsOwnTD(String s) {
> > >  super(s);
> > >      this.setBgColor("#FFFFCC");
> > >  }
> > >
> > >  //override other methods here
> > > }
> > >
> > > Then, instead of creating two separate TDs, you'll create
> > > only one JimsOwnTD:
> > >
> > > JimsOwnTD jotd = JimsOwnTD("Foo");
> > >
> > > and it should inherit what you need.
> > >
> > > Klaus
> > >
> > > At 10:48 AM 4/11/2002 -0400, Nemesh, Jim wrote:
> > >
> > >
> > > > > -Original Message-
> > > > > From: Jeremy W. Redmond [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Thursday, April 11, 2002 8:00 AM
> > > > > To: ECS Users List
> > > > > Subject: Re: Help for a new user - Working with elements
> > > > >
> > > > >
> > > > >
> > > > > Posting the code snippet that you are trying might be helpful.
> > > >
> > > > Here's the basic idea:
> > > >
> > > > TD data = new TD("Foo");
> > > >TD format = new TD();
> > > > format.setBgColor("#CC");
> > > > Enumeration formatEKeys = format.attributes();
> > > > while (formatEKeys.hasMoreElements()) {
> > > >   

Re: Help for a new user - Working with elements

2002-04-11 Thread snagy

Ok,

Let me see if I understand this.  You basically are creating an element that
is formatted but contains no information, and you want to apply that
elements format to another element.  Is that right?  There are currently no
merge(Element e1, Element e2) functions.  You could do a couple of things.
Create you format element and clone() it before adding any childelements to
the clone, or you could call attributes() and go through the enumeration and
getAttribute(enum.nextElement()) and populate an empty element that way.  If
this isn't what you are wanting to do let me know and I'll try and think up
another suggestion.  I'll re-subscribe to this list tommorrow from my new
work addy so I can get back to you a little quicker next time.

-stephan


- Original Message -
From: "Nemesh, Jim" <[EMAIL PROTECTED]>
To: "'ECS Users List'" <[EMAIL PROTECTED]>
Cc: "Lemaire, Joe" <[EMAIL PROTECTED]>
Sent: Thursday, April 11, 2002 12:50 PM
Subject: RE: Help for a new user - Working with elements


> How's that?
>
> Isn't the line:
> Enumeration formatEKeys = format.attributes();
> getting the attributes?
>
> Then:
> while (formatEKeys.hasMoreElements()) {
> String o = (String) formatEKeys.nextElement();
>
> Iterating through those attributes?
>
> -Jim
>
>
> > -Original Message-
> > From: Klaus Sonnenleiter [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, April 11, 2002 12:02 PM
> > To: ECS Users List
> > Subject: RE: Help for a new user - Working with elements
> >
> >
> > In that case, your problem is you're going through the elements, not
> > through the attributes.
> >
> > At 11:50 AM 4/11/2002 -0400, you wrote:
> > >Here's the trick:
> > >
> > > The attributes will be defined by someone else
> > using the class,
> > >so the attributes will not be static.  Any attributes could be set
> > >in the format class, and I need to copy them.  I want this to be
> > >generic as possible, so I can loop through a set of TD's, set a
> > >condition to modify a format, then apply that format to only those
> > >records that need it.  I can't just call setBgColor on all the TD's,
> > >unless I do some tricks with reflexion to pass the name of the method
> > >call.  I want this to be simple and easy for a user.
> > >
> > > So, my question still remains:
> > >
> > > How do I copy these attributes from one TD to another?
> > >
> > > I've tried to create a ConcreteElement and do it like this:
> > >
> > >   TD data = new TD("Foo");
> > > TD format = new TD();
> > > format.setBgColor("#CC");
> > >
> > >   Enumeration formatEKeys = format.attributes();
> > > ConcreteElement ce = new ConcreteElement();
> > > while (formatEKeys.hasMoreElements()) {
> > > String o = (String) formatEKeys.nextElement();
> > > System.out.println (o);
> > > String value = format.getAttribute(o);
> > > System.out.println (value);
> > > ce.addElementToRegistry (o, value);
> > > System.out.println (ce);
> > > data.addElement (ce);
> > > }
> > > System.out.println (data);
> > >
> > > I get the following result:
> > >
> > >bgcolor
> > >#CC
> > ><>#CC
> > >Foo<>#CC
> > >
> > > Almost, but not quite.  Can someone help me clean up this
> > >code so it produces:
> > >
> > > Foo
> > >
> > > Thanks yet again.
> > >
> > > > -Original Message-
> > > > From: Klaus Sonnenleiter [mailto:[EMAIL PROTECTED]]
> > > >
> > > >
> > > > Jim,
> > > >
> > > > You could probably get to where you want to go by looping
> > through the
> > > > attributes and copying them one by one. But it seems
> > > > unnecessary to me. You
> > > > could also create classes that inherit from TD and set some
> > > > defaults, like this
> > > >
> > > > class JimsOwnTD extends TD {
> > > >  JimsOwnTD() {
> > > >  this("default")
> > > >  }
> > > >
> > > >  JimsOwnTD(String s) {
> > > >