示例#1
0
  private void setOptions(UIComponent parent) {
    // create layout options for this pane via attributes defined in pe:layoutPane
    String position = getPosition();
    LayoutOptions thisLayoutOptions = getOptions();
    LayoutOptions options;

    if (parent instanceof LayoutPane) {
      LayoutOptions parentLayoutOptions = ((LayoutPane) parent).getOptions();
      options = parentLayoutOptions.getChildOptions();
      if (options == null) {
        options = new LayoutOptions();
        parentLayoutOptions.setChildOptions(options);
      }
    } else if (parent instanceof Layout) {
      options = (LayoutOptions) ((Layout) parent).getOptions();
      if (options == null) {
        Layout layout = ((Layout) parent);
        options = new LayoutOptions();
        layout.setOptions(options);

        // options for all panes
        LayoutOptions panes = null;
        String resizerTip = layout.getResizerTip();
        if (resizerTip != null) {
          panes = new LayoutOptions();
          panes.addOption(Layout.PropertyKeys.resizerTip.toString(), resizerTip);
        }

        String togglerTipOpen = layout.getTogglerTipOpen();
        if (togglerTipOpen != null) {
          if (panes == null) {
            panes = new LayoutOptions();
          }

          panes.addOption(Layout.PropertyKeys.togglerTip_open.toString(), togglerTipOpen);
        }

        String togglerTipClosed = layout.getTogglerTipClosed();
        if (togglerTipClosed != null) {
          if (panes == null) {
            panes = new LayoutOptions();
          }

          panes.addOption(Layout.PropertyKeys.togglerTip_closed.toString(), togglerTipClosed);
        }

        if (panes != null) {
          options.setPanesOptions(panes);
        }
      }
    } else if (parent instanceof UIForm) {
      // layout pane can be within a h:form
      setOptions(parent.getParent());

      return;
    } else if (parent instanceof HtmlPanelGroup
        && Layout.STYLE_CLASS_LAYOUT_CONTENT.equals(((HtmlPanelGroup) parent).getStyleClass())
        && "block".equals(((HtmlPanelGroup) parent).getLayout())) {
      // layout pane can be within h:panelGroup representing a HTML div
      setOptions(parent.getParent());

      return;
    } else if (parent instanceof OutputPanel
        && Layout.STYLE_CLASS_LAYOUT_CONTENT.equals(((OutputPanel) parent).getStyleClass())
        && "block".equals(((OutputPanel) parent).getLayout())) {
      // layout pane can be within p:outputPanel representing a HTML div
      setOptions(parent.getParent());

      return;
    } else if (parent != null && parent.toString().contains(Layout.STYLE_CLASS_LAYOUT_CONTENT)) {
      // plain div (UIInstructions) with class "ui-layout-content"
      setOptions(parent.getParent());

      return;
    } else {
      throw new FacesException(
          "LayoutPane can be only placed within another LayoutPane, Layout, UIForm or DIV with class 'ui-layout-content'");
    }

    if (Layout.PANE_POSITION_CENTER.equals(position)) {
      options.setCenterOptions(thisLayoutOptions);
    } else if (Layout.PANE_POSITION_NORTH.equals(position)) {
      options.setNorthOptions(thisLayoutOptions);
    } else if (Layout.PANE_POSITION_SOUTH.equals(position)) {
      options.setSouthOptions(thisLayoutOptions);
    } else if (Layout.PANE_POSITION_WEST.equals(position)) {
      options.setWestOptions(thisLayoutOptions);
    } else if (Layout.PANE_POSITION_EAST.equals(position)) {
      options.setEastOptions(thisLayoutOptions);
    } else {
      throw new FacesException(
          "Pane position "
              + position
              + " is invalid. Valid positions are 'center', 'north' 'south', 'west', 'east'");
    }
  }
  @PostConstruct
  protected void initialize() {
    // 1. set options for first layout
    layoutOptionsOne = new LayoutOptions();

    // options for all panes (center and west)
    LayoutOptions panes = new LayoutOptions();
    panes.addOption("slidable", false);
    panes.addOption("spacing", 6);
    panes.addOption("resizeWhileDragging", true);
    layoutOptionsOne.setPanesOptions(panes);

    // options for west pane
    LayoutOptions west = new LayoutOptions();
    west.addOption("size", 150);
    west.addOption("minSize", 40);
    west.addOption("maxSize", 300);
    layoutOptionsOne.setWestOptions(west);

    // 2. set options for second layout
    layoutOptionsTwo = new LayoutOptions();

    // options for all panes
    panes = new LayoutOptions();
    panes.addOption("slidable", false);
    panes.addOption("spacing", 6);
    panes.addOption("resizeWhileDragging", true);
    layoutOptionsTwo.setPanesOptions(panes);

    // options for east pane
    LayoutOptions east = new LayoutOptions();
    panes.addOption("resizable", false);
    panes.addOption("closable", false);
    east.addOption("size", "50%");
    layoutOptionsTwo.setEastOptions(east);

    // options for nested east layout
    LayoutOptions childEastOptions = new LayoutOptions();
    east.setChildOptions(childEastOptions);

    // options for east-south pane
    LayoutOptions eastSouth = new LayoutOptions();
    eastSouth.addOption("size", "50%");
    childEastOptions.setSouthOptions(eastSouth);
  }
示例#3
0
  public LayoutOptions getOptions() {
    if (options != null) {
      return options;
    }

    options = new LayoutOptions();
    options.addOption(PropertyKeys.resizable.toString(), isResizable());
    options.addOption(PropertyKeys.closable.toString(), isClosable());
    options.addOption(PropertyKeys.spacing_open.toString(), getSpacingOpen());
    options.addOption(PropertyKeys.spacing_closed.toString(), getSpacingClosed());
    options.addOption(PropertyKeys.initClosed.toString(), isInitClosed());
    options.addOption(PropertyKeys.initHidden.toString(), isInitHidden());
    options.addOption(PropertyKeys.resizeWhileDragging.toString(), isResizeWhileDragging());

    String size = getSize();
    if (size != null) {
      options.addOption(PropertyKeys.size.toString(), size);
    }

    String minSize = getMinSize();
    if (minSize != null) {
      options.addOption(PropertyKeys.minSize.toString(), minSize);
    }

    String maxSize = getMaxSize();
    if (maxSize != null) {
      options.addOption(PropertyKeys.maxSize.toString(), maxSize);
    }

    String minWidth = getMinWidth();
    if (minWidth != null) {
      options.addOption(PropertyKeys.minWidth.toString(), minWidth);
    }

    String maxWidth = getMaxWidth();
    if (maxWidth != null) {
      options.addOption(PropertyKeys.maxWidth.toString(), maxWidth);
    }

    String minHeight = getMinHeight();
    if (minHeight != null) {
      options.addOption(PropertyKeys.minHeight.toString(), minHeight);
    }

    String maxHeight = getMaxHeight();
    if (maxHeight != null) {
      options.addOption(PropertyKeys.maxHeight.toString(), maxHeight);
    }

    return options;
  }