cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: r330559 - in /cocoon/whiteboard/guilder: ./ java/org/apache/cocoon/guilder/ java/org/apache/cocoon/guilder/block/ java/org/apache/cocoon/guilder/menu/ java/org/apache/cocoon/guilder/properties/ java/org/apache/cocoon/guilder/utils/
Date Thu, 03 Nov 2005 14:42:59 GMT
Author: ugo
Date: Thu Nov  3 06:42:42 2005
New Revision: 330559

URL: http://svn.apache.org/viewcvs?rev=330559&view=rev
Log:
Guilder Beta 2

Added:
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java   (with
props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java   (with props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java   (with
props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java
  (with props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java   (with props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl   (with
props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java  
(with props)
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java   (with props)
Modified:
    cocoon/whiteboard/guilder/build.xml
    cocoon/whiteboard/guilder/guilder.properties
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/Console.java
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/PropertiesPanel.java
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/block/Blocks.java
    cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/properties/PropertiesManager.java

Modified: cocoon/whiteboard/guilder/build.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/build.xml?rev=330559&r1=330558&r2=330559&view=diff
==============================================================================
--- cocoon/whiteboard/guilder/build.xml (original)
+++ cocoon/whiteboard/guilder/build.xml Thu Nov  3 06:42:42 2005
@@ -31,10 +31,18 @@
   </target>
     
   <target name="compile" depends="init, prepare">
-    <javac srcdir="java" debug="on" deprecation="on" destdir="build/classes" target="1.3"
source="1.3"/>
-    <copy 
-      file="java/org/apache/cocoon/guilder/block/gump2xhtml.xsl" 
-      todir="build/classes/org/apache/cocoon/guilder/block"/>
+    <javac srcdir="java" debug="on" deprecation="on" destdir="build/classes" target="1.3"
source="1.3">
+      <classpath>
+        <fileset dir="${cocoon.project.home}/lib">
+          <include name="optional/commons-transaction-*.jar"/>
+        </fileset>
+      </classpath>
+    </javac>   
+    <copy todir="build/classes">
+      <fileset dir="java">
+        <include name="**/*.xsl"/>
+      </fileset>
+    </copy>   
   </target>
  
   <target name="package" depends="compile">
@@ -42,7 +50,7 @@
       <manifest>
         <attribute name="Built-By" value="${user.name}"/>
         <attribute name="Main-Class" value="org.apache.cocoon.guilder.Console"/>
-        <attribute name="class-path" value="../../lib/endorsed/xercesImpl-2.7.1.jar ../../lib/endorsed/xml-apis-1.3.02.jar"/>
+        <attribute name="class-path" value="../../lib/endorsed/xercesImpl-2.7.1.jar ../../lib/endorsed/xml-apis-1.3.02.jar
../../lib/optional/commons-transaction-1.0.1.jar"/>
       </manifest>
     </jar>
   </target>

Modified: cocoon/whiteboard/guilder/guilder.properties
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/guilder.properties?rev=330559&r1=330558&r2=330559&view=diff
==============================================================================
--- cocoon/whiteboard/guilder/guilder.properties (original)
+++ cocoon/whiteboard/guilder/guilder.properties Thu Nov  3 06:42:42 2005
@@ -13,4 +13,4 @@
 #  limitations under the License.
 
 cocoon.project.home=../../branches/BRANCH_2_1_X
-version=1.0-b1
+version=1.0-b2

Modified: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/Console.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/Console.java?rev=330559&r1=330558&r2=330559&view=diff
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/Console.java (original)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/Console.java Thu Nov  3 06:42:42
2005
@@ -21,13 +21,13 @@
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
-import java.io.IOException;
 
 import javax.swing.AbstractButton;
 import javax.swing.ButtonGroup;
 import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JFrame;
+import javax.swing.JMenuBar;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.JTabbedPane;
@@ -36,6 +36,7 @@
 import org.apache.cocoon.guilder.block.Block;
 import org.apache.cocoon.guilder.block.Blocks;
 import org.apache.cocoon.guilder.block.BlocksPanelListener;
+import org.apache.cocoon.guilder.menu.ConsoleMenuBar;
 
 /**
  * 
@@ -128,9 +129,6 @@
         JButton save = new JButton("Save");
         save.addActionListener(this);
         buttons.add(save);
-        JButton cancel = new JButton("Build");
-        cancel.addActionListener(this);
-        buttons.add(cancel);
         JButton jettyButton = new JButton("Start Jetty");
         jettyButton.addActionListener(this);
         buttons.add(jettyButton);
@@ -151,6 +149,10 @@
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setSize(600,600);
         frame.setResizable(false);
+        
+        //Set Menu
+        JMenuBar menuBar = new ConsoleMenuBar();
+        frame.setJMenuBar(menuBar);
 
         //Create and set up the content pane.
         JComponent newContentPane = new Console();
@@ -166,23 +168,6 @@
         if (e.getActionCommand().equals("Save")) {
             this.blocks.save();
             this.propertiesPanel.save();
-        } else if (e.getActionCommand().equals("Build")) {
-            String os = System.getProperty("os.name");
-            String command = null;
-            if (os.equals("Linux") || os.equals("Mac OS X")) {
-                command = "./build.sh";
-            } else if (os.startsWith("Win")) {
-                command = "build.bat";
-            } else {
-                System.out.println("OS: " + os);
-                System.out.println("Your OS is not supported, please report it.");
-            }
-            CommandExecutor ce = new CommandExecutor();
-            try {
-                ce.executeCommand(command);
-            } catch (IOException e1) {
-                e1.printStackTrace();
-            }
         } else if (e.getActionCommand().equals("Start Jetty")) {
             JButton start = (JButton) e.getSource();
             start.setText("Stop Jetty");

Modified: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/PropertiesPanel.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/PropertiesPanel.java?rev=330559&r1=330558&r2=330559&view=diff
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/PropertiesPanel.java (original)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/PropertiesPanel.java Thu Nov
 3 06:42:42 2005
@@ -15,12 +15,17 @@
  */
 package org.apache.cocoon.guilder;
 
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.util.Properties;
 
 import javax.swing.BoxLayout;
 import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
 import javax.swing.JPanel;
 
 import org.apache.cocoon.guilder.properties.PropertiesManager;
@@ -31,23 +36,17 @@
  * 
  * @version CVS $Id$
  */
-public class PropertiesPanel extends JPanel implements ItemListener {
+public class PropertiesPanel extends JPanel implements ActionListener, ItemListener {
     
     private static final long serialVersionUID = 1L;
     
-    public static final String BUILD_PROPERTIES_PATH = "build.properties";
-    public static final String LOCAL_BUILD_PROPERTIES_PATH = "local.build.properties";
-
-    private static Properties properties;
+    private Properties properties;
+    
+    private String[] logLevel = {"DEBUG", "INFO", "WARN", "ERROR", "FATAL"};
     
     public PropertiesPanel() {
-        if (properties == null) {
-            PropertiesManager propertiesManager = new PropertiesManager();
-            properties = propertiesManager.getProperties(BUILD_PROPERTIES_PATH);        
-            propertiesManager = new PropertiesManager(properties);
-            properties = propertiesManager.getProperties(LOCAL_BUILD_PROPERTIES_PATH);
-        }
         this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+        this.properties = PropertiesManager.getBuildProperties();
         this.addComponents();
     }
     
@@ -64,6 +63,15 @@
         addCheckBox("exclude.javadocs");
         addCheckBox("include.sources-in-jars");
         addCheckBox("exclude.validate.xdocs");
+        JPanel logPanel = new JPanel(new FlowLayout());        
+        JComboBox log = new JComboBox(this.logLevel);
+        log.setName("build.webapp.loglevel");
+        log.setSelectedItem(this.properties.getProperty(log.getName()));
+        log.addActionListener(this);
+        logPanel.add(log);
+        JLabel logLabel = new JLabel(log.getName());
+        logPanel.add(logLabel);
+        this.add(logPanel);
     }
     
     private void addCheckBox(String text) {
@@ -86,7 +94,12 @@
     }
     
     public void save() {
-        new PropertiesManager(properties).writeProperties(LOCAL_BUILD_PROPERTIES_PATH);
+        new PropertiesManager(properties).writeProperties(PropertiesManager.LOCAL_BUILD_PROPERTIES_PATH);
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        JComboBox combo = (JComboBox) e.getSource();
+        this.properties.setProperty(combo.getName(), (String) combo.getSelectedItem());
     }
 
 }

Modified: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/block/Blocks.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/block/Blocks.java?rev=330559&r1=330558&r2=330559&view=diff
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/block/Blocks.java (original)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/block/Blocks.java Thu Nov  3
06:42:42 2005
@@ -15,63 +15,48 @@
  */
 package org.apache.cocoon.guilder.block;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.StringWriter;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-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.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
 import org.apache.cocoon.guilder.properties.PropertiesManager;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
+import org.apache.cocoon.guilder.utils.XmlUtils;
 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;
+
 
 /**
  * 
  * Description of Blocks.
- * 
+ *
  * @version CVS $Id$
  */
 public class Blocks {
 
     public static final String GUMP_FILE_PATH = "gump.xml";
-    public static final String BLOCKS_PROPERTIES_PATH = "blocks.properties";
-    public static final String LOCAL_BLOCKS_PROPERTIES_PATH = "local.blocks.properties";
     private static Document doc;
-    private static Properties properties;
+    private Properties properties;
     private static Map blocks;
     
     public Blocks() {
         if (doc == null) {
-            doc = getXML();
+            InputStream gump = null;
+            try {
+                gump = new FileInputStream(GUMP_FILE_PATH);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+            InputStream xsl = ClassLoader.getSystemResourceAsStream("org/apache/cocoon/guilder/block/gump2xhtml.xsl");
+            doc = XmlUtils.transform(gump, xsl);
         }
-        if (properties == null) {
-            PropertiesManager propertiesManager = new PropertiesManager();
-            properties = propertiesManager.getProperties(BLOCKS_PROPERTIES_PATH);       

-            propertiesManager = new PropertiesManager(properties);
-            properties = propertiesManager.getProperties(LOCAL_BLOCKS_PROPERTIES_PATH);
-        }        
+        this.properties = PropertiesManager.getBlocksProperties();
         if (blocks == null) {
             this.initBlocks();
             this.computeDependencies();
@@ -83,9 +68,9 @@
     }
     
     public Properties getProperties() {
-        return properties;
+        return this.properties;
     }
-    
+        
     private void initBlocks() {
         blocks = new HashMap();
         Element root = doc.getDocumentElement();
@@ -102,7 +87,7 @@
                 block.setStatus(blockEl.getAttribute("status"));
                 //Get DESCRIPTION
                 Element descr = (Element)blockEl.getElementsByTagName("description").item(0);
-                block.setDescription(serializeNode(doc, descr));
+                block.setDescription(XmlUtils.serializeNode(doc, descr));
                 //Get DEPENDENCIES
                 NodeList deps = blockEl.getElementsByTagName("depend");
                 for (int j=0; j<deps.getLength(); j++) {
@@ -113,8 +98,8 @@
                     }
                 }
                 //Get SELECTED
-                if (properties.getProperty("include.block." + block.getName()) != null 
-                        && properties.getProperty("include.block." + block.getName()).equals("false"))
{
+                if (this.properties.getProperty("include.block." + block.getName()) != null

+                        && this.properties.getProperty("include.block." + block.getName()).equals("false"))
{
                     block.setSelected(false);                        
                 } else {
                     block.setSelected(true);
@@ -144,57 +129,7 @@
     }
     
     public void save() {
-        new PropertiesManager(properties).writeProperties(LOCAL_BLOCKS_PROPERTIES_PATH);
-    }
-
-    private String serializeNode(Document doc, Element node) {
-        StringWriter stringOut = new StringWriter();
-        try {
-            OutputFormat format = new OutputFormat(doc); //Serialize DOM
-            format.setIndenting(false);
-            format.setOmitXMLDeclaration(true);
-            XMLSerializer serial = new XMLSerializer(stringOut, format);
-            serial.asDOMSerializer(); // As a DOM Serializer
-            serial.serialize(node);
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-        return stringOut.toString();
-    }
-    
-    private Document getXML() {
-        try {
-            Source xmlSource = new StreamSource(new FileInputStream(GUMP_FILE_PATH));
-            Source xsltSource = new StreamSource(
-                    this.getClass().getResourceAsStream("gump2xhtml.xsl"));
-            //Use DOMResult? yes, but don't work :D
-            StreamResult transResult = new StreamResult();
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            transResult.setOutputStream(baos);
-            TransformerFactory tf = TransformerFactory.newInstance();
-            Transformer t = tf.newTransformer(xsltSource);
-            t.transform(xmlSource, transResult);            
-            Document newDoc = null;
-            DocumentBuilderFactory factory =
-                DocumentBuilderFactory.newInstance();
-            DocumentBuilder builder = factory.newDocumentBuilder();
-            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-            newDoc = builder.parse(bais); 
-            return newDoc;
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (TransformerConfigurationException e) {
-            e.printStackTrace();
-        } catch (TransformerException e) {
-            e.printStackTrace();
-        } catch (ParserConfigurationException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (SAXException e) {
-            e.printStackTrace();
-        }
-        return null;
+        new PropertiesManager(this.properties).writeProperties(PropertiesManager.LOCAL_BLOCKS_PROPERTIES_PATH);
     }
     
-}
+}
\ No newline at end of file

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java Thu Nov
 3 06:42:42 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.menu;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+
+import org.apache.cocoon.guilder.utils.CommandExecutor;
+
+public class BuildListener implements ActionListener {
+
+    public void actionPerformed(ActionEvent e) {
+        String os = System.getProperty("os.name");
+        String command = null;
+        if (os.equals("Linux") || os.equals("Mac OS X")) {
+            command = "./build.sh";
+        } else if (os.startsWith("Win")) {
+            command = "build.bat";
+        } else {
+            System.out.println("OS: " + os);
+            System.out.println("Your OS is not supported, please report it.");
+        }
+        command += " " + e.getActionCommand();
+        CommandExecutor ce = new CommandExecutor();
+        try {
+            ce.executeCommandAndWait(command);
+        } catch (IOException e1) {
+            e1.printStackTrace();
+        }            
+    }
+
+}

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildListener.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java Thu Nov 
3 06:42:42 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.menu;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+public class BuildMenu extends JMenu {
+
+    private static final long serialVersionUID = 1L;
+    
+    public BuildMenu() {
+        BuildListener listener = new BuildListener();
+        this.setText("Build");
+        this.setMnemonic('B');
+        JMenuItem clean = new JMenuItem("Clean");
+        clean.setMnemonic('C');
+        clean.setActionCommand("clean");
+        clean.addActionListener(listener);
+        this.add(clean);
+        JMenuItem webapp = new JMenuItem("Webapp");
+        webapp.setMnemonic('W');
+        webapp.setActionCommand("webapp");
+        webapp.addActionListener(listener);
+        this.add(webapp);
+        JMenu eclipse = new JMenu("Eclipse project");
+        eclipse.setMnemonic('E');
+        JMenuItem eclipseCustom = new JMenuItem("Custom Blocks");
+        eclipseCustom.setMnemonic('u');
+        eclipseCustom.setActionCommand("eclipse-project");
+        eclipseCustom.addActionListener(listener);
+        eclipse.add(eclipseCustom);
+        JMenuItem eclipseAll = new JMenuItem("All Blocks");
+        eclipseAll.setMnemonic('A');
+        eclipseAll.setActionCommand("-Dinclude.all.blocks=true eclipse-project");
+        eclipseAll.addActionListener(listener);
+        eclipse.add(eclipseAll);
+        this.add(eclipse);
+    }
+
+}

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/BuildMenu.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java Thu
Nov  3 06:42:42 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.menu;
+
+import javax.swing.JMenuBar;
+
+public class ConsoleMenuBar extends JMenuBar {
+    
+    private static final long serialVersionUID = 1L;
+
+    public ConsoleMenuBar() {
+        this.add(new BuildMenu());
+        // this.add(new ToolsMenu());        
+    }
+
+}

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ConsoleMenuBar.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java
(added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java
Thu Nov  3 06:42:42 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.menu;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.cocoon.guilder.properties.PropertiesManager;
+import org.apache.cocoon.guilder.utils.XmlUtils;
+import org.apache.commons.transaction.util.FileHelper;
+
+public class LogConsoleListener implements ItemListener {
+    
+    //This path was taken from build.webapp property
+    private String logConfigurationFile = 
+        PropertiesManager.getBuildProperties().getProperty("build.webapp") 
+        + "WEB-INF/logkit.xconf";
+    
+    public LogConsoleListener() {
+    }
+    
+    public boolean isSelected() {
+        File backup = new File(this.logConfigurationFile + ".bck");
+        return backup.exists();
+    }
+
+    public void itemStateChanged(ItemEvent e) {
+        if (e.getStateChange() == ItemEvent.SELECTED) {
+            this.select();
+        } else {
+            this.unselect();
+        }
+    }
+
+    private void select() {
+        InputStream logkit_is = null;
+        OutputStream logkit_os = null;
+        try {
+            logkit_is = new FileInputStream(this.logConfigurationFile);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        File logkit_backup = new File(this.logConfigurationFile + ".bck");
+        if (!logkit_backup.exists()) {
+            try {
+                FileHelper.copy(logkit_is, logkit_backup);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }            
+        }
+        try {
+            logkit_is = new FileInputStream(this.logConfigurationFile + ".bck");
+            logkit_os = new FileOutputStream(this.logConfigurationFile);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        InputStream xsl = ClassLoader.getSystemResourceAsStream("org/apache/cocoon/guilder/menu/enableLF5Factory.xsl");
+        XmlUtils.transform(logkit_is, xsl, logkit_os);        
+    }
+    
+    private void unselect() {
+        File in = new File(this.logConfigurationFile + ".bck");
+        File out = new File(this.logConfigurationFile);
+        try {
+            FileHelper.copy(in, out);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        in.delete();
+    }
+}
\ No newline at end of file

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/LogConsoleListener.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java Thu Nov 
3 06:42:42 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.menu;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenu;
+
+public class ToolsMenu extends JMenu {
+    
+    private static final long serialVersionUID = 1L;
+
+    public ToolsMenu() {
+        LogConsoleListener listener = new LogConsoleListener();
+        this.setText("Tools");
+        this.setMnemonic('T');
+        JCheckBoxMenuItem logConsole = new JCheckBoxMenuItem("Graphic log console");
+        logConsole.setMnemonic('l');
+        logConsole.setSelected(listener.isSelected());
+        logConsole.addItemListener(listener);
+        this.add(logConsole);
+    }
+
+}

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/ToolsMenu.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl Thu
Nov  3 06:42:42 2005
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- Version: $Id$ -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <xsl:template match="factories">    
+    <factories>
+      <xsl:copy-of select="child::*"/>
+      <factory type="lf5" class="org.apache.avalon.excalibur.logger.factory.LF5TargetFactory"/>
+    </factories>
+  </xsl:template>
+  
+  <xsl:template match="cocoon">
+    <lf5>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </lf5>
+  </xsl:template>
+  
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+        
+</xsl:stylesheet>
\ No newline at end of file

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/menu/enableLF5Factory.xsl
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/properties/PropertiesManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/properties/PropertiesManager.java?rev=330559&r1=330558&r2=330559&view=diff
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/properties/PropertiesManager.java
(original)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/properties/PropertiesManager.java
Thu Nov  3 06:42:42 2005
@@ -30,7 +30,15 @@
  */
 public class PropertiesManager {
     
+    public static final String BLOCKS_PROPERTIES_PATH = "blocks.properties";
+    public static final String LOCAL_BLOCKS_PROPERTIES_PATH = "local.blocks.properties";
+    public static final String BUILD_PROPERTIES_PATH = "build.properties";
+    public static final String LOCAL_BUILD_PROPERTIES_PATH = "local.build.properties";
+    
     private Properties props;
+    private static Properties blocksProperties;
+    private static Properties buildProperties;
+    
     
     public PropertiesManager() {       
     }
@@ -67,6 +75,26 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
-   }
+    }
+    
+    public static Properties getBlocksProperties() {
+        if (blocksProperties == null) {
+            PropertiesManager propertiesManager = new PropertiesManager();
+            blocksProperties = propertiesManager.getProperties(BLOCKS_PROPERTIES_PATH); 
      
+            propertiesManager = new PropertiesManager(blocksProperties);
+            blocksProperties = propertiesManager.getProperties(LOCAL_BLOCKS_PROPERTIES_PATH);
+        }        
+        return blocksProperties;
+    }
+    
+    public static Properties getBuildProperties() {
+        if (buildProperties == null) {
+            PropertiesManager propertiesManager = new PropertiesManager();
+            buildProperties = propertiesManager.getProperties(BUILD_PROPERTIES_PATH);   
    
+            propertiesManager = new PropertiesManager(buildProperties);
+            buildProperties = propertiesManager.getProperties(LOCAL_BUILD_PROPERTIES_PATH);
+        }
+        return buildProperties;
+    }
     
 }

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java Thu
Nov  3 06:42:42 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * 
+ * Description of CommandExecutor.
+ * 
+ * @version CVS $Id$
+ */
+public class CommandExecutor {
+    
+    /**
+     * Execute the command and print the output to the console. Return only when the process
has terminated.
+     * @param command The command
+     * @return the instance of the process
+     * @throws IOException
+     */
+    public Process executeCommandAndWait(String command) throws IOException {
+        Process process = this.executeCommand(command);
+        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+        String line;
+        while ((line = reader.readLine()) != null) {
+            System.out.println(line);
+        }
+        return process;
+    }
+    
+    /**
+     * Execute the command and return an instance of the process;
+     * @param command The command
+     * @return the instance of the process
+     * @throws IOException
+     */
+    public Process executeCommand(String command) throws IOException {
+        return Runtime.getRuntime().exec(command);        
+    }
+    
+}

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/CommandExecutor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java?rev=330559&view=auto
==============================================================================
--- cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java (added)
+++ cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java Thu Nov 
3 06:42:42 2005
@@ -0,0 +1,117 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.guilder.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+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.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+public class XmlUtils {
+
+    /**
+     * Serialize the node
+     * @param doc Owner Document of the node
+     * @param node The node to serialize
+     * @return A string with the serialized node
+     */
+    public static String serializeNode(Document doc, Element node) {
+        StringWriter stringOut = new StringWriter();
+        try {
+            OutputFormat format = new OutputFormat(doc); //Serialize DOM
+            format.setIndenting(false);
+            format.setOmitXMLDeclaration(true);
+            XMLSerializer serial = new XMLSerializer(stringOut, format);
+            serial.asDOMSerializer(); // As a DOM Serializer
+            serial.serialize(node);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return stringOut.toString();
+    }
+    
+    /**
+     * Given two InpuStream (xml and xsl) return a Document with
+     * the result of transformation with Trax
+     * @param xml The InputStream with the xml source
+     * @param xsl The InputStream with the xsl stylesheet 
+     * @return A Document
+     */
+    public static Document transform(InputStream xml, InputStream xsl) {
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            transform(xml, xsl, baos);
+            DocumentBuilderFactory factory =
+                DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+            return builder.parse(bais);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (SAXException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * Execute xslt transformation
+     * @param xml The InputStream with the xml source
+     * @param xsl The InputStream with the xsl stylesheet
+     * @param out The OutputStream where save the result
+     */
+    public static void transform(InputStream xml, InputStream xsl, OutputStream out) {
+        try {
+            Source xmlSource = new StreamSource(xml);
+            Source xsltSource = new StreamSource(xsl);
+            StreamResult transResult = new StreamResult();
+            transResult.setOutputStream(out);
+            TransformerFactory tf = TransformerFactory.newInstance();
+            Transformer t = tf.newTransformer(xsltSource);
+            t.transform(xmlSource, transResult);            
+        } catch (TransformerConfigurationException e) {
+            e.printStackTrace();
+        } catch (TransformerException e) {
+            e.printStackTrace();
+        }
+    }
+    
+
+}

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/guilder/java/org/apache/cocoon/guilder/utils/XmlUtils.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message