Examples of TabSet


Examples of javax.swing.text.TabSet

  {
    TabStop ts1 = new TabStop(1.0f);
    TabStop ts2 = new TabStop(2.0f);
    TabStop ts3 = new TabStop(3.0f);
    TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
    TabSet s = new TabSet(tabs);
    harness.check(s.getTabCount(), 3);
   
    harness.check(new TabSet(null).getTabCount(), 0);
  }
View Full Code Here

Examples of javax.swing.text.TabSet

  {
    TabStop ts1 = new TabStop(1.0f);
    TabStop ts2 = new TabStop(2.0f);
    TabStop ts3 = new TabStop(3.0f);
    TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
    TabSet s = new TabSet(tabs);
    harness.check(s.getTabCount(), 3);
    harness.check(s.getTab(0), ts1);
    harness.check(s.getTab(1), ts2);
    harness.check(s.getTab(2), ts3);
   
    // try negative
    boolean pass = false;
    try
    {
      s.getTab(-1);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try too large
    pass = false;
    try
    {
      s.getTab(3);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
View Full Code Here

Examples of javax.swing.text.TabSet

  {
    TabStop ts1 = new TabStop(1.0f);
    TabStop ts2 = new TabStop(2.0f);
    TabStop ts3 = new TabStop(3.0f);
    TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
    TabSet s = new TabSet(tabs);
    harness.check(s.getTabCount(), 3);
    harness.check(s.getTab(0), ts1);
    harness.check(s.getTab(1), ts2);
    harness.check(s.getTab(2), ts3);
   
    // try modifying the original tab array
    TabStop ts4 = new TabStop(4.0f);
    tabs[1] = ts4;
    harness.check(s.getTab(1), ts2);
   
    // what if the original array is not ordered?
    TabStop[] tabs2 = new TabStop[] {ts1, ts3, ts2};
    TabSet s2 = new TabSet(tabs2);
    harness.check(s2.getTabCount(), 3);
    harness.check(s2.getTab(0), ts1);
    harness.check(s2.getTab(1), ts3);
    harness.check(s2.getTab(2), ts2);
   
    // try null
    s2 = new TabSet(null);
    harness.check(s2.getTabCount(), 0);
  }
View Full Code Here

Examples of javax.swing.text.TabSet

        for (int j = 0; j < tabs.length; j++) {
            int tab = j + 1;
            tabs[j] = new TabStop(tab * tabWidth);
        }

        TabSet tabSet = new TabSet(tabs);
        SimpleAttributeSet attributes = new SimpleAttributeSet();
        StyleConstants.setTabSet(attributes, tabSet);
        int length = this.getDocument().getLength();
        this.getStyledDocument().setParagraphAttributes(0, length, attributes, false);
    }
View Full Code Here

Examples of javax.swing.text.TabSet

      tabs[j] = new TabStop((j + 1) * tabWidth);
    }

    SimpleAttributeSet attributes = new SimpleAttributeSet();

    StyleConstants.setTabSet(attributes, new TabSet(tabs));

    getDocument().removeUndoableEditListener(undoManager); // Avoid this change to be undone
    getStyledDocument().setParagraphAttributes(0, getDocument().getLength(), attributes, false);
    getDocument().addUndoableEditListener(undoManager);
  }
View Full Code Here

Examples of javax.swing.text.TabSet

    {
      int tab = j + 1;
      tabs[j] = new TabStop( tab * tabWidth );
    }
    TabSet tabSet = new TabSet(tabs);
    SimpleAttributeSet attributes = new SimpleAttributeSet();
    StyleConstants.setTabSet(attributes, tabSet);
    int length = textPane.getDocument().getLength();
    textPane.getStyledDocument().setParagraphAttributes(0, length, attributes, false);
  }
View Full Code Here

Examples of org.openfaces.component.select.TabSet

    private static final String BACK_BORDER_CLASS_PREFIX = "o_tabset_back_border_";
    private static final String FRONT_BORDER_CLASS_PREFIX = "o_tabset_front_border_";
    public static final String ATTR_CONSIDER_TAB_NON_RENDERED = "o_considerTabNonRendered";

    protected void changeTabIndex(UIComponent component, int selectedIndex) {
        TabSet tabSet = (TabSet) component;
        int oldSelectedIndex = tabSet.getSelectedIndex();
        if (oldSelectedIndex != selectedIndex) {
            tabSet.setSelectedIndex(selectedIndex);
            tabSet.queueEvent(new SelectionChangeEvent(tabSet, oldSelectedIndex, selectedIndex));
        }

        List<Object> tabItems = getTabItems(tabSet);
        Object tabItem = tabItems.get(selectedIndex);
        Object tabValue = (tabItem instanceof TabSetItem) ? ((TabSetItem) tabItem).getItemValue() : null;
        tabSet.setSubmittedValue(tabValue);
    }
View Full Code Here

Examples of org.openfaces.component.select.TabSet

    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        if (AjaxUtil.getSkipExtraRenderingOnPortletsAjax(context))
            return;

        ResponseWriter writer = context.getResponseWriter();
        TabSet tabSet = (TabSet) component;

        writer.startElement("table", tabSet);
        writeIdAttribute(context, tabSet);
        writer.writeAttribute("border", "0", null);
        writer.writeAttribute("cellspacing", "0", null);
        writer.writeAttribute("cellpadding", "0", null);

        writeAttribute(writer, "style", tabSet.getStyle());
        writeAttribute(writer, "class", tabSet.getStyleClass());

        Rendering.writeStandardEvents(writer, tabSet);
    }
View Full Code Here

Examples of org.openfaces.component.select.TabSet

    public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
        if (AjaxUtil.getSkipExtraRenderingOnPortletsAjax(context))
            return;

        ResponseWriter writer = context.getResponseWriter();
        TabSet tabSet = (TabSet) component;
        List<UIComponent> tabChildren = tabSet.getChildren();

        TabPlacement tabPlacement = getTabPlacement(tabSet);
        boolean verticalTabs = tabPlacement.equals(TabPlacement.LEFT) || tabPlacement.equals(TabPlacement.RIGHT);

        TabAlignment tabAlign = tabSet.getAlignment();
        if (tabAlign == null) {
            tabAlign = TabAlignment.TOP_OR_LEFT;
        }

        List<Object> tabItems = getTabItems(tabSet);

        String emptySpaceClasses = getEmptySpaceClasses(tabSet, context);

        if (!verticalTabs) {
            writer.startElement("tr", tabSet);
            if (tabAlign.equals(TabAlignment.BOTTOM_OR_RIGHT)) {
                insertHorizontalSpacer(context, tabSet, emptySpaceClasses);
            }
        } else if (tabAlign.equals(TabAlignment.BOTTOM_OR_RIGHT)) {
            insertVerticalSpacer(context, tabSet, emptySpaceClasses);
        }

        String idPrefix = tabSet.getClientId(context) + Rendering.CLIENT_ID_SUFFIX_SEPARATOR;
        int gapWidth = tabSet.getGapWidth();

        int allTabCount = tabItems.size();
        List<Object> renderedTabItems = new ArrayList<Object>(allTabCount);
        int[] originalTabIndexes = new int[allTabCount];
        for (int i = 0, tabsAdded = 0; i < allTabCount; i++) {
            Object item = tabItems.get(i);
            if (isItemRendered(item)) {
                renderedTabItems.add(item);
                originalTabIndexes[tabsAdded++] = i;
            }
        }
        for (int i = 0, tabCount = renderedTabItems.size(); i < tabCount; i++) {

            Object item = renderedTabItems.get(i);
            if (!isItemRendered(item))
                continue;

            if (gapWidth > 0) {
                if (TabAlignment.TOP_OR_LEFT.equals(tabAlign)) {
                    if (verticalTabs) {
                        writeVerticalGap(writer, tabSet, gapWidth, emptySpaceClasses);
                    } else {
                        writeHorizontalGap(writer, tabSet, gapWidth, emptySpaceClasses);
                    }
                }
            }

            if (verticalTabs) {
                writer.startElement("tr", tabSet);
            }

            writer.startElement("td", tabSet);

            String attr = verticalTabs ? "align" : "valign";
            writer.writeAttribute(attr, tabPlacement.toString(), null);

            //        writer.startElement("div", tabSet);
            int absoluteTabIndex = originalTabIndexes[i];
            writer.writeAttribute("id", idPrefix + absoluteTabIndex, "id");

            if (tabSet.isFocusable()) {
                writer.startElement("div", tabSet);
                String defaultFocusedClass = Styles.getCSSClass(context, component,
                        !Environment.isExplorer6() ? "border: 1px solid transparent;" : "", StyleGroup.selectedStyleGroup(1));
                writer.writeAttribute("class", defaultFocusedClass, null);
            }
            /*...............*/
            if (item instanceof String) {
                writer.writeText(item, null);
            } else if (item instanceof UIComponent) {
                ((UIComponent) item).encodeAll(context);
            } else if (item != null) {
                writer.writeText(item.toString(), null);
            }
            /*                      */
            if (tabSet.isFocusable()) {
                writer.endElement("div");
            }
            //        writer.endElement("div");

            if (i == (tabCount - 1)) {
View Full Code Here

Examples of org.openfaces.component.select.TabSet

        writer.flush();
    }

    private void encodeScriptsAndStyles(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        TabSet tabSet = (TabSet) component;

        List<Object> tabs = getTabItems(tabSet);
        int selectedIndex = getSelectedIndex(context, tabSet, tabs);

        Rendering.renderHiddenField(writer,
                component.getClientId(context) + SELECTED_INDEX_SUFFIX,
                String.valueOf(selectedIndex));

        TabPlacement placement = tabSet.getPlacement();
        if (placement == null) {
            placement = TabPlacement.TOP;
        }

        List<Object> borderSideNames = borderNames.getListWithFirst(placement, -1);
        String borderMask = "border-{0}: {4}; border-{1}: {4}; border-{2}: {4}; border-{3}: {5};";
        String frontBorderClass = FRONT_BORDER_CLASS_PREFIX + placement;

        int gapWidth = tabSet.getGapWidth();
        boolean hasGap = gapWidth > 0;

        String borderMaskPre;
        if (hasGap) {
            borderMaskPre = "border-{0}: {4}; border-{1}: {4}; border-{2}: {4}; border-{3}: {5};";
        } else {
            borderMaskPre = "border-{0}: {4}; border-{1}: {4}; border-{2}: 0px; border-{3}: {5};";
        }

        String backBorderClassPre = BACK_BORDER_CLASS_PREFIX + placement;

        String borderMaskPost;
        if (hasGap) {
            borderMaskPost = borderMaskPre;
        } else {
            borderMaskPost = "border-{0}: 0px;border-{1}: {4};border-{2}: {4};border-{3}: {5};";
        }
        String backBorderClassPost = backBorderClassPre;

        String frontBorderStyle = tabSet.getFrontBorderStyle();
        boolean frontBorderDefined = frontBorderStyle != null && frontBorderStyle.length() > 0;
        if (frontBorderDefined) {
            String frontBorder = formatBorderClassString(borderMask, borderSideNames, frontBorderStyle, "0px");
            frontBorderClass = Styles.getCSSClass(context, tabSet, frontBorder, frontBorderClass);
        }

        String backBorderStyle = tabSet.getBackBorderStyle();
        boolean backBorderDefined = backBorderStyle != null && backBorderStyle.length() > 0;
        if (backBorderDefined || frontBorderDefined) {
            String backBorderPre = formatBorderClassString(borderMaskPre, borderSideNames, backBorderStyle, frontBorderStyle);
            backBorderClassPre = Styles.getCSSClass(context, tabSet, backBorderPre, backBorderClassPre);

            String backBorderPost = formatBorderClassString(borderMaskPost, borderSideNames, backBorderStyle, frontBorderStyle);
            backBorderClassPost = Styles.getCSSClass(context, component, backBorderPost);
        }

        String defaultClass = DEFAULT_CLASS_PREFIX + placement;
        /**/
        String tabClass = Styles.getCSSClass(context, component, tabSet.getTabStyle(), defaultClass, tabSet.getTabClass());
        String defaultRolloverClass = DEFAULT_ROLLOVER_CLASS_PREFIX + placement;
        String rolloverClass = Styles.getCSSClass(context, component, tabSet.getRolloverTabStyle(), StyleGroup.rolloverStyleGroup(), tabSet.getRolloverTabClass(), defaultRolloverClass);
        String defaultSelectedClass = DEFAULT_SELECTED_STYLE.format(new Object[]{placement});
        String selectedClass = Styles.getStyleClassesStr(context, component, tabSet.getSelectedTabStyle(), tabSet.getSelectedTabClass(), defaultSelectedClass, StyleGroup.selectedStyleGroup());
        String defaultSelectedRolloverClass = DEFAULT_SELECTED_ROLLOVER_CLASS_PREFIX + placement.toString();
        String selectedRolloverClass = Styles.getCSSClass(context, component, tabSet.getRolloverSelectedTabStyle(), StyleGroup.selectedStyleGroup(1), tabSet.getRolloverSelectedTabClass(), defaultSelectedRolloverClass);
        String focusedTabClass = Styles.getStyleClassesStr(context, component, tabSet.getFocusedTabStyle(), tabSet.getFocusedTabClass(), null, StyleGroup.selectedStyleGroup(2));
        /// focus area style
        String defaultFocusedClass = Styles.getCSSClass(context, component, Rendering.DEFAULT_FOCUSED_STYLE, StyleGroup.selectedStyleGroup(1));
        String focusAreaClass = Styles.getCSSClass(context, component, tabSet.getFocusAreaStyle(),
                StyleGroup.selectedStyleGroup(2), tabSet.getFocusAreaClass(), defaultFocusedClass);

        String focusedClass = Styles.getCSSClass(context, tabSet,
                tabSet.getFocusedStyle(), StyleGroup.selectedStyleGroup(1), tabSet.getFocusedClass(), null);

        String onchange = tabSet.getOnchange();

        String defaultDisabledClass = DEFAULT_CLASS_PREFIX + "disabled";
             ScriptBuilder sb = new ScriptBuilder();
        sb.initScript(context, tabSet, "O$.TabSet._init",
                getTabIds(context, tabSet, tabs),
                selectedIndex,
                placement,
                new String[]{
                        tabClass,
                        selectedClass,
                        rolloverClass,
                        selectedRolloverClass,
                        focusedTabClass
                },
                new String[]{
                        frontBorderClass,
                        backBorderClassPre,
                        backBorderClassPost

                },
                tabSet.isFocusable(),
                focusAreaClass,
                focusedClass,
               onchange != null ? new AnonymousFunction(onchange, "event") : null);

        Rendering.renderInitScript(context, sb,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.