Package com.totsp.gwittir.client.beans

Examples of com.totsp.gwittir.client.beans.Binding


    public void set(BoundWidget widget) {
        Address a = (Address) widget.getModel();
        AddressEdit e = (AddressEdit) widget;

        binding.getChildren()
               .add(new Binding(e.address1, "value", a, "address1"));
        binding.getChildren()
               .add(new Binding(e.address2, "value", a, "address2"));
        binding.getChildren().add(new Binding(e.city, "value", a, "city"));
        binding.getChildren().add(new Binding(e.state, "value", a, "state"));
        binding.getChildren().add(new Binding(e.zip, "value", a, "zip"));
        binding.getChildren().add(new Binding(e.type, "value", a, "type"));

        e.state.setRenderer(new Renderer() {
                public Object render(Object o) {
                    return ((StateLookup) o).name;
                }
View Full Code Here


    public void set(BoundWidget widget) {
        final Contact c = (Contact) widget.getModel();
        final ContactEdit e = (ContactEdit) widget;
        binding.getChildren()
               .add(new Binding(e.firstName, "value", c, "firstName"));
        binding.getChildren()
               .add(new Binding(e.lastName, "value", c, "lastName"));
        binding.getChildren().add(new Binding(e.notes, "value", c, "notes"));
        binding.getChildren()
               .add(new Binding(e.addresses, "value", c, "addresses"));
        binding.setLeft();

        e.newAddress.setAction(new Action() {
                public void execute(BoundWidget w) {
                    final Address newAddress = new Address();
View Full Code Here

       
      }

      public void set(BoundWidget<?> widget) {
        if(widget instanceof Page){
          b = new Binding( widget, "label.value", widget, "model.emailAddress");
          b.setLeft();
        }
      }

      public void unbind(BoundWidget<?> widget) {
View Full Code Here

                public Object render(Object o) {
                    return ((FlickrPhoto) o).getThumbnail();
                }
            });

        Binding images = new Binding(group, "value", search, "photos");

        images.getChildren()
              .add(
            new Binding(
                box, "value",
                new Converter() {
                public Object convert(Object original) {
                    if (original == null) {
                        return original;
                    } else {
                        return original.toString()
                                       .split(",");
                    }
                }
            }, search, "tags",
                new Converter() {
                public Object convert(Object original) {
                    if (original == null) {
                        return original;
                    } else {
                        String[] strings = (String[]) original;
                        StringBuffer ret = new StringBuffer();

                        for (int i = 0; i < strings.length; i++) {
                            ret.append(strings[i]);

                            if (i < (strings.length - 1)) {
                                ret.append(",");
                            }
                        }

                        return ret.toString();
                    }
                }
            }));
        images.getChildren()
              .add(new Binding(title, "value", search, "title"));
        images.setLeft();
        images.bind();

        SoftScrollArea mmsa = new SoftScrollArea();
        mmsa.addMouseListener(mmsa.MOUSE_MOVE_SCROLL_LISTENER);
        mmsa.setHeight("190px");
        mmsa.setWidth("800px");
        mmsa.setWidget(group);
        vp.add(mmsa);

        Image larger = new Image();
        Converter<FlickrPhoto, String> converter = new Converter<FlickrPhoto, String>() {
                public String convert(FlickrPhoto o) {
                    return o.getNormal();
                }
            };

        Binding bigBinding = new Binding(larger, "value", null, group, "selected", converter);
        bigBinding.bind();
        vp.add(larger);
    }
View Full Code Here

    }

    protected BoundWidget createWidget(Binding parent, Field field,
        SourcesPropertyChangeEvents target) {
        final BoundWidget widget;
        Binding binding;

        if(field.getCellProvider() != null) {
            widget = field.getCellProvider().get();
        } else {
            final Property p = Introspector.INSTANCE.getDescriptor(target)
                                                    .getProperty(field
                    .getPropertyName());
            widget = this.factory.getWidgetProvider(field.getPropertyName(),
                    p.getType()).get();

            // TODO Figure out some way to make this read only.
        }

       


        binding = new Binding(widget, "value", field.getValidator(),
                field.getFeedback(), target, field.getPropertyName(), null, null);
        widget.setModel(this.getValue());

        if(field.getConverter() != null) {
            binding.getRight().converter = field.getConverter();
        }

        if(field.getComparator() != null) {
            widget.setComparator(field.getComparator());
        }
View Full Code Here

       model1.setTestProp("model1");

       MockModel model2 = new MockModel();
       model2.setTestProp("model2");

       Binding b = new Binding(model1, "testProp", model2,
"testProp");
       b.bind();
       GWT.log( ""+model1, null);
       GWT.log( ""+model2, null);
       assert "model1".equals(model1.getTestProp());
       assert "model2".equals(model2.getTestProp());

       b.setRight();

       assert "model1".equals( model1.getTestProp());
       assert "model1".equals(model2.getTestProp());

       // WORKS UP TO THIS POINT
View Full Code Here

    private ConverterWrapper converter = new ConverterWrapper();
    private boolean hasFirstSet = false;
    /** Creates a new instance of PopupDatePicker */
    public PopupDatePicker() {
       
        Binding b = new Binding( label, "value", null, base, "value", converter);
        b.setLeft();
        b.bind();
        pp.setWidget(base);
        this.hp.add( this.label );
        this.hp.add( this.icon );
        fp.setWidget( hp );
        this.initWidget( fp );
View Full Code Here

            table.getFlexCellFormatter().setColSpan(row, 0, this.columns.length);
            table.getRowFormatter().setStyleName(row, "spacer");
            row++;
        }

        Binding bindingRow = new Binding();
        topBinding.getChildren().add(bindingRow);

        int count = topBinding.getChildren().size();
        final Button handle;
        int startColumn = 0;

        if ((this.masks & BoundTable.ROW_HANDLE_MASK) > 0) {
            handle = new Button((this.getActive() && (rowHandles.size() < 9))
                    ? Integer.toString(this.rowHandles.size() + 1) : " ");
            handle.setStyleName("rowHandle");
            handle.addFocusListener(new FocusListener() {

                public void onFocus(Widget sender) {
                    if (shiftDown) {
                        return;
                    }

                    setActive(true);

                    List newSelected = null;

                    if ((masks & BoundTable.MULTIROWSELECT_MASK) > 0) {
                        newSelected = new ArrayList(getSelected());

                        if (newSelected.contains(o)) {
                            newSelected.remove(o);
                        } else {
                            newSelected.add(o);
                        }
                    } else {
                        newSelected = new ArrayList();
                        newSelected.add(o);
                    }

                    setSelected(newSelected);
                }

                public void onLostFocus(Widget sender) {
                }
            });
            handle.addClickListener(new ClickListener() {

                public void onClick(Widget sender) {
                    setActive(true);

                    List newSelected = null;

                    if ((masks & BoundTable.MULTIROWSELECT_MASK) > 0) {
                        newSelected = new ArrayList(getSelected());

                        if (newSelected.contains(o)) {
                            newSelected.remove(o);
                        } else {
                            newSelected.add(o);
                        }
                    } else {
                        newSelected = new ArrayList();
                        newSelected.add(o);
                    }

                    if (handle != null) {
                        handle.setFocus(true);
                    }

                    if (handle != null) {
                        handle.setFocus(true);
                    }

                    setSelected(newSelected);
                }
            });
            startColumn++;
            this.rowHandles.add(handle);
            this.table.setWidget(row, 0, handle);
        } else {
            handle = null;
        }

        if (count < 10) {
            SuggestedKeyBinding kb = new SuggestedKeyBinding(Integer.toString(
                    count).charAt(0), false, true, false);
            Task task = new Task() {

                public void run() {
                    List newSelected = new ArrayList(getSelected());

                    if (newSelected.contains(o)) {
                        newSelected.remove(o);
                    } else {
                        newSelected.add(o);
                    }

                    setSelected(newSelected);

                    if (handle != null) {
                        handle.setFocus(true);
                    }
                }
            };

            this.keyBindings.put(kb, task);

            if (this.getActive()) {
                try {
                    KeyboardController.INSTANCE.register(kb, task);
                } catch (KeyBindingException kbe) {
                    BoundTable.LOG.log(Level.DEBUG, "Unable to register" + kb,
                            kbe);
                }
            }
        }

        for (int col = 0; col < this.columns.length; col++) {
            Widget widget = (Widget) createCellWidget(bindingRow, col, o);

            try {
                table.setWidget(row, col + startColumn, widget);

                if (widget instanceof HasFocus) {
                    addSelectedFocusListener((HasFocus) widget,
                            topBinding.getChildren().size() - 1, col + startColumn);
                }

                if (widget instanceof SourcesClickEvents) {
                    addSelectedClickListener((SourcesClickEvents) widget,
                            topBinding.getChildren().size() - 1, col + startColumn);
                }

                if (this.columns[col].getStyleName() != null) {
                    table.getCellFormatter().setStyleName(row, col + startColumn,
                            this.columns[col].getStyleName());
                }
            } catch (RuntimeException e) {
                BoundTable.LOG.log(Level.ERROR, widget + "", e);
            }
        }

        boolean odd = (this.calculateRowToObjectOffset(new Integer(row)).intValue() % 2) != 0;
        this.table.getRowFormatter().setStyleName(row, odd ? "odd" : "even");

        if (this.isAttached()) {
            bindingRow.setLeft();
            bindingRow.bind();
        }
    }
View Full Code Here

                bindings = new Binding[this.columns.length];
                this.bindingCache.put(target, bindings);
            }

            if (bindings[colIndex] == null) {
                bindings[colIndex] = new Binding(widget, "value",
                        col.getValidator(), col.getFeedback(), target,
                        col.getPropertyName(), null, null);
                BoundTable.LOG.log(Level.SPAM,
                        "Created binding " + bindings[colIndex], null);
            }
View Full Code Here

    }

    private void init(int masksValue) {
        //GWT.log( "Init "+ +masksValue + " :: "+((masksValue & BoundTable.MULTI_REQUIRES_SHIFT) > 0), null);
        final BoundTable instance = this;
        this.topBinding = new Binding();
        this.masks = masksValue;
        this.factory = (this.factory == null)
                ? new BoundWidgetTypeFactory(true) : this.factory;

        if (((this.masks & BoundTable.SORT_MASK) > 0)
View Full Code Here

TOP

Related Classes of com.totsp.gwittir.client.beans.Binding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.