Author: [email protected]
Date: Wed Mar 18 10:47:55 2009
New Revision: 5040
Added:
trunk/user/test/com/google/gwt/user/client/ui/FileUploadTest.java
Modified:
trunk/user/src/com/google/gwt/user/client/ui/FileUpload.java
trunk/user/test/com/google/gwt/user/UISuite.java
Log:
Added setEnabled(boolean)/isEnabled() methods to FileUpload.java
Patch by: jlabanca
Review by: rjrjr
Issue: 633
Modified: trunk/user/src/com/google/gwt/user/client/ui/FileUpload.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/client/ui/FileUpload.java
(original)
+++ trunk/user/src/com/google/gwt/user/client/ui/FileUpload.java Wed Mar
18
10:47:55 2009
@@ -90,7 +90,8 @@
// Trigger a change event now.
if (eventPending) {
allowEvent = true;
-
fileUpload.getElement().dispatchEvent(Document.get().createChangeEvent());
+ fileUpload.getElement().dispatchEvent(
+ Document.get().createChangeEvent());
allowEvent = false;
eventPending = false;
}
@@ -165,11 +166,30 @@
return getInputElement().getName();
}
+ /**
+ * Gets whether this widget is enabled.
+ *
+ * @return <code>true</code> if the widget is enabled
+ */
+ public boolean isEnabled() {
+ return !getElement().getPropertyBoolean("disabled");
+ }
+
@Override
public void onBrowserEvent(Event event) {
if (impl.onBrowserEvent(event)) {
super.onBrowserEvent(event);
}
+ }
+
+ /**
+ * Sets whether this widget is enabled.
+ *
+ * @param enabled <code>true</code> to enable the widget,
<code>false</code>
+ * to disable it
+ */
+ public void setEnabled(boolean enabled) {
+ getElement().setPropertyBoolean("disabled", !enabled);
}
public void setName(String name) {
Modified: trunk/user/test/com/google/gwt/user/UISuite.java
==============================================================================
--- trunk/user/test/com/google/gwt/user/UISuite.java (original)
+++ trunk/user/test/com/google/gwt/user/UISuite.java Wed Mar 18 10:47:55
2009
@@ -45,6 +45,7 @@
import com.google.gwt.user.client.ui.DockPanelTest;
import com.google.gwt.user.client.ui.ElementWrappingTest;
import com.google.gwt.user.client.ui.FastStringMapTest;
+import com.google.gwt.user.client.ui.FileUploadTest;
import com.google.gwt.user.client.ui.FlexTableTest;
import com.google.gwt.user.client.ui.FlowPanelTest;
import com.google.gwt.user.client.ui.FocusPanelTest;
@@ -125,6 +126,7 @@
suite.addTestSuite(ElementWrappingTest.class);
suite.addTestSuite(EventTest.class);
suite.addTestSuite(FastStringMapTest.class);
+ suite.addTestSuite(FileUploadTest.class);
suite.addTestSuite(FlexTableTest.class);
suite.addTestSuite(FlowPanelTest.class);
suite.addTestSuite(FocusPanelTest.class);
Added: trunk/user/test/com/google/gwt/user/client/ui/FileUploadTest.java
==============================================================================
--- (empty file)
+++ trunk/user/test/com/google/gwt/user/client/ui/FileUploadTest.java Wed
Mar 18 10:47:55 2009
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * 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 com.google.gwt.user.client.ui;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests for {...@link FileUpload}.
+ *
+ */
+public class FileUploadTest extends GWTTestCase {
+
+ public String getModuleName() {
+ return "com.google.gwt.user.User";
+ }
+
+ public void testDisable() {
+ FileUpload fileUpload = new FileUpload();
+ assertTrue(fileUpload.isEnabled());
+ fileUpload.setEnabled(false);
+ assertFalse(fileUpload.isEnabled());
+ fileUpload.setEnabled(true);
+ assertTrue(fileUpload.isEnabled());
+ }
+}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---