Package com.daikit.daikit4gxt.client.ui.popup

Source Code of com.daikit.daikit4gxt.client.ui.popup.MyFormDialog

/**
* Copyright (C) 2013 DaiKit.com - daikit4gxt module (admin@daikit.com)
*
*         Project home : http://code.daikit.com/daikit4gxt
*
* 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.daikit.daikit4gxt.client.ui.popup;

import com.daikit.daikit4gxt.client.DkMain;
import com.daikit.daikit4gxt.client.ui.forms.MyFixedFormPanel;
import com.google.gwt.uibinder.client.UiChild;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.widget.core.client.Component;
import com.sencha.gxt.widget.core.client.container.MarginData;


/**
* Dialog box for forms
*
* @author tcaselli
* @version $Revision$ Last modifier: $Author$ Last commit: $Date$
*/
public abstract class MyFormDialog extends MySimpleControlsPopup
{
  protected final MyFixedFormPanel formPanel;

  /**
   * Constructor. Wrapper to {@link #MyFormDialog(boolean, int, int, DisplayableButton...)} with
   * width=DkMain.config().getDefaultPopupWidth()
   *
   * @param resizable
   * @param numberOfColumns
   *           in the form
   * @param displayableButtons
   */
  public MyFormDialog(final boolean resizable, final int numberOfColumns, final DisplayableButton... displayableButtons)
  {
    this(resizable, numberOfColumns, DkMain.config().getPopupWidth(), displayableButtons);
  }

  /**
   * Constructor
   *
   * @param resizable
   * @param numberOfColumns
   *           in the form
   * @param width
   * @param displayableButtons
   */
  public MyFormDialog(final boolean resizable, final int numberOfColumns, final int width,
      final DisplayableButton... displayableButtons)
  {
    super(resizable, displayableButtons);
    setWidth(width);
    formPanel = new MyFixedFormPanel(numberOfColumns, width - 6 * 2);// double padding 6px
    setKeepScrollableWidth(false);
    super.add(formPanel);
  }

  @Override
  public void setWidth(final int width)
  {
    super.setWidth(width);
    if (formPanel != null)
    {
      formPanel.setWidth(width - 6 * 2);
    }
  }

  /**
   * Please use addField(Widget, int) instead of add(IsWidget).
   */
  @Deprecated
  @Override
  public void add(final IsWidget child)
  {
    super.add(child);
  }

  /**
   * Please use addField(Widget, int) instead of add(Widget).
   */
  @Deprecated
  @Override
  public void add(final Widget child)
  {
    super.add(child);
  }

  /**
   * Please use addField(Widget, int) instead of add(Widget, MarginData).
   */
  @Deprecated
  @Override
  @UiChild(limit = 1, tagname = "child")
  public void add(final Widget child, final MarginData layoutData)
  {
    super.add(child, layoutData);
  }

  protected void addField(final Component widget)
  {
    formPanel.add(widget);
  }

  protected void addField(final Component widget, final int columnIndex)
  {
    formPanel.add(widget, columnIndex);
  }

  /**
   * set to false if you are sure there will be no scroll bar to be displayed, default is false.
   *
   * @param scrollable
   */
  public void setKeepScrollableWidth(final boolean scrollable)
  {
    formPanel.setKeepScrollableWidth(scrollable);
  }

  /**
   * @return the formPanel
   */
  public MyFixedFormPanel getFormPanel()
  {
    return formPanel;
  }
}
TOP

Related Classes of com.daikit.daikit4gxt.client.ui.popup.MyFormDialog

TOP
Copyright © 2018 www.massapi.com. 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.