# Copyright 2006 James Tauber and contributors
# Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
#
# 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.
from pyjamas import DOM
from pyjamas import Factory

from Widget import Widget

class FileUpload(Widget):
    def __init__(self, **kwargs):
        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-FileUpload"
        if kwargs.has_key('Element'):
            element = kwargs.pop('Element')
        else:
            element = DOM.createElement("input")
        DOM.setAttribute(element, "type", "file")
        self.setElement(element)
        Widget.__init__(self, **kwargs)

    def getFilename(self):
        return DOM.getAttribute(self.getElement(), "value")

    def getName(self):
        return DOM.getAttribute(self.getElement(), "name")

    def setName(self, name):
        DOM.setAttribute(self.getElement(), "name", name)

Factory.registerClass('pyjamas.ui.FileUpload', FileUpload)


@@ -758,16 +758,135 @@
 idget):%0A
+%0A    props = %5B(%22name%22, %22Name%22, %22Name%22, None),%0A              %22filename%22, %22File Name%22, %22FileName%22, None),%0A            %5D%0A%0A
     def 
@@ -923,30 +923,15 @@
     
-if not kwargs.has_key(
+kwargs%5B
 'Sty
@@ -941,18 +941,23 @@
 ame'
-):
+%5D =
  kwargs
-%5B
+.get(
 'Sty
@@ -967,10 +967,10 @@
 ame'
-%5D=
+, 
 %22gwt
@@ -985,51 +985,10 @@
 oad%22
+)
 %0A
-        if kwargs.has_key('Element'):%0A    
     
@@ -1025,45 +1025,18 @@
 ent'
-)%0A        else:%0A            element =
+, None) or
  DOM
@@ -1183,16 +1183,83 @@
 wargs)%0A%0A
+    def _getProps(self):%0A        return Widget.props + self.props%0A%0A
     def 
@@ -1334,24 +1334,119 @@
 , %22value%22)%0A%0A
+    def setFilename(self, value):%0A        DOM.setAttribute(self.getElement(), %22value%22, value)%0A%0A
     def getN

add fileupload props