Esempio n. 1
0
  public WizardPageSelector(
      ArrayList<WizardPage<I, T>> pages, final CommandWithArg<WizardPage<I, T>> onSelected) {
    onSelected_ = onSelected;

    WizardResources res = WizardResources.INSTANCE;
    WizardResources.Styles styles = res.styles();

    FlowPanel pageSelectorPanel = new FlowPanel();
    pageSelectorPanel.addStyleName(styles.wizardPageSelector());
    pageSelectorPanel.setSize("100%", "100%");
    for (int i = 0; i < pages.size(); i++) {
      final WizardPage<I, T> page = pages.get(i);
      PageSelectorItem pageSelector =
          new PageSelectorItem(
              page,
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  onSelected_.execute(page);
                }
              });

      if (i == 0) pageSelector.addStyleName(styles.wizardPageSelectorItemFirst());

      if (i == (pages.size() - 1)) pageSelector.addStyleName(styles.wizardPageSelectorItemLast());

      pageSelectorPanel.add(pageSelector);
    }

    initWidget(pageSelectorPanel);
  }
Esempio n. 2
0
    PageSelectorItem(final WizardPageInfo pageInfo, ClickHandler clickHandler) {
      WizardResources res = WizardResources.INSTANCE;
      WizardResources.Styles styles = res.styles();

      LayoutPanel layoutPanel = new LayoutPanel();
      layoutPanel.addStyleName(styles.wizardPageSelectorItem());

      ImageResource pageImageResource = pageInfo.getImage();
      Image image = null;
      if (pageImageResource != null) {
        image = new Image(pageImageResource);
        layoutPanel.add(image);
        layoutPanel.setWidgetLeftWidth(image, 10, Unit.PX, image.getWidth(), Unit.PX);
        layoutPanel.setWidgetTopHeight(
            image, 40 - (image.getHeight() / 2), Unit.PX, image.getHeight(), Unit.PX);
      }

      FlowPanel captionPanel = new FlowPanel();
      Label titleLabel = new Label(pageInfo.getTitle());
      titleLabel.addStyleName(styles.headerLabel());
      captionPanel.add(titleLabel);
      Label subTitleLabel = new Label(pageInfo.getSubTitle());
      subTitleLabel.addStyleName(styles.subcaptionLabel());
      captionPanel.add(subTitleLabel);
      layoutPanel.add(captionPanel);
      layoutPanel.setWidgetLeftWidth(
          captionPanel, 10 + (image == null ? 0 : image.getWidth()) + 12, Unit.PX, 450, Unit.PX);
      layoutPanel.setWidgetTopHeight(captionPanel, 19, Unit.PX, 55, Unit.PX);

      Image arrowImage = new Image(res.wizardDisclosureArrow());
      layoutPanel.add(arrowImage);
      layoutPanel.setWidgetRightWidth(arrowImage, 20, Unit.PX, arrowImage.getWidth(), Unit.PX);
      layoutPanel.setWidgetTopHeight(
          arrowImage, 40 - (arrowImage.getHeight() / 2), Unit.PX, arrowImage.getHeight(), Unit.PX);

      layoutPanel.addDomHandler(clickHandler, ClickEvent.getType());

      initWidget(layoutPanel);
    }