How does the Original Java Code compare w/ the JAVA Code produced by NetRexx?
Bob Hamilton Richardson Texas USA On Mon, Jan 16, 2012 at 1:04 PM, <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by kenner
*really GREAT* conversation!
Thank you all! Thomas. O==) Am 16.01.2012 16:31, schrieb [hidden email]
--
Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
In reply to this post by Robert L Hamilton
C:\Documents and Settings\keklein\My Documents\REXX\NetRexx\FocusConceptsDemoProject\src\misc+ Mon 01/16/2012 15:28 > type FocusConceptsDemo.java.keep /* Generated from 'FocusConceptsDemo.nrx' 16 Jan 2012 15:28:08 [v3.01] *//* Options: Crossref Decima l Java Logo Trace2 Verbose3 */package misc; public class FocusConceptsDemo extends javax.swing.JPanel{private static final java.lang.String $0=" FocusConceptsDemo.nrx"; /* properties static */ protected static javax.swing.JFrame frame; protected static netrexx.lang.Rexx properties; protected static javax.swing.JTextField t1; protected static javax.swing.JTextField t2; protected static javax.swing.JTextField t3; protected static javax.swing.JTextField t4; protected static javax.swing.JButton b1; protected static javax.swing.JButton b2; protected static javax.swing.JButton b3; protected static javax.swing.JButton b4; protected static javax.swing.JTextArea text1; public FocusConceptsDemo(){ super((java.awt.LayoutManager)(new java.awt.BorderLayout()));javax.swing.JPanel buttonPanel=null;jav ax.swing.JPanel textAreaPanel=null;javax.swing.JPanel textFieldPanel=null; b1=new javax.swing.JButton("JButton"); b4=new javax.swing.JButton("JButton"); b3=new javax.swing.JButton("JButton"); b2=new javax.swing.JButton("JButton"); buttonPanel=new javax.swing.JPanel((java.awt.LayoutManager)(new java.awt.GridLayout(1,1))); buttonPanel.add((java.awt.Component)b1); buttonPanel.add((java.awt.Component)b3); buttonPanel.add((java.awt.Component)b2); buttonPanel.add((java.awt.Component)b4); text1=new javax.swing.JTextArea("JTextArea",15,40); textAreaPanel=new javax.swing.JPanel((java.awt.LayoutManager)(new java.awt.BorderLayout())); textAreaPanel.add((java.awt.Component)text1,(java.lang.Object)java.awt.BorderLayout.CENTER); t1=new javax.swing.JTextField("JTextField"); t4=new javax.swing.JTextField("JTextField"); t3=new javax.swing.JTextField("JTextField"); t2=new javax.swing.JTextField("JTextField"); textFieldPanel=new javax.swing.JPanel((java.awt.LayoutManager)(new java.awt.GridLayout(1,1))); textFieldPanel.add((java.awt.Component)t2); textFieldPanel.add((java.awt.Component)t1); textFieldPanel.add((java.awt.Component)t4); textFieldPanel.add((java.awt.Component)t3); add((java.awt.Component)buttonPanel,(java.lang.Object)java.awt.BorderLayout.PAGE_START); add((java.awt.Component)textAreaPanel,(java.lang.Object)java.awt.BorderLayout.CENTER); add((java.awt.Component)textFieldPanel,(java.lang.Object)java.awt.BorderLayout.PAGE_END); setBorder(javax.swing.BorderFactory.createEmptyBorder(20,20,20,20));return;} protected static void createAndShowGUI(){javax.swing.JComponent newContentPane=null; frame=new javax.swing.JFrame("FocusConceptsDemo"); frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); newContentPane=(javax.swing.JComponent)(new misc.FocusConceptsDemo()); newContentPane.setOpaque(isTrue()); frame.setContentPane((java.awt.Container)newContentPane); frame.pack(); frame.setVisible(isTrue());return;} public static boolean isTrue(){ return (1==1);} public static boolean isFalse(){ return new netrexx.lang.Rexx(isTrue()).OpNot(null);} public static void main(java.lang.String args[]) throws java.lang.ClassNotFoundException,java.lang.I nstantiationException,java.lang.IllegalAccessException,javax.swing.UnsupportedLookAndFeelException{ javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); javax.swing.UIManager.put((java.lang.Object)"swing.boldMetal",(java.lang.Object)java.lang.Boolean.FA LSE); javax.swing.SwingUtilities.invokeLater((java.lang.Runnable)(new misc.FocusConceptsDemo.RunnableImp() ));return;} static class RunnableImp implements java.lang.Runnable{private final transient java.lang.String $0=" FocusConceptsDemo.nrx"; public void run(){ misc.FocusConceptsDemo.createAndShowGUI(); return;}public RunnableImp(){return;}}} C:\Documents and Settings\keklein\My Documents\REXX\NetRexx\FocusConceptsDemoProject\src\misc+ Mon 01/16/2012 15:28 Kenneth Klein _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by kenner
On 01/16/2012 08:04 PM, [hidden email] wrote:
> Is the source to java2nrx written in netrexx? Is it available? > java2nrx is not written in NetRexx. I took the Java 1.5 parser and Abstract Syntax Tree from http://code.google.com/p/javaparser and modified the DumpVisitor.java code to emit NetRexx instead of Java. Spared me writing the whole AST parsing code. Thus not written in NetRexx, and not easily translated because of the frequent use of type definitions, which do not have an equivalent in NetRexx. Source code available (easily imported as eclipse project) at http://kenai.com/nonav/projects/netrexx/sources/svn-contrib/show/tags/java2nrx-V1.0.0/java2nrx?rev=38 Feel free to contribute Marc _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by kenner
On 16 January 2012 11:04, <[hidden email]> wrote:
As has been mentioned earlier Runnable isn't a class it's an interface. In Java (and NetRexx) parlance an interface describes the things a class should do, but doesn't implement them. It's an OO inheritance trick to allow library objects to call your classes via predefined methods. (The phrase "call back" and/or "user exit" spring to mind.) When you create a class and implement an interface your class becomes a subclass of that interface. In the example what you've done is create a class (FocusConceptsDemo.RunnableImp) that "is a" Runnable object when it comes into existence. Java's threading model (which is used by Swing to do it's stuff) expects your "call back" to be an object of type Runnable so it can call the run method when it's ready. You set the chain in motion from your main method by calling javax.swing.SwingUtilities.invokeLater and once Swing has all its ducks in a row it will call your run method to execute your code. Easy really (ha!)
Alan. PS You can fix the compile problems in the exception handler section by giving each exception variable a unique name. i.e. do UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") catch ex1=UnsupportedLookAndFeelException ex1.printStackTrace() catch ex2=IllegalAccessException ex2.printStackTrace() catch ex3=InstantiationException ex3.printStackTrace() catch ex4=ClassNotFoundException ex4.printStackTrace() end Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Alan
-- Needs more cowbell. |
In reply to this post by Marc Remes-2
Good, and also funny point, Marc!
Hence, what is the problem with Java2Nrx ?? Thomas. ============================================================== Am 16.01.2012 21:36, schrieb Marc Remes: > On 01/16/2012 08:04 PM, [hidden email] wrote: >> Is the source to java2nrx written in netrexx? Is it available? >> > > java2nrx is not written in NetRexx. I took the Java 1.5 parser and > Abstract Syntax Tree > from http://code.google.com/p/javaparser and modified the > DumpVisitor.java code to emit NetRexx instead of Java. > Spared me writing the whole AST parsing code. > Thus not written in NetRexx, and not easily translated because of the > frequent use of type definitions, which do not have an equivalent in > NetRexx. > > Source code available (easily imported as eclipse project) at > http://kenai.com/nonav/projects/netrexx/sources/svn-contrib/show/tags/java2nrx-V1.0.0/java2nrx?rev=38 > > > Feel free to contribute > > Marc > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > -- Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
In reply to this post by Marc Remes-2
On 1/16/2012 2:36 PM, Marc Remes wrote:
> > Source code available (easily imported as eclipse project) at > http://kenai.com/nonav/projects/netrexx/sources/svn-contrib/show/tags/java2nrx-V1.0.0/java2nrx?rev=38 > > I would dearly love to know how this is done. I fired up Eclipse, I had the above URL in my Paste buffer, but never did see any obvious way to make the two communicate. In explication: I did most of my work in the past in Netbeans, but have now "migrated" to Eclipse ... where I remain a complete noob (outside of some clearly spelled-out tasks). Even if I never build Java2Nrx, I'd appreciate knowing how to achieve this level of integration between SVN and Eclipse. More details greatly appreciated! Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by alansam
Actually, Runnable is much simpler than that: It tells Java exactly
one thing - This program has a method called "run". That's all it
does. It is needed because Java looks for a method called "run" when
it needs to start a new thread for a program.
In the simplest case (one extra thread), you don't even need to create another class to use it - just add "implements Runnable" to your main class statement and you can put the run method for your "subtask" thread right in with your other code. Here is a simple example of creating a thread for your program which does something once every second (increment a counter or update a progress display, etc): -------------------------- NetRexx sample code ThreadDemo.nrx ------------------------------- class ThreadDemo implements Runnable properties static myinstance=ThreadDemo null savedthread=Thread null method main(is=String[]) static myinstance=ThreadDemo() -- Load this program (create instance) if savedthread=null then do -- If subtask has not been started savedthread=Thread(myinstance) -- create subtask to do something every second savedthread.start -- start the subtask thread end say "get on with the main stuff " /* now get on with the program stuff */ method run loop forever Thread.sleep(1000) -- sleep for 1 second if savedthread=null then return say "do something now" /* do something every second here */ catch ie=InterruptedException say ie.toString end -------------------------- End of NetRexx sample code: ------------------------------- I use the above technique often for simple threading requirements. You can just set the "savedthread" variable to null at any time in your main program to cause the subtask thread to terminate. (If you start the above sample with "nrc -run ThreadDemo", you can end it with CTRL-C ) -- Kermit On 1/16/2012 12:47 PM, Alan Sampson wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by alansam
I still don't know why, but your code fixes do work. They compile at least. Don't know how I would test the exceptions. Now I am trying to understand how to control the order and selection of components eligible for focus. I want to skip some textboxes that are for display only. On to the KeyboardFocusManager! Kenneth Klein Systems Specialist 502-868-3644 859-750-5179 (Cell) 502-868-2298 (Fax) [hidden email]
On 16 January 2012 11:04, <kenneth.klein@...> wrote: Here is another sample from the java tutorial, converted to netrexx and working. The conversion with java2nrx was fairly complete. A couple stray curly brackets survived. A couple properties keywords were superfluously created. The exception processing didn't compile so it's just commented out. And I still don't understand how the class "Runnable" works, but I just blindly followed Alan's tips like with ButtonDemo. As has been mentioned earlier Runnable isn't a class it's an interface. In Java (and NetRexx) parlance an interface describes the things a class should do, but doesn't implement them. It's an OO inheritance trick to allow library objects to call your classes via predefined methods. (The phrase "call back" and/or "user exit" spring to mind.) When you create a class and implement an interface your class becomes a subclass of that interface. In the example what you've done is create a class (FocusConceptsDemo.RunnableImp) that "is a" Runnable object when it comes into existence. Java's threading model (which is used by Swing to do it's stuff) expects your "call back" to be an object of type Runnable so it can call the run method when it's ready. You set the chain in motion from your main method by calling javax.swing.SwingUtilities.invokeLater and once Swing has all its ducks in a row it will call your run method to execute your code. Easy really (ha!) Alan. PS You can fix the compile problems in the exception handler section by giving each exception variable a unique name. i.e. do UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") catch ex1=UnsupportedLookAndFeelException ex1.printStackTrace() catch ex2=IllegalAccessException ex2.printStackTrace() catch ex3=InstantiationException ex3.printStackTrace() catch ex4=ClassNotFoundException ex4.printStackTrace() end -- Can't tweet, won't tweet!_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 17 January 2012 08:12, <[hidden email]> wrote: --
The exception handling code wouldn't compile "out of the box" because the generated code was attempting to redefine the type of the ex variable. This would be OK in Java because the variables are treated as being in different scopes. Because NetRexx is more dynamic and you don't need to predefine variables it was protecting you from clobbering something you'd already created.
The way I chose to solve the compilation was to create different variables for each exception case. I could equally have predefined ex as an Exception and it would have compiled too. I chose to do it the way I did for clarity only. Here's a sample the alternative:
ex = Exception do
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") catch ex=UnsupportedLookAndFeelException ex.printStackTrace() catch ex=IllegalAccessException ex.printStackTrace() catch ex=InstantiationException ex.printStackTrace() catch ex=ClassNotFoundException ex.printStackTrace() end If you want to test the exception handling code you could just stuff a signal clause anywhere after the do and the first catch clause. The following program:
/* NetRexx */
options replace format comments java crossref symbols binary import javax.swing. ex = Exception loop for 50 do gronk() catch ex = UnsupportedLookAndFeelException
ex.printStackTrace(System.out) catch ex = IllegalAccessException ex.printStackTrace(System.out) catch ex = InstantiationException ex.printStackTrace(System.out)
catch ex = ClassNotFoundException ex.printStackTrace(System.out) end end say 'All done' return
method gronk static signals UnsupportedLookAndFeelException, - IllegalAccessException, - InstantiationException, - ClassNotFoundException
rx = Random() ri = rx.nextInt(4) say '>>>' ri select case ri when 0 then signal IllegalAccessException() when 1 then
signal UnsupportedLookAndFeelException("L&F") when 2 then signal InstantiationException() otherwise signal ClassNotFoundException()
end will drive the catch blocks. Alan. Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Alan
-- Needs more cowbell. |
In reply to this post by Tom Maynard
As an example of the integration between SVN and eclipse,
here's the list of things to do to check out the java2nrx project from kenai SVN into eclipse. Install eclipse 3.6 or 3.7, helios or indigo download Eclipse IDE for Java EE Developers, most complete Install eclipse subversive plugin Help -> Install New Software Work with standard site : http://download.eclipse.org/releases/indigo or helios In Collaboration, select 'Subversive SVN Team provider' Press Next Select again and Next Accept terms and Finish Restart now after Installing Software Window -> Open Perspective -> Other -> SVN Repository Exploring From Subversive Connector Discovery, select SVN Kit 1.3.5 and Finish Install both proposed additional items, Subversive SVN Connectors and SVNKit, Next, Next Accept terms and Finish OK for unsigned content Restart now Connect to kenai SVN repository Create SSH public/private key (or use existing) Login to http://kenai.com/ with $USERNAME and $PASSWORD My page -> Edit My Profile -> SSH keys tab Add Public Key In eclipse, from the SVN Repository perspective, right-click in the 'SVN Repositories' view New -> Repository Location URL svn+ssh://$[hidden email]/netrexx~svn-contrib where $USERNAME is your kenai username as found on View Public Profile Authentication credentials, $USERNAME and PASSWORD Check 'Save authentication' On the SSH Settings, check Private Key and browse to your Private key file, Enter passphrase if keypair is protected by passphrase Finish You will be prompted for local password vault to store the given credentials In the SVN Repositories, you should be able to browse the svn.kenai.com/netrexx~svn-contrib repository Get the source, several ways.. Window -> Open Perspective -> Java File -> New -> Java Project Project name: java2nrx Finish Right click on java2nrx directory Team -> Share Project -> SVN -> Next Use existing repository location -> Next -> Simple Mode URL: svn+ssh://$[hidden email]/netrexx~svn-contrib/java2nrx Finish .. already exist, wish to proceed -> Yes Voilà Marc _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 1/17/2012 3:51 PM, Marc Remes wrote:
> As an example of the integration between SVN and eclipse, > here's the list of things to do to check out the java2nrx project from > kenai SVN into eclipse. > > Thank you, Marc, for the detailed, step-by-step procedure. I'll be working my way through these steps as soon as tomorrow. I'll also make an effort to preserve these instructions for future reference by others. This is a great piece of knowledge, for anyone working with Eclipse and SVN. Tom. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Marc Remes-2
Thank you, Marc, for publishing this!
Thomas. ============================================================================ Am 17.01.2012 22:51, schrieb Marc Remes: > As an example of the integration between SVN and eclipse, > here's the list of things to do to check out the java2nrx project from > kenai SVN into eclipse. > > > Install eclipse 3.6 or 3.7, helios or indigo > download Eclipse IDE for Java EE Developers, most complete > > Install eclipse subversive plugin > Help -> Install New Software > Work with standard site : > http://download.eclipse.org/releases/indigo or helios > In Collaboration, select 'Subversive SVN Team provider' > Press Next > Select again and Next > Accept terms and Finish > Restart now after Installing Software > > Window -> Open Perspective -> Other -> SVN Repository Exploring > From Subversive Connector Discovery, select SVN Kit 1.3.5 and Finish > Install both proposed additional items, Subversive SVN Connectors > and SVNKit, Next, Next > Accept terms and Finish > OK for unsigned content > Restart now > > Connect to kenai SVN repository > Create SSH public/private key (or use existing) > Login to http://kenai.com/ with $USERNAME and $PASSWORD > My page -> Edit My Profile -> SSH keys tab > Add Public Key > > In eclipse, from the SVN Repository perspective, right-click in the > 'SVN Repositories' view > New -> Repository Location > URL svn+ssh://$[hidden email]/netrexx~svn-contrib > where $USERNAME is your kenai username as found on View Public > Profile > Authentication credentials, $USERNAME and PASSWORD > Check 'Save authentication' > On the SSH Settings, check Private Key and browse to your Private > key file, > Enter passphrase if keypair is protected by passphrase > Finish > You will be prompted for local password vault to store the given > credentials > In the SVN Repositories, you should be able to browse the > svn.kenai.com/netrexx~svn-contrib repository > > Get the source, several ways.. > Window -> Open Perspective -> Java > File -> New -> Java Project > Project name: java2nrx > Finish > Right click on java2nrx directory > Team -> Share Project -> SVN -> Next > Use existing repository location -> Next -> Simple Mode > URL: svn+ssh://$[hidden email]/netrexx~svn-contrib/java2nrx > Finish > .. already exist, wish to proceed -> Yes > Voilà > > > Marc > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > -- Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
Free forum by Nabble | Edit this page |