Scout Eclipse Neon 固定宽度的两列

Scout Eclipse Neon two columns with fix width

我有表格,我想将其分为两栏。首先是长且可滚动的,其他需要始终保持在右侧。第二列的宽度需要小一些,这样就不会占用太多屏幕 space。

我的代码看起来像这样:

@Order(1000.0)
public class MainBox extends AbstractGroupBox {

    @Override
    protected TriState getConfiguredScrollable() {

      return TriState.FALSE;
    }

    @Order(1000.0)
    public class OfferBox extends SxAbstractGroupBox {

      @Override
      protected TriState getConfiguredScrollable() {

        return TriState.TRUE;
      }

      @Override
      protected int getConfiguredGridColumnCount() {

        return 1;
      }

      @Override
      protected int getConfiguredGridX() {

        return 0;
      }

      @Override
      protected int getConfiguredGridY() {

        return 0;
      }

      @Override
      protected double getConfiguredGridWeightX() {

        return 1; // This should stretch this box 
      }
      ......
    }

    @Order(4000.0)
    public class ShortCutBox extends AbstractGroupBox {

      @Override
      protected TriState getConfiguredScrollable() {

        return TriState.TRUE;
      }

      @Override
      protected int getConfiguredGridColumnCount() {

         return 1;
      }

      @Override
      protected int getConfiguredGridX() {

         return 1;
      }

      @Override
      protected int getConfiguredGridY() {

         return 0;
      }

     @Override
     protected double getConfiguredGridWeightX() {

        return 0; // this defined that box shouldn't stretch
     }

     @Override
     protected int getConfiguredWidthInPixel() {

         return 200;  // This should give me fix width 200
     }

     @Order(4100)
     public class MyButton1 extends AbstractButton {

     }

     @Order(4200)
     public class MyButton2 extends AbstractButton {

     }
     ....
  }
}

但是这个配置给出了这样的布局:

如果我将按钮设置为

@Override
protected int getConfiguredHorizontalAlignment() {

   return 1;
}

它看起来是正确的,但问题是框仍然是右边的框仍然延伸到左边的框上方,因此在左侧面板的右侧滚动和单击字段不起作用。 (黑色矩形内)

我错过了什么?

我刚刚查看了您的问题,我可以通过执行以下操作构建您认为想要的布局:

1。 我添加了 getConfiguredGridW() 方法,returning 1 到你的两个组框,以实现每个组框只跨越一列(parent 组框有网格列数=2 ).

2。 此外,我从两个组框中删除了 getConfiguredGridX()getConfiguredGridY() 方法,因为我认为它们不是必需的,因为 Scout 在 [=42] 时自动以这种方式排序它们=]组框的getConfiguredGridColumnCount()returns 2(或默认)。

3。 这个很重要: 在每个按钮中,我重写了 getConfiguredProcessButton() returning false(而不是默认情况下的 true),正如我所经历的那样,scout 以不同的方式构建其网格布局,当将按钮声明为 non-process 按钮。 java 文档还说:

Configures whether this button is a process button. Process buttons are typically displayed on a dedicated button bar at the bottom of a form. Non-process buttons can be placed anywhere on a form. Subclasses can override this method. Default is true.

4。 这个是可选的: 添加 getConfiguredFillHorizontal() 和 return true,使右侧分组框的所有按钮的宽度都扩大到 parent 分组框的宽度。

我的整个安排是这样的:

@Order(1000.0)
public class MainBox extends AbstractGroupBox {

    @Override
    protected TriState getConfiguredScrollable() {

        return TriState.FALSE;
    }

    @Order(1000.0)
    public class OfferBox extends AbstractGroupBox {

        @Override
        protected TriState getConfiguredScrollable() {

            return TriState.TRUE;
        }

        @Override
        protected int getConfiguredGridColumnCount() {

            return 1;
        }

        @Override
        protected int getConfiguredGridW() {
            return 1;   // XXX: Added
        }

        /*
        // XXX: Removed
        @Override
        protected int getConfiguredGridX() {

            return 0;
        }

        @Override
        protected int getConfiguredGridY() {

            return 0;
        }
        */

        @Override
        protected double getConfiguredGridWeightX() {

            return 1; // This should stretch this box
        }

        @Override
        protected void injectFieldsInternal(OrderedCollection<IFormField> fields) {
            // Used to inject some dummy fields to enable scrolling
            for (int i = 0; i < 30; i++) {
                 // Add some fields here
            }
        }
    }

    @Order(4000.0)
    public class ShortCutBox extends AbstractGroupBox {

        @Override
        protected TriState getConfiguredScrollable() {

            return TriState.TRUE;
        }

        @Override
        protected int getConfiguredGridColumnCount() {

            return 1;
        }

        @Override
        protected int getConfiguredGridW() {
            return 1;   // XXX: Added
        }

        /*
        // XXX: Removed
        @Override
        protected int getConfiguredGridX() {

            return 1;
        }

        @Override
        protected int getConfiguredGridY() {

            return 0;
        }
        */

        @Override
        protected double getConfiguredGridWeightX() {

            return 0; // this defined that box shouldn't stretch
        }

        @Override
        protected int getConfiguredWidthInPixel() {

            return 200; // This should give me fix width 200
        }

        @Order(4100)
        public class MyButton1 extends AbstractButton {

            @Override
            protected String getConfiguredLabel() {
                return "Button 1";
            }

            @Override
            protected boolean getConfiguredProcessButton() {
                return false;   // XXX: Added
            }

            @Override
            protected boolean getConfiguredFillHorizontal() {
                return true; // XXX: This is optional
            }
        }

        @Order(4200)
        public class MyButton2 extends AbstractButton {

            @Override
            protected String getConfiguredLabel() {
                return "Button 2";
            }

            @Override
            protected boolean getConfiguredProcessButton() {
                return false;   // XXX: Added
            }

            @Override
            protected boolean getConfiguredFillHorizontal() {
                // XXX: This is optional. Enlarge buttons to group box width
                return true;
            }
        }
    }
}

结果: Final Layout,请忽略scrollbar-tooltip覆盖;)

如果这对你有用,请告诉我!

此致, 马蒂亚斯