コード例 #1
0
 /**
  * if debugging is enabled (see {@link Debug}), debug info is set to the widget as tooltip and/or
  * decoration. Can be overridden by subclass to add specific debug info
  *
  * @param widget widget to apply debug info to
  */
 protected void setDebugInfo(RCPWidget widget) {
   if (Debug.layout()) {
     String debugInfo = ""; // $NON-NLS-1$
     if (widget instanceof RCPControl) {
       if (widget instanceof RCPComposite) {
         Layout layout = ((RCPComposite) widget).getClientComposite().getLayout();
         if (layout != null) {
           debugInfo +=
               widget.getId()
                   + ".layout = "
                   + layout.toString()
                   + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
         }
       }
       RCPControl control = (RCPControl) widget;
       Object layoutData = control.getSWTControl().getLayoutData();
       if (layoutData != null) {
         debugInfo +=
             widget.getId()
                 + ".layoutData = "
                 + layoutData.toString()
                 + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
       }
       control.getSWTControl().setToolTipText(debugInfo);
     }
   }
 }
コード例 #2
0
  /**
   * Synchronizes this Composite's layout with the given GridLayoutRule's data. Ensures that, at the
   * end of the method execution, all children of the Composite have a layout's data either null or
   * of type GridData.
   */
  public static void platformSpecificRefresh(Object containerView, GridLayoutRule rule) {
    assert rule != null;
    if (!(containerView instanceof SWTContainerView)) return;
    final Composite context = (Composite) ((SWTContainerView) containerView).getContentPane();
    if (context == null || context.isDisposed()) return;

    final Layout previousLayout = context.getLayout();
    context.setLayout(convertIntoSWTGridLayout(rule));

    // we check if we changed the type of the layout
    if (previousLayout == null && context.getLayout() == null) return;
    if (previousLayout != null
        && context.getLayout() != null
        && previousLayout.getClass().equals(context.getLayout().getClass())) return;

    for (Control child : context.getChildren())
      if (!(child.getLayoutData() instanceof GridData)) {
        Object data = child.getData(SWTWidgetView.WAZAABI_HOST_KEY);
        if (data instanceof AbstractComponentEditPart)
          child.setLayoutData(
              GridDataStyleRuleManager.getFirstGridData((AbstractComponentEditPart) data));
      }
  }