[jboss-cvs] JBossAS SVN: r79280 - in projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper: ui and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 8 18:42:24 EDT 2008
Author: stalep
Date: 2008-10-08 18:42:24 -0400 (Wed, 08 Oct 2008)
New Revision: 79280
Added:
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopBaseSettings.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/util/xml/
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/util/xml/BaseConfigParser.java
Modified:
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopCompile.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopRun.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMediator.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMenuBar.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTableModel.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTablePane.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/CompileMediator.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/classpath/ClasspathTablePane.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/options/CompileOptionsPane.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/xml/XmlTablePane.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/RunMediator.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/classpath/RunClasspathTablePane.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/options/RunOptionsPane.java
projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/xml/RunXmlTablePane.java
Log:
[JBAOP-538]
added support to load/save settings.
Added: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopBaseSettings.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopBaseSettings.java (rev 0)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopBaseSettings.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -0,0 +1,241 @@
+/*
+ * 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.core;
+
+import java.util.List;
+
+/**
+ * A AopBaseSettings.
+ *
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class AopBaseSettings
+{
+
+ protected List<String> aopXml;
+ protected List<String> classpath;
+ protected List<String> transformPath;
+
+ /** Set the verbose level of the compiler */
+ protected boolean verbose;
+ protected boolean suppress;
+ protected boolean noopt;
+ protected boolean report;
+ protected String workingdir;
+
+ /**
+ * Create a new AopBaseSettings.
+ *
+ */
+ public AopBaseSettings()
+ {
+ super();
+ }
+
+
+ public void removeClasspath(String cp)
+ {
+ if(classpath.contains(cp))
+ classpath.remove(cp);
+ }
+
+ public void addClasspath(String cp)
+ {
+ if(!classpath.contains(cp))
+ classpath.add(cp);
+ }
+
+
+ public void removeXml(String cp)
+ {
+ if(aopXml.contains(cp))
+ aopXml.remove(cp);
+ }
+
+ public void addXml(String cp)
+ {
+ if(!aopXml.contains(cp))
+ aopXml.add(cp);
+ }
+
+ /**
+ * Get the aopXml.
+ *
+ * @return the aopXml.
+ */
+ public List<String> getAopXml()
+ {
+ return aopXml;
+ }
+
+ /**
+ * Set the aopXml.
+ *
+ * @param aopXml The aopXml to set.
+ */
+ public void setAopXml(List<String> aopXml)
+ {
+ this.aopXml = aopXml;
+ }
+
+ /**
+ * Get the classpath.
+ *
+ * @return the classpath.
+ */
+ public List<String> getClasspath()
+ {
+ return classpath;
+ }
+
+ /**
+ * Set the classpath.
+ *
+ * @param classpath The classpath to set.
+ */
+ public void setClasspath(List<String> classpath)
+ {
+ this.classpath = classpath;
+ }
+
+ /**
+ * Get the transformPath.
+ *
+ * @return the transformPath.
+ */
+ public List<String> getTransformPath()
+ {
+ return transformPath;
+ }
+
+ /**
+ * Set the transformPath.
+ *
+ * @param transformPath The transformPath to set.
+ */
+ public void setTransformPath(List<String> transformPath)
+ {
+ this.transformPath = transformPath;
+ }
+
+ /**
+ * Get the verbose.
+ *
+ * @return the verbose.
+ */
+ public boolean isVerbose()
+ {
+ return verbose;
+ }
+
+ /**
+ * Set the verbose.
+ *
+ * @param verbose The verbose to set.
+ */
+ public void setVerbose(boolean verbose)
+ {
+ this.verbose = verbose;
+ }
+
+ /**
+ * Get the suppress.
+ *
+ * @return the suppress.
+ */
+ public boolean isSuppress()
+ {
+ return suppress;
+ }
+
+ /**
+ * Set the suppress.
+ *
+ * @param suppress The suppress to set.
+ */
+ public void setSuppress(boolean suppress)
+ {
+ this.suppress = suppress;
+ }
+
+ /**
+ * Get the noopt.
+ *
+ * @return the noopt.
+ */
+ public boolean isNoopt()
+ {
+ return noopt;
+ }
+
+ /**
+ * Set the noopt.
+ *
+ * @param noopt The noopt to set.
+ */
+ public void setNoopt(boolean noopt)
+ {
+ this.noopt = noopt;
+ }
+
+ /**
+ * Get the report.
+ *
+ * @return the report.
+ */
+ public boolean isReport()
+ {
+ return report;
+ }
+
+ /**
+ * Set the report.
+ *
+ * @param report The report to set.
+ */
+ public void setReport(boolean report)
+ {
+ this.report = report;
+ }
+
+ /**
+ * Get the workingdir.
+ *
+ * @return the workingdir.
+ */
+ public String getWorkingdir()
+ {
+ return workingdir;
+ }
+
+ /**
+ * Set the workingdir.
+ *
+ * @param workingdir The workingdir to set.
+ */
+ public void setWorkingdir(String workingdir)
+ {
+ this.workingdir = workingdir;
+ }
+
+}
\ No newline at end of file
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopCompile.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopCompile.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopCompile.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -23,7 +23,6 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.List;
/**
* A Compile.
@@ -31,242 +30,20 @@
* @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
* @version $Revision: 1.1 $
*/
-public class AopCompile implements Serializable
+public class AopCompile extends AopBaseSettings implements Serializable
{
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
- private List<String> aopXml;
- private List<String> classpath;
- private List<String> transformPath;
- private List<String> aopClasspath;
- /** Set the verbose level of the compiler */
- private boolean verbose;
-
- private boolean suppress;
-
- private boolean noopt;
-
- private boolean report;
-
- private String workingdir;
-
public AopCompile()
{
aopXml = new ArrayList<String>();
classpath = new ArrayList<String>();
transformPath = new ArrayList<String>();
- aopClasspath = new ArrayList<String>();
setVerbose(true);
}
- /**
- * Get the aopXml.
- *
- * @return the aopXml.
- */
- public List<String> getAopXml()
- {
- return aopXml;
- }
-
- /**
- * Set the aopXml.
- *
- * @param aopXml The aopXml to set.
- */
- public void setAopXml(List<String> aopXml)
- {
- this.aopXml = aopXml;
- }
-
- /**
- * Get the classpath.
- *
- * @return the classpath.
- */
- public List<String> getClasspath()
- {
- return classpath;
- }
-
- /**
- * Set the classpath.
- *
- * @param classpath The classpath to set.
- */
- public void setClasspath(List<String> classpath)
- {
- this.classpath = classpath;
- }
- public void removeClasspath(String cp)
- {
- if(classpath.contains(cp))
- classpath.remove(cp);
- }
-
- public void addClasspath(String cp)
- {
- if(!classpath.contains(cp))
- classpath.add(cp);
- }
-
- public void removeXml(String cp)
- {
- if(aopXml.contains(cp))
- aopXml.remove(cp);
- }
-
- public void addXml(String cp)
- {
- if(!aopXml.contains(cp))
- aopXml.add(cp);
- }
-
- /**
- * Get the transformPath.
- *
- * @return the transformPath.
- */
- public List<String> getTransformPath()
- {
- return transformPath;
- }
-
- /**
- * Set the transformPath.
- *
- * @param transformPath The transformPath to set.
- */
- public void setTransformPath(List<String> transformPath)
- {
- this.transformPath = transformPath;
- }
-
- /**
- * Get the aopClasspath.
- *
- * @return the aopClasspath.
- */
- public List<String> getAopClasspath()
- {
- return aopClasspath;
- }
-
- /**
- * Set the aopClasspath.
- *
- * @param aopClasspath The aopClasspath to set.
- */
- public void setAopClasspath(List<String> aopClasspath)
- {
- this.aopClasspath = aopClasspath;
- }
-
- /**
- * Get the verbose.
- *
- * @return the verbose.
- */
- public boolean isVerbose()
- {
- return verbose;
- }
-
- /**
- * Set the verbose.
- *
- * @param verbose The verbose to set.
- */
- public void setVerbose(boolean verbose)
- {
- this.verbose = verbose;
- }
-
- /**
- * Get the suppress.
- *
- * @return the suppress.
- */
- public boolean isSuppress()
- {
- return suppress;
- }
-
- /**
- * Set the suppress.
- *
- * @param suppress The suppress to set.
- */
- public void setSuppress(boolean suppress)
- {
- this.suppress = suppress;
- }
-
- /**
- * Get the noopt.
- *
- * @return the noopt.
- */
- public boolean isNoopt()
- {
- return noopt;
- }
-
- /**
- * Set the noopt.
- *
- * @param noopt The noopt to set.
- */
- public void setNoopt(boolean noopt)
- {
- System.out.println("setting noopt to: "+noopt);
- this.noopt = noopt;
- }
-
- /**
- * Get the report.
- *
- * @return the report.
- */
- public boolean isReport()
- {
- return report;
- }
-
- /**
- * Set the report.
- *
- * @param report The report to set.
- */
- public void setReport(boolean report)
- {
- this.report = report;
- }
-
- /**
- * Get the workingdir.
- *
- * @return the workingdir.
- */
- public String getWorkingdir()
- {
- return workingdir;
- }
-
- /**
- * Set the workingdir.
- *
- * @param workingdir The workingdir to set.
- */
- public void setWorkingdir(String workingdir)
- {
- this.workingdir = workingdir;
- }
-
-
-
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopRun.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopRun.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/core/AopRun.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -21,8 +21,8 @@
*/
package org.jboss.aophelper.core;
+import java.io.Serializable;
import java.util.ArrayList;
-import java.util.List;
/**
* A AopRun.
@@ -30,28 +30,13 @@
* @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
* @version $Revision: 1.1 $
*/
-public class AopRun
+public class AopRun extends AopBaseSettings implements Serializable
{
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
- private List<String> aopXml;
- private List<String> classpath;
- private List<String> transformPath;
- private List<String> aopClasspath;
-
- /** Set the verbose level of the compiler */
- private boolean verbose;
-
- private boolean suppress;
-
- private boolean noopt;
-
- private boolean report;
-
+
private boolean loadtime;
- private String workingdir;
-
private String executionClass;
public AopRun()
@@ -59,217 +44,10 @@
aopXml = new ArrayList<String>();
classpath = new ArrayList<String>();
transformPath = new ArrayList<String>();
- aopClasspath = new ArrayList<String>();
setVerbose(true);
}
/**
- * Get the aopXml.
- *
- * @return the aopXml.
- */
- public List<String> getAopXml()
- {
- return aopXml;
- }
-
- /**
- * Set the aopXml.
- *
- * @param aopXml The aopXml to set.
- */
- public void setAopXml(List<String> aopXml)
- {
- this.aopXml = aopXml;
- }
-
- /**
- * Get the classpath.
- *
- * @return the classpath.
- */
- public List<String> getClasspath()
- {
- return classpath;
- }
-
- /**
- * Set the classpath.
- *
- * @param classpath The classpath to set.
- */
- public void setClasspath(List<String> classpath)
- {
- this.classpath = classpath;
- }
-
- public void removeClasspath(String cp)
- {
- if(classpath.contains(cp))
- classpath.remove(cp);
- }
-
- public void addClasspath(String cp)
- {
- if(!classpath.contains(cp))
- classpath.add(cp);
- }
-
-
- public void removeXml(String cp)
- {
- if(aopXml.contains(cp))
- aopXml.remove(cp);
- }
-
- public void addXml(String cp)
- {
- if(!aopXml.contains(cp))
- aopXml.add(cp);
- }
-
- /**
- * Get the transformPath.
- *
- * @return the transformPath.
- */
- public List<String> getTransformPath()
- {
- return transformPath;
- }
-
- /**
- * Set the transformPath.
- *
- * @param transformPath The transformPath to set.
- */
- public void setTransformPath(List<String> transformPath)
- {
- this.transformPath = transformPath;
- }
-
- /**
- * Get the aopClasspath.
- *
- * @return the aopClasspath.
- */
- public List<String> getAopClasspath()
- {
- return aopClasspath;
- }
-
- /**
- * Set the aopClasspath.
- *
- * @param aopClasspath The aopClasspath to set.
- */
- public void setAopClasspath(List<String> aopClasspath)
- {
- this.aopClasspath = aopClasspath;
- }
-
- /**
- * Get the verbose.
- *
- * @return the verbose.
- */
- public boolean isVerbose()
- {
- return verbose;
- }
-
- /**
- * Set the verbose.
- *
- * @param verbose The verbose to set.
- */
- public void setVerbose(boolean verbose)
- {
- this.verbose = verbose;
- }
-
- /**
- * Get the suppress.
- *
- * @return the suppress.
- */
- public boolean isSuppress()
- {
- return suppress;
- }
-
- /**
- * Set the suppress.
- *
- * @param suppress The suppress to set.
- */
- public void setSuppress(boolean suppress)
- {
- this.suppress = suppress;
- }
-
- /**
- * Get the noopt.
- *
- * @return the noopt.
- */
- public boolean isNoopt()
- {
- return noopt;
- }
-
- /**
- * Set the noopt.
- *
- * @param noopt The noopt to set.
- */
- public void setNoopt(boolean noopt)
- {
- System.out.println("setting noopt to: "+noopt);
- this.noopt = noopt;
- }
-
- /**
- * Get the report.
- *
- * @return the report.
- */
- public boolean isReport()
- {
- return report;
- }
-
- /**
- * Set the report.
- *
- * @param report The report to set.
- */
- public void setReport(boolean report)
- {
- this.report = report;
- }
-
- /**
- * Get the workingdir.
- *
- * @return the workingdir.
- */
- public String getWorkingdir()
- {
- return workingdir;
- }
-
- /**
- * Set the workingdir.
- *
- * @param workingdir The workingdir to set.
- */
- public void setWorkingdir(String workingdir)
- {
- this.workingdir = workingdir;
- }
-
- /**
* Get the executionClass.
*
* @return the executionClass.
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMediator.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMediator.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMediator.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -21,6 +21,15 @@
*/
package org.jboss.aophelper.ui;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.jboss.aophelper.ui.compile.CompileMediator;
+import org.jboss.aophelper.ui.run.RunMediator;
+import org.jboss.aophelper.util.xml.BaseConfigParser;
+
/**
* A AopHelperMediator.
*
@@ -87,4 +96,42 @@
{
this.mainPane = mainPane;
}
+
+ /**
+ *
+ *
+ */
+ public void loadSettings()
+ {
+ File[] file = mainPane.createFileCooser();
+
+ if(file[0] != null)
+ {
+ BaseConfigParser.parse(file[0]);
+ CompileMediator.instance().refresh();
+ RunMediator.instance().refresh();
+ }
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void saveSettings()
+ {
+
+ File[] file = mainPane.createFileCooser();
+ if(file[0] != null && !file[0].isDirectory())
+ {
+ System.out.println("saving to file: "+file[0].getAbsoluteFile());
+ String output = BaseConfigParser.getDOMAsString();
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter(file[0].getAbsoluteFile()));
+ out.write(output);
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+ }
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMenuBar.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMenuBar.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/AopHelperMenuBar.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -54,6 +54,7 @@
private void init()
{
add(createFileMenu());
+ add(createEditMenu());
add(Box.createHorizontalGlue());
add(createHelpMenu());
@@ -139,6 +140,36 @@
return fileMenu;
}
+ private JMenu createEditMenu()
+ {
+ JMenu editMenu = new JMenu("Edit");
+ editMenu.setMnemonic('E');
+
+ JMenuItem save = new JMenuItem("Save settings", 'S');
+ save.setAccelerator(KeyStroke.getKeyStroke('S',
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
+ save.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event)
+ {
+ AopHelperMediator.instance().saveSettings();
+ }
+ });
+ editMenu.add(save);
+
+ JMenuItem load = new JMenuItem( "Load settings", 'L');
+ load.setAccelerator(KeyStroke.getKeyStroke('L',
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
+ load.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event)
+ {
+ AopHelperMediator.instance().loadSettings();
+ }
+ });
+ editMenu.add(load);
+
+ return editMenu;
+ }
+
public void setCompileMode()
{
compile.setEnabled(false);
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTableModel.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTableModel.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTableModel.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -113,6 +113,21 @@
fireTableDataChanged();
}
}
+
+ public void addRows(List<String> newRows)
+ {
+ for(String row : newRows)
+ {
+ addRow(row);
+ }
+ }
+
+ public void clearRows()
+ {
+ getData().clear();
+ rows = 0;
+ fireTableDataChanged();
+ }
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTablePane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTablePane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/GenericEditTablePane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -44,7 +44,6 @@
private static final long serialVersionUID = 1L;
private JTable table;
-// private ClasspathTableModel tableModel;
private JScrollPane scrollPane;
private int selectedRow;
private String selected;
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/CompileMediator.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/CompileMediator.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/CompileMediator.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -149,6 +149,13 @@
{
this.outputPane = outputPane;
}
+
+ public void refresh()
+ {
+ classpathTable.refresh();
+ xmlTable.refresh();
+ compileOptionsPane.refresh();
+ }
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/classpath/ClasspathTablePane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/classpath/ClasspathTablePane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/classpath/ClasspathTablePane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -87,6 +87,11 @@
tableModel.addRow(path);
AopHandler.instance().getCompile().addClasspath(path);
}
-
}
+
+ public void refresh()
+ {
+ tableModel.clearRows();
+ tableModel.addRows(AopHandler.instance().getCompile().getClasspath());
+ }
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/options/CompileOptionsPane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/options/CompileOptionsPane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/options/CompileOptionsPane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -39,6 +39,7 @@
import org.jboss.aophelper.annotation.AopHelperAction;
import org.jboss.aophelper.core.Action;
+import org.jboss.aophelper.core.AopHandler;
import org.jboss.aophelper.core.AopOption;
import org.jboss.aophelper.core.AopState;
import org.jboss.aophelper.ui.compile.CompileMediator;
@@ -216,5 +217,15 @@
{
workingdir.setText(dir);
}
+
+
+ public void refresh()
+ {
+ setWorkingDir(AopHandler.instance().getCompile().getWorkingdir());
+ verbose.setSelected(AopHandler.instance().getCompile().isVerbose());
+ noopt.setSelected(AopHandler.instance().getCompile().isNoopt());
+ suppress.setSelected(AopHandler.instance().getCompile().isSuppress());
+ }
+
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/xml/XmlTablePane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/xml/XmlTablePane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/compile/xml/XmlTablePane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -23,6 +23,7 @@
import org.jboss.aophelper.annotation.AopHelperAction;
import org.jboss.aophelper.core.Action;
+import org.jboss.aophelper.core.AopHandler;
import org.jboss.aophelper.core.AopOption;
import org.jboss.aophelper.core.AopState;
import org.jboss.aophelper.ui.GenericEditTableModel;
@@ -78,4 +79,10 @@
}
+ public void refresh()
+ {
+ tableModel.clearRows();
+ tableModel.addRows(AopHandler.instance().getCompile().getAopXml());
+ }
+
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/RunMediator.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/RunMediator.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/RunMediator.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -165,4 +165,11 @@
{
this.runOutputPane = runOutputPane;
}
+
+ public void refresh()
+ {
+ runClasspathTable.refresh();
+ runXmlTable.refresh();
+ runOptionsPane.refresh();
+ }
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/classpath/RunClasspathTablePane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/classpath/RunClasspathTablePane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/classpath/RunClasspathTablePane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -89,5 +89,11 @@
}
}
+
+ public void refresh()
+ {
+ tableModel.clearRows();
+ tableModel.addRows(AopHandler.instance().getRun().getClasspath());
+ }
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/options/RunOptionsPane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/options/RunOptionsPane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/options/RunOptionsPane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -39,6 +39,7 @@
import org.jboss.aophelper.annotation.AopHelperAction;
import org.jboss.aophelper.core.Action;
+import org.jboss.aophelper.core.AopHandler;
import org.jboss.aophelper.core.AopOption;
import org.jboss.aophelper.core.AopState;
import org.jboss.aophelper.ui.run.RunMediator;
@@ -278,5 +279,15 @@
{
executionClass.setText(exeClass);
}
+
+ public void refresh()
+ {
+ setWorkingDir(AopHandler.instance().getRun().getWorkingdir());
+ setExecutionClass(AopHandler.instance().getRun().getExecutionClass());
+ verbose.setSelected(AopHandler.instance().getRun().isVerbose());
+ noopt.setSelected(AopHandler.instance().getRun().isNoopt());
+ suppress.setSelected(AopHandler.instance().getRun().isSuppress());
+ loadtime.setSelected(AopHandler.instance().getRun().isLoadtime());
+ }
}
Modified: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/xml/RunXmlTablePane.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/xml/RunXmlTablePane.java 2008-10-08 18:42:41 UTC (rev 79279)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/ui/run/xml/RunXmlTablePane.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -23,6 +23,7 @@
import org.jboss.aophelper.annotation.AopHelperAction;
import org.jboss.aophelper.core.Action;
+import org.jboss.aophelper.core.AopHandler;
import org.jboss.aophelper.core.AopOption;
import org.jboss.aophelper.core.AopState;
import org.jboss.aophelper.ui.GenericEditTableModel;
@@ -78,5 +79,11 @@
}
+ public void refresh()
+ {
+ tableModel.clearRows();
+ tableModel.addRows(AopHandler.instance().getRun().getAopXml());
+ }
+
}
Added: projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/util/xml/BaseConfigParser.java
===================================================================
--- projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/util/xml/BaseConfigParser.java (rev 0)
+++ projects/aop/trunk/aophelper/src/main/java/org/jboss/aophelper/util/xml/BaseConfigParser.java 2008-10-08 22:42:24 UTC (rev 79280)
@@ -0,0 +1,351 @@
+/*
+ * 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.util.xml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.aophelper.core.AopBaseSettings;
+import org.jboss.aophelper.core.AopCompile;
+import org.jboss.aophelper.core.AopHandler;
+import org.jboss.aophelper.core.AopRun;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * A BaseConfigParser.
+ * NOTE: this class is a ugly bugly xml parser/creator. will rewrite when time permits....
+ *
+ * <aophelper>
+ <compile>
+ <classpaths>
+ <classpath></classpath>
+ </classpath>
+ <aopxmls>
+ <aopxml></aopxml>
+ </aopxmls>
+ <options>
+ <verbose>true</verbose>
+ <suppress>true</suppress>
+ <report>true</report>
+ <noopt>true</noopt>
+ </options>
+ <workingdir></workingdir>
+ </compile>
+
+ <run>
+ <classpaths>
+ <classpath></classpath>
+ </classpath>
+ <aopxmls>
+ <aopxml></aopxml>
+ </aopxmls>
+ <options>
+ <verbose>true</verbose>
+ <suppress>true</suppress>
+ <report>true</report>
+ <noopt>true</noopt>
+ <loadtime>true</loadtime>
+ </options>
+ <workingdir></workingdir>
+ <execlass></execlass>
+ </run>
+
+<aophelper>
+ *
+ * @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class BaseConfigParser
+{
+
+ public static void parse(File file)
+ {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ try
+ {
+ db = dbf.newDocumentBuilder();
+ Document doc = db.parse(file);
+ Node aophelper = findElementNode("aophelper", doc);
+ Node compile = findElementNode("compile", aophelper);
+ Node run = findElementNode("run", aophelper);
+
+ AopHandler.instance().setCompile( parseCompile(compile));
+ AopHandler.instance().setRun(parseRun(run));
+
+ }
+ catch (ParserConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (SAXException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ private static AopCompile parseCompile(Node compile)
+ {
+ AopCompile aopCompile = new AopCompile();
+ parseBaseSettings(compile, aopCompile);
+
+ return aopCompile;
+ }
+
+ private static void parseBaseSettings(Node root, AopBaseSettings base)
+ {
+ Node classpaths = findElementNode("classpaths", root);
+ base.setClasspath(getNodesText(classpaths.getChildNodes()));
+
+ Node aopxmls = findElementNode("aopxmls", root);
+ base.setAopXml(getNodesText(aopxmls.getChildNodes()));
+
+ Node options = findElementNode("options", root);
+ Node verbose = findElementNode("verbose", options);
+ base.setVerbose(getNodeText(verbose).equals("true"));
+
+ Node suppress = findElementNode("suppress", options);
+ base.setSuppress(getNodeText(suppress).equals("true"));
+ Node noopt = findElementNode("noopt", options);
+ base.setNoopt(getNodeText(noopt).equals("true"));
+ Node report = findElementNode("report", options);
+ base.setReport(getNodeText(report).equals("true"));
+
+
+ Node workingdir = findElementNode("workingdir", root);
+ base.setWorkingdir(getNodeText(workingdir));
+ }
+ private static AopRun parseRun(Node run)
+ {
+ AopRun aopRun = new AopRun();
+ parseBaseSettings(run, aopRun);
+
+ Node loadtime = findElementNode("loadtime", run);
+ aopRun.setLoadtime(getNodeText(loadtime).equals("true"));
+ Node exeClass = findElementNode("execlass", run);
+ aopRun.setExecutionClass(getNodeText(exeClass));
+
+ return aopRun;
+ }
+
+ private static Node findElementNode(String elementName, Node root){
+
+ Node matchingNode = null;
+ //Check to see if root is the desired element. If so return root.
+ String nodeName = root.getNodeName();
+
+ if((nodeName != null) & (nodeName.equals(elementName)))
+ return root;
+
+ //Check to see if root has any children if not return null
+ if(!(root.hasChildNodes()))
+ return null;
+
+ //Root has children, so continue searching for them
+ NodeList childNodes = root.getChildNodes();
+ int noChildren = childNodes.getLength();
+ for(int i = 0; i < noChildren; i++)
+ {
+ if(matchingNode == null)
+ {
+ Node child = childNodes.item(i);
+ matchingNode = findElementNode(elementName,child);
+ }
+ else break;
+
+ }
+
+ return matchingNode;
+ }
+
+
+ private static String getNodeText(Node node) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ for (Node child = node.getFirstChild();
+ child != null;
+ child = child.getNextSibling()) {
+
+ if (child.getNodeType() == Node.TEXT_NODE) {
+ return child.getNodeValue();
+ }
+ }
+ }
+ else if (node.getNodeType() == Node.TEXT_NODE) {
+ return node.getNodeValue();
+ }
+ return null;
+ }
+
+ private static List<String> getNodesText(NodeList list)
+ {
+ List<String> text = new ArrayList<String>();
+ for(int i=0; i < list.getLength(); i++)
+ {
+ String t = getNodeText(list.item(i)).trim();
+ if(t != null && t.length() > 0)
+ text.add(t);
+ }
+
+ return text;
+ }
+
+// public static void main(String[] args)
+// {
+// BaseConfigParser.parse(new File("/home/stalep/jboss/svn/jboss-aop/aophelper/test_config.xml"));
+//
+// System.out.println("OUT: \n"+BaseConfigParser.getDOMAsString(createDOM()));
+// }
+
+ public static String getDOMAsString() {
+ try {
+ Document doc = createDOM();
+ Source source = new DOMSource(doc);
+
+ StringWriter writer = new StringWriter();
+ Result result = new StreamResult(writer);
+
+ // Write the DOM document to the writer
+ Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ xformer.transform(source, result);
+
+ return writer.toString();
+ }
+ catch (TransformerConfigurationException e) {
+ e.printStackTrace();
+ }
+ catch (TransformerException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static Document createDOM() {
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.newDocument();
+ Element root = doc.createElement("aophelper");
+ Element compile = doc.createElement("compile");
+ Element run = doc.createElement("run");
+ populateCompile(compile, doc);
+ populateRun(run, doc);
+ root.appendChild(compile);
+ root.appendChild(run);
+ doc.appendChild(root);
+
+ return doc;
+ }
+ catch (ParserConfigurationException e) {
+ System.out.println("ERROR in CreateDOM \n"+e.toString());
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static void populateCompile(Element compile, Document doc)
+ {
+ populateBase(compile, doc, AopHandler.instance().getCompile());
+ }
+
+ private static void populateRun(Element run, Document doc)
+ {
+ populateBase(run, doc, AopHandler.instance().getRun());
+ Element loadtime = doc.createElement("loadtime");
+ loadtime.appendChild( doc.createTextNode(Boolean.toString(AopHandler.instance().getRun().isLoadtime())));
+ run.appendChild(loadtime);
+ Element exeClass = doc.createElement("execlass");
+ if(AopHandler.instance().getRun().getExecutionClass() != null)
+ exeClass.appendChild( doc.createTextNode(AopHandler.instance().getRun().getExecutionClass()));
+ run.appendChild(exeClass);
+
+ }
+
+ private static void populateBase(Element base, Document doc, AopBaseSettings settings)
+ {
+ Element classpaths = doc.createElement("classpaths");
+ for(String cp : settings.getClasspath())
+ {
+ Element classpath = doc.createElement("classpath");
+ classpath.appendChild( doc.createTextNode(cp));
+ classpaths.appendChild(classpath);
+ }
+ base.appendChild(classpaths);
+
+ Element aopxmls = doc.createElement("aopxmls");
+ for(String xml : settings.getAopXml())
+ {
+ Element xmlaop = doc.createElement("aopxml");
+ xmlaop.appendChild( doc.createTextNode(xml));
+ aopxmls.appendChild(xmlaop);
+ }
+ base.appendChild(aopxmls);
+
+ Element options = doc.createElement("options");
+ Element verbose = doc.createElement("verbose");
+ verbose.appendChild( doc.createTextNode(Boolean.toString(settings.isVerbose())));
+ options.appendChild(verbose);
+ Element suppress = doc.createElement("suppress");
+ suppress.appendChild( doc.createTextNode(Boolean.toString(settings.isSuppress())));
+ options.appendChild(suppress);
+ Element noopt = doc.createElement("noopt");
+ noopt.appendChild( doc.createTextNode(Boolean.toString(settings.isNoopt())));
+ options.appendChild(noopt);
+ Element report = doc.createElement("report");
+ report.appendChild( doc.createTextNode(Boolean.toString(settings.isReport())));
+ options.appendChild(report);
+
+ base.appendChild(options);
+
+ Element workingdir = doc.createElement("workingdir");
+ if(settings.getWorkingdir() != null)
+ workingdir.appendChild( doc.createTextNode(settings.getWorkingdir()));
+ base.appendChild(workingdir);
+ }
+
+
+
+
+}
More information about the jboss-cvs-commits
mailing list