Commits

Kresimir Sojat  committed e25494f

Sketch for new modular build system.

  • Participants
  • Parent commits 3e0b3a8

Comments (0)

Files changed (18)

File neman/cells/build.xml

+<project name='neman-cells' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/cells/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organsiation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='cells' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar'/>
+        </dependency>
+    </dependencies>
+</ivy-module>

File neman/core/build.xml

+<project name='neman-core' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/core/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organisation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='core' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar' ext='jar'/>
+        </dependency>
+    </dependencies>
+</ivy-module>

File neman/json/build.xml

+<project name='neman-json' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/json/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organisation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='json' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <!-- TODO: Add neman-core -->
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar'/>
+        </dependency>
+        <dependency org='org.codehaus' name='jackson' rev='0.9.2'>
+            <artifact
+                name='jackson'
+                type='jar'
+                url='http://www.cowtowncoder.com/hatchery/jackson/0.9.2/jackson-0.9.2.jar'/>
+        </dependency>
+    </dependencies>
+</ivy-module>

File neman/swing/build.xml

+<project name='neman-swing' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/swing/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organsiation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='swing' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar' ext='jar'/>
+        </dependency>
+        <!-- TODO: Add core -->
+    </dependencies>
+</ivy-module>

File neman/utils/build.xml

+<project name='neman-utils' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/utils/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organisation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='utils' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar' ext='jar'/>
+        </dependency>
+        <!-- TODO: Add core -->
+        <dependency org='net.java' name='textile-j' rev='2.2'/>
+        <dependency org='commons-cli' name='commons-cli' rev='1.1'>
+            <exclude org='junit'/>
+        </dependency>
+    </dependencies>
+</ivy-module>

File neman/web/build.xml

+<project name='neman-web' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/web/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organisation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='web' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar' ext='jar'/>
+        </dependency>
+        <!-- TODO: Add core -->
+        <dependency org='org.mortbay.jetty' name='jetty' rev='6.1.11'/>
+        <dependency org='org.mortbay.jetty' name='jetty-plus' rev='6.1.11'/>
+    </dependencies>
+</ivy-module>

File neman/webapps/build.xml

+<project name='neman-webapps' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/webapps/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organisation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='webapps' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar'/>
+        </dependency>
+        <!-- TODO: Add web, xml and core to list -->
+    </dependencies>
+</ivy-module>

File neman/xml/build.xml

+<project name='neman-xml' basedir='.' xmlns:ivy='antlib:org.apache.ivy.ant'>
+    <property file='${basedir}/local.properties'/>
+    <property file='${basedir}/build.properties'/>
+
+    <import file='${zg.xml}'/>
+</project>

File neman/xml/ivy.xml

+<ivy-module version='2.0'>
+    <info
+        organisation='net.ksojat'
+        module='neman'/>
+    <publications>
+        <artifact name='xml' type='jar' ext='jar'/>
+    </publications>
+    <dependencies>
+        <dependency org='clojure' name='clojure' rev='svn1205'>
+            <artifact name='clojure' type='jar'/>
+        </dependency>
+        <!-- TODO: Add core -->
+        <dependency org='org.jdom' name='jdom' rev='1.1'/>
+    </dependencies>
+</ivy-module>

File src/net/ksojat/neman/core.clj

 ;  (when-let [res (apply str-join "/" res)]
 ;    (.getResource (RT/baseLoader) res)))
 
-;(defn resource-as-stream [res]
-;  (when res
-;    (.getResourceAsStream (RT/baseLoader) res)))
+(defn resource-as-stream [res]
+  (when res (.getResourceAsStream (RT/baseLoader) res)))
 
-(defn resource-as-stream [& res]
-  (when-let [res (apply str-join "/" res)]
-    (.getResource (RT/baseLoader) res)))
+;(defn resource-as-stream [& res]
+;  (when-let [res (apply str-join "/" res)]
+;    (.getResource (RT/baseLoader) res)))
 
 ;(defn resource-as-file [res]
 ;  (when-let [res (apply str-join "/" res)]

File src/net/ksojat/neman/swing.clj

 (defmethod ctor javax.swing.AbstractButton [c s]
   (let [o (Reflector/invokeConstructor c RT/EMPTY_ARRAY)]
     (set-abutton o s)))
+
+;;
+;; Event listeners.
+;;
+
+(defmulti on (fn [object method handler-fn] [(class object) method]))
+
+;; Listeneres for java.awt.Component
+(import '(java.awt Component))
+
+(import '(java.awt.event ComponentAdapter ComponentEvent))
+
+(defmethod on [Component :resize] [object _ handler-fn]
+  (let [listener (proxy [ComponentAdapter] []
+                   (componentResized [#^ComponentEvent e] (handler-fn e)))]
+    (.addComponentListener object listener)
+    listener))
+
+(defmethod on [Component :move] [object _ handler-fn]
+  (let [listener (proxy [ComponentAdapter] []
+                   (componentMoved [#^ComponentEvent e] (handler-fn e)))]
+    (.addComponentListener object listener)
+    listener))
+
+(defmethod on [Component :show] [object _ handler-fn]
+  (let [listener (proxy [ComponentAdapter] []
+                   (componentShown [#^CompoentEvent e] (handler-fn e)))]
+    (.addComponentListener object listener)
+    (listener)))
+
+(defmethod on [Component :hide] [object _ handler-fn]
+  (let [listener (proxy [ComponentAdapter] []
+                   (componentHidden [#^ComponentEvent e] (handler-fn e)))]
+    (.addComponentListener object listener)
+    listener))
+
+(import '(java.awt.event FocusAdapter FocusEvent))
+
+(defmethod on [Component :focus-gained] [object _ handler-fn]
+  (let [listener (proxy [FocusAdapter] []
+                   (focusGained [#^FocusEvent e] (handler-fn e)))]
+    (.addFocusListener object listener)
+    listener))
+
+(defmethod on [Component :focus-lost] [object _ handler-fn]
+  (let [listener (proxy [FocusAdapter] []
+                   (focusLost [#^FocusEvent e] (handler-fn e)))]
+    (.addFocusListener object listener)
+    listener))
+
+(import '(java.awt.event HierarchyBoundsAdapter HierarchyListener HierarchyEvent))
+
+(defmethod on [Component :hierarchy-changed] [object _ handler-fn]
+  (let [listener (proxy [HierarchyListener] []
+                   (hierarchyChanged [#^HierarchyEvent e] (handler-fn e)))]
+    (.addHierarchyListener object listener)
+    listener))
+
+(defmethod on [Component :ancestor-moved] [object _ handler-fn]
+  (let [listener (proxy [HierarchyBoundsAdapter] []
+                   (ancestorMoved [#^HierarchyEvent e] (handler-fn e)))]
+    (.addHierarchyBoundsListener object listener)
+    listener))
+
+(defmethod on [Component :ancestor-resized] [object _ handler-fn]
+  (let [listener (proxy [HierarchyBoundsAdapter] []
+                   (ancestorResized [#^HierarchyEvent e] (handler-fn e)))]
+    (.addHierarchyBoundsListener object listener)
+    listener))
+
+; TODO: InputMethodListener
+
+(import '(java.awt.event KeyAdapter KeyEvent))
+
+(defmethod on [Component :key-pressed] [object _ handler-fn]
+  (let [listener (proxy [KeyAdapter] []
+                   (keyPressed [#^KeyEvent e] (handler-fn e)))]
+    (.addKeyListener object listener)
+    listener))
+
+(defmethod on [Component :key-released] [object _ handler-fn]
+  (let [listener (proxy [KeyAdapter] []
+                   (keyReleased [#^KeyEvent e] (handler-fn e)))]
+    (.addKeyListener object listener)
+    listener))
+
+(defmethod on [Component :key-typed] [object _ handler-fn]
+  (let [listener (proxy [KeyAdapter] []
+                   (keyTyped [#^KeyEvent e] (handler-fn e)))]
+    (.addKeyListener object listener)
+    listener))
+
+(import '(java.awt.event MouseAdapter MouseMotionAdapter MouseWheelListener MouseEvent))
+
+(defmethod on [Component :mouse-clicked] [object _ handler-fn]
+  (let [listener (proxy [MouseAdapter] []
+                   (mouseClicked [#^MouseEvent e] (handler-fn)))]
+    (.addMouseListener object listener)
+    listener))
+
+(defmethod on [Component :mouse-entered] [object _ handler-fn]
+  (let [listener (proxy [MouseAdapter] []
+                   (mouseEntered [#^MouseEvent e] (handler-fn e)))]
+    (.addMouseListener object listener)
+    listener))
+
+(defmethod on [Component :mouse-pressed] [object _ handler-fn]
+  (let [listener (proxy [MouseAdapter] []
+                   (mousePressed [#^MouseEvent e] (handler-fn e)))]
+    (.addMouseListener object listener)
+    listener))
+
+(defmethod on [Component :mouse-released] [object _ handler-fn]
+  (let [listener (proxy [MouseAdapter] []
+                   (mouseReleased [#^MouseEvent e] (handler-fn e)))]
+    (.addMouseListener object listener)
+    listener))
+
+(defmethod on [Component :mouse-dragged] [object _ handler-fn]
+  (let [listener (proxy [MouseMotionAdapter] []
+                   (mouseDragged [#^MouseEvent e] (handler-fn e)))]
+    (.addMouseMotionListener object listener)
+    listener))
+
+(defmethod on [Component :mouse-moved] [object _ handler-fn]
+  (let [listener (proxy [MouseMotionAdapter] []
+                   (mouseMoved [#^MouseEvent e] (handler-fn e)))]
+    (.addMouseMotionListener object listener)
+    listener))
+
+(defmethod on [Component :wheel-moved] [object _ handler-fn]
+  (let [listener (proxy [MouseWheelListener] []
+                   (mouseWheelMoved [#^MouseEvent e] (handler-fn e)))]
+    (.addMouseWheelListener object listener)
+    listener))
+
+;; Listeners for java.awt.ItemSelectable
+(import '(java.awt ItemSelectable))
+
+(import '(java.awt.event ItemListener ItemEvent))
+
+(defmethod on [ItemSelectable :item-changed] [object _ handler-fn]
+  (let [listener (proxy [ItemListener] []
+                   (itemStateChanged [#^ItemEvent e] (handler-fn e)))]
+    (.addItemListener object listener)
+    listener))
+
+
+;; Listeners for java.awt.Container
+(import '(java.awt Container))
+
+(import '(java.awt.event ContainerAdapter ContainerEvent))
+
+(defmethod on [Container :component-added] [object _ handler-fn]
+  (let [listener (proxy [ContainerAdapter] []
+                   (componentAdded [#^ComponentEvent e] (handler-fn e)))]
+    (.addComponentListener object listener)
+    listener))
+
+(defmethod on [Container :component-removed] [object _ handler-fn]
+  (let [listener (proxy [ContainerAdapter] []
+                   (componentRemoved [#^ComponentEvenet e] (handler-fn e)))]
+    (.addComponentListener object listener)
+    listener))
+
+;; Listeners for javax.swing.JComponent
+(import '(javax.swing JComponent))
+
+(import '(javax.swing.event AncestorListener AncestorEvent))
+
+(defmethod on [JComponent :ancestor-added] [object _ handler-fn]
+  (let [listener (proxy [AncestorListener] []
+                   (ancestorAdded   [#^AncestorEvent e] (handler-fn e))
+                   (ancestorMoved   [#^AncestorEvent e])
+                   (ancestorRemoved [#^AncestorEvent e]))]
+    (.addAncestorListener object listener)
+    listener))
+
+(defmethod on [JComponent :ancestor-moved] [object _ handler-fn]
+  (let [listener (proxy [AncestorListener] []
+                   (ancestorAdded   [#^AncestorEvent e])
+                   (ancestorMoved   [#^AncestorEvent e] (handler-fn e))
+                   (ancestorRemoved [#^AncestorEvent e]))]
+    (.addAncestorListener object listener)
+    listener))
+
+(defmethod on [JComponent :ancestor-removed] [object _ handler-fn]
+  (let [listener (proxy [AncestorListener] []
+                   (ancestorAdded   [#^AncestorEvent e])
+                   (ancestorMoved   [#^AncestorEvent e])
+                   (ancestorRemoved [#^AncestorEvent e] (handler-fn e)))]
+    (.addAncestorListener object listener)
+    listener))
+
+;; Listeners for javax.swing.AbstractButton
+(import '(javax.swing AbstractButton))
+
+(import '(java.awt.event ActionListener ActionEvent))
+
+(defmethod on [AbstractButton :action] [object _ handler-fn]
+  (let [listener (proxy [ActionListener] []
+                   (actionPerformed [#^ActionEvent e] (handler-fn e)))]
+    (.addActionListener object listener)
+    listener))
+
+(import '(javax.swing.event ChangeListener ChangeEvent))
+
+(defmethod on [AbstractButton :state-changed] [object _ handler-fn]
+  (let [listener (proxy [ChangeListener] []
+                   (stateChanged [#^ChangeEvent e] (handler-fn e)))]
+    (.addChangeListener object listener)
+    listener))
+
+;; Listeners for javax.swing.JMenuItem
+(import '(javax.swing JMenuItem))
+
+(import '(javax.swing.event MenuDragMouseListener MenuDragMouseEvent))
+
+(defmethod on [JMenuItem :mouse-dragged] [object _ handler-fn]
+  (let [listener (proxy [MenuDragMouseListener] []
+                   (menuDragMouseDragged  [#^MenuDragMouseEvent e] (handler-fn e))
+                   (menuDragMouseEntered  [#^MenuDragMouseEvent e])
+                   (menuDragMouseExited   [#^MenuDragMouseEvent e])
+                   (menuDragMouseReleased [#^MenuDragMouseEvent e]))]
+    (.addMenuDragMouseListener object listener)
+    listener))
+
+(defmethod on [JMenuItem :mouse-drag-entered] [object _ handler-fn]
+  (let [listener (proxy [MenuDragMouseListener] []
+                   (menuDragMouseDragged  [#^MenuDragMouseEvent e])
+                   (menuDragMouseEntered  [#^MenuDragMouseEvent e] (handler-fn e))
+                   (menuDragMouseExited   [#^MenuDragMouseEvent e])
+                   (menuDragMouseReleased [#^MenuDragMouseEvent e]))]
+    (.addMenuDragMouseListener object listener)
+    listener))
+
+(defmethod on [JMenuItem :mouse-drag-exited] [object _ handler-fn]
+  (let [listener (proxy [MenuDragMouseListener] []
+                   (menuDragMouseDragged  [#^MenuDragMouseEvent e])
+                   (menuDragMouseEntered  [#^MenuDragMouseEvent e])
+                   (menuDragMouseExited   [#^MenuDragMouseEvent e] (handler-fn e))
+                   (menuDragMouseReleased [#^MenuDragMouseEvent e]))]
+    (.addMenuDragMouseListener object listener)
+    listener))
+
+(defmethod on [JMenuItem :mouse-drag-released] [object _ handler-fn]
+  (let [listener (proxy [MenuDragMouseListener] []
+                   (menuDragMouseDragged  [#^MenuDragMouseEvent e])
+                   (menuDragMouseEntered  [#^MenuDragMouseEvent e])
+                   (menuDragMouseExited   [#^MenuDragMouseEvent e])
+                   (menuDragMouseReleased [#^MenuDragMouseEvent e] (handler-fn e)))]
+    (.addMenuDragMouseListener object listener)
+    listener))
+
+(import '(javax.swing.event MenuKeyListener MenuKeyEvent))
+
+(defmethod on [JMenuItem :menu-key-pressed] [object _ handler-fn]
+  (let [listener (proxy [MenuKeyListener] []
+                   (menuKeyPressed  [#^MenuKeyEvent e] (handler-fn e))
+                   (menuKeyReleased [#^MenuKeyEvent e])
+                   (menuKeyTyped    [#^MenuKeyEvent e]))]
+    (.addMenuKeyListener object listener)
+    listener))
+
+(defmethod on [JMenuItem :menu-key-released] [object _ handler-fn]
+  (let [listener (proxy [MenuKeyListener] []
+                   (menuKeyPressed  [#^MenuKeyEvent e])
+                   (menuKeyReleased [#^MenuKeyEvent e] (handler-fn e))
+                   (menuKeyTyped    [#^MenuKeyEvent e]))]
+    (.addMenuKeyListener object listener)
+    listener))
+
+(defmethod on [JMenuItem :menu-key-typed] [object _ handler-fn]
+  (let [listener (proxy [MenuKeyListener] []
+                   (menuKeyPressed  [#^MenuKeyEvent e])
+                   (menuKeyReleased [#^MenuKeyEvent e])
+                   (menuKeyTyped    [#^MenuKeyEvent e] (handler-fn e)))]
+    (.addMenuKeyListener object listener)
+    listener))
+
+;; Listeners for javax.swing.JMenu
+(import '(javax.swing JMenu))
+
+(import '(javax.swing.event MenuListener MenuEvent))
+
+(defmethod on [JMenu :menu-canceled] [object _ handler-fn]
+  (let [listener (proxy [MenuListener] []
+                   (menuCanceled   [#^MenuEvent e] (handler-fn e))
+                   (menuDeselected [#^MenuEvent e])
+                   (menuSelected   [#^MenuEvent e]))]
+    (.addMenuListener object listener)
+    listener))
+
+(defmethod on [JMenu :menu-deselected] [object _ handler-fn]
+  (let [listener (proxy [MenuListener] []
+                   (menuCanceled   [#^MenuEvent e])
+                   (menuDeselected [#^MenuEvent e] (handler-fn e))
+                   (menuSelected   [#^MenuEvent e]))]
+    (.addMenuListener object listener)
+    listener))
+
+(defmethod on [JMenu :menu-selected] [object _ handler-fn]
+  (let [listener (proxy [MenuListener] []
+                   (menuCanceled   [#^MenuEvent e])
+                   (menuDeselected [#^MenuEvent e])
+                   (menuSelected   [#^MenuEvent e] (handler-fn e)))]
+    (.addMenuListener object listener)
+    listener))