Author: dmaliarevich
Date: 2008-11-20 06:30:07 -0500 (Thu, 20 Nov 2008)
New Revision: 11899
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dataTableScroller/dataTableScroller.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableScrollerTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2906, richfaces datascroller template was
updated, styles were added.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dataTableScroller/dataTableScroller.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dataTableScroller/dataTableScroller.css 2008-11-20
11:27:58 UTC (rev 11898)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dataTableScroller/dataTableScroller.css 2008-11-20
11:30:07 UTC (rev 11899)
@@ -1,39 +1,38 @@
-@CHARSET "UTF-8";
-.dr-div-heigth {
- height : 20px;}
- .dr-div-width {
- width : 400px;}
-.dr-dscr-button {
-background-color:#F1EEE9;
-border:1px solid #C0C0C0;
-cursor:pointer;
-font-family:verdana;
-font-size:11px;
-width:25px;
+.rich-datascr {
+ width : 400px;
+ display: table;
}
-.dr-dscr-inact {
-border-top:2px solid #D4CFC7;
-color: #D4CFC7;
-cursor:pointer;
-font-family:verdana;
-font-size:11px;
-width:25px;
+.rich-dtascroller-table {
+ background-color:#FFFFFF;
+ border:1px solid #C0C0C0;
}
-.dr-dscr-act {
-border-top:2px solid #000000;
-color:#000000;
-font-family:verdana;
-font-size:11px;
-width:25px;
+
+.rich-datascr-button, .rich-datascr-button-dsbld {
+ background-color:#F1EEE9;
+ border:1px solid #C0C0C0;
+ cursor:pointer;
+ font-family:verdana;
+ font-size:11px;
+ width:25px;
}
-.dr-dscr-t {
-background-color:#FFFFFF;
-border:1px solid #C0C0C0;
+
+.rich-datascr-button-dsbld {
+ color: gray;
}
-.dr-tbpnl-cntnt {
-border-style:solid;
-color:#000000;
-font-family:verdana;
-font-size:11px;
+
+.rich-datascr-act {
+ border-top:2px solid #000000;
+ color:#000000;
+ font-family:verdana;
+ font-size:11px;
+ width:25px;
}
+.rich-datascr-inact {
+ border-top:2px solid #D4CFC7;
+ color: #D4CFC7;
+ cursor:pointer;
+ font-family:verdana;
+ font-size:11px;
+ width:25px;
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-11-20
11:27:58 UTC (rev 11898)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-11-20
11:30:07 UTC (rev 11899)
@@ -692,6 +692,72 @@
}
/**
+ * Parses the size attribute.
+ *
+ * @param sourceElement the source element
+ * @param attributeName the attribute name
+ * @param defaultValue the default value
+ *
+ * @return the int size
+ */
+ public static int parseSizeAttribute(Element sourceElement, String attributeName,
+ int defaultValue) {
+
+ if (sourceElement.hasAttribute(attributeName)) {
+ String attrValue = sourceElement.getAttribute(attributeName);
+
+ if (attrValue.endsWith(Constants.PIXEL))
+ attrValue = attrValue.substring(0, attrValue.length()
+ - Constants.PIXEL.length());
+
+ try {
+ /*
+ * Decoding attribute's value
+ */
+ int intValue = Integer.decode(attrValue);
+ return intValue;
+ } catch (NumberFormatException e) {
+ /*
+ * if attribute's value is not a number do nothing
+ * return default value
+ */
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Parses the number attribute.
+ *
+ * @param sourceElement the source element
+ * @param attributeName the attribute name
+ * @param defaultValue the default value
+ *
+ * @return the int number
+ */
+ public static int parseNumberAttribute(Element sourceElement,
+ String attributeName, int defaultValue) {
+
+ if (sourceElement.hasAttribute(attributeName)) {
+ String attrValue = sourceElement.getAttribute(attributeName);
+
+ try {
+ /*
+ * Decoding attribute's value
+ */
+ int intValue = Integer.decode(attrValue);
+ return intValue;
+ } catch (NumberFormatException e) {
+ /*
+ * if attribute's value is not a number do nothing
+ * return default value
+ */
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
* Checks if is blank.
*
* @param value the value
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2008-11-20
11:27:58 UTC (rev 11898)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2008-11-20
11:30:07 UTC (rev 11899)
@@ -704,11 +704,11 @@
currentDayControl = sdf.format(calendar.getTime());
// cellWidth
- cellWidth = parseSizeAttribute(sourceElement, ATTR_CELL_WIDTH,
+ cellWidth = ComponentUtil.parseSizeAttribute(sourceElement, ATTR_CELL_WIDTH,
DEFAULT_CELL_WIDTH);
// cellHeight
- cellHeight = parseSizeAttribute(sourceElement, ATTR_CELL_HEIGHT,
+ cellHeight = ComponentUtil.parseSizeAttribute(sourceElement, ATTR_CELL_HEIGHT,
DEFAULT_CELL_HEIGHT);
// tableWidth
@@ -730,14 +730,14 @@
DIRECTIONS_BOTTOM_RIGHT);
// zindex
- zindex = parseNumberAttribute(sourceElement, RichFaces.ATTR_ZINDEX, 3);
+ zindex = ComponentUtil.parseNumberAttribute(sourceElement, RichFaces.ATTR_ZINDEX, 3);
// horizontalOffset
- horizontalOffset = parseNumberAttribute(sourceElement,
+ horizontalOffset = ComponentUtil.parseNumberAttribute(sourceElement,
RichFaces.ATTR_HORIZONTAL_OFFSET, 0);
// verticalOffset
- verticalOffset = parseNumberAttribute(sourceElement,
+ verticalOffset = ComponentUtil.parseNumberAttribute(sourceElement,
RichFaces.ATTR_VERTICAL_OFFSET, 0);
}
@@ -935,54 +935,6 @@
}
- private int parseSizeAttribute(Element sourceElement, String attributeName,
- int defaultValue) {
-
- if (sourceElement.hasAttribute(attributeName)) {
- String attrValue = sourceElement.getAttribute(attributeName);
-
- if (attrValue.endsWith(Constants.PIXEL))
- attrValue = attrValue.substring(0, attrValue.length()
- - Constants.PIXEL.length());
-
- try {
- // decode attribute's value
- int intValue = Integer.decode(attrValue);
-
- // richfaces Calendar counts weekdays from 0 but
- // java.util.Calendar counts weekdays from 1
- return intValue;
- } catch (NumberFormatException e) {
- // if attribute's value is not number do nothing and then return
- // default value
- }
- }
-
- return defaultValue;
- }
-
- private int parseNumberAttribute(Element sourceElement,
- String attributeName, int defaultValue) {
-
- if (sourceElement.hasAttribute(attributeName)) {
- String attrValue = sourceElement.getAttribute(attributeName);
-
- try {
- // decode attribute's value
- int intValue = Integer.decode(attrValue);
-
- // richfaces Calendar counts weekdays from 0 but
- // java.util.Calendar counts weekdays from 1
- return intValue;
- } catch (NumberFormatException e) {
- // if attribute's value is not number do nothing and then return
- // default value
- }
- }
-
- return defaultValue;
- }
-
/**
* @param sourceElement
* @param locale
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableScrollerTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableScrollerTemplate.java 2008-11-20
11:27:58 UTC (rev 11898)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableScrollerTemplate.java 2008-11-20
11:30:07 UTC (rev 11899)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
@@ -19,8 +19,6 @@
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMText;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -30,285 +28,253 @@
*/
public class RichFacesDataTableScrollerTemplate extends VpeAbstractTemplate {
- final static int EMPTY_CELL = 1;
- final static int NUM_CELL = 2;
+ private static final String COMPONENT_NAME = "richFacesDataTableScroller";
//$NON-NLS-1$
+ private static final String STYLE_PATH =
"dataTableScroller/dataTableScroller.css"; //$NON-NLS-1$
- final static int SCROLL_CELL = 3;
+ private static final String RIGHT_DOUBLE_SCROLL_SYMBOL = "��";
//$NON-NLS-1$
+ private static final String RIGHT_SINGLE_SCROLL_SYMBOL = "�";
//$NON-NLS-1$
+ private static final String LEFT_DOUBLE_SCROLL_SYMBOL = "��";
//$NON-NLS-1$
+ private static final String LEFT_SINGLE_SCROLL_SYMBOL = "�"; //$NON-NLS-1$
- final static String STYLE_PATH = "dataTableScroller/dataTableScroller.css";
//$NON-NLS-1$
+ /*
+ * Minimal cells number in datascroller.
+ */
+ private static final int MINIMAL_CELLS_NUMBER = 5;
+ /*
+ * Default active datascroller page number.
+ */
+ private static final int DEFAULT_PAGE_NUMBER = 1;
- /**
- * Default size component This parameter need for calculate default number
- * of cells
- */
- final static String DEFAULT_STYLE_WIDTH = "width : 400px;"; //$NON-NLS-1$
+ private static final String CSS_RICH_DATASCR = "rich-datascr";
//$NON-NLS-1$
+ private static final String CSS_RICH_DATASCROLLER_TABLE =
"rich-dtascroller-table"; //$NON-NLS-1$
+ private static final String CSS_RICH_DATASCR_BUTTON =
"rich-datascr-button"; //$NON-NLS-1$
+ private static final String CSS_RICH_DATASCR_CTRLS_SEPARATOR =
"rich-datascr-ctrls-separator"; //$NON-NLS-1$
+ private static final String CSS_RICH_DATASCR_ACT = "rich-datascr-act";
//$NON-NLS-1$
+ private static final String CSS_RICH_DATASCR_INACT = "rich-datascr-inact";
//$NON-NLS-1$
+ private static final String CSS_RICH_DATASCR_BUTTON_DSBLD =
"rich-datascr-button-dsbld"; //$NON-NLS-1$
- /**
- * Minimal size component This parameter need for calculate minimal number
- * of cells
- */
- final static String MIN_STYLE_WIDTH = "width : 225px;"; //$NON-NLS-1$
+ private static final String ATTR_BOUNDARY_CONTROLS = "boundaryControls";
//$NON-NLS-1$
+ private static final String ATTR_FAST_CONTROLS = "fastControls";
//$NON-NLS-1$
+ private static final String ATTR_MAX_PAGES = "maxPages"; //$NON-NLS-1$
+ private static final String ATTR_PAGE = "page"; //$NON-NLS-1$
+ private static final String ATTR_STEP_CONTROLS = "stepControls";
//$NON-NLS-1$
- final static String RIGHT_DOUBLE_SCROLL_SYMBOL = ">>"; //$NON-NLS-1$
+ private static final String ATTR_INACTIVE_STYLE = "inactiveStyle";
//$NON-NLS-1$
+ private static final String ATTR_INACTIVE_STYLE_CLASS =
"inactiveStyleClass"; //$NON-NLS-1$
+ private static final String ATTR_SELECTED_STYLE = "selectedStyle";
//$NON-NLS-1$
+ private static final String ATTR_SELECTED_STYLE_CLASS =
"selectedStyleClass"; //$NON-NLS-1$
+ private static final String ATTR_TABLE_STYLE = "tableStyle"; //$NON-NLS-1$
+ private static final String ATTR_TABLE_STYLE_CLASS = "tableStyleClass";
//$NON-NLS-1$
- final static String RIGHT_SINGLE_SCROLL_SYMBOL = ">"; //$NON-NLS-1$
+ private static final String ATTR_VALUE_SHOW = "show"; //$NON-NLS-1$
- final static String LEFT_DOUBLE_SCROLL_SYMBOL = "<<"; //$NON-NLS-1$
+ private boolean showBoundaryControls;
+ private boolean showFastControls;
+ private int maxPages;
+ private int page;
+ private boolean showStepControls;
+ private String inactiveStyle;
+ private String inactiveStyleClass;
+ private String selectedStyle;
+ private String selectedStyleClass;
+ private String tableStyle;
+ private String tableStyleClass;
+ private String style;
+ private String styleClass;
- final static String LEFT_SINGLE_SCROLL_SYMBOL = "<"; //$NON-NLS-1$
+ /**
+ *
+ * Constructor.
+ */
+ public RichFacesDataTableScrollerTemplate() {
+ super();
+ }
- /**
- * Minimal cells in datascroller
- */
- final static int MIN_NUM_CELLS = 9;
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ readAttributes(sourceNode);
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
+ COMPONENT_NAME);
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ VpeCreationData creationData = new VpeCreationData(div);
- /**
- *
- * Constructor.
- */
- public RichFacesDataTableScrollerTemplate() {
- super();
+ div.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_CENTER);
+ div.setAttribute(HTML.ATTR_CLASS, styleClass);
+ if (ComponentUtil.isNotBlank(style)) {
+ div.setAttribute(HTML.ATTR_STYLE, style);
}
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- Element source = (Element) sourceNode;
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
- "richFacesDataScrollerTable"); //$NON-NLS-1$
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- String style = source.getAttribute(RichFaces.ATTR_STYLE);
- div.setAttribute(HTML.ATTR_CLASS, "dr-div-heigth"); //$NON-NLS-1$
- if (style == null) {
- style = DEFAULT_STYLE_WIDTH;
- }
+ nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
+ tbody.appendChild(tr);
+ table.appendChild(tbody);
+ div.appendChild(table);
- nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
- table.setAttribute(HTML.ATTR_CLASS,
- "dr-dscr-t dr-tbpnl-cntnt"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_CELLSPACING, "1"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
- nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
- nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
- tbody.appendChild(tr);
- table.appendChild(tbody);
-
- VpeCreationData creationData = new VpeCreationData(div);
- /* Add scroll cells */
- nsIDOMElement child1 = createCell(visualDocument, false, LEFT_DOUBLE_SCROLL_SYMBOL,
SCROLL_CELL);
- nsIDOMElement child2 = createCell(visualDocument, false, LEFT_SINGLE_SCROLL_SYMBOL,
SCROLL_CELL);
- /* Add empty cells */
- nsIDOMElement child3 = createCell(visualDocument, false, Constants.EMPTY, EMPTY_CELL);
- tr.appendChild(child1);
- tr.appendChild(child2);
- tr.appendChild(child3);
-
- String str = getWidth(style);
- int size = getSize(str);
- int minSize = getSize(getWidth(MIN_STYLE_WIDTH));
- /* check size */
- if (size < minSize) {
- size = minSize;
- style = MIN_STYLE_WIDTH;
- }
- size /= (minSize / MIN_NUM_CELLS);
- /* Add number cells in datascroller */
- for (int i = 0; i < (size - 6); i++) {
- nsIDOMElement child = createCell(visualDocument, (i == 0 ? true : false),
Constants.EMPTY + (i + 1), NUM_CELL);
- tr.appendChild(child);
- }
- /* Add empty cell */
- child1 = createCell(visualDocument, false, Constants.EMPTY, EMPTY_CELL);
- /* Add scroll cells */
- child2 = createCell(visualDocument, false, RIGHT_SINGLE_SCROLL_SYMBOL,
- SCROLL_CELL);
- child3 = createCell(visualDocument, false, RIGHT_DOUBLE_SCROLL_SYMBOL,
- SCROLL_CELL);
- tr.appendChild(child1);
- tr.appendChild(child2);
- tr.appendChild(child3);
-
- div.setAttribute(HTML.ATTR_STYLE, style);
- div.appendChild(table);
- return creationData;
+ table.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_CENTER);
+ table.setAttribute(HTML.ATTR_CLASS, tableStyleClass);
+ if (ComponentUtil.isNotBlank(tableStyle)) {
+ table.setAttribute(HTML.ATTR_STYLE, tableStyle);
}
+ table.setAttribute(HTML.ATTR_CELLSPACING, "1"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
- /**
- *
- * Method for creating one cell in table.
- *
- * @param visualDocument
- * @param color -
- * border and text color
- * @param text -
- * text in cell
- * @return Element
+ /*
+ * Create left side controls
*/
- private nsIDOMElement createCell(nsIDOMDocument visualDocument, boolean active, String
text, int sellType) {
- nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
- td.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_CENTER);
- nsIDOMText d = visualDocument.createTextNode(text);
- if (sellType == NUM_CELL) {
- td.setAttribute(HTML.ATTR_CLASS,
- (active ? "dr-dscr-act" : "dr-dscr-inact")); //$NON-NLS-1$
//$NON-NLS-2$
- td.appendChild(d);
- } else if (sellType == EMPTY_CELL) {
- td
- .setAttribute(HTML.ATTR_CLASS,
- "dr-dscr-button"); //$NON-NLS-1$
- } else {
- td
- .setAttribute(HTML.ATTR_CLASS,
- "dr-dscr-button"); //$NON-NLS-1$
- td.appendChild(d);
- }
- return td;
+ if (showBoundaryControls) {
+ createCell(visualDocument, tr, LEFT_DOUBLE_SCROLL_SYMBOL,
+ CSS_RICH_DATASCR_BUTTON + Constants.WHITE_SPACE
+ + CSS_RICH_DATASCR_BUTTON_DSBLD, Constants.EMPTY);
}
+ if (showFastControls) {
+ createCell(visualDocument, tr, LEFT_SINGLE_SCROLL_SYMBOL,
+ CSS_RICH_DATASCR_BUTTON + Constants.WHITE_SPACE
+ + CSS_RICH_DATASCR_BUTTON_DSBLD, Constants.EMPTY);
+ }
+ if (showStepControls) {
+ createCell(visualDocument, tr, Constants.EMPTY,
+ CSS_RICH_DATASCR_BUTTON + Constants.WHITE_SPACE
+ + CSS_RICH_DATASCR_BUTTON_DSBLD, Constants.EMPTY);
+ }
- /**
- * Method for remove attributes .
+ /*
+ * Create page numbers controls
*/
- @Override
- public void removeAttribute(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMNode visualNode,Object data, String name) {
- super.removeAttribute(pageContext, sourceElement, visualDocument, visualNode, data,
name);
- nsIDOMElement element = (nsIDOMElement)
visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- element.removeAttribute(name);
+ for (int i = 1; i <= maxPages; i++) {
+ createCell(visualDocument, tr, String.valueOf(i),
+ (i == 1 ? selectedStyleClass : inactiveStyleClass),
+ (i == 1 ? selectedStyle : inactiveStyle));
}
-
/*
- * @see
com.exadel.vpe.editor.template.VpeAbstractTemplate#setAttribute(com.exadel.vpe.editor.context.VpePageContext,
- * org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.Node,
- * java.lang.Object, java.lang.String, java.lang.String)
+ * Create right side controls
*/
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data, String name, String
value) {
- super.setAttribute(pageContext, sourceElement, visualDocument,
- visualNode, data, name, value);
- nsIDOMElement element = (nsIDOMElement)
visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- int size = 45;
- if (name.equalsIgnoreCase(RichFaces.ATTR_STYLE)) {
- String str = getWidth(value);
- size = getSize(str);
- int minSize = getSize(getWidth(MIN_STYLE_WIDTH));
- if (size < minSize) {
- size = minSize;
- value = MIN_STYLE_WIDTH;
- }
- size /= (minSize / MIN_NUM_CELLS);
- nsIDOMElement tr = getTR(element);
- nsIDOMNodeList nodes = tr.getChildNodes();
- long nodesLength = nodes.getLength();
- if (nodesLength != size) {
- if (size < nodesLength) {
- // Remove cells in datascroller
- for (int i = size; i < nodesLength; i++) {
- tr.removeChild(nodes.item(size - 3));
- }
- } else {
- // Remove cells in datascroller
- for (int i = 0; i < 3; i++) {
- tr.removeChild(nodes.item(nodesLength - 3));
- }
- // Add cells in datascroller
- for (int i = 0; i < (size - nodesLength); i++) {
- nsIDOMElement cell = createCell(visualDocument, false,Constants.EMPTY +
(nodesLength - 5 + i), NUM_CELL);
- tr.appendChild(cell);
- }
- nsIDOMElement child1 = createCell(visualDocument, false, Constants.EMPTY,
EMPTY_CELL);
- nsIDOMElement child2 = createCell(visualDocument, false,RIGHT_SINGLE_SCROLL_SYMBOL,
SCROLL_CELL);
- nsIDOMElement child3 = createCell(visualDocument, false, RIGHT_DOUBLE_SCROLL_SYMBOL,
SCROLL_CELL);
- tr.appendChild(child1);
- tr.appendChild(child2);
- tr.appendChild(child3);
- }
- }
- }
- element.setAttribute(name, value);
+ if (showStepControls) {
+ createCell(visualDocument, tr, Constants.EMPTY,
+ CSS_RICH_DATASCR_BUTTON, Constants.EMPTY);
+ }
+ if (showFastControls) {
+ createCell(visualDocument, tr, RIGHT_SINGLE_SCROLL_SYMBOL,
+ CSS_RICH_DATASCR_BUTTON, Constants.EMPTY);
+ }
+ if (showBoundaryControls) {
+ createCell(visualDocument, tr, RIGHT_DOUBLE_SCROLL_SYMBOL,
+ CSS_RICH_DATASCR_BUTTON, Constants.EMPTY);
+ }
+ return creationData;
+ }
+
+ /**
+ * Creates the cell with central alignment.
+ *
+ * @param visualDocument the visual document
+ * @param tr the table row to add the cell
+ * @param text the text in the cell
+ * @param styleClass the style class for the cell
+ * @param style the style for the cell
+ */
+ private void createCell(nsIDOMDocument visualDocument, nsIDOMElement tr,
+ String text, String styleClass, String style) {
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+ td.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_CENTER);
+ nsIDOMText cellText = visualDocument.createTextNode(text);
+
+ if (ComponentUtil.isNotBlank(styleClass)) {
+ td.setAttribute(HTML.ATTR_CLASS, styleClass);
}
-
- /**
- * Method for parse style and get width.
- *
- * @param style
- * @return size
- */
- private String getWidth(String style) {
- String[] sub = style.split(Constants.SEMICOLON);
- for (int i = 0; i < sub.length; i++) {
- sub[i] = sub[i].trim();
- sub[i] = sub[i].toLowerCase();
- int pos = sub[i].indexOf(HTML.STYLE_PARAMETER_WIDTH);
- if (pos != -1) {
- if (pos == 0 || sub[i].charAt(pos - 1) != '-') {
- pos = sub[i].indexOf(Constants.COLON);
- return sub[i].substring(pos + 1);
- }
- }
- }
- return null;
+ if (ComponentUtil.isNotBlank(style)) {
+ td.setAttribute(HTML.ATTR_STYLE, style);
}
- /**
- * Method for convert String to number
- *
- * @param size
- * @return number
- */
- private int getSize(String size) {
- if(size==null) {
- return 0;
- }
- String num = size;
- int pos = size.indexOf(Constants.PIXEL);
- if (pos != -1) {
- num = size.substring(0, pos);
- }
- try {
- num = num.trim();
- Integer i = Integer.valueOf(num);
- return i.intValue();
- } catch (NumberFormatException e) {
- return 0;
- }
+ td.appendChild(cellText);
+ tr.appendChild(td);
+
+ }
+
+ /**
+ * Read attributes from the source element.
+ *
+ * @param sourceNode
+ * the source node
+ */
+ private void readAttributes(Node sourceNode) {
+
+ Element sourceElement = (Element) sourceNode;
+ String attrValue = null;
+
+ showBoundaryControls = (!sourceElement
+ .hasAttribute(ATTR_BOUNDARY_CONTROLS) || ATTR_VALUE_SHOW
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_BOUNDARY_CONTROLS)));
+
+ showFastControls = (!sourceElement.hasAttribute(ATTR_FAST_CONTROLS) || ATTR_VALUE_SHOW
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_FAST_CONTROLS)));
+
+ maxPages = ComponentUtil.parseNumberAttribute(sourceElement,
+ ATTR_MAX_PAGES, MINIMAL_CELLS_NUMBER);
+
+ page = ComponentUtil.parseNumberAttribute(sourceElement, ATTR_PAGE,
DEFAULT_PAGE_NUMBER);
+
+ showStepControls = (!sourceElement.hasAttribute(ATTR_STEP_CONTROLS) || ATTR_VALUE_SHOW
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_STEP_CONTROLS)));
+
+ inactiveStyle = sourceElement.getAttribute(ATTR_INACTIVE_STYLE);
+
+ inactiveStyleClass = CSS_RICH_DATASCR_INACT;
+ attrValue = sourceElement.getAttribute(ATTR_INACTIVE_STYLE_CLASS);
+ if (ComponentUtil.isNotBlank(attrValue)) {
+ inactiveStyleClass += Constants.WHITE_SPACE + attrValue;
}
- /**
- *
- * Get Tag TR Element.
- *
- * @param parent
- * Element
- * @return Element Tag TR
- */
- private nsIDOMElement getTR(nsIDOMElement parent) {
- nsIDOMNodeList list = parent.getChildNodes();
- nsIDOMNode tableNode = list.item(0);
- nsIDOMElement table = (nsIDOMElement)
tableNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- nsIDOMNodeList tableList = table.getChildNodes();
- nsIDOMNode tbodyNode = tableList.item(0);
- nsIDOMElement tbody = (nsIDOMElement)
tbodyNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ selectedStyle = sourceElement.getAttribute(ATTR_SELECTED_STYLE);
- nsIDOMNodeList tbodyList = tbody.getChildNodes();
- nsIDOMNode tempNode = tbodyList.item(0);
- nsIDOMElement returnElement = (nsIDOMElement)
tempNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- return returnElement;
+ selectedStyleClass = CSS_RICH_DATASCR_ACT;
+ attrValue = sourceElement.getAttribute(ATTR_SELECTED_STYLE_CLASS);
+ if (ComponentUtil.isNotBlank(attrValue)) {
+ selectedStyleClass += Constants.WHITE_SPACE + attrValue;
}
+
+ tableStyle = sourceElement.getAttribute(ATTR_TABLE_STYLE);
+
+ tableStyleClass = CSS_RICH_DATASCROLLER_TABLE;
+ attrValue = sourceElement.getAttribute(ATTR_TABLE_STYLE_CLASS);
+ if (ComponentUtil.isNotBlank(attrValue)) {
+ tableStyleClass += Constants.WHITE_SPACE + attrValue;
+ }
+
+ style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+
+ styleClass = CSS_RICH_DATASCR;
+ attrValue = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
+ if (ComponentUtil.isNotBlank(attrValue)) {
+ styleClass += Constants.WHITE_SPACE + attrValue;
+ }
+
+ }
+
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+
}
\ No newline at end of file