Java 类org.eclipse.draw2d.UpdateListener 实例源码

项目:Hydrograph    文件:CustomFigureCanvas.java   
private void customLayoutViewPort() {
    try {
        Object nullArray = Array.newInstance(UpdateListener.class, 0);
        reflectionField.set(getLightweightSystem().getUpdateManager(), nullArray);
         getLightweightSystem().getUpdateManager().addUpdateListener(new UpdateListener() {

            @Override
            public void notifyPainting(Rectangle damage, java.util.Map dirtyRegions) {
                if (containerForSearchTextBox != null) {
                    int count =((Composite)containerForSearchTextBox).getChildren().length;
                        containerForSearchTextBox.setBounds(0, 0, containerForSearchTextBox.getBounds().width, containerHeight*count);  
                 }
            }

            @Override
            public void notifyValidating() {
                if (!isDisposed()) {
                    layoutViewport();
                }
            }
        });
    } catch (IllegalAccessException e) {
        LOGGER.error(e.getMessage(),e);
        throwExceptionWhenReflectionIsFailed(e);
    }
}