1 /*******************************************************************************
\r
2 * Copyright (c) 2006 Sybase, Inc. and others.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * Sybase, Inc. - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.eclipse.jst.pagedesigner.css2.layout;
\r
14 import org.eclipse.draw2d.LayoutManager;
\r
15 import org.eclipse.jst.pagedesigner.css2.ICSSStyle;
\r
16 import org.eclipse.jst.pagedesigner.css2.layout.table.CSSTRGroupLayout;
\r
17 import org.eclipse.jst.pagedesigner.css2.layout.table.CSSTRLayout;
\r
18 import org.eclipse.jst.pagedesigner.css2.layout.table.CSSTableCaptionLayout;
\r
19 import org.eclipse.jst.pagedesigner.css2.layout.table.CSSTableCellLayout;
\r
20 import org.eclipse.jst.pagedesigner.css2.layout.table.CSSTableLayout2;
\r
21 import org.eclipse.jst.pagedesigner.css2.property.ICSSPropertyID;
\r
22 import org.eclipse.jst.pagedesigner.css2.property.PositionMeta;
\r
27 public final class DisplayToLayout {
\r
32 * @return the layout
\r
34 public static CSSLayout displayToLayout(CSSFigure figure, String display,
\r
35 LayoutManager old) {
\r
36 if ("block".equalsIgnoreCase(display)) //$NON-NLS-1$
\r
38 return new CSSBlockFlowLayout(figure);
\r
39 } else if ("inline".equalsIgnoreCase(display)) //$NON-NLS-1$
\r
41 return new CSSInlineFlowLayout(figure);
\r
42 } else if ("table".equalsIgnoreCase(display) || "inline-table".equalsIgnoreCase(display)) //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
\r
44 return new CSSTableLayout2(figure);
\r
45 } else if ("table-row".equalsIgnoreCase(display)) //$NON-NLS-1$
\r
47 return new CSSTRLayout(figure);
\r
48 } else if ("table-row-group".equalsIgnoreCase(display) //$NON-NLS-1$
\r
49 || "table-header-group".equalsIgnoreCase(display) //$NON-NLS-1$
\r
50 || "table-footer-group".equalsIgnoreCase(display)) //$NON-NLS-1$
\r
52 return new CSSTRGroupLayout(figure);
\r
53 } else if ("table-cell".equalsIgnoreCase(display)) //$NON-NLS-1$
\r
55 return new CSSTableCellLayout(figure);
\r
56 } else if (display.equalsIgnoreCase("table-caption")) //$NON-NLS-1$
\r
58 return new CSSTableCaptionLayout(figure);
\r
59 } else if ("inline-block".equalsIgnoreCase(display)) //$NON-NLS-1$
\r
61 return new CSSBlockFlowLayout(figure) {
\r
65 * @see org.eclipse.jst.pagedesigner.css2.layout.CSSBlockFlowLayout#isInlineBlock()
\r
67 public boolean isInlineBlock() {
\r
71 } else if (ICSSPropertyID.VAL_LIST_ITEM.equalsIgnoreCase(display)) {
\r
72 return new CSSListItemLayout(figure);
\r
79 * @return true if is inline
\r
81 public static boolean isInline(String display) {
\r
82 return "inline".equalsIgnoreCase(display) //$NON-NLS-1$
\r
83 || "inline-block".equalsIgnoreCase(display); //$NON-NLS-1$
\r
88 * @return true if is positioned
\r
90 public static boolean isPositioned(ICSSStyle style) {
\r
91 Object position = style.getStyleProperty(ICSSPropertyID.ATTR_POSITION);
\r
92 if (PositionMeta.STATIC.equalsIgnoreCase((String) position)) {
\r
98 private DisplayToLayout()
\r
100 // util class, no instantiation
\r