[jboss-cvs] JBossAS SVN: r78750 - in projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper: manager and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 22 07:34:51 EDT 2008


Author: stalep
Date: 2008-09-22 07:34:51 -0400 (Mon, 22 Sep 2008)
New Revision: 78750

Added:
   projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/
   projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/CompileManager.java
   projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/RunManager.java
Log:
[JBAOP-538]
Implemented run mode.


Added: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/CompileManager.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/CompileManager.java	                        (rev 0)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/CompileManager.java	2008-09-22 11:34:51 UTC (rev 78750)
@@ -0,0 +1,180 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.aophelper.manager;
+
+import java.io.File;
+
+import org.jboss.aophelper.core.Action;
+import org.jboss.aophelper.core.AopHandler;
+import org.jboss.aophelper.core.AopOption;
+import org.jboss.aophelper.ui.AopHelperMediator;
+import org.jboss.aophelper.ui.compile.CompileMediator;
+import org.jboss.aophelper.util.AopCompileCommand;
+
+/**
+ * A CompileManager.
+ * 
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompileManager
+{
+   private CompileMediator mediator;
+   
+   public CompileManager()
+   {
+      mediator = CompileMediator.instance();
+   }
+
+   public void performAction(Action a, AopOption to)
+   {
+      if(a.equals(Action.ADD))
+      {
+         if(to.equals(AopOption.CLASSPATH))
+            addClasspath();
+         else if(to.equals(AopOption.AOPXML))
+            addXml();
+         else if(to.equals(AopOption.SUPPRESS))
+            setSuppress(true);
+         else if(to.equals(AopOption.VERBOSE))
+            setVerbose(true);
+         else if(to.equals(AopOption.NOOPT))
+            setNoopt(true);
+      }
+      else if(a.equals(Action.REMOVE))
+      {
+         if(to.equals(AopOption.CLASSPATH))
+            removeClasspath();
+         else if(to.equals(AopOption.AOPXML))
+            removeXml();
+         else if(to.equals(AopOption.SUPPRESS))
+            setSuppress(false);
+         else if(to.equals(AopOption.VERBOSE))
+            setVerbose(false);
+         else if(to.equals(AopOption.NOOPT))
+            setNoopt(false);
+      }
+      else if(a.equals(Action.SET))
+      {
+         if(to.equals(AopOption.WORKINGDIR))
+            setWorkingdir();
+      }
+      else if(a.equals(Action.RUN))
+      {
+        compile();
+      }
+      
+   }
+   
+   private void addClasspath()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      
+      System.out.println("got "+files.length+" number of files");
+      
+      for(File f : files)
+      {
+         AopHandler.instance().getCompile().addClasspath(f.getAbsolutePath());
+         mediator.getClasspathModel().addRow(f.getAbsolutePath());
+      }
+   }
+   
+   private void removeClasspath()
+   {
+      String selected = mediator.getClasspathTable().getSelectedItem();
+      if(selected != null)
+      {
+         AopHandler.instance().getCompile().removeClasspath(selected);
+         mediator.getClasspathModel().removeRow(selected);
+         mediator.getClasspathTable().clearSelectedItem();
+      }
+   }
+
+   private void addXml()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      
+      System.out.println("got "+files.length+" number of files");
+      
+      for(File f : files)
+      {
+         AopHandler.instance().getCompile().addXml(f.getAbsolutePath());
+         mediator.getXmlModel().addRow(f.getAbsolutePath());
+      }
+   }
+   
+   private void removeXml()
+   {
+      String selected = mediator.getXmlTable().getSelectedItem();
+      if(selected != null)
+      {
+         AopHandler.instance().getCompile().removeClasspath(selected);
+         mediator.getXmlModel().removeRow(selected);
+         mediator.getXmlTable().clearSelectedItem();
+      }
+   }
+   
+   private void setVerbose(boolean verbose)
+   {
+      AopHandler.instance().getCompile().setVerbose(verbose);
+   }
+   
+   private void setSuppress(boolean suppress)
+   {
+      AopHandler.instance().getCompile().setSuppress(suppress);
+   }
+   
+   private void setNoopt(boolean noopt)
+   {
+      AopHandler.instance().getCompile().setNoopt(noopt);
+   }
+   
+   private void setWorkingdir()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      for(File f : files)
+      {
+         AopHandler.instance().getCompile().setWorkingdir(f.getAbsolutePath());
+         mediator.getCompileOptionsPane().setWorkingDir(f.getAbsolutePath());
+      }
+   }
+   
+   private void compile()
+   {
+      System.out.println("LETS COMPILE!");
+      AopCompileCommand compile = new AopCompileCommand();
+      String output = compile.execute();
+      mediator.getOutputPane().setText(output);
+      System.out.println("output: "+output);
+//      
+//      java.util.Properties props = System.getProperties();
+//      java.util.Enumeration<?> e = props.propertyNames();
+//      
+//      while(e.hasMoreElements())
+//         System.out.println(e.toString());
+      
+      System.out.println("CLASSPATH: "+System.getProperty("java.class.path"));
+
+   }
+   
+   
+}

Added: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/RunManager.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/RunManager.java	                        (rev 0)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/manager/RunManager.java	2008-09-22 11:34:51 UTC (rev 78750)
@@ -0,0 +1,208 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.aophelper.manager;
+
+import java.io.File;
+
+import org.jboss.aophelper.core.Action;
+import org.jboss.aophelper.core.AopHandler;
+import org.jboss.aophelper.core.AopOption;
+import org.jboss.aophelper.ui.AopHelperMediator;
+import org.jboss.aophelper.ui.run.RunMediator;
+import org.jboss.aophelper.util.AopRunCommand;
+
+/**
+ * A RunManager.
+ * 
+ * @author <a href="stalep at gmail.com">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class RunManager
+{
+
+   private RunMediator runMediator;
+   
+   public RunManager()
+   {
+      runMediator = RunMediator.instance();
+   }
+   
+   public void performAction(Action a, AopOption to)
+   {
+      if(a.equals(Action.ADD))
+      {
+         if(to.equals(AopOption.CLASSPATH))
+            addClasspath();
+         else if(to.equals(AopOption.AOPXML))
+            addXml();
+         else if(to.equals(AopOption.SUPPRESS))
+            setSuppress(true);
+         else if(to.equals(AopOption.VERBOSE))
+            setVerbose(true);
+         else if(to.equals(AopOption.NOOPT))
+            setNoopt(true);
+         else if(to.equals(AopOption.LOADTIME))
+            setLoadtime(true);
+      }
+      else if(a.equals(Action.REMOVE))
+      {
+         if(to.equals(AopOption.CLASSPATH))
+            removeClasspath();
+         else if(to.equals(AopOption.AOPXML))
+            removeXml();
+         else if(to.equals(AopOption.SUPPRESS))
+            setSuppress(false);
+         else if(to.equals(AopOption.VERBOSE))
+            setVerbose(false);
+         else if(to.equals(AopOption.NOOPT))
+            setNoopt(false);
+         else if(to.equals(AopOption.LOADTIME))
+            setLoadtime(false);
+      }
+      else if(a.equals(Action.SET))
+      {
+         if(to.equals(AopOption.WORKINGDIR))
+            setWorkingdir();
+         else if(to.equals(AopOption.EXECLASS))
+            setExecutionClass();
+      }
+      else if(a.equals(Action.RUN))
+      {
+        run();
+      }
+      
+   }
+   
+   private void addClasspath()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      
+      System.out.println("got "+files.length+" number of files");
+      
+      for(File f : files)
+      {
+         AopHandler.instance().getRun().addClasspath(f.getAbsolutePath());
+         runMediator.getRunClasspathModel().addRow(f.getAbsolutePath());
+      }
+   }
+   
+   private void removeClasspath()
+   {
+      String selected = runMediator.getRunClasspathTable().getSelectedItem();
+      if(selected != null)
+      {
+         AopHandler.instance().getRun().removeClasspath(selected);
+         runMediator.getRunClasspathModel().removeRow(selected);
+         runMediator.getRunClasspathTable().clearSelectedItem();
+      }
+   }
+
+   private void addXml()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      
+      System.out.println("got "+files.length+" number of files");
+      
+      for(File f : files)
+      {
+         AopHandler.instance().getRun().addXml(f.getAbsolutePath());
+         runMediator.getRunXmlModel().addRow(f.getAbsolutePath());
+      }
+   }
+   
+   private void removeXml()
+   {
+      String selected = runMediator.getRunXmlTable().getSelectedItem();
+      if(selected != null)
+      {
+         AopHandler.instance().getRun().removeClasspath(selected);
+         runMediator.getRunXmlModel().removeRow(selected);
+         runMediator.getRunXmlTable().clearSelectedItem();
+      }
+   }
+   
+   private void setVerbose(boolean verbose)
+   {
+      AopHandler.instance().getRun().setVerbose(verbose);
+   }
+   
+   private void setSuppress(boolean suppress)
+   {
+      AopHandler.instance().getRun().setSuppress(suppress);
+   }
+   
+   private void setNoopt(boolean noopt)
+   {
+      AopHandler.instance().getRun().setNoopt(noopt);
+   }
+   
+   private void setLoadtime(boolean runtime)
+   {
+      AopHandler.instance().getRun().setLoadtime(runtime);
+   }
+   
+   
+   private void setWorkingdir()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      for(File f : files)
+      {
+         AopHandler.instance().getRun().setWorkingdir(f.getAbsolutePath());
+         runMediator.getRunOptionsPane().setWorkingDir(f.getAbsolutePath());
+      }
+   }
+   
+   private void setExecutionClass()
+   {
+      File[] files = AopHelperMediator.instance().getMainPane().createFileCooser();
+      for(File f : files)
+      {
+         AopHandler.instance().getRun().setExecutionClass(f.getAbsolutePath());
+         runMediator.getRunOptionsPane().setExecutionClass(f.getAbsolutePath());
+      }
+   }
+   
+   private void run()
+   {
+      System.out.println("LETS RUN!");
+      AopRunCommand run = new AopRunCommand();
+      String output = run.execute();
+      runMediator.getRunOutputPane().setText(output);
+      System.out.println("output: "+output);
+      
+//      AopCompileCommand compile = new AopCompileCommand();
+//      String output = compile.execute();
+//      runMediator.getRunOutputPane().setText(output);
+//      System.out.println("output: "+output);
+//      
+//      java.util.Properties props = System.getProperties();
+//      java.util.Enumeration<?> e = props.propertyNames();
+//      
+//      while(e.hasMoreElements())
+//         System.out.println(e.toString());
+      
+      System.out.println("CLASSPATH: "+System.getProperty("java.class.path"));
+
+   }
+   
+   
+}




More information about the jboss-cvs-commits mailing list