代码之家  ›  专栏  ›  技术社区  ›  Real Red.

EclipseRCP:是否可以在不重绘的情况下向上移动字段?

  •  0
  • Real Red.  · 技术社区  · 17 年前

    但是,我希望在label组合中没有错误显示时,下面的其他字段在display中上移。当有错误要显示时,错误应该出现在它的位置(在所有其他字段的顶部),将其他字段向下推。

    有没有一种方法可以在不重新绘制所有控件的情况下实现这种效果?

    1 回复  |  直到 17 年前
        1
  •  0
  •   Ian Leslie    16 年前

    是的,打电话 layout (true) 在父母身上。

    例如,我有一个视图,在顶部有一个搜索栏,可以切换谁的可见性。我有一个创建搜索组合的方法和一个删除它的方法:

    private void createNameSearchBar () {
        mySearchControl = new CardSearchControl (myViewComposite, SWT.NONE);
        mySearchControl.setSearchListener (this);
    }
    
    
    private void disposeNameSearchBar () {
        mySearchControl.dispose ();
        mySearchControl = null;
    }
    
    private CardSearchControl mySearchControl = null;
    private Composite myViewComposite;
    private boolean mySearchBarState;
    

    要隐藏或显示搜索栏控件,我调用此方法(myViewComposite是拥有搜索栏和所有其他控件的顶级控件):

    public void setSearchBarState (boolean show)  {
        mySearchBarState = show;
    
        if (myViewComposite == null  ||  myViewComposite.isDisposed ())
            return; // no work to do
    
        if (mySearchBarState  &&  mySearchControl == null)  {
            createNameSearchBar ();
            mySearchControl.moveAbove (null);
            myViewComposite.layout (true);
        }  else if (!mySearchBarState  &&  mySearchControl != null)  {
            disposeNameSearchBar ();
            myViewComposite.layout (true);
        }
    }