001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.getahead.dwrdemo.reverse;
017:
018: import java.util.Collection;
019: import java.util.Date;
020:
021: import jsx3.GI;
022: import jsx3.app.Model;
023: import jsx3.app.Server;
024: import jsx3.gui.Block;
025: import jsx3.gui.Button;
026: import jsx3.gui.ColorPicker;
027: import jsx3.gui.DatePicker;
028: import jsx3.gui.Form;
029: import jsx3.gui.Select;
030: import jsx3.gui.Slider;
031: import jsx3.gui.TextBox;
032:
033: import org.directwebremoting.ScriptSession;
034: import org.directwebremoting.WebContext;
035: import org.directwebremoting.WebContextFactory;
036:
037: /**
038: * @author Joe Walker [joe at getahead dot ltd dot uk]
039: */
040: public class Reverse {
041: public void buttonEnable() {
042: getServer().getJSX("button", Button.class).setEnabled(
043: Form.STATEENABLED, true);
044: }
045:
046: public void buttonDisable() {
047: getServer().getJSX("button", Button.class).setEnabled(
048: Form.STATEDISABLED, true);
049: }
050:
051: public void select(String index) {
052: getServer().getJSX("select", Select.class).setValue(index);
053: }
054:
055: public void slide(int position) {
056: getServer().getJSX("slider", Slider.class).setValue(position);
057: }
058:
059: public void text(String message) {
060: getServer().getJSX("textbox", TextBox.class).setValue(message);
061: }
062:
063: public void textEnable() {
064: getServer().getJSX("textbox", TextBox.class).setEnabled(
065: Form.STATEENABLED, true);
066: }
067:
068: public void textDisable() {
069: getServer().getJSX("textbox", TextBox.class).setEnabled(
070: Form.STATEDISABLED, true);
071: }
072:
073: public void dateToday() {
074: getServer().getJSX("datePicker", DatePicker.class).setDate(
075: new Date());
076: }
077:
078: public void dateEpoch() {
079: getServer().getJSX("datePicker", DatePicker.class).setDate(
080: new Date(0));
081: }
082:
083: public void color(String color) {
084: getServer().getJSX("colorPicker", ColorPicker.class).setValue(
085: color);
086: }
087:
088: public void create() {
089: Button button = new Button("createCreated", 0, 0, 300,
090: "Created Button");
091: getServer().getJSX("blockCreate", Block.class).setChild(button,
092: Model.PERSISTNONE, (String) null, null);
093: }
094:
095: /**
096: *
097: */
098: private Server getServer() {
099: WebContext context = WebContextFactory.get();
100: String page = context.getContextPath() + "/gi/reverse.html";
101: Collection<ScriptSession> sessions = context
102: .getScriptSessionsByPage(page);
103:
104: return GI.getServer(sessions, "reverse");
105: }
106: }
|