Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2016-03-30 10:59:13 -0400
committerFlorian Thienel2016-03-30 10:59:13 -0400
commitdcefc01f19bef58e6a91255565a42f79c91e40d8 (patch)
tree3edf9e83db25f1cab25c1d422c4168b2d92f7595
parentc1cce509c462d5a5dbccee19f5307e8b232a6b3e (diff)
downloadorg.eclipse.mylyn.docs.vex-dcefc01f19bef58e6a91255565a42f79c91e40d8.tar.gz
org.eclipse.mylyn.docs.vex-dcefc01f19bef58e6a91255565a42f79c91e40d8.tar.xz
org.eclipse.mylyn.docs.vex-dcefc01f19bef58e6a91255565a42f79c91e40d8.zip
add table-related boxes into the box structure
Signed-off-by: Florian Thienel <florian@thienel.org>
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java51
1 files changed, 50 insertions, 1 deletions
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
index 2a621e99..0fadc44d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
@@ -16,6 +16,10 @@ import static org.eclipse.vex.core.internal.boxes.BoxFactory.nodeReference;
import static org.eclipse.vex.core.internal.boxes.BoxFactory.nodeReferenceWithInlineContent;
import static org.eclipse.vex.core.internal.boxes.BoxFactory.nodeReferenceWithText;
import static org.eclipse.vex.core.internal.boxes.BoxFactory.rootBox;
+import static org.eclipse.vex.core.internal.boxes.BoxFactory.table;
+import static org.eclipse.vex.core.internal.boxes.BoxFactory.tableCell;
+import static org.eclipse.vex.core.internal.boxes.BoxFactory.tableRow;
+import static org.eclipse.vex.core.internal.boxes.BoxFactory.tableRowGroup;
import static org.eclipse.vex.core.internal.boxes.BoxFactory.verticalBlock;
import static org.eclipse.vex.core.internal.visualization.CssBoxFactory.endOffsetPlaceholder;
import static org.eclipse.vex.core.internal.visualization.CssBoxFactory.endTag;
@@ -140,7 +144,15 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
public VisualizeResult visit(final IElement element) {
final Styles styles = styleSheet.getStyles(element);
final Collection<VisualizeResult> childrenResults = traverseChildren(element);
- if (isListRoot(styles)) {
+ if (isTable(styles)) {
+ return new VisualizeResult(element, styles, childrenResults, visualizeAsTable(element, styles, childrenResults));
+ } else if (isTableRowGroup(styles)) {
+ return new VisualizeResult(element, styles, childrenResults, visualizeAsTableRowGroup(element, styles, childrenResults));
+ } else if (isTableRow(styles)) {
+ return new VisualizeResult(element, styles, childrenResults, visualizeAsTableRow(element, styles, childrenResults));
+ } else if (isTableCell(styles)) {
+ return new VisualizeResult(element, styles, childrenResults, visualizeAsTableCell(element, styles, childrenResults));
+ } else if (isListRoot(styles)) {
return new VisualizeResult(element, styles, childrenResults, visualizeAsList(element, styles, childrenResults));
} else if (isListItem(styles)) {
return new VisualizeResult(element, styles, childrenResults, visualizeAsListItem(element, styles, childrenResults));
@@ -191,6 +203,24 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
return CSS.LIST_ITEM.equals(styles.getDisplay());
}
+ private static boolean isTable(final Styles styles) {
+ return CSS.TABLE.equals(styles.getDisplay());
+ }
+
+ private static boolean isTableRowGroup(final Styles styles) {
+ return CSS.TABLE_ROW_GROUP.equals(styles.getDisplay())
+ || CSS.TABLE_HEADER_GROUP.equals(styles.getDisplay())
+ || CSS.TABLE_FOOTER_GROUP.equals(styles.getDisplay());
+ }
+
+ private static boolean isTableRow(final Styles styles) {
+ return CSS.TABLE_ROW.equals(styles.getDisplay());
+ }
+
+ private static boolean isTableCell(final Styles styles) {
+ return CSS.TABLE_CELL.equals(styles.getDisplay());
+ }
+
private static boolean isDisplayedAsBlock(final Styles styles) {
// currently we can only render blocks or inline, hence everything that is not inline must be a block
return !isDisplayedInline(styles);
@@ -209,6 +239,25 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
}
/*
+ * Render as Table
+ */
+ private IStructuralBox visualizeAsTable(final IElement element, final Styles styles, final Collection<VisualizeResult> childrenResults) {
+ return table(visualizeAsBlock(element, styles, childrenResults));
+ }
+
+ private IStructuralBox visualizeAsTableRowGroup(final IElement element, final Styles styles, final Collection<VisualizeResult> childrenResults) {
+ return tableRowGroup(visualizeAsBlock(element, styles, childrenResults));
+ }
+
+ private IStructuralBox visualizeAsTableRow(final IElement element, final Styles styles, final Collection<VisualizeResult> childrenResults) {
+ return tableRow(visualizeAsBlock(element, styles, childrenResults));
+ }
+
+ private IStructuralBox visualizeAsTableCell(final IElement element, final Styles styles, final Collection<VisualizeResult> childrenResults) {
+ return tableCell(visualizeAsBlock(element, styles, childrenResults));
+ }
+
+ /*
* Render as List
*/

Back to the top