Ejemplo n.º 1
0
 /**
  * 组件删除
  *
  * @param e 容器事件
  */
 @Override
 public void componentRemoved(ContainerEvent e) {
   if (isRefreshing) {
     return;
   }
   XWidgetCreator xwc = ((XWidgetCreator) e.getChild());
   Widget wgt = xwc.toData();
   WTitleLayout wlayout = this.toData();
   wlayout.removeWidget(wgt);
 }
Ejemplo n.º 2
0
 /**
  * 组件增加
  *
  * @param e 容器事件
  */
 @Override
 public void componentAdded(ContainerEvent e) {
   if (isRefreshing) {
     return;
   }
   WTitleLayout layout = this.toData();
   XWidgetCreator creator = (XWidgetCreator) e.getChild();
   FRTitleLayout lay = (FRTitleLayout) getLayout();
   Object constraints = lay.getConstraints(creator);
   if (ComparatorUtils.equals(WTitleLayout.TITLE, constraints)) {
     layout.addTitle(creator.toData(), creator.getBounds());
   } else if (ComparatorUtils.equals(WTitleLayout.BODY, constraints)) {
     layout.addBody(creator.toData(), creator.getBounds());
   }
 }
Ejemplo n.º 3
0
 @Override
 public void componentAdded(ContainerEvent e) {
   if (isRefreshing) {
     return;
   }
   XWidgetCreator creator = (XWidgetCreator) e.getChild();
   WHorizontalBoxLayout wlayout = this.toData();
   Widget wgt = creator.toData();
   for (int i = 0, count = this.getComponentCount(); i < count; i++) {
     if (creator == this.getComponent(i)) {
       wlayout.addWidget(wgt, i);
       wlayout.setWidthAtWidget(wgt, creator.getWidth());
     }
   }
   this.recalculateChildrenPreferredSize();
 }
Ejemplo n.º 4
0
 /** 将WLayout转换为XLayoutContainer */
 @Override
 public void convert() {
   isRefreshing = true;
   WTitleLayout layout = this.toData();
   this.removeAll();
   for (int i = 0, num = layout.getWidgetCount(); i < num; i++) {
     BoundsWidget bw = (BoundsWidget) layout.getWidget(i);
     if (bw != null) {
       Rectangle bounds = bw.getBounds();
       XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget());
       String constraint =
           bw.getWidget().acceptType(Label.class) ? WTitleLayout.TITLE : WTitleLayout.BODY;
       this.add(comp, constraint);
       comp.setBounds(bounds);
     }
   }
   isRefreshing = false;
 }