ContactDialog.java :  » GWT » gwtoolbox » org » gwtoolbox » sample » mail » client » ui » Java Open Source

Java Open Source » GWT » gwtoolbox 
gwtoolbox » org » gwtoolbox » sample » mail » client » ui » ContactDialog.java
/*
 * Copyright (c) 2006-2007 The original author(s).
 *
 * 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 org.gwtoolbox.sample.mail.client.ui;

import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import org.gwtoolbox.sample.mail.client.Contact;
import org.gwtoolbox.widget.client.active.ActiveCheckBox;
import org.gwtoolbox.widget.client.active.ActiveDateBox;
import org.gwtoolbox.widget.client.active.ActiveTextBox;
import org.gwtoolbox.widget.client.active.ErrorMessageCallback;
import org.gwtoolbox.widget.client.dialog.SimpleDialog;

/**
 * @author Bram Smeets
 */
public class ContactDialog extends SimpleDialog {

    public ContactDialog(Contact contact) {
        super("Edit contact: " + contact.getName().getFullName(), "Close");

        DockPanel panel = new DockPanel();
        panel.add(contact.getImage(), DockPanel.WEST);

        FlexTable table = new FlexTable();
        panel.add(table, DockPanel.CENTER);

        Label label = new Label("First name: ");
        label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
        table.setWidget(0, 0, label);
        table.setWidget(0, 1, new ActiveTextBox(contact, "name.firstName", new DefaultErrorMessageCallback()));

        table.setWidget(1, 0, new Label("Middle name: "));
        table.setWidget(1, 1, new ActiveTextBox(contact, "name.middleName", new DefaultErrorMessageCallback()));

        table.setWidget(2, 0, new Label("Last name: "));
        table.setWidget(2, 1, new ActiveTextBox(contact, "name.lastName", new DefaultErrorMessageCallback()));

        table.setWidget(3, 0, new Label("Email: "));
        table.setWidget(3, 1, new ActiveTextBox(contact, "email", new DefaultErrorMessageCallback()));

        table.setWidget(4, 0, new Label("Private?: "));
        table.setWidget(4, 1, new ActiveCheckBox(contact, "privateContact"));

        table.setWidget(5, 0, new Label("Birth Date: "));
        table.setWidget(5, 1, new ActiveDateBox(contact, "birthDate"));

        setWidget(panel);
    }

    private class DefaultErrorMessageCallback implements ErrorMessageCallback {

        public void onError(String[] messages) {
        }

        public void clearError() {
        }

    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.