Example usage for com.google.gwt.user.client.ui HorizontalPanel add

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel add

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel add.

Prototype

@Override
    public void add(Widget w) 

Source Link

Usage

From source file:com.dingziran.effective.client.content.widgets.CwBasicButton.java

License:Apache License

/**
 * Constructor.//  w  ww . j a v a2 s  .co m
 *
 * @param constants the constants
 */
public CwBasicButton(CwConstants constants) {
    super(constants.cwBasicButtonName(), constants.cwBasicButtonDescription());
    this.constants = constants;
    view = new ContentWidgetView(hasMargins(), hasScrollableContent());
    view.setName(getName());
    view.setDescription(getDescription());
    setWidget(view);
    // Create a panel to align the widgets
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(10);
    final String msg = constants.cwBasicButtonClickMessage();
    // Add a normal button
    Button normalButton = new Button(constants.cwBasicButtonNormal(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert(msg);
        }
    });
    normalButton.ensureDebugId("cwBasicButton-normal");
    hPanel.add(normalButton);

    // Add a disabled button
    Button disabledButton = new Button(constants.cwBasicButtonDisabled());
    disabledButton.ensureDebugId("cwBasicButton-disabled");
    disabledButton.setEnabled(false);
    hPanel.add(disabledButton);
    view.setExample(hPanel);
}

From source file:com.dingziran.effective.client.content.widgets.CwCustomButton.java

License:Apache License

/**
 * Constructor./*from   www.  j av  a  2 s.c  om*/
 *
 * @param constants the constants
 */
public CwCustomButton(CwConstants constants) {
    super(constants.cwCustomButtonName(), constants.cwCustomButtonDescription());
    this.constants = constants;
    view = new ContentWidgetView(hasMargins(), hasScrollableContent());
    view.setName(getName());
    view.setDescription(getDescription());
    setWidget(view);
    // Create a panel to layout the widgets
    VerticalPanel vpanel = new VerticalPanel();
    HorizontalPanel pushPanel = new HorizontalPanel();
    pushPanel.setSpacing(10);
    HorizontalPanel togglePanel = new HorizontalPanel();
    togglePanel.setSpacing(10);

    // Combine all the panels
    vpanel.add(new HTML(constants.cwCustomButtonPush()));
    vpanel.add(pushPanel);
    vpanel.add(new HTML("<br><br>" + constants.cwCustomButtonToggle()));
    vpanel.add(togglePanel);

    // Add a normal PushButton
    PushButton normalPushButton = new PushButton(new Image(Showcase.images.gwtLogo()));
    normalPushButton.ensureDebugId("cwCustomButton-push-normal");
    pushPanel.add(normalPushButton);

    // Add a disabled PushButton
    PushButton disabledPushButton = new PushButton(new Image(Showcase.images.gwtLogo()));
    disabledPushButton.ensureDebugId("cwCustomButton-push-disabled");
    disabledPushButton.setEnabled(false);
    pushPanel.add(disabledPushButton);

    // Add a normal ToggleButton
    ToggleButton normalToggleButton = new ToggleButton(new Image(Showcase.images.gwtLogo()));
    normalToggleButton.ensureDebugId("cwCustomButton-toggle-normal");
    togglePanel.add(normalToggleButton);

    // Add a disabled ToggleButton
    ToggleButton disabledToggleButton = new ToggleButton(new Image(Showcase.images.gwtLogo()));
    disabledToggleButton.ensureDebugId("cwCustomButton-toggle-disabled");
    disabledToggleButton.setEnabled(false);
    togglePanel.add(disabledToggleButton);

    view.setExample(vpanel);
}

From source file:com.dynamobi.pentaho.whlabel.client.WHLabel.java

License:Open Source License

public void onModuleLoad() {
    dropDownPanel.setSpacing(20);/*w w w  .j  av  a 2s  .  c  o  m*/
    setDataSources();
    HorizontalPanel currLabelPanel = new HorizontalPanel();
    currLabelPanel.add(dsListBox);
    Label spaceLabel = new Label();
    spaceLabel.setWidth("10");
    spaceLabel.setText(" ");
    currLabelPanel.add(spaceLabel);
    currLabelPanel.add(currSelectedLabel);
    dropDownPanel.add(currLabelPanel);
    labelTable.setHeader(0, "Warehouse Label");
    labelTable.setHeader(1, "Timestamp");
    labelTable.setHeight("100");
    labelTable.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Cell cell = labelTable.getCellForEvent(event);
            int rowIndex = cell.getRowIndex();
            for (int i = 0; i < labelTable.getRowCount(); i++)
                labelTable.getRowFormatter().setStyleName(i, "dwTableRow");
            labelTable.getRowFormatter().setStyleName(rowIndex, "selectedRow");
        }
    });

    labelTable.setStyleName("labelTable");
    dropDownPanel.add(labelTable);
    buttonTable.setWidget(0, 0, unsetLabelButton);
    unsetLabelButton.setStyleName("button");
    setLabelButton.setStyleName("button");
    unsetLabelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent bce) {
            String selectedLabel = "null";
            final String currentSchema = dsListBox.getItemText(dsListBox.getSelectedIndex());
            setDWLabel(currentSchema, selectedLabel);
        }
    });

    setLabelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent bce) {
            String selectedLabel = "";
            for (int i = 0; i < labelTable.getRowCount(); i++) {
                if (labelTable.getRowFormatter().getStyleName(i).equalsIgnoreCase("selectedRow"))
                    selectedLabel = labelTable.getText(i, 0);
            }
            selectedLabel += " " + dsListBox.getItemText(dsListBox.getSelectedIndex());
            for (int i = 0; i < labelTable.getRowCount(); i++) {
                if (labelTable.getRowFormatter().getStyleName(i).equalsIgnoreCase("selectedRow"))
                    selectedLabel = labelTable.getText(i, 0);
            }
            //selectedLabel += " "+dsListBox.getItemText(dsListBox.getSelectedIndex());
            final String currentSchema = dsListBox.getItemText(dsListBox.getSelectedIndex());
            setDWLabel(currentSchema, selectedLabel);
        }
    });

    //      cancelButton.addClickHandler(new ClickHandler() {
    //         public void onClick(ClickEvent bce) {
    //            final String currentSchema = dsListBox.getItemText(dsListBox.getSelectedIndex());
    //            getDWLabel(currentSchema);
    //         }
    //      });
    //      
    buttonTable.setWidget(0, 1, setLabelButton);
    //      buttonTable.setWidget(0, 2, cancelButton);
    buttonTable.getCellFormatter().setStyleName(0, 0, "buttonRight");
    //      buttonTable.getCellFormatter().setStyleName(0, 1, "buttonCenter");
    buttonTable.getCellFormatter().setStyleName(0, 2, "buttonLeft");
    buttonTable.setStyleName("buttonTable");
    buttonPanel.add(buttonTable);
    dropDownPanel.add(buttonPanel);
    mainPanel.add(dropDownPanel);
    RootPanel.get("description").add(mainPanel);

    //      currLabelPanel.add(currSelectedLabel);
    //      RootPanel.get("warehouseLabel").add(currLabelPanel);

    dsListBox.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent arg0) {
            final String currentSchema = dsListBox.getItemText(dsListBox.getSelectedIndex());
            updateDWLabels(currentSchema);
        }
    });
}

From source file:com.edgenius.wiki.gwt.client.BaseEntryPoint.java

License:Open Source License

public boolean isSessionExpired(String currUsername) {
    String username = (String) profile.getObject();
    if (StringUtil.equals(username, currUsername))
        //both null, maybe
        return false;

    if (username != null && !username.equalsIgnoreCase(currUsername)) {
        //user changed
        profile.setObject(currUsername);
        showLoginPanel();// w  w  w. ja v  a 2 s  .c o m
        //show a warning to user
        HorizontalPanel msg = new HorizontalPanel();
        HTML label = new HTML(Msg.consts.session_expired() + "&nbsp; ");
        ClickLink login = new ClickLink(Msg.consts.login());
        login.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                LoginDialog dialogue = new LoginDialog(LoginDialog.LOGIN);
                dialogue.showbox();
            }
        });
        msg.add(label);
        msg.add(login);
        globalMessage.error(msg);
        //session expired, logout, broadcast
        login(null);
        return true;
    }

    return false;
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEAnchorDialog.java

License:Open Source License

public MCEAnchorDialog(TinyMCE tiny) {
    super(tiny);//from   w  ww  . jav a  2 s . c o  m

    this.setText(Msg.consts.insert_anchor());
    Label label = new Label(Msg.consts.anchor_name());

    HorizontalPanel func = new HorizontalPanel();
    func.add(label);
    func.add(box);

    VerticalPanel panel = new VerticalPanel();
    panel.add(message);
    panel.add(func);

    panel.setSize("100%", "100%");
    func.setSize("100%", "100%");
    label.setStyleName(Css.FORM_LABEL);
    box.setStyleName(Css.FORM_INPUT);
    this.setWidget(panel);

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {
            box.setFocus(true);
        }
    });
}

From source file:com.edgenius.wiki.gwt.client.editor.PlainEditor.java

License:Open Source License

public PlainEditor(final Editor editor) {
    textArea.addKeyPressHandler(new ContentChangeListener());
    textArea.addKeyDownHandler(new ContentChangeListener());
    textArea.addKeyPressHandler(new QuickHelpKeyListener());

    HorizontalPanel funcPanel = new HorizontalPanel();
    if (Editor.RICH_ENABLE) {
        switchLink.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                switchBusy.setVisible(true);
                switchLink.setVisible(false);
                editor.toRichEditor();/*from w  ww .  j av a 2 s. c om*/
            }
        });
        HorizontalPanel switchPanel = new HorizontalPanel();
        switchPanel.add(switchBusy);
        switchPanel.add(switchLink);
        switchLink.addStyleName(Css.RIGHT);
        switchBusy.addStyleName(Css.RIGHT);
        switchPanel.setCellWidth(switchLink, "100");
        switchBusy.setVisible(false);
        funcPanel.add(switchPanel);
    }

    //      HelpButton helpLink = new HelpButton(true);
    //      funcPanel.add(helpLink);

    topPanel.add(quickHelpBar);
    topPanel.add(funcPanel);

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // main
    VerticalPanel panel = new VerticalPanel();
    panel.add(topPanel);
    panel.add(textArea);
    panel.setWidth("100%");

    funcPanel.addStyleName(Css.RIGHT);
    topPanel.setStyleName(Css.EDIT_TOOLBAR);
    quickHelpBar.setStyleName(Css.QUICK_HELP);
    textArea.setStyleName(Css.MARKUP_TEXTAREA);
    //this is require of TinyMCE richeditor - to auto resize according to browser window. The class attribute link outter style is not working
    textArea.setWidth("100%");
    DOM.setElementAttribute(textArea.getElement(), "id", id);

    this.setWidget(panel);
}

From source file:com.edgenius.wiki.gwt.client.home.porlet.MessagePortlet.java

License:Open Source License

/**
 * A common callback success, as this portlet can accept response from Portlet invoke 
 * or from a message send refresh callback.
 *//*  w  ww  .  j  av  a  2s  . c o m*/
private void callback(GeneralModel model, MessageListModel msgs) {
    busy(false);
    messagePanel.clear();
    if (!GwtClientUtils.preSuccessCheck(model, null)) {
        //show error message on item part rather than general error message on HTML page above
        messagePanel.add(ErrorCode.getMessage(model.errorCode, model.errorMsg));
        return;
    }

    if (msgs.list.size() == 0) {
        none.setStyleName(Css.PORTLET_WEAK_TEXT);
        messagePanel.add(none);
        return;
    }

    for (Iterator<MessageModel> iter = msgs.list.iterator(); iter.hasNext();) {
        final MessageModel msg = iter.next();
        String puid = HTMLPanel.createUniqueId();
        String puid1 = HTMLPanel.createUniqueId();
        String puid2 = HTMLPanel.createUniqueId();
        String puid3 = HTMLPanel.createUniqueId();
        HTMLPanel msgPanel = new HTMLPanel("<div style=\"display:inline;font-weight:bold;\" id=\"" + puid1
                + "\"></div>" + "<div style=\"display:inline\" id=\"" + puid2
                + "\"></div> <div class=\"weaktext\">" + Msg.consts.by() + "</div><div class=\"weaklink\" id=\""
                + puid + "\"></div><div class=\"weaktext\">" + Msg.consts.on() + " "
                + GwtClientUtils.toDisplayDate(msg.date) + "</div>" + "<div style=\"display:inline\" id=\""
                + puid3 + "\"></div>");

        if ((msg.targetType == SharedConstants.MSG_TARGET_USER
                //TODO: how to distinguish the contributor and admin?
                || msg.targetType == SharedConstants.MSG_TARGET_SPACE_CONTRIBUTE_USERS
                || msg.targetType == SharedConstants.MSG_TARGET_SPACE_ADMIN_ONLY)
                && !StringUtil.isBlank(msg.target)) {
            msgPanel.add(new Label(
                    (msg.targetType == SharedConstants.MSG_TARGET_USER ? "@" : "@@") + msg.target + " "),
                    puid1);
        }
        if (msg.targetType == SharedConstants.MSG_TARGET_INSTANCE_ADMIN_ONLY
                && StringUtil.isBlank(msg.target)) {
            //message to system admin
            Image msgAdmin = new Image(IconBundle.I.get().error());
            msgAdmin.setTitle(Msg.consts.msg_to_admin());
            msgPanel.add(msgAdmin, puid1);
        }

        //don't use UserProfileLink - click user link will invoke reply message, rather than jump to user profile
        //UserProfileLink authorPop = new UserProfileLink(msg.author, null,msg.author,msg.authorPortrait);
        ClickLink authorPop = new ClickLink(msg.authorUsername);
        //auto popup for user profile
        new UserPopup(authorPop, null, msg.authorUsername, msg.authorPortrait);
        authorPop.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent evt) {
                if (msg.authorUid != -1) {
                    postPanel.fillTarget(SharedConstants.MSG_TARGET_USER, msg.authorUsername);
                } else {
                    //reply anonymous means to all 
                    postPanel.fillTarget(null, null);
                }
                postPanel.focusToEnd(true);
            }
        });

        msgPanel.add(new Label(msg.text), puid2);
        msgPanel.add(authorPop, puid);
        if (msg.removable) {
            Image bin = new Image(IconBundle.I.get().bin_close());
            bin.setTitle(Msg.consts.delete());
            bin.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    if (Window.confirm(Msg.consts.confirm_delete_message())) {
                        NotificationControllerAsync notifyController = ControllerFactory
                                .getNotificationController();
                        notifyController.deleteMessage(currentPage, msg.uid, new NotificationCallback());
                    }
                }
            });
            msgPanel.add(bin, puid3);
        }

        DOM.setStyleAttribute(msgPanel.getElement(), "display", "inline");

        HorizontalPanel itemPanel = new HorizontalPanel();
        Widget portrait = GwtClientUtils.createUserSmallPortrait(msg.authorPortrait,
                SharedConstants.PORTRAIT_SIZE_SMALL);
        itemPanel.add(portrait);
        itemPanel.setCellWidth(portrait, "50px");
        itemPanel.add(msgPanel);
        messagePanel.add(itemPanel);
    }

    clearControl();

    controlBar.setPaginationInfo(msgs.hasPre, msgs.hasNxt, msgs.currentPage);
    addControl(controlBar);
}

From source file:com.edgenius.wiki.gwt.client.home.porlet.PageListPortlet.java

License:Open Source License

protected void fillList(List<PageItemModel> pages, int fillType, int style) {
    container.clear();//from   w ww . ja va 2 s. co  m
    //show page items one by one on fragment panel
    if (pages != null && pages.size() > 0) {
        for (Iterator<PageItemModel> iter = pages.iterator(); iter.hasNext();) {
            final PageItemModel item = iter.next();
            FlowPanel itemPanel = new FlowPanel();

            if (fillType == FILL_TYPE_DRAFT) {
                //append delete image to allow delete draft from portlet
                Image dot;
                if (item.type == PageType.MANUAL_DRAFT) {
                    dot = new Image(IconBundle.I.get().bullet_green());
                    dot.setTitle(Msg.consts.manual_draft());
                } else if (item.type == PageType.AUTO_DRAFT) {
                    dot = new Image(IconBundle.I.get().bullet_yellow());
                    dot.setTitle(Msg.consts.auto_draft());
                } else {
                    dot = new Image(IconBundle.I.get().bullet_red());
                    dot.setTitle(Msg.consts.conflict_draft());
                }
                itemPanel.add(dot);
            }
            Hyperlink title;
            if (fillType == FILL_TYPE_DRAFT) {
                title = getDraftLink(item);
            } else {
                //default Page Link
                title = getPageLink(item);
            }
            Label date = new Label(GwtClientUtils.toDisplayDate(item.modifiedDate));
            date.setStyleName(Css.PORTLET_WEAK_TEXT);

            //add key of this item
            itemPanel.add(new Hidden(item.uuid, item.uuid + item.type));

            if (item.pinTop) {
                itemPanel.add(new Image(IconBundle.I.get().pin_small()));
            }

            itemPanel.add(title);
            if (fillType == FILL_TYPE_DRAFT || fillType == FILL_TYPE_MYPAGE) {
                //append spaceUname
                Label spaceLabel = new Label("(" + item.spaceUname + ")");
                spaceLabel.setStyleName(Css.PORTLET_WEAK_TEXT);
                itemPanel.add(spaceLabel);
            }
            itemPanel.add(date);
            if (fillType == FILL_TYPE_DRAFT) {
                //append delete image to allow delete draft from portlet
                Image bin = new Image(IconBundle.I.get().bin_close());
                bin.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        if (Window.confirm(Msg.params.confirm_delete_draft(item.title))) {
                            //put enable busy before async call as offline call immediately return and busy icon won't disappear if 
                            //enable after async call
                            busy(true);
                            PageControllerAsync pageController = ControllerFactory.getPageController();
                            pageController.removeDraft(item.spaceUname, item.uuid, item.type,
                                    new RefreshDraftAsync());
                        }
                    }
                });
                bin.setTitle(Msg.consts.delete_draft());
                itemPanel.add(bin);
            }

            if ((style & STYLE_SHOW_CREATED_BY) > 0 || (style & STYLE_SHOW_MODIFIED_BY) > 0) {
                //please be aware of, the PageItem has only modifier info - this will be filled to creator info when 
                //widget style is WIDGET_STYLE_ITEM_SHORT_BY_CREATE_DATE
                UserProfileLink modifier = new UserProfileLink(item.modifier, item.spaceUname,
                        item.modifierUsername, item.modifierPortrait);
                Label mL;
                if ((style & STYLE_SHOW_CREATED_BY) > 0)
                    mL = new Label(Msg.consts.created_by());
                else
                    mL = new Label(Msg.consts.modified_by());

                mL.setStyleName(Css.PORTLET_WEAK_TEXT);
                modifier.setStyleName(Css.WEAK_LINK);
                itemPanel.add(mL);
                itemPanel.add(modifier);
            }
            if ((style & STYLE_SHOW_PORTRAIT) > 0) {
                HorizontalPanel panel = new HorizontalPanel();
                Widget portrait = GwtClientUtils.createUserSmallPortrait(item.modifierPortrait,
                        SharedConstants.PORTRAIT_SIZE_SMALL);
                panel.add(portrait);
                panel.setCellWidth(portrait, "50px");
                panel.add(itemPanel);
                container.add(panel);
                panel.setStyleName(Css.ITEM);
            } else {
                itemPanel.setStyleName(Css.ITEM);
                container.add(itemPanel);
            }
        }
    } else {
        empty();
    }
}

From source file:com.edgenius.wiki.gwt.client.page.DiffPanel.java

License:Open Source License

private void diffMessage(final DiffListModel model) {

    diffMessage.cleanMessage();/*from  www.  j a  va  2  s  .  c o  m*/

    String id1 = HTMLPanel.createUniqueId();
    //head
    StringBuffer buf = new StringBuffer("<div class='historyAction diff'><div class='msg' id='").append(id1)
            .append("'></div>");
    buf.append("<div class='action'>");

    buf.append(
            "<div class='indicator diff-text'><div class='diff-insertion'>Added</div> <div class='diff-deletion'>Deleted</div></div>");
    //diff 1
    String idp1 = null, idp2 = null, idp3 = null, idn1 = null, idn2 = null, idn3 = null;
    idn1 = HTMLPanel.createUniqueId();
    idn2 = HTMLPanel.createUniqueId();
    idn3 = HTMLPanel.createUniqueId();
    buf.append("<div class='round next'><div class='version' id='").append(idn1)
            .append("'></div><div class='author' id='").append(idn2).append("'></div><div class='date' id='")
            .append(idn3).append("'></div></div>");
    //diff 2
    idp1 = HTMLPanel.createUniqueId();
    idp2 = HTMLPanel.createUniqueId();
    idp3 = HTMLPanel.createUniqueId();

    buf.append("<div class='current'>vs</div>");

    buf.append("<div class='round prev'><div class='version' id='").append(idp1)
            .append("'></div><div class='author' id='").append(idp2).append("'></div><div class='date' id='")
            .append(idp3).append("'></div></div>");

    //end
    buf.append("</div></div>");

    //put this message into 
    HTMLPanel msgPanel = new HTMLPanel(buf.toString());
    msgPanel.add(new Label(Msg.consts.comparing_view()), id1);

    diffActionMsg(msgPanel, model.prevHistoryItem, idn1, idn2, idn3);
    diffActionMsg(msgPanel, model.nextHistoryItem, idp1, idp2, idp3);

    HorizontalPanel panel = new HorizontalPanel();
    panel.add(msgPanel);

    diffMessage.warning(panel, false);
}

From source file:com.edgenius.wiki.gwt.client.page.EditPanel.java

License:Open Source License

/**
 * Only put value to panel, does not change visible attribute of this panel.
 * @param model//w ww  . j  av a 2  s. c o m
 */
private void fillPanel(final PageModel model) {
    setCurrentToken(GwtClientUtils.getToken());

    functionBtnBar.loadEditFunc(model == null ? 0 : model.attribute);
    draftStatusBar.setText("");
    draftStatusBar.removeStyleName(Css.ERROR);
    titleBox.removeStyleName(Css.ERROR);
    dirty = false;

    //always hide print button as it maybe a new page 
    main.setPrintBtnVisible(false);

    if (model == null) {
        //clear all fields
        titleBox.setText("");
        tagBox.setText("");
        contentArea.setText("");
    } else {
        if (model.autoSaveUid != null) {
            HorizontalPanel messagePanel = new HorizontalPanel();
            HTML m1 = new HTML(
                    Msg.params.resume_auto_draft(GwtClientUtils.toDisplayDate(model.autoSaveDate)) + " &nbsp;");
            ClickLink resumeDraftButton = new ClickLink(Msg.consts.resume_auto_draft());
            messagePanel.add(m1);
            messagePanel.add(resumeDraftButton);
            messagePanel.add(new HTML("?"));
            autoSaveMsgUuid = message.info(messagePanel, -1, true);
            resumeDraftButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    autoSaveMsgUuid = null;
                    message.cleanMessage();
                    PageControllerAsync action = ControllerFactory.getPageController();
                    //get this user's draft and its attachments
                    action.editDraft(model.autoSaveUid, PageType.AUTO_DRAFT, true,
                            new LoadDraftAsync(PageType.AUTO_DRAFT));
                }
            });
        }
        if (model.editingUserFullname != null) {
            HorizontalPanel messagePanel = new HorizontalPanel();
            HTML m1 = new HTML(Msg.params.page_editing_warn(model.editingTime <= 1 ? Msg.consts.just_now()
                    : Msg.params.in_minutes_ago(model.editingTime + "")));
            UserProfileLink userButton = new UserProfileLink(model.editingUserFullname, main.getSpaceUname(),
                    model.editingUsername, model.editingUserPortrait);
            messagePanel.add(userButton);
            messagePanel.add(m1);
            messagePanel.add(new HTML("."));
            message.warning(messagePanel, 100000, true);
        }

        //update page info : if user refresh page during edit, those info be catch back.
        main.setCurrentPageTitle(model.title);
        PageMain.setParentPageUuid(model.parentPageUuid);
        main.setPageAttribute(model.attribute);
        main.setNewPageType(model.newPageType);
        main.setSpaceUname(model.spaceUname);
        main.setPageVersion(model.pageVersion);
        main.setPageUuid(model.pageUuid == null ? "" : model.pageUuid.toString());

        //put fields into edit box
        titleBox.setText(model.title == null ? ""
                : (model.title.length() > TITLE_MAX_LEN ? model.title.substring(0, TITLE_MAX_LEN)
                        : model.title));
        tagBox.setText(model.tagString == null ? "" : model.tagString);
        tagBox.setSpaceUname(model.spaceUname);

        //must call before setText(), so that content could point to correct editor 
        contentArea.enableRich(model.isRichContent);
        contentArea.setText(model.content == null ? "" : model.content);
        contentArea.resize();

        if (templatePanel != null) {
            templatePanel.initPanel();
        }
        if (!GwtUtils.contains(model.attribute, PageAttribute.NO_ATTACHMENT)) {
            attachmentBtn.setVisible(true);
            attPanel.mergeAttachments(model.attachmentJson);
            if (GwtUtils.isAnonymous(main.getLoginUser()))
                attPanel.setReadonly(true);
            else
                attPanel.setReadonly(false);
        } else {
            //hide all attachment and panel...
            setAttachmentCount(0);
            attachmentBtn.setVisible(false);
            attPanel.setVisible(false);
            attPanel.setReadonly(false);
            attPanel.reset();
        }

        main.fillEditNavBar(model);

        if (model.draftUid != null) {
            HorizontalPanel messagePanel = new HorizontalPanel();
            HTML m1 = new HTML(
                    Msg.params.resume_draft(GwtClientUtils.toDisplayDate(model.draftDate)) + " &nbsp;");
            ClickLink resumeDraftButton = new ClickLink(Msg.consts.resume_draft());
            messagePanel.add(m1);
            messagePanel.add(resumeDraftButton);
            messagePanel.add(new HTML("?"));

            message.info(messagePanel, -1, true);
            resumeDraftButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    autoSaveMsgUuid = null;
                    message.cleanMessage();
                    PageControllerAsync action = ControllerFactory.getPageController();
                    //get this user's draft and its attachments
                    action.editDraft(model.draftUid, PageType.MANUAL_DRAFT, true,
                            new LoadDraftAsync(PageType.MANUAL_DRAFT));
                }
            });

            final MessageDialog confirmDraftDlg = new MessageDialog(MessageDialog.TYPE_CONFIRM,
                    Msg.consts.confirm() + " " + Msg.consts.resume_draft(),
                    Msg.params.resume_manual_draft(GwtClientUtils.toDisplayDate(model.draftDate)));
            confirmDraftDlg.addMessageListener(new MessageDialogListener() {
                public void cancelled() {
                }

                public void confirmed() {
                    autoSaveMsgUuid = null;
                    message.cleanMessage();
                    PageControllerAsync action = ControllerFactory.getPageController();
                    //get this user's draft and its attachments
                    action.editDraft(model.draftUid, PageType.MANUAL_DRAFT, true,
                            new LoadDraftAsync(PageType.MANUAL_DRAFT));
                }
            });
            confirmDraftDlg.showbox();

        }
    }
}