public void initializeLayoutSet(final LayoutSet layoutSet) {
   layoutSet.addColor(ILayoutSetConstants.CONFIG_BLACK, Graphics.getColor(0, 0, 0));
   layoutSet.addColor(ILayoutSetConstants.CONFIG_WHITE, Graphics.getColor(255, 255, 255));
   String path = ILayoutSetConstants.IMAGE_PATH_BUSINESS;
   layoutSet.addImagePath(
       ILayoutSetConstants.CONFIG_DIALOG_CLOSE, path + "close.png"); // $NON-NLS-1$
   layoutSet.addImagePath(
       ILayoutSetConstants.CONFIG_DIALOG_ICON, path + "conf_dialog_icon.png"); // $NON-NLS-1$
 }
 private void testPreserveControlProperties(Scale scale) {
   // bound
   Rectangle rectangle = new Rectangle(10, 10, 10, 10);
   scale.setBounds(rectangle);
   Fixture.preserveWidgets();
   IWidgetAdapter adapter = WidgetUtil.getAdapter(scale);
   assertEquals(rectangle, adapter.getPreserved(Props.BOUNDS));
   Fixture.clearPreserved();
   // enabled
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.TRUE, adapter.getPreserved(Props.ENABLED));
   Fixture.clearPreserved();
   scale.setEnabled(false);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.FALSE, adapter.getPreserved(Props.ENABLED));
   Fixture.clearPreserved();
   scale.setEnabled(true);
   // visible
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.TRUE, adapter.getPreserved(Props.VISIBLE));
   Fixture.clearPreserved();
   scale.setVisible(false);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.FALSE, adapter.getPreserved(Props.VISIBLE));
   Fixture.clearPreserved();
   // menu
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(null, adapter.getPreserved(Props.MENU));
   Fixture.clearPreserved();
   Menu menu = new Menu(scale);
   MenuItem item = new MenuItem(menu, SWT.NONE);
   item.setText("1 Item");
   scale.setMenu(menu);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(menu, adapter.getPreserved(Props.MENU));
   Fixture.clearPreserved();
   // foreground background font
   Color background = Graphics.getColor(122, 33, 203);
   scale.setBackground(background);
   Color foreground = Graphics.getColor(211, 178, 211);
   scale.setForeground(foreground);
   Font font = Graphics.getFont("font", 12, SWT.BOLD);
   scale.setFont(font);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(background, adapter.getPreserved(Props.BACKGROUND));
   assertEquals(foreground, adapter.getPreserved(Props.FOREGROUND));
   assertEquals(font, adapter.getPreserved(Props.FONT));
   Fixture.clearPreserved();
 }
示例#3
0
  static void create(final List actions, final Composite actionBar) {
    Control[] children = actionBar.getChildren();
    for (int i = 0; i < children.length; i++) {
      children[i].dispose();
    }

    actionBar.setLayout(new RowLayout());
    Iterator iterator = actions.iterator();
    while (iterator.hasNext()) {
      Object next = iterator.next();
      if (next instanceof Action) {
        final Action action = (Action) next;
        new ActionBarButton(action, actionBar);
        Label separator = new Label(actionBar, SWT.NONE);
        separator.setText(" ");
        Label separator2 = new Label(actionBar, SWT.NONE);
        separator2.setText(" ");
        Label separator3 = new Label(actionBar, SWT.NONE);
        separator3.setText(" ");
      } else {
        Label separator = new Label(actionBar, SWT.SEPARATOR | SWT.VERTICAL);
        separator.setForeground(Graphics.getColor(255, 255, 255));
        Label separator2 = new Label(actionBar, SWT.NONE);
        separator2.setText(" ");
        Label separator3 = new Label(actionBar, SWT.NONE);
        separator3.setText(" ");
      }
    }
    actionBar.layout();
  }
示例#4
0
 private int getTextWidth(final int index) {
   int result = 0;
   String text = getText(index);
   if (text.length() > 0) {
     result = Graphics.stringExtent(parent.getFont(), text).x;
   }
   return result;
 }
示例#5
0
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  *
  * @since 1.3
  */
 public Rectangle getBounds() {
   checkWidget();
   Rectangle result = new Rectangle(0, 0, 0, 0);
   int index = parent.indexOf(this);
   if (index != -1) {
     int selectionIndex = parent.getSelectionIndex();
     boolean selected = index == selectionIndex;
     Rectangle padding = parent.getItemPadding(selected);
     String text = getText();
     if (text != null) {
       Point extent = Graphics.stringExtent(parent.getFont(), text);
       result.width = extent.x;
       result.height = extent.y;
     }
     Image image = getImage();
     if (image != null) {
       Rectangle imageSize = image.getBounds();
       result.width += imageSize.width + IMAGE_TEXT_SPACING;
       result.height = Math.max(result.height, imageSize.height);
     }
     result.width += 2 * ITEM_BORDER + padding.width;
     result.height += ITEM_BORDER + padding.height;
     if (selected) {
       result.height += SELECTED_ITEM_BORDER;
     }
     if (selectionIndex != -1) {
       if (index + 1 == selectionIndex || index - 1 == selectionIndex) {
         result.width -= ITEM_BORDER;
       }
     }
     if (isBarTop()) {
       if (index != selectionIndex) {
         result.y += SELECTED_ITEM_BORDER;
       }
     } else {
       result.y = parent.getBounds().height - 2 * parent.getBorderWidth() - result.height;
       if (index != selectionIndex) {
         result.y -= SELECTED_ITEM_BORDER;
       }
     }
     if (index > 0) {
       TabItem leftItem = parent.getItem(index - 1);
       Rectangle leftItemBounds = leftItem.getBounds();
       result.x = leftItemBounds.x + leftItemBounds.width + TABS_SPACING;
       if (index == selectionIndex || index - 1 == selectionIndex) {
         result.x -= TABS_SPACING;
       }
     }
   }
   return result;
 }
示例#6
0
 /**
  * Returns a rectangle describing the size and location relative to its parent of the text at a
  * column in the table. An empty rectangle is returned if index exceeds the index of the table's
  * last column.
  *
  * @param index the index that specifies the column
  * @return the receiver's bounding text rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Rectangle getTextBounds(final int index) {
   checkWidget();
   int itemIndex = parent.indexOf(this);
   if (!parent.checkData(this, itemIndex)) {
     error(SWT.ERROR_WIDGET_DISPOSED);
   }
   int left = 0;
   int top = 0;
   int width = 0;
   Rectangle cellPadding = parent.getCellPadding();
   if (index == 0 && parent.getColumnCount() == 0) {
     int imageWidth = 0;
     int spacing = 0;
     if (parent.hasColumnImages(0)) {
       imageWidth = parent.getItemImageSize().x;
       spacing = getSpacing(0);
     }
     left = getLeft(0) + cellPadding.x + imageWidth + spacing;
     top = getTop(itemIndex);
     Font font = getFont();
     width = Graphics.stringExtent(font, getText(0)).x;
   } else if (itemIndex != -1 && index < parent.getColumnCount()) {
     int imageWidth = 0;
     if (parent.hasColumnImages(index)) {
       imageWidth = parent.getItemImageSize().x;
     }
     int spacing = getSpacing(index);
     left = getLeft(index) + cellPadding.x + imageWidth + spacing;
     top = getTop(itemIndex);
     width = getColumnWidth(index) - cellPadding.width - imageWidth - spacing;
     if (width < 0) {
       width = 0;
     }
   }
   int height = getHeight(index);
   return new Rectangle(left, top, width, height);
 }
示例#7
0
abstract class ExampleTab {

  private boolean contentCreated;
  private final CTabFolder folder;
  protected final List controls;

  private Composite exmplComp;
  protected Composite styleComp;
  protected Color[] bgColors;
  protected Color[] fgColors;
  private Font font;
  private int fgIndex;
  private int bgIndex;
  private int rbIndex;
  private boolean showBgImage = false;
  private boolean showBgGradient = false;

  private boolean visible = true;
  private boolean enabled = true;
  private Text text;
  private final StringBuffer content = new StringBuffer();
  private SimpleFontDialog fontChooser;
  private ColorChooser fgColorChooser;
  private ColorChooser bgColorChooser;
  private int defaultStyle = SWT.NONE;
  private final CTabItem item;
  private final Set properties = new HashSet();

  public static final Color BG_COLOR_GREEN = Graphics.getColor(154, 205, 50);
  public static final Color BG_COLOR_BLUE = Graphics.getColor(105, 89, 205);
  public static final Color BG_COLOR_BROWN = Graphics.getColor(192, 172, 137);
  public static final Color FG_COLOR_RED = Graphics.getColor(194, 0, 23);
  public static final Color FG_COLOR_BLUE = Graphics.getColor(28, 96, 141);
  public static final Color FG_COLOR_ORANGE = Graphics.getColor(249, 158, 0);

  public static final Color BGG_COLOR_GREEN = Graphics.getColor(0, 255, 0);
  public static final Color BGG_COLOR_BLUE = Graphics.getColor(0, 0, 255);

  private static final String[] SWT_CURSORS = {
    "null",
    "CURSOR_ARROW",
    "CURSOR_WAIT",
    "CURSOR_APPSTARTING",
    "CURSOR_CROSS",
    "CURSOR_HELP",
    "CURSOR_NO",
    "CURSOR_SIZEALL",
    "CURSOR_SIZENS",
    "CURSOR_SIZEWE",
    "CURSOR_SIZEN",
    "CURSOR_SIZES",
    "CURSOR_SIZEE",
    "CURSOR_SIZEW",
    "CURSOR_SIZENE",
    "CURSOR_SIZESE",
    "CURSOR_SIZESW",
    "CURSOR_SIZENW",
    "CURSOR_IBEAM",
    "CURSOR_HAND",
    "CURSOR_UPARROW"
  };

  public static Image BG_PATTERN_IMAGE =
      Graphics.getImage("resources/pattern.png", ExampleTab.class.getClassLoader());

  public ExampleTab(final CTabFolder parent, final String title) {
    folder = parent;
    controls = new ArrayList();
    item = new CTabItem(folder, SWT.NONE);
    item.setText(title + " ");
  }

  public void createContents() {
    if (!contentCreated) {
      Control sashForm = createSashForm();
      item.setControl(sashForm);
      initColors();
      createExampleControls(exmplComp);
      createStyleControls(styleComp);
      exmplComp.layout();
      styleComp.layout();
      contentCreated = true;
    }
  }

  protected void createNew() {
    controls.clear();
    destroyExampleControls();
    createExampleControls(exmplComp);
    updateVisible();
    updateEnabled();
    if (fgColorChooser != null) {
      updateFgColor();
    }
    if (bgColorChooser != null) {
      updateBgColor();
    }
    updateBgImage();
    updateBgGradient();
    if (fontChooser != null) {
      // Control control = ( Control )controls.get( 0 );
      // font = control.getFont();
      // if( font != null ) {
      //   fontChooser.setFont( font );
      // }
      updateFont();
    }
    exmplComp.layout();
  }

  private Control createSashForm() {
    SashForm vertSashForm = new SashForm(folder, SWT.VERTICAL);
    SashForm horSashForm = new SashForm(vertSashForm, SWT.HORIZONTAL);
    Composite leftComp = new Composite(horSashForm, SWT.NONE);
    Composite rightComp = new Composite(horSashForm, SWT.NONE);
    Composite footComp = new Composite(vertSashForm, SWT.NONE);
    createLeft(leftComp);
    createRight(rightComp);
    createFoot(footComp);
    horSashForm.setWeights(new int[] {60, 40});
    vertSashForm.setWeights(new int[] {95, 5});
    return vertSashForm;
  }

  private void createLeft(final Composite parent) {
    parent.setLayout(new FillLayout());
    Group exmplGroup = new Group(parent, SWT.NONE);
    exmplGroup.setLayout(new FillLayout());
    exmplComp = new Composite(exmplGroup, SWT.NONE);
  }

  private void createRight(final Composite parent) {
    parent.setLayout(new FillLayout());
    Group styleGroup = new Group(parent, SWT.NONE);
    styleGroup.setText("Styles and Parameters");
    styleGroup.setLayout(new FillLayout());
    styleComp = new Composite(styleGroup, SWT.NONE);
    styleComp.setLayout(new RowLayout(SWT.VERTICAL));
  }

  private void createFoot(final Composite parent) {
    parent.setLayout(new FillLayout());
    text = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
    text.setText("---");
  }

  private void initColors() {
    bgColors = new Color[] {null, BG_COLOR_GREEN, BG_COLOR_BLUE, BG_COLOR_BROWN};
    fgColors = new Color[] {null, FG_COLOR_RED, FG_COLOR_BLUE, FG_COLOR_ORANGE};
  }

  protected abstract void createStyleControls(final Composite parent);

  protected abstract void createExampleControls(final Composite parent);

  /**
   * TODO [rst] Refactor ExampleTab to evaluate style controls before example controls are created.
   */
  protected void setDefaultStyle(final int style) {
    this.defaultStyle = style;
  }

  protected Button createStyleButton(final String fieldName, final int style) {
    return createStyleButton(fieldName, style, false);
  }

  protected Button createStyleButton(final String name, final int style, final boolean checked) {
    Button button = new Button(styleComp, SWT.CHECK);
    button.setText(name);
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            createNew();
          }
        });
    button.setData("style", new Integer(style));
    button.setSelection(checked);
    return button;
  }

  protected Button createPropertyButton(final String text) {
    return createPropertyButton(text, SWT.CHECK);
  }

  protected Button createPropertyButton(final String text, final int style) {
    Button button = new Button(styleComp, style);
    button.setText(text);
    return button;
  }

  protected Button createPropertyCheckbox(final String text, final String prop) {
    return createPropertyCheckbox(text, prop, false);
  }

  protected Button createPropertyCheckbox(
      final String text, final String prop, final boolean checked) {
    final Button button = new Button(styleComp, SWT.CHECK);
    button.setText(text);
    button.setSelection(checked);
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            if (button.getSelection()) {
              properties.add(prop);
            } else {
              properties.remove(prop);
            }
            createNew();
          }
        });
    return button;
  }

  public final boolean hasCreateProperty(final String name) {
    return properties.contains(name);
  }

  /**
   * Creates a checkbutton to show / hide the registered controls.
   *
   * @return the created checkbutton
   */
  protected Button createVisibilityButton() {
    final Button button = new Button(styleComp, SWT.CHECK);
    button.setText("Visible");
    button.setSelection(visible);
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            visible = button.getSelection();
            updateVisible();
          }
        });
    return button;
  }

  /**
   * Creates a checkbutton to enable / disabled the registered controls.
   *
   * @return the created checkbutton.
   */
  protected Button createEnablementButton() {
    final Button button = new Button(styleComp, SWT.CHECK);
    button.setText("Enabled");
    button.setSelection(enabled);
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            enabled = button.getSelection();
            updateEnabled();
          }
        });
    return button;
  }

  /**
   * Creates a button to change the foreground color of all registered controls.
   *
   * @return the created button
   */
  protected Button createFgColorButton() {
    fgColorChooser = new ColorChooser();
    final Button button = new Button(styleComp, SWT.PUSH);
    button.setText("Foreground");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            fgIndex = (fgIndex + 1) % fgColors.length;
            updateFgColor();
          }
        });
    return button;
  }

  /**
   * Creates a button to change the background color of all registered controls.
   *
   * @return the created button
   */
  protected Button createBgColorButton() {
    bgColorChooser = new ColorChooser();
    final Button button = new Button(styleComp, SWT.PUSH);
    button.setText("Background");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            bgIndex = (bgIndex + 1) % fgColors.length;
            updateBgColor();
          }
        });
    return button;
  }

  /**
   * Creates a button to change the background gradient of all registered controls.
   *
   * @return the created button
   */
  protected Button createBgGradientButton() {
    final Button button = new Button(styleComp, SWT.CHECK);
    button.setText("Background Gradient");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            showBgGradient = button.getSelection();
            updateBgGradient();
          }
        });
    return button;
  }

  /**
   * Creates a checkbox that controls whether a background image is set on the registered controls.
   *
   * @return the created checkbox
   */
  protected Button createBgImageButton() {
    final Button button = new Button(styleComp, SWT.CHECK);
    button.setText("Background Image");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            showBgImage = button.getSelection();
            updateBgImage();
          }
        });
    return button;
  }

  protected Button createFontChooser() {
    final Button button = new Button(styleComp, SWT.PUSH);
    button.setText("Font");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            fontChooser = new SimpleFontDialog(getShell());
            Control control = (Control) controls.get(0);
            fontChooser.setFont(control.getFont());
            fontChooser.open(
                new Runnable() {
                  public void run() {
                    font = fontChooser.getFont();
                    updateFont();
                  }
                });
          }
        });
    return button;
  }

  /** Experimental. Switching themes at runtime does not yet work properly. */
  protected void createThemeSwitcher(final Composite parent) {
    final Button button = new Button(parent, SWT.PUSH);
    button.setText("Theme Switcher");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            Shell shell = new Shell(parent.getShell(), SWT.DIALOG_TRIM);
            shell.setText("Theme Switcher");
            shell.setLayout(new GridLayout());
            Button themeButton = new Button(shell, SWT.PUSH);
            themeButton.setText("Switch Theme");
            themeButton.addSelectionListener(
                new SelectionAdapter() {
                  String[] availableThemeIds = ThemeUtil.getAvailableThemeIds();

                  public void widgetSelected(final SelectionEvent e) {
                    int index = 0;
                    String currThemeId = ThemeUtil.getCurrentThemeId();
                    for (int i = 0; i < availableThemeIds.length; i++) {
                      if (currThemeId.equals(availableThemeIds[i])) {
                        index = (i + 1) % availableThemeIds.length;
                      }
                    }
                    String newThemeId = availableThemeIds[index];
                    ThemeUtil.setCurrentThemeId(newThemeId);
                  }
                });
            shell.pack();
            shell.open();
          }
        });
  }

  /**
   * Creates a combo that controls whether a cursor is set on the registered controls.
   *
   * @return the created combo
   */
  protected Combo createCursorCombo() {
    Composite group = new Composite(styleComp, SWT.NONE);
    group.setLayout(new GridLayout(2, false));
    new Label(group, SWT.NONE).setText("Cursor");
    final Combo combo = new Combo(group, SWT.READ_ONLY);
    combo.setItems(SWT_CURSORS);
    combo.select(0);
    combo.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(final SelectionEvent e) {
            String selection = null;
            int index = combo.getSelectionIndex();
            if (index > 0) {
              selection = combo.getItem(index);
            }
            updateCursor(selection);
          }
        });
    return combo;
  }

  /** Creates a text that controls whether a border radius is set on the registered controls. */
  protected void cteateRoundedBorderGroup() {
    Group group = new Group(styleComp, SWT.NONE);
    group.setText("Rounded Border");
    group.setLayout(new GridLayout(2, false));
    new Label(group, SWT.NONE).setText("Width");
    final Text textWidth = new Text(group, SWT.SINGLE | SWT.BORDER);
    textWidth.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(group, SWT.NONE).setText("Color");
    final Button buttonColor = new Button(group, SWT.PUSH);
    buttonColor.setLayoutData(new GridData(20, 20));
    buttonColor.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            rbIndex = (rbIndex + 1) % bgColors.length;
            if (bgColors[rbIndex] == null) {
              buttonColor.setText("");
            } else {
              buttonColor.setText("\u2588");
            }
            buttonColor.setForeground(bgColors[rbIndex]);
          }
        });
    new Label(group, SWT.NONE).setText("Radius ");
    Composite radiusGroup = new Composite(group, SWT.NONE);
    radiusGroup.setLayout(new GridLayout(4, false));
    new Label(radiusGroup, SWT.NONE).setText("T-L");
    final Text textTopLeft = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textTopLeft.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(radiusGroup, SWT.NONE).setText("T-R");
    final Text textTopRight = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textTopRight.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(radiusGroup, SWT.NONE).setText("B-L");
    final Text textBottomLeft = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textBottomLeft.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(radiusGroup, SWT.NONE).setText("B-R");
    final Text textBottomRight = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textBottomRight.setLayoutData(new GridData(20, SWT.DEFAULT));
    Button button = new Button(group, SWT.PUSH);
    button.setText("Set");
    button.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(final SelectionEvent e) {
            int width = parseInt(textWidth.getText());
            Color color = buttonColor.getBackground();
            int topLeft = parseInt(textTopLeft.getText());
            int topRight = parseInt(textTopRight.getText());
            int bottomRight = parseInt(textBottomRight.getText());
            int bottomLeft = parseInt(textBottomLeft.getText());
            updateRoundedBorder(width, color, topLeft, topRight, bottomRight, bottomLeft);
          }
        });
  }

  /**
   * Adds a control to the list of registered controls. Registered controls can be hidden and
   * disabled by the checkbuttons in the property area. This method is to be called within <code>
   * createExampleControls</code>.
   *
   * @param control A control that should be remote controlled.
   */
  protected void registerControl(final Control control) {
    controls.add(control);
  }

  protected void log(final String msg) {
    content.insert(0, msg.trim() + text.getLineDelimiter());
    text.setText(content.toString());
  }

  private void destroyExampleControls() {
    Control[] controls = exmplComp.getChildren();
    for (int i = 0; i < controls.length; i++) {
      controls[i].dispose();
    }
  }

  protected int getStyle() {
    int result = SWT.NONE;
    Control[] ctrls = styleComp.getChildren();
    if (ctrls.length == 0) {
      result = defaultStyle;
    } else {
      for (int i = 0; i < ctrls.length; i++) {
        if (ctrls[i] instanceof Button) {
          Button button = (Button) ctrls[i];
          if (button.getSelection()) {
            Object data = button.getData("style");
            if (data instanceof Integer) {
              int style = ((Integer) data).intValue();
              result |= style;
            }
          }
        }
      }
    }
    return result;
  }

  private void updateVisible() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setVisible(visible);
    }
  }

  private void updateEnabled() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setEnabled(enabled);
    }
  }

  private void updateFgColor() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setForeground(fgColors[fgIndex]);
    }
  }

  private void updateBgColor() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setBackground(bgColors[bgIndex]);
    }
  }

  private void updateBgGradient() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      Object adapter = control.getAdapter(IWidgetGraphicsAdapter.class);
      IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
      if (showBgGradient) {
        Color[] gradientColors =
            new Color[] {
              BGG_COLOR_BLUE, BGG_COLOR_GREEN, BGG_COLOR_BLUE, BGG_COLOR_GREEN, BGG_COLOR_BLUE
            };
        int[] percents = new int[] {0, 25, 50, 75, 100};
        gfxAdapter.setBackgroundGradient(gradientColors, percents);
      } else {
        gfxAdapter.setBackgroundGradient(null, null);
      }
    }
  }

  private void updateBgImage() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setBackgroundImage(showBgImage ? BG_PATTERN_IMAGE : null);
    }
  }

  private void updateFont() {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setFont(font);
    }
    // Force layout
    if (controls.size() > 0) {
      Composite parent = ((Control) controls.get(0)).getParent();
      parent.layout(true, true);
    }
  }

  private void updateCursor(final String selection) {
    Cursor cursor = null;
    Class swtClass = SWT.class;
    if (selection != null) {
      try {
        Field field = swtClass.getField(selection);
        int cursorStyle = field.getInt(swtClass);
        cursor = Display.getCurrent().getSystemCursor(cursorStyle);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      control.setCursor(cursor);
    }
  }

  private void updateRoundedBorder(
      final int width,
      final Color color,
      final int topLeft,
      final int topRight,
      final int bottomRight,
      final int bottomLeft) {
    Iterator iter = controls.iterator();
    while (iter.hasNext()) {
      Control control = (Control) iter.next();
      Object adapter = control.getAdapter(IWidgetGraphicsAdapter.class);
      IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
      gfxAdapter.setRoundedBorder(width, color, topLeft, topRight, bottomRight, bottomLeft);
    }
  }

  private int parseInt(final String text) {
    int result;
    try {
      result = Integer.parseInt(text);
    } catch (NumberFormatException e) {
      result = -1;
    }
    return result;
  }

  protected Shell getShell() {
    return folder.getShell();
  }
}