JBoss Tools SVN: r11902 - trunk/vpe/plugins/org.jboss.tools.vpe.html/templates.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-11-20 07:23:57 -0500 (Thu, 20 Nov 2008)
New Revision: 11902
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
Log:
corrcted table tag by advice of yzhishko
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2008-11-20 12:17:03 UTC (rev 11901)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2008-11-20 12:23:57 UTC (rev 11902)
@@ -1813,7 +1813,7 @@
<vpe:tag name="table" case-sensitive="no">
<vpe:template children="yes" modify="yes">
<vpe:copy
- attrs="style,class,width,border,frame,rules,cellspacing,cellpadding,align,bgcolor,background" />
+ attrs="style,class,width,border,bordercolor,frame,rules,cellspacing,cellpadding,align,bgcolor,background" />
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
17 years, 5 months
JBoss Tools SVN: r11901 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-11-20 07:17:03 -0500 (Thu, 20 Nov 2008)
New Revision: 11901
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/calendar.xhtml.xml
Log:
corrected test
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/calendar.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/calendar.xhtml.xml 2008-11-20 12:02:41 UTC (rev 11900)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/calendar.xhtml.xml 2008-11-20 12:17:03 UTC (rev 11901)
@@ -6,7 +6,7 @@
SIZE=" " VALUE="" />
<IMG
- SRC="/.*org\.jboss\.tools\.jsf\.vpe.richfaces\/resources\/calendar\/calendar\.gif/"
+ SRC="/.*/resources/calendar/calendar.gif/"
STYLE="vertical-align: middle;" CLASS="rich-calendar-button null"
VPE-USER-TOGGLE-ID="true" />
17 years, 5 months
JBoss Tools SVN: r11900 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-11-20 07:02:41 -0500 (Thu, 20 Nov 2008)
New Revision: 11900
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3221
https://jira.jboss.org/jira/browse/JBIDE-3220
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-11-20 11:30:07 UTC (rev 11899)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-11-20 12:02:41 UTC (rev 11900)
@@ -512,7 +512,7 @@
while ((currentElement.getParentNode() != null)
&& (currentElement.getParentNode().getNodeType() == Node.ELEMENT_NODE)) {
- currentElement = parent = (Element) parent.getParentNode();
+ currentElement = parent = (Element) currentElement.getParentNode();
if (findOnlyPanelMenuParent) {
if ((parent != null)
&& parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-11-20 11:30:07 UTC (rev 11899)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-11-20 12:02:41 UTC (rev 11900)
@@ -550,7 +550,7 @@
while ((currentElement.getParentNode() != null)
&& (currentElement.getParentNode().getNodeType() == Node.ELEMENT_NODE)) {
- currentElement = parent = (Element) parent.getParentNode();
+ currentElement = parent = (Element) currentElement.getParentNode();
if (findOnlyPanelMenuParent) {
if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
17 years, 5 months
JBoss Tools SVN: r11899 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces: src/org/jboss/tools/jsf/vpe/richfaces and 1 other directories.
by jbosstools-commits@lists.jboss.org
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
17 years, 5 months
JBoss Tools SVN: r11898 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-11-20 06:27:58 -0500 (Thu, 20 Nov 2008)
New Revision: 11898
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3221
https://jira.jboss.org/jira/browse/JBIDE-3220
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-11-20 03:27:10 UTC (rev 11897)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-11-20 11:27:58 UTC (rev 11898)
@@ -18,7 +18,6 @@
import java.util.Map;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
-import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -26,16 +25,15 @@
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
+import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.ResourceUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMText;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
public class RichFacesPanelMenuGroupTemplate extends VpeAbstractTemplate implements
VpeToggableTemplate {
@@ -163,7 +161,7 @@
// srcNode = (Element) groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE);
// }
nsIDOMElement creationDataDiv = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ .createElement(HTML.TAG_DIV);
VpeCreationData creationData = new VpeCreationData(creationDataDiv);
//added by estherbin fixed https://jira.jboss.org/jira/browse/JBIDE-1605 issue.
final Element elementToPass = (srcNode != null ? srcNode : groupSourceElement);
@@ -189,7 +187,7 @@
expanded = expandedIds.contains(childId);
}
nsIDOMElement div = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ .createElement(HTML.TAG_DIV);
creationDataDiv.appendChild(div);
div.setAttribute(COMPONENT_ATTR_VPE_SUPPORT, NAME_COMPONENT);
div.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, childId);
@@ -198,7 +196,7 @@
visualDocument, div, expanded, childId);
nsIDOMElement childSpan = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ .createElement(HTML.TAG_SPAN);
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(childSpan);
@@ -251,15 +249,15 @@
String divClass = EMPTY;
nsIDOMElement table = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ .createElement(HTML.TAG_TABLE);
div.appendChild(table);
- table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0"); //$NON-NLS-1$
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0"); //$NON-NLS-1$
- table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
nsIDOMElement tableBodyRow = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ .createElement(HTML.TAG_TR);
table.appendChild(tableBodyRow);
/*
@@ -274,9 +272,9 @@
if (ids.length > 1) {
for (int i = 1; i <= ids.length - 1; i++) {
nsIDOMElement spacerTd = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
nsIDOMElement spacerImg = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
spacerTd.appendChild(spacerImg);
ComponentUtil.setImg(spacerImg,
PANEL_MENU_GROUP_ICON_SPACER_PATH);
@@ -288,17 +286,17 @@
}
nsIDOMElement column1 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
column1.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, activeChildId);
tableBodyRow.appendChild(column1);
nsIDOMElement column2 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
tableBodyRow.appendChild(column2);
- column2.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, WIDTH_100_PERSENTS);
+ column2.setAttribute(HTML.ATTR_STYLE, WIDTH_100_PERSENTS);
nsIDOMElement column3 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
column3.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, activeChildId);
tableBodyRow.appendChild(column3);
@@ -340,8 +338,9 @@
column2.appendChild(text);
column2.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, activeChildId);
- boolean childOfPanelMenu = anySuitableParent.getNodeName().endsWith(
- PANEL_MENU_END_TAG);
+ boolean childOfPanelMenu = anySuitableParent != null ? anySuitableParent
+ .getNodeName().endsWith(PANEL_MENU_END_TAG)
+ : false;
/*
* Group Icon Routine
@@ -371,10 +370,10 @@
}
nsIDOMElement imgIcon = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
nsIDOMElement imgSpacer = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
ComponentUtil.setImg(imgSpacer, PANEL_MENU_GROUP_ICON_SPACER_PATH);
setDefaultImgAttributes(imgSpacer);
@@ -474,26 +473,26 @@
tableStyle += SPACE + pmg_style;
}
- iconCell.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, iconCellClass);
+ iconCell.setAttribute(HTML.ATTR_CLASS, iconCellClass);
// iconCell.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, iconCellStyle);
for (nsIDOMElement indentTdCell : indentTds) {
- indentTdCell.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, iconCellClass);
+ indentTdCell.setAttribute(HTML.ATTR_CLASS, iconCellClass);
}
- column2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, labelCellClass);
- emptyCell.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, emptyCellClass);
- div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, divClass);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, tableClass);
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, tableStyle);
+ column2.setAttribute(HTML.ATTR_CLASS, labelCellClass);
+ emptyCell.setAttribute(HTML.ATTR_CLASS, emptyCellClass);
+ div.setAttribute(HTML.ATTR_CLASS, divClass);
+ table.setAttribute(HTML.ATTR_CLASS, tableClass);
+ table.setAttribute(HTML.ATTR_STYLE, tableStyle);
}
private static void setDefaultImgAttributes(nsIDOMElement element) {
- element.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH,
+ element.setAttribute(HTML.ATTR_WIDTH,
DEFAULT_SIZE_VALUE);
element.setAttribute(VSPACE, NO_SIZE_VALUE);
element.setAttribute(HSPACE, NO_SIZE_VALUE);
- element.setAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT,
+ element.setAttribute(HTML.ATTR_HEIGHT,
DEFAULT_SIZE_VALUE);
}
@@ -507,22 +506,26 @@
*/
private static final Element getGroupParent(Element sourceElement,
boolean findOnlyPanelMenuParent) {
- Element parent = (Element) sourceElement.getParentNode();
- while ((parent.getParentNode() != null)
- && (parent.getParentNode().getNodeType() == Node.ELEMENT_NODE)) {
+ Element parent = null;
+ Element currentElement = sourceElement;
+
+ while ((currentElement.getParentNode() != null)
+ && (currentElement.getParentNode().getNodeType() == Node.ELEMENT_NODE)) {
+ currentElement = parent = (Element) parent.getParentNode();
if (findOnlyPanelMenuParent) {
- if ((parent!=null) && parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
+ if ((parent != null)
+ && parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
break;
}
} else {
- if ((parent!=null) && parent.getNodeName().endsWith(PANEL_MENU_END_TAG)
+ if ((parent != null)
+ && parent.getNodeName().endsWith(PANEL_MENU_END_TAG)
|| parent.getNodeName().endsWith(
PANEL_MENU_GROUP_END_TAG)) {
break;
}
}
- parent = (Element) parent.getParentNode();
}
return parent;
}
@@ -533,7 +536,9 @@
String pathIconCollapsed = pmg_iconCollapsed;
String pathIconDisabled = pmg_iconDisabled;
- if (anySuitableParent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
+ if ((anySuitableParent != null)
+ && (anySuitableParent.getNodeName()
+ .endsWith(PANEL_MENU_END_TAG))) {
if (pathIconExpanded == null) {
pathIconExpanded = pm_iconExpandedTopGroup;
}
@@ -553,7 +558,7 @@
} else {
String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(
pathIconDisabled, pageContext, true);
- imgIcon.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
+ imgIcon.setAttribute(HTML.ATTR_SRC,
imgFullPath);
}
} else {
@@ -569,7 +574,7 @@
} else {
String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(
pathIconExpanded, pageContext, true);
- imgIcon.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
+ imgIcon.setAttribute(HTML.ATTR_SRC,
imgFullPath);
}
} else {
@@ -584,7 +589,7 @@
} else {
String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(
pathIconCollapsed, pageContext, true);
- imgIcon.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
+ imgIcon.setAttribute(HTML.ATTR_SRC,
imgFullPath);
}
} else {
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-11-20 03:27:10 UTC (rev 11897)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-11-20 11:27:58 UTC (rev 11898)
@@ -14,13 +14,12 @@
import java.util.List;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
-import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
-import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.ResourceUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -125,7 +124,7 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
nsIDOMElement creationDataDiv = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ .createElement(HTML.TAG_DIV);
VpeCreationData creationData = new VpeCreationData(creationDataDiv);
Element itemSourceElement = (Element) sourceNode;
Element srcElement = null;
@@ -149,31 +148,33 @@
readPanelMenuAttributes(panelMenuParent);
readPanelMenuItemAttributes(itemSourceElement);
- creationDataDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, DR_TOP_DIV);
- creationDataDiv.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0"); //$NON-NLS-1$
- creationDataDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, MARGIN_TOP);
+ creationDataDiv.setAttribute(HTML.ATTR_CLASS, DR_TOP_DIV);
+ creationDataDiv.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
+ creationDataDiv.setAttribute(HTML.ATTR_STYLE, MARGIN_TOP);
- boolean childOfPanelMenu = anySuitableParent.getNodeName().endsWith(
- PANEL_MENU_END_TAG);
- boolean childOfPanelMenuGroup = anySuitableParent.getNodeName().endsWith(
- PANEL_MENU_GROUP_END_TAG);
+ boolean childOfPanelMenu = anySuitableParent != null ? anySuitableParent
+ .getNodeName().endsWith(PANEL_MENU_END_TAG)
+ : false;
+ boolean childOfPanelMenuGroup = anySuitableParent != null ? anySuitableParent
+ .getNodeName().endsWith(PANEL_MENU_GROUP_END_TAG)
+ : false;
if (childOfPanelMenu || childOfPanelMenuGroup) {
creationDataDiv.setAttribute("vpeSupport", COMPONENT_NAME); //$NON-NLS-1$
nsIDOMElement table = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ .createElement(HTML.TAG_TABLE);
creationDataDiv.appendChild(table);
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
+ table.setAttribute(HTML.ATTR_CELLPADDING,
NO_SIZE_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
+ table.setAttribute(HTML.ATTR_CELLSPACING,
NO_SIZE_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
+ table.setAttribute(HTML.ATTR_BORDER,
NO_SIZE_VALUE);
nsIDOMElement tr = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ .createElement(HTML.TAG_TR);
table.appendChild(tr);
/*
@@ -189,15 +190,15 @@
continue;
}
nsIDOMElement spacerTd = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
nsIDOMElement spacerImg = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
spacerTd.appendChild(spacerImg);
ComponentUtil.setImg(spacerImg, IMG_SPACER_SRC);
setDefaultImgAttributes(spacerImg);
- spacerTd.setAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT,
+ spacerTd.setAttribute(HTML.ATTR_HEIGHT,
DEFAULT_SIZE_VALUE);
- spacerTd.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH,
+ spacerTd.setAttribute(HTML.ATTR_WIDTH,
DEFAULT_SIZE_VALUE);
tr.appendChild(spacerTd);
}
@@ -205,12 +206,12 @@
nsIDOMElement tdNowrapLeft = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
tr.appendChild(tdNowrapLeft);
nsIDOMElement tdLabel = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
tr.appendChild(tdLabel);
/*
@@ -251,23 +252,23 @@
tdLabel.appendChild(text);
nsIDOMElement tdRight = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ .createElement(HTML.TAG_TD);
tr.appendChild(tdRight);
nsIDOMElement imgIcon = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
setDefaultImgAttributes(imgIcon);
setIcon(childOfPanelMenu, pageContext, imgIcon);
nsIDOMElement imgSpacer1 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
setDefaultImgAttributes(imgSpacer1);
ComponentUtil.setImg(imgSpacer1, IMG_SPACER_SRC);
tdNowrapLeft.appendChild(imgSpacer1);
nsIDOMElement imgSpacer = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ .createElement(HTML.TAG_IMG);
setDefaultImgAttributes(imgSpacer);
ComponentUtil.setImg(imgSpacer, IMG_SPACER_SRC);
@@ -302,7 +303,7 @@
List<Node> children = ComponentUtil.getChildren(itemSourceElement);
nsIDOMElement childSpan = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ .createElement(HTML.TAG_SPAN);
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(childSpan);
if (!children.isEmpty()) {
@@ -333,9 +334,9 @@
private static void setDefaultImgAttributes(nsIDOMElement element) {
element.setAttribute(VSPACE, NO_SIZE_VALUE);
element.setAttribute(HSPACE, NO_SIZE_VALUE);
- element.setAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT,
+ element.setAttribute(HTML.ATTR_HEIGHT,
DEFAULT_SIZE_VALUE);
- element.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH,
+ element.setAttribute(HTML.ATTR_WIDTH,
DEFAULT_SIZE_VALUE);
}
@@ -411,7 +412,7 @@
ComponentUtil.setImg(img, imgPath[1]);
} else {
String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(imgPath[0], pageContext, true);
- img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, imgFullPath);
+ img.setAttribute(HTML.ATTR_SRC, imgFullPath);
}
}
}
@@ -520,17 +521,17 @@
}
}
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, tableStyle);
- iconCell.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, iconCellStyle);
- labelCell.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, labelCellStyle);
- emptyCell.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, emptyCellStyle);
+ table.setAttribute(HTML.ATTR_STYLE, tableStyle);
+ iconCell.setAttribute(HTML.ATTR_STYLE, iconCellStyle);
+ labelCell.setAttribute(HTML.ATTR_STYLE, labelCellStyle);
+ emptyCell.setAttribute(HTML.ATTR_STYLE, emptyCellStyle);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, tableClass);
- tr.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, trClass);
- iconCell.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, iconCellClass);
- imgIcon.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, imgIconClass);
- labelCell.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, labelCellClass);
- emptyCell.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, emptyCellClass);
+ table.setAttribute(HTML.ATTR_CLASS, tableClass);
+ tr.setAttribute(HTML.ATTR_CLASS, trClass);
+ iconCell.setAttribute(HTML.ATTR_CLASS, iconCellClass);
+ imgIcon.setAttribute(HTML.ATTR_CLASS, imgIconClass);
+ labelCell.setAttribute(HTML.ATTR_CLASS, labelCellClass);
+ emptyCell.setAttribute(HTML.ATTR_CLASS, emptyCellClass);
}
/**
@@ -539,13 +540,18 @@
* @param sourceItemElement the source item element
* @param findOnlyPanelMenuParent flag to find only panel menu parent
*
- * @return the item parent
+ * @return the item parent, can return null
*/
private static final Element getItemParent(Element sourceItemElement,
boolean findOnlyPanelMenuParent) {
- Element parent = (Element) sourceItemElement.getParentNode();
- while ((parent.getParentNode() != null)
- && (parent.getParentNode().getNodeType() == Node.ELEMENT_NODE)) {
+ Element parent = null;
+ Element currentElement = sourceItemElement;
+
+ while ((currentElement.getParentNode() != null)
+ && (currentElement.getParentNode().getNodeType() == Node.ELEMENT_NODE)) {
+
+ currentElement = parent = (Element) parent.getParentNode();
+
if (findOnlyPanelMenuParent) {
if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
break;
@@ -557,7 +563,7 @@
break;
}
}
- parent = (Element) parent.getParentNode();
+
}
return parent;
}
17 years, 5 months
JBoss Tools SVN: r11897 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui: src/org/jboss/tools/smooks/analyzer and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-11-19 22:27:10 -0500 (Wed, 19 Nov 2008)
New Revision: 11897
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/messages.properties
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DateTypeDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
Log:
JBIDE-3208
1.Modify the Javabean data creation wizard GUI
2.Modify the XML2Java generate/parse analyzer
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2008-11-20 03:27:10 UTC (rev 11897)
@@ -22,8 +22,8 @@
org.eclipse.emf.edit.ui,
org.eclipse.xsd.edit,
org.jboss.tools.smooks.core,
- org.jboss.tools.common.model.ui,
- org.eclipse.wst.xml.ui;bundle-version="1.0.401"
+ org.eclipse.wst.xml.ui,
+ org.eclipse.wst.sse.ui;bundle-version="1.1.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .,
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AbstractAnalyzer.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -72,12 +72,14 @@
protected void setSelectorIsUsed(String selector) {
+ if(selector != null) selector = selector.trim();
userdResourceTypeMap.put(selector, new Object());
}
- protected boolean isSelectorIsUsed(String resourceType) {
- return (userdResourceTypeMap.get(resourceType) != null);
+ protected boolean isSelectorIsUsed(String selector) {
+ if(selector != null) selector = selector.trim();
+ return (userdResourceTypeMap.get(selector) != null);
}
protected void addResourceConfigType(SmooksResourceListType resourceList,
@@ -126,6 +128,7 @@
protected ResourceConfigType findResourceConfigTypeWithSelector(
String selector, SmooksResourceListType listType) {
+ if(selector != null) selector = selector.trim();
if (isReferenceSelector(selector)) {
selector = this.getBeanIdWithRawSelectorString(selector);
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -125,6 +125,8 @@
}
protected void setSelectorIsUsed(String selector) {
+ if (selector == null)
+ return;
userdResourceTypeMap.put(selector, new Object());
}
@@ -137,6 +139,8 @@
}
protected boolean isSelectorIsUsed(String resourceType) {
+ if (resourceType == null)
+ return false;
return (userdResourceTypeMap.get(resourceType) != null);
}
@@ -494,7 +498,7 @@
sourceName = sourceClazz.getName();
}
String selector = rc.getSelector();
- if(selector != null){
+ if (selector != null) {
selector = selector.trim();
}
if (sourceName.equals(selector)) {
@@ -546,12 +550,12 @@
AnyType binding = (AnyType) iterator.next();
String property = SmooksModelUtils.getAttributeValueFromAnyType(
binding, SmooksModelUtils.ATTRIBUTE_PROPERTY);
- if(property != null){
+ if (property != null) {
property = property.trim();
}
String selector = SmooksModelUtils.getAttributeValueFromAnyType(
binding, SmooksModelUtils.ATTRIBUTE_SELECTOR);
- if(selector != null){
+ if (selector != null) {
selector = selector.trim();
}
JavaBeanModel childTargetModel = findTheChildJavaBeanModel(
@@ -788,45 +792,83 @@
}
}
}
+ List<JavaBeanModel> list = new ArrayList<JavaBeanModel>();
if (current == null) {
- rootClassName = this.getDataSourceClass(graphInfo, TARGET_DATA);
+ // rootClassName = this.getDataSourceClass(graphInfo, TARGET_DATA);
+ // TODO if there isn't any BeanPopulater throws exception
+ // MODIFY by Dart 2008.11.17
+ String classString = getDataSourceClass(graphInfo, TARGET_DATA);
+ if (classString != null && loader != null) {
+ try {
+ String[] classes = classString.split(";");
+ if (classes != null) {
+ for (int i = 0; i < classes.length; i++) {
+ String clazzName = classes[i];
+ list.add(JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(loader
+ .loadClass(clazzName)));
+ }
+ return list;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ throw new RuntimeException(
+ "Can't load Java bean model form the config file.");
}
// if can't load the source from GraphicalInformation , return NULL
if (current == null && rootClassName == null)
- return null;
- Class rootClass = null;
- if (rootClassName == null) {
+ return list;
+ int startIndex = resourceConfigList.indexOf(current);
+ for (int i = startIndex; i < resourceConfigList.size(); i++) {
+ ResourceConfigType resourceConfig = (ResourceConfigType) resourceConfigList
+ .get(i);
+ ResourceType resourceType = resourceConfig.getResource();
+ String selector = resourceConfig.getSelector();
+ if (selector != null)
+ selector = selector.trim();
+ if (isSelectorIsUsed(selector))
+ continue;
+ if (resourceType == null)
+ continue;
+ String resource = resourceType.getValue();
+ if (resource != null)
+ resource = resource.trim();
+ if (!BEANPOPULATOR.equals(resource)) {
+ continue;
+ }
+ Class rootClass = null;
rootClassName = SmooksModelUtils.getParmaText(
- SmooksModelUtils.BEAN_CLASS, current);
- }
- if (rootClassName != null && loader != null) {
- try {
- rootClass = loader.loadClass(rootClassName);
- } catch (ClassNotFoundException e) {
- // TODO if can't find the class throws exception
- // MODIFY by Dart 2008.11.12
- throw new RuntimeException("Can't find the class : \""
- + rootClassName + "\" to create the JavaBean model");
+ SmooksModelUtils.BEAN_CLASS, resourceConfig);
+ if (rootClassName != null && loader != null) {
+ try {
+ rootClass = loader.loadClass(rootClassName);
+ } catch (ClassNotFoundException e) {
+ // TODO if can't find the class throws exception
+ // MODIFY by Dart 2008.11.12
+ throw new RuntimeException("Can't find the class : \""
+ + rootClassName + "\" to create the JavaBean model");
+ }
}
+ boolean rootIsError = false;
+ JavaBeanModel rootModel = null;
+ if (rootClass != null) {
+ rootModel = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(rootClass);
+ } else {
+ rootModel = new JavaBeanModel(null, rootClassName);
+ rootIsError = true;
+ }
+ if (resourceConfig != null) {
+ rootModel.setBeanClassString(SmooksModelUtils.getParmaText(
+ SmooksModelUtils.BEAN_CLASS, resourceConfig));
+ setSelectorIsUsed(selector);
+ buildChildrenOfTargetInputModel(listType, rootModel, false,
+ rootIsError, resourceConfig, loader);
+ list.add(rootModel);
+ }
}
- boolean rootIsError = false;
- JavaBeanModel rootModel = null;
- if (rootClass != null) {
- rootModel = JavaBeanModelFactory
- .getJavaBeanModelWithLazyLoad(rootClass);
- } else {
- rootModel = new JavaBeanModel(null, rootClassName);
- rootIsError = true;
- }
- if (current != null) {
- rootModel.setBeanClassString(SmooksModelUtils.getParmaText(
- SmooksModelUtils.BEAN_CLASS, current));
- setSelectorIsUsed(rootClassName);
- buildChildrenOfTargetInputModel(listType, rootModel, false,
- rootIsError, current, loader);
- }
- List<JavaBeanModel> list = new ArrayList<JavaBeanModel>();
- list.add(rootModel);
return list;
}
@@ -848,8 +890,11 @@
String selector = SmooksModelUtils
.getAttributeValueFromAnyType(binding,
SmooksModelUtils.ATTRIBUTE_SELECTOR);
- processBindingPropertyFromTargetModel(listType, property,
- selector, beanModel, classLoader);
+ if (selector != null)
+ selector = selector.trim();
+ if (!isSelectorIsUsed(selector))
+ processBindingPropertyFromTargetModel(listType, property,
+ selector, beanModel, classLoader);
}
}
@@ -870,7 +915,8 @@
parentModel.addProperty(model);
model.setError(Messages.getString("JavaBeanAnalyzer.DontExist")); //$NON-NLS-1$
}
-
+ if (isSelectorIsUsed(selector))
+ return;
if (isReferenceSelector(selector)) {
selector = selector.substring(2, selector.length() - 1);
ResourceConfigType resourceConfig = findResourceConfigTypeWithSelector(
@@ -880,6 +926,11 @@
"Can't find some ResourceConfig element in the config file.Maybe some ResourceConfig element miss <param name = \"beanId\">"
+ selector + "</param>");
}
+ String resourceConfigSelector = resourceConfig.getSelector();
+ if (resourceConfigSelector != null) {
+ resourceConfigSelector = resourceConfigSelector.trim();
+ setSelectorIsUsed(resourceConfigSelector);
+ }
String beanClassText = SmooksModelUtils.getParmaText(
SmooksModelUtils.BEAN_CLASS, resourceConfig);
model.setBeanClassString(beanClassText);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModelFactory.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -22,7 +22,6 @@
*/
public class JavaBeanModelFactory {
-
private static final List PRIMITIVE_CLASSES = new ArrayList();
static{
PRIMITIVE_CLASSES.add(Integer.class);
@@ -34,7 +33,9 @@
PRIMITIVE_CLASSES.add(Character.class);
PRIMITIVE_CLASSES.add(BigInteger.class);
PRIMITIVE_CLASSES.add(BigDecimal.class);
+ PRIMITIVE_CLASSES.add(Boolean.class);
PRIMITIVE_CLASSES.add(Byte.class);
+ PRIMITIVE_CLASSES.add(java.util.Calendar.class);
}
/**
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanConfigWizardPage.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -10,10 +10,11 @@
******************************************************************************/
package org.jboss.tools.smooks.javabean.ui;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.IWizardNode;
-import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -41,9 +42,10 @@
private JavaBeanModelLoadComposite javaPropertySelectComposite;
- public JavaBeanModel getJavaBeanModel(){
- if(javaPropertySelectComposite == null) return null;
- return javaPropertySelectComposite.getCheckedJavaBeanModel();
+
+ public List<JavaBeanModel> getJavaBeanModelList() {
+ if(javaPropertySelectComposite == null) return Collections.EMPTY_LIST;
+ return javaPropertySelectComposite.getJavabeanList();
}
public JavaBeanConfigWizardPage(IJavaProject selection) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelCreationDialog.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -55,9 +55,7 @@
*/
@Override
protected void okPressed() {
- returnModel = jc.getCheckedJavaBeanModel();
super.okPressed();
-// returnModel = jc.getCheckedJavaBeanModel();
}
/*
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -11,7 +11,6 @@
package org.jboss.tools.smooks.javabean.ui;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.jdt.core.IJavaProject;
@@ -22,13 +21,18 @@
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -51,6 +55,7 @@
public class JavaBeanModelLoadComposite extends Composite implements
SelectionListener {
+ private List<JavaBeanModel> javabeanList = new ArrayList<JavaBeanModel>();
protected Text classText;
private Button classBrowseButton;
protected String classFullName;
@@ -61,6 +66,7 @@
protected JavaBeanModel returnJavaBeanModel = null;
protected ProjectClassLoader loader = null;
+ private TableViewer listViewer;
public JavaBeanModelLoadComposite(Composite parent, int style,
IRunnableContext runnableContext, IJavaProject project,
@@ -74,7 +80,9 @@
// this.runnableContext = new
// ProgressMonitorDialog(parent.getShell());
if (this.runnableContext == null)
- throw new Exception(Messages.getString("JavaBeanModelLoadComposite.InitRunnableContextException")); //$NON-NLS-1$
+ throw new Exception(
+ Messages
+ .getString("JavaBeanModelLoadComposite.InitRunnableContextException")); //$NON-NLS-1$
}
if (project != null) {
@@ -91,6 +99,14 @@
this(parent, style, runnableContext, project, true);
}
+ public List<JavaBeanModel> getJavabeanList() {
+ return javabeanList;
+ }
+
+ public void setJavabeanList(List<JavaBeanModel> javabeanList) {
+ this.javabeanList = javabeanList;
+ }
+
protected Control createCompositeContent() {
Composite parent = this;
parent.setLayout(new FillLayout());
@@ -100,86 +116,129 @@
com.setLayout(layout);
Label classLabel = new Label(com, SWT.NULL);
- classLabel.setText(Messages.getString("JavaBeanModelLoadComposite.ClassNameText")); //$NON-NLS-1$
-
- Composite classTextContainer = new Composite(com, SWT.NONE);
+ classLabel.setText(Messages
+ .getString("JavaBeanModelLoadComposite.ClassNameText")); //$NON-NLS-1$
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- classTextContainer.setLayoutData(gd);
+ gd.horizontalSpan = 2;
+ classLabel.setLayoutData(gd);
+ // Composite classTextContainer = new Composite(com, SWT.NONE);
+ // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ // gd.grabExcessHorizontalSpace = true;
+ // classTextContainer.setLayoutData(gd);
+ //
+ // GridLayout gl = new GridLayout();
+ // gl.numColumns = 2;
+ // classTextContainer.setLayout(gl);
+ //
+ // {
+ // classText = new Text(classTextContainer, SWT.BORDER);
+ // gd = new GridData(GridData.FILL_HORIZONTAL);
+ // gd.grabExcessHorizontalSpace = true;
+ // classText.setLayoutData(gd);
+ // classText.addModifyListener(new ModifyListener() {
+ // public void modifyText(ModifyEvent arg0) {
+ // classFullName = classText.getText();
+ // }
+ // });
+ //
+ // classBrowseButton = new Button(classTextContainer, SWT.NONE);
+ // classBrowseButton.addSelectionListener(this);
+ // classBrowseButton.setText(Messages.getString("JavaBeanModelLoadComposite.Browse")); //$NON-NLS-1$
+ // }
- GridLayout gl = new GridLayout();
- gl.numColumns = 2;
- classTextContainer.setLayout(gl);
+ Composite listViewerComposite = new Composite(com, SWT.NONE);
+ GridLayout listLayout = new GridLayout();
+ listLayout.numColumns = 2;
+ listViewerComposite.setLayout(listLayout);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ listViewerComposite.setLayoutData(gd);
- {
- classText = new Text(classTextContainer, SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- classText.setLayoutData(gd);
- classText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent arg0) {
- classFullName = classText.getText();
+ listViewer = new TableViewer(listViewerComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ listViewer.getControl().setLayoutData(gd);
+ listViewer.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List) inputElement).toArray();
}
- });
+ return new Object[] {};
+ }
- classBrowseButton = new Button(classTextContainer, SWT.NONE);
- classBrowseButton.addSelectionListener(this);
- classBrowseButton.setText(Messages.getString("JavaBeanModelLoadComposite.Browse")); //$NON-NLS-1$
- }
- return com;
- }
+ public void dispose() {
- protected void recordModel() {
- // this.currentRootJavaBeanModel.setProperties(null);
- // this.fillCheckStateModel(this.currentRootJavaBeanModel);
- }
+ }
- protected void fillTheModelWithCheckStatus(JavaBeanModel javaBeanModel,
- CheckboxTreeViewer viewer) {
- ArrayList clist = new ArrayList();
- if (javaBeanModel.propertiesHasBeenLoaded()) {
- List children = javaBeanModel.getProperties();
- for (Iterator iterator = children.iterator(); iterator.hasNext();) {
- JavaBeanModel child = (JavaBeanModel) iterator.next();
- boolean checked = viewer.getChecked(child);
- if (checked) {
- clist.add(child);
- fillTheModelWithCheckStatus(child, viewer);
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+
+ }
+
+ });
+ listViewer.setLabelProvider(new LabelProvider() {
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof JavaBeanModel) {
+ return SmooksUIActivator.getDefault().getImageRegistry().get(
+ JavaImageConstants.IMAGE_JAVA_OBJECT);
}
+ return super.getImage(element);
}
- }
- javaBeanModel.setProperties(clist);
- }
- /**
- *
- * @return
- */
- public JavaBeanModel getCheckedJavaBeanModel() {
- return this.fillCheckStateModel(currentRootJavaBeanModel);
+ @Override
+ public String getText(Object element) {
+ if (element instanceof JavaBeanModel) {
+ return ((JavaBeanModel) element).getBeanClassString();
+ }
+ return super.getText(element);
+ }
+
+ });
+ listViewer.setInput(javabeanList);
+
+ Composite buttonArea = new Composite(listViewerComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonArea.setLayoutData(gd);
+
+ GridLayout buttonAreaLayout = new GridLayout();
+ buttonArea.setLayout(buttonAreaLayout);
+
+ Button addButton = new Button(buttonArea, SWT.BORDER);
+ addButton.setText("Add");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ addButton.setLayoutData(gd);
+ addButton.addSelectionListener(this);
+
+ Button removeButton = new Button(buttonArea, SWT.BORDER);
+ removeButton.setText("Remove");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ removeButton.setLayoutData(gd);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection selection = (IStructuredSelection) listViewer
+ .getSelection();
+ if (selection.isEmpty())
+ return;
+ javabeanList.removeAll(selection.toList());
+ listViewer.refresh();
+ }
+
+ });
+ return com;
}
- /**
- *
- * @return
- */
- public JavaBeanModel fillCheckStateModel(JavaBeanModel rootJavaBean) {
- if (rootJavaBean == null) {
- // List list = (List) treeViewer.getInput();
- // if (list != null)
- // rootJavaBean = (JavaBeanModel) list.get(0);
+ public ProjectClassLoader getProjectClassLoader() {
+ if (loader == null) {
try {
- ProjectClassLoader loader = new ProjectClassLoader(javaProject);
- Class clazz = loader.loadClass(classFullName);
- rootJavaBean = JavaBeanModelFactory
- .getJavaBeanModelWithLazyLoad(clazz);
+ loader = new ProjectClassLoader(javaProject);
} catch (Exception e) {
- // ignore
}
}
- // if (rootJavaBean != null)
- // this.fillTheModelWithCheckStatus(rootJavaBean, treeViewer);
- return rootJavaBean;
+ return loader;
}
public void widgetDefaultSelected(SelectionEvent arg0) {
@@ -194,8 +253,10 @@
try {
dialog = JavaUI.createTypeDialog(this.getShell(), runnableContext,
scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false);
- dialog.setMessage(Messages.getString("JavaBeanModelLoadComposite.SourceJavaBean")); //$NON-NLS-1$
- dialog.setTitle(Messages.getString("JavaBeanModelLoadComposite.SearchJavaType")); //$NON-NLS-1$
+ dialog.setMessage(Messages
+ .getString("JavaBeanModelLoadComposite.SourceJavaBean")); //$NON-NLS-1$
+ dialog.setTitle(Messages
+ .getString("JavaBeanModelLoadComposite.SearchJavaType")); //$NON-NLS-1$
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
@@ -203,13 +264,27 @@
Object result = results[0];
String packageFullName = JavaModelUtil
.getTypeContainerName((IType) result);
+ String className = null;
if (packageFullName == null
|| packageFullName.length() <= 0) {
- classText.setText(((IType) result).getElementName());
+ className = ((IType) result).getElementName();
} else {
- classText.setText(packageFullName + "." //$NON-NLS-1$
- + ((IType) result).getElementName());
+ className = packageFullName + "." //$NON-NLS-1$
+ + ((IType) result).getElementName();
}
+ if (className != null) {
+ ClassLoader l = this.getProjectClassLoader();
+ if (l != null) {
+ Class clazz = l.loadClass(className);
+ if (clazz != null) {
+ JavaBeanModel model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(clazz);
+ javabeanList.add(model);
+ listViewer.refresh();
+ }
+ }
+
+ }
}
}
} catch (Exception e) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.smooks.javabean.ui;
-import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -63,15 +63,14 @@
*/
@Override
public boolean performFinish() {
- result = page.getJavaBeanModel();
+ result = page.getJavaBeanModelList();
return true;
}
public Object getTreeViewerInputContents() {
- if(result == null) return null;
- List<Object> list = new ArrayList<Object>();
- list.add(result);
- return list;
+ if (result == null)
+ return null;
+ return result;
}
public void init(IEditorSite site, IEditorInput input) {
@@ -117,12 +116,16 @@
}
public String getStructuredDataSourcePath() {
- JavaBeanModel model = page.getJavaBeanModel();
- if (model != null) {
- Class clazz = model.getBeanClass();
- if (clazz != null)
- return clazz.getName();
+ List<JavaBeanModel> list = page.getJavaBeanModelList();
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator<JavaBeanModel> iterator = list.iterator(); iterator
+ .hasNext(); buffer.append(";")) {
+ JavaBeanModel javaBeanModel = (JavaBeanModel) iterator.next();
+ Class clazz = javaBeanModel.getBeanClass();
+ if (clazz != null) {
+ buffer.append(clazz.getName());
+ }
}
- return null;
+ return buffer.toString();
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/messages.properties
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/messages.properties 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/messages.properties 2008-11-20 03:27:10 UTC (rev 11897)
@@ -2,7 +2,7 @@
JavaBeanConfigWizardPage.JavaBeanSelectionDialogErrorMsg=Please select a Java project.
JavaBeanConfigWizardPage.JavaBeanSelectionDialogTitle=JavaBean Class selection page
JavaBeanModelLoadComposite.Browse=Browse...
-JavaBeanModelLoadComposite.ClassNameText=Class Name:
+JavaBeanModelLoadComposite.ClassNameText=JavaBean Model List \:
JavaBeanModelLoadComposite.InitRunnableContextException=Can't init IRunnableContext
JavaBeanModelLoadComposite.SearchJavaType=Search Java Type
JavaBeanModelLoadComposite.SourceJavaBean=Source Java Bean:
@@ -12,8 +12,8 @@
JavaBeanPropertiesSection.ErrorMessageTitle=Error
JavaBeanPropertiesSection.JavaBeanProperties=JavaBean Properties
JavaBeanPropertiesSection.JavaType=Java Type:
-JavaBeanPropertiesSection.MappingType=Mapping Type :
+JavaBeanPropertiesSection.MappingType=Mapping Type \:
JavaBeanPropertiesSection.SearchJavaType=Search Java Type
-JavaBeanPropertiesSection.TargetInstanceClass=Target instance class name :
+JavaBeanPropertiesSection.TargetInstanceClass=Target instance class name \:
JavaBeanPropertiesSection.TypeDialogErrorMessage=can't open type selection dialog
JavaBeanPropertiesSection.TypePropertyName=type
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DateTypeDetailPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DateTypeDetailPage.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DateTypeDetailPage.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -27,6 +27,7 @@
*/
public class DateTypeDetailPage extends AbstractSmooksModelDetailPage {
+ private static final String DECODER = "decoder";
private Text formatText;
private Combo localeLangaugeCombo;
private Combo localeContryCombo;
@@ -134,7 +135,7 @@
this.parentEditor.fireEditorDirty(true);
return;
}
- text = "decorat:"+text;
+ text = DECODER+ ":" + text;
if(this.resourceConfigList != null){
resourceConfigList.setSelector(text);
this.parentEditor.fireEditorDirty(true);
@@ -153,7 +154,7 @@
protected void initSectionUI() {
if(this.resourceConfigList != null){
String formate = SmooksModelUtils.getParmaText("format", resourceConfigList); //$NON-NLS-1$
- String locallang = SmooksModelUtils.getParmaText("Locale-Language", resourceConfigList); //$NON-NLS-1$
+ String locallang = SmooksModelUtils.getParmaText("locale-language", resourceConfigList); //$NON-NLS-1$
String localcontry = SmooksModelUtils.getParmaText("locale-country", resourceConfigList); //$NON-NLS-1$
if(formate == null) formate = ""; //$NON-NLS-1$
if(locallang == null) locallang = ""; //$NON-NLS-1$
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -50,6 +50,7 @@
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
@@ -59,6 +60,7 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -126,6 +128,7 @@
import org.jboss.tools.smooks.ui.IViewerInitor;
import org.jboss.tools.smooks.ui.SmooksUIActivator;
import org.jboss.tools.smooks.ui.StructuredDataCreationWizardDailog;
+import org.jboss.tools.smooks.ui.ViewerInitorStore;
import org.jboss.tools.smooks.ui.gef.editparts.SmooksEditPartFactory;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
import org.jboss.tools.smooks.ui.gef.model.GraphRootModel;
@@ -150,6 +153,8 @@
ISelectionChangedListener, ISelectionProvider,
org.eclipse.emf.common.command.CommandStackListener, ISaveListener {
+ private final String[] REQUIRED_SOURCE_SELECT_TYPE = new String[] { "org.jboss.tools.smooks.xml.viewerInitor.xml" };
+
private List<IAnalyzeListener> analyzeListenerList = new ArrayList<IAnalyzeListener>();
protected boolean disableMappingGUI = false;
@@ -301,11 +306,16 @@
gridLayout.horizontalSpacing = 0;
form.getBody().setLayout(gridLayout);
Composite rootMainControl = form.getBody();
- form.setText(Messages.getString("SmooksGraphicalFormPage.MappingPageFormTitle")); //$NON-NLS-1$
- mappingGUISection = this.createPageSectionHeader(rootMainControl,
- Section.TITLE_BAR | Section.DESCRIPTION,
- Messages.getString("SmooksGraphicalFormPage.MappingSectionTitle"), //$NON-NLS-1$
- Messages.getString("SmooksGraphicalFormPage.MappingSectionDescription")); //$NON-NLS-1$
+ form.setText(Messages
+ .getString("SmooksGraphicalFormPage.MappingPageFormTitle")); //$NON-NLS-1$
+ mappingGUISection = this
+ .createPageSectionHeader(
+ rootMainControl,
+ Section.TITLE_BAR | Section.DESCRIPTION,
+ Messages
+ .getString("SmooksGraphicalFormPage.MappingSectionTitle"), //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.MappingSectionDescription")); //$NON-NLS-1$
Composite mainComposite = toolkit.createComposite(mappingGUISection);
mappingGUISection.setClient(mainComposite);
@@ -400,8 +410,11 @@
underToolPanel.setLayout(underLayout);
underToolPanel.setLayoutData(sgd1);
{
- sourceLink = toolkit.createHyperlink(underToolPanel,
- Messages.getString("SmooksGraphicalFormPage.SourceSelectLinkText"), SWT.NONE); //$NON-NLS-1$
+ sourceLink = toolkit
+ .createHyperlink(
+ underToolPanel,
+ Messages
+ .getString("SmooksGraphicalFormPage.SourceSelectLinkText"), SWT.NONE); //$NON-NLS-1$
sourceLink.addHyperlinkListener(new DataSelectLinkListener(
sourceViewer));
}
@@ -418,8 +431,11 @@
composite1.setLayout(composite1Layout);
}
{
- targetLink = toolkit.createHyperlink(underToolPanel,
- Messages.getString("SmooksGraphicalFormPage.TargetSelectLinkText"), SWT.NONE); //$NON-NLS-1$
+ targetLink = toolkit
+ .createHyperlink(
+ underToolPanel,
+ Messages
+ .getString("SmooksGraphicalFormPage.TargetSelectLinkText"), SWT.NONE); //$NON-NLS-1$
GridData label2LData = new GridData();
label2LData.horizontalAlignment = GridData.END;
targetLink.setLayoutData(label2LData);
@@ -468,7 +484,7 @@
this.getSmooksResource().unload();
this.initTransformViewerModel((IEditorSite) getSite(),
getEditorInput());
- } catch (Throwable e) {
+ } catch (Throwable e) {
throwable = e;
}
if (throwable == null) {
@@ -602,7 +618,8 @@
protected void createSourceGraphModels() {
clearExsitingGraphModels(SourceModel.class);
- if(sourceViewer == null) return;
+ if (sourceViewer == null)
+ return;
Tree tree = sourceViewer.getTree();
TreeItem[] items = tree.getItems();
createGraphModels(items, SourceModel.class);
@@ -658,7 +675,8 @@
protected void createTargetGraphModels() {
clearExsitingGraphModels(TargetModel.class);
- if(targetViewer == null) return;
+ if (targetViewer == null)
+ return;
Tree tree = targetViewer.getTree();
TreeItem[] items = tree.getItems();
createGraphModels(items, TargetModel.class);
@@ -713,9 +731,12 @@
boolean cleanError = MessageDialog
.openQuestion(
getSite().getShell(),
- Messages.getString("SmooksGraphicalFormPage.CleanErrorsDialogTitle"), //$NON-NLS-1$
- Messages.getString("SmooksGraphicalFormPage.CleanErrorsDialogContents1") //$NON-NLS-1$
- + Messages.getString("SmooksGraphicalFormPage.CleanErrorsDialogContents2")); //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.CleanErrorsDialogTitle"), //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.CleanErrorsDialogContents1") //$NON-NLS-1$
+ + Messages
+ .getString("SmooksGraphicalFormPage.CleanErrorsDialogContents2")); //$NON-NLS-1$
if (cleanError)
return;
}
@@ -746,9 +767,14 @@
exp = e;
}
if (exp != null) {
- ErrorDialog.openError(getSite().getShell(), Messages.getString("SmooksGraphicalFormPage.SaveErrorDlgTitle"), //$NON-NLS-1$
- Messages.getString("SmooksGraphicalFormPage.SaveErrorDlgContent"), UIUtils //$NON-NLS-1$
- .createErrorStatus(exp));
+ ErrorDialog
+ .openError(
+ getSite().getShell(),
+ Messages
+ .getString("SmooksGraphicalFormPage.SaveErrorDlgTitle"), //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.SaveErrorDlgContent"), UIUtils //$NON-NLS-1$
+ .createErrorStatus(exp));
}
super.doSave(monitor);
commandStackChanged = false;
@@ -859,7 +885,8 @@
*
*/
protected void createConnectionModels() {
- if(rootModel == null) return;
+ if (rootModel == null)
+ return;
List children = this.rootModel.getChildren();
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
TreeItemRelationModel source = (TreeItemRelationModel) iterator
@@ -996,16 +1023,19 @@
if (dialog.open() == org.eclipse.jface.dialogs.Dialog.OK) {
sourceDataTypeID = wizard.getSourceDataTypeID();
targetDataTypeID = wizard.getTargetDataTypeID();
- sourceTreeViewerInputModel = wizard
- .getSourceTreeViewerInputContents();
- targetTreeViewerInputModel = wizard
- .getTargetTreeViewerInputContents();
- this.getSmooksConfigurationFileGenerateContext()
- .setSourceDataTypeID(sourceDataTypeID);
- this.getSmooksConfigurationFileGenerateContext()
- .setTargetDataTypeID(targetDataTypeID);
+ // sourceTreeViewerInputModel = wizard
+ // .getSourceTreeViewerInputContents();
+ // targetTreeViewerInputModel = wizard
+ // .getTargetTreeViewerInputContents();
+ SmooksConfigurationFileGenerateContext context = getSmooksConfigurationFileGenerateContext();
+ context.setSourceDataTypeID(sourceDataTypeID);
+ context.setTargetDataTypeID(targetDataTypeID);
+ sourceTreeViewerInputModel = selectSourceDataSource(
+ sourceDataTypeID, context);
+ targetTreeViewerInputModel = selectTargetDataSource(
+ targetDataTypeID, context);
graphicalInformationSaver.doSave(new NullProgressMonitor(),
- getSmooksConfigurationFileGenerateContext());
+ context);
}
}
smooksResource = this.getSmooksResource();
@@ -1019,6 +1049,51 @@
}
}
+ private boolean requiredSelectDataSource(String typeID) {
+ for (int i = 0; i < this.REQUIRED_SOURCE_SELECT_TYPE.length; i++) {
+ String s = REQUIRED_SOURCE_SELECT_TYPE[i];
+ if (s.equals(typeID))
+ return true;
+ }
+ return false;
+ }
+
+ private Object selectTargetDataSource(String typeID,
+ SmooksConfigurationFileGenerateContext context) {
+ if (requiredSelectDataSource(typeID)) {
+ IStructuredDataCreationWizard wizard1 = ViewerInitorStore
+ .getInstance().getStructuredDataCreationWizard(
+ typeID);
+ WizardDialog dialog1 = new WizardDialog(getSite().getShell(),
+ wizard1);
+ ((Wizard) wizard1).setWindowTitle("Target Data Selection");
+ if (dialog1.open() == Dialog.OK) {
+ context.getProperties().put("targetDataPath",
+ wizard1.getStructuredDataSourcePath());
+ }
+ return wizard1.getTreeViewerInputContents();
+ }
+ return null;
+ }
+
+ private Object selectSourceDataSource(String typeID,
+ SmooksConfigurationFileGenerateContext context) {
+ if (requiredSelectDataSource(typeID)) {
+ IStructuredDataCreationWizard wizard1 = ViewerInitorStore
+ .getInstance().getStructuredDataCreationWizard(
+ typeID);
+ WizardDialog dialog1 = new WizardDialog(getSite().getShell(),
+ wizard1);
+ ((Wizard) wizard1).setWindowTitle("Source Data Selection");
+ if (dialog1.open() == Dialog.OK) {
+ context.getProperties().put("sourceDataPath",
+ wizard1.getStructuredDataSourcePath());
+ }
+ return wizard1.getTreeViewerInputContents();
+ }
+ return null;
+ }
+
protected void initSmooksContext(GraphInformations graph,
SmooksConfigurationFileGenerateContext context) {
Params params = graph.getParams();
@@ -1134,8 +1209,10 @@
if (!MessageDialog
.openQuestion(
getSite().getShell(),
- Messages.getString("SmooksGraphicalFormPage.ReselectViewerContentDlgTitle"), //$NON-NLS-1$
- Messages.getString("SmooksGraphicalFormPage.ReselectViewerContentDlgContent"))) { //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.ReselectViewerContentDlgTitle"), //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.ReselectViewerContentDlgContent"))) { //$NON-NLS-1$
return;
}
}
@@ -1165,13 +1242,23 @@
commandStackChanged = true;
firePropertyChange(PROP_DIRTY);
} catch (Exception e) {
- MessageDialog.openError(getSite().getShell(), Messages.getString("SmooksGraphicalFormPage.FillViewerErrorTitle"), //$NON-NLS-1$
- Messages.getString("SmooksGraphicalFormPage.FillViewerErrorContent") //$NON-NLS-1$
- + e.toString());
+ MessageDialog
+ .openError(
+ getSite().getShell(),
+ Messages
+ .getString("SmooksGraphicalFormPage.FillViewerErrorTitle"), //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.FillViewerErrorContent") //$NON-NLS-1$
+ + e.toString());
}
} else {
- MessageDialog.openError(getSite().getShell(), Messages.getString("SmooksGraphicalFormPage.FillViewerErrorTitle"), //$NON-NLS-1$
- Messages.getString("SmooksGraphicalFormPage.FillViewerErrorContent")); //$NON-NLS-1$
+ MessageDialog
+ .openError(
+ getSite().getShell(),
+ Messages
+ .getString("SmooksGraphicalFormPage.FillViewerErrorTitle"), //$NON-NLS-1$
+ Messages
+ .getString("SmooksGraphicalFormPage.FillViewerErrorContent")); //$NON-NLS-1$
}
}
}
@@ -1333,7 +1420,8 @@
// System.out.println("Block a event fire !!");
return;
}
- rootModel.firePropertyChange(AbstractStructuredDataModel.P_REFRESH_PANEL, null,
+ rootModel.firePropertyChange(
+ AbstractStructuredDataModel.P_REFRESH_PANEL, null,
new Object());
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -20,7 +20,6 @@
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jst.jsp.core.internal.modelhandler.TagModelLoader;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Shell;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-11-20 03:24:35 UTC (rev 11896)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-11-20 03:27:10 UTC (rev 11897)
@@ -10,16 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.xml2java.analyzer;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import javax.swing.text.html.HTMLDocument.HTMLReader.TagAction;
-
-import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
@@ -50,6 +43,7 @@
import org.jboss.tools.smooks.xml.model.DocumentObject;
import org.jboss.tools.smooks.xml.model.TagObject;
import org.jboss.tools.smooks.xml.model.TagPropertyObject;
+import org.w3c.dom.ranges.DocumentRange;
/**
* @author Dart Peng
@@ -57,6 +51,8 @@
*/
public class XML2JavaAnalyzer extends AbstractAnalyzer {
+ private static final String SPACE_SPLITER = " ";
+
/*
* (non-Javadoc)
*
@@ -78,28 +74,41 @@
List sourceConnections = dataModel.getModelSourceConnections();
if (sourceConnections.isEmpty())
continue;
+ AbstractXMLObject newParent = (AbstractXMLObject) dataModel
+ .getReferenceEntityModel();
+ String newParentSelector = generateParentSelector(newParent);
processSourceConnections(sourceConnections, context, listType,
- (SourceModel) dataModel);
+ (SourceModel) dataModel, newParentSelector);
}
}
}
+
+ protected String generateParentSelector(AbstractXMLObject xmlObject){
+ String selector = xmlObject.getName();
+ while(xmlObject.getParent() != null && !(xmlObject.getParent() instanceof DocumentObject)){
+ xmlObject = xmlObject.getParent();
+ selector = xmlObject.getName() + SPACE_SPLITER + selector;
+ }
+ return selector;
+ }
protected void processSourceConnections(List sourceConnections,
SmooksConfigurationFileGenerateContext context,
- SmooksResourceListType listType, SourceModel sourceModel) {
+ SmooksResourceListType listType, SourceModel sourceModel,
+ String parentSelector) {
for (Iterator iterator = sourceConnections.iterator(); iterator
.hasNext();) {
LineConnectionModel connection = (LineConnectionModel) iterator
.next();
processLineConnection(connection, context, listType, sourceModel,
- null);
+ null, parentSelector);
}
}
protected void processLineConnection(LineConnectionModel connection,
SmooksConfigurationFileGenerateContext context,
SmooksResourceListType listType, SourceModel sourceModel,
- String beanID) {
+ String beanID, String parentSelector) {
if (this.connectionIsUsed(connection))
return;
setConnectionUsed(connection);
@@ -116,11 +125,12 @@
context.getGeneratorResourceList().add(resourceConfigType);
// addResourceConfigType(listType, resourceConfigType);
// set the selector string value
- resourceConfigType.setSelector(source.getName());
+ resourceConfigType.setSelector(parentSelector);
// add the properties of connection
List<PropertyModel> propertyList = connection.getProperties();
- for (Iterator<PropertyModel> iterator = propertyList.iterator(); iterator.hasNext();) {
+ for (Iterator<PropertyModel> iterator = propertyList.iterator(); iterator
+ .hasNext();) {
PropertyModel propertyModel = (PropertyModel) iterator.next();
if (propertyModel.getName().equals("selector-namespace")) {
resourceConfigType.setSelectorNamespace(propertyModel
@@ -153,14 +163,15 @@
// add bindings param
ParamType bindingsParam = addParamTypeToResourceConfig(
resourceConfigType, SmooksModelConstants.BINDINGS, null);
- processBindingsParam(bindingsParam, target, source, context, listType);
+ processBindingsParam(bindingsParam, target, source, context, listType,
+ parentSelector);
//
}
protected void processBindingsParam(ParamType bindingsParam,
JavaBeanModel javaBean, AbstractXMLObject source,
SmooksConfigurationFileGenerateContext context,
- SmooksResourceListType listType) {
+ SmooksResourceListType listType, String parentSelector) {
List properties = javaBean.getProperties();
for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
boolean isComplex = true;
@@ -177,12 +188,13 @@
if (child.isPrimitive() || child.getProperties().isEmpty()) {
isComplex = false;
}
-
+ String resourceConfigSelector = parentSelector;
String selector = getSelectorID(child);
if (!isComplex) {
selector = getSelectorIDViaXMLObject(
(AbstractXMLObject) sourceModel
- .getReferenceEntityModel(), source);
+ .getReferenceEntityModel(), source,
+ resourceConfigSelector);
}
AnyType binding = SmooksModelUtils.addBindingTypeToParamType(
bindingsParam, child.getName(), selector, null, null);
@@ -190,8 +202,11 @@
UIUtils.assignConnectionPropertyToBinding(connection, binding,
new String[] { "property", "selector" });
if (isComplex) {
+ AbstractXMLObject newParent = (AbstractXMLObject) sourceModel
+ .getReferenceEntityModel();
+ String newParentSelector = newParent.getName();
processLineConnection(connection, context, listType,
- (SourceModel) sourceModel, selector);
+ (SourceModel) sourceModel, selector, newParentSelector);
} else {
setConnectionUsed(connection);
continue;
@@ -200,18 +215,21 @@
}
protected String getSelectorIDViaXMLObject(AbstractXMLObject sourceModel,
- AbstractXMLObject currentRoot) {
+ AbstractXMLObject currentRoot, String resourceConfigSelector) {
String name = sourceModel.getName();
if (sourceModel instanceof TagPropertyObject) {
name = "@" + name;
}
AbstractXMLObject parent = sourceModel.getParent();
while (parent != null && parent.getName() != null) {
- name = parent.getName() + " " + name;
if (parent == currentRoot)
break;
+ name = parent.getName() + SPACE_SPLITER + name;
parent = parent.getParent();
}
+ if (resourceConfigSelector != null) {
+ name = resourceConfigSelector + SPACE_SPLITER + name;
+ }
return name;
}
@@ -227,14 +245,15 @@
public MappingResourceConfigList analyzeMappingSmooksModel(
SmooksResourceListType listType, Object sourceObject,
Object targetObject) {
+ JavaBeanModel tempBean = null;
if (sourceObject instanceof DocumentObject) {
sourceObject = ((DocumentObject) sourceObject).getRootTag();
}
- if (targetObject instanceof List) {
- targetObject = (JavaBeanModel) ((List) targetObject).get(0);
+ if (targetObject instanceof List && !((List) targetObject).isEmpty()) {
+ tempBean = (JavaBeanModel) ((List) targetObject).get(0);
}
if (!(sourceObject instanceof AbstractXMLObject)
- || !(targetObject instanceof JavaBeanModel)) {
+ || !(tempBean instanceof JavaBeanModel)) {
// TODO if the type of input source/target data is illegal , throw
// exceptions.
// MODIFY by Dart 2008.11.07
@@ -244,7 +263,6 @@
return MappingResourceConfigList.createEmptyList();
}
AbstractXMLObject sourceRoot = (AbstractXMLObject) sourceObject;
- JavaBeanModel sourceTarget = (JavaBeanModel) targetObject;
ResourceConfigType rootResourceConfig = findFirstMappingResourceConfig(listType);
// if can't find the root , return null
@@ -255,27 +273,108 @@
// throw new RuntimeException("Can't parse the config file.");
return null;
}
- String xmlName = rootResourceConfig.getSelector();
- AbstractXMLObject source = findXMLObjectByName(xmlName, sourceRoot);
- if (source == null) {
- // TODO if can't find the root , throw exception
- // MODIFY by Dart 2008.11.07
- throw new RuntimeException(Messages
- .getString("XML2JavaAnalyzer.CantFindRootNodeErrorMessage")); //$NON-NLS-1$
- // return MappingResourceConfigList.createEmptyList();
+ MappingResourceConfigList rcl = new MappingResourceConfigList();
+ List rlist = listType.getAbstractResourceConfig();
+ int startIndex = rlist.indexOf(rootResourceConfig);
+ for (int i = startIndex; i < rlist.size(); i++) {
+ ResourceConfigType resourceConfig = (ResourceConfigType) rlist
+ .get(i);
+ ResourceType resource = resourceConfig.getResource();
+ if (resource == null)
+ continue;
+ String populator = resource.getValue();
+ if (populator != null)
+ populator = populator.trim();
+ if (!JavaBeanAnalyzer.BEANPOPULATOR.equals(populator))
+ continue;
+ String selector = resourceConfig.getSelector();
+ if (isSelectorIsUsed(selector))
+ continue;
+ AbstractXMLObject source = findChildXMLObjectByName(selector,
+ sourceRoot);
+ if (source == null) {
+ // TODO if can't find the root , throw exception
+ // MODIFY by Dart 2008.11.17
+ throw new RuntimeException(
+ Messages
+ .getString("XML2JavaAnalyzer.CantFindRootNodeErrorMessage") + " : " + selector); //$NON-NLS-1$
+ // return MappingResourceConfigList.createEmptyList();
+ }
+ JavaBeanModel target = findJavaBeanModel(((List) targetObject),
+ resourceConfig);
+ if (target == null) {
+ // TODO if can't find the root , throw exception
+ // MODIFY by Dart 2008.11.17
+ String clazzName = SmooksModelUtils.getParmaText("beanClass",
+ resourceConfig);
+ if (clazzName != null)
+ throw new RuntimeException("Can't find the Java class"
+ + " : " + clazzName);
+ else
+ throw new RuntimeException("Java class name is NULL ");
+
+ }
+ this.createMappingResourceConfigList(rcl, listType, resourceConfig,
+ source, target);
}
-
- MappingResourceConfigList rcl = new MappingResourceConfigList();
- this.createMappingResourceConfigList(rcl, listType, rootResourceConfig,
- source, sourceTarget);
return rcl;
}
- public static AbstractXMLObject findXMLObjectByName(String selector,
+ protected JavaBeanModel findJavaBeanModel(List javaBeanModelList,
+ ResourceConfigType resourceConfig) {
+ for (Iterator iterator = javaBeanModelList.iterator(); iterator
+ .hasNext();) {
+ JavaBeanModel bean = (JavaBeanModel) iterator.next();
+ Class clazz = bean.getBeanClass();
+ if (clazz != null) {
+ String clazzName = SmooksModelUtils.getParmaText("beanClass",
+ resourceConfig);
+ if (clazzName != null)
+ clazzName = clazzName.trim();
+ if (clazz.getName().equals(clazzName)) {
+ return bean;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static AbstractXMLObject findChildXMLObjectByName(String selector,
AbstractXMLObject root) {
if (selector == null)
return null;
- if (selector.equals(root.getName())) {
+ selector = selector.trim();
+ String[] nameArray = null;
+ if (selector.indexOf(SPACE_SPLITER) != -1) {
+ nameArray = selector.split(SPACE_SPLITER);
+ }
+ if (nameArray != null) {
+ if (nameArray.length > 1) {
+ String firstNodeName = nameArray[0];
+ root = findChildXMLObjectByName(firstNodeName, root);
+ if (root == null)
+ return null;
+ for (int i = 1; i < nameArray.length; i++) {
+ String name = nameArray[i];
+ if (root instanceof TagObject) {
+ List<AbstractXMLObject> childrenTags = root
+ .getChildren();
+ for (Iterator iterator = childrenTags.iterator(); iterator
+ .hasNext();) {
+ AbstractXMLObject abstractXMLObject = (AbstractXMLObject) iterator
+ .next();
+ if (abstractXMLObject.getName().equalsIgnoreCase(
+ name)) {
+ root = abstractXMLObject;
+ break;
+ }
+ }
+ }
+ }
+ return root;
+ }
+ }
+ if (selector.equalsIgnoreCase(root.getName())) {
return root;
}
if (root instanceof TagObject) {
@@ -289,7 +388,7 @@
for (Iterator iterator = tags.iterator(); iterator.hasNext();) {
AbstractXMLObject tagChild = (AbstractXMLObject) iterator
.next();
- AbstractXMLObject result = findXMLObjectByName(selector,
+ AbstractXMLObject result = findChildXMLObjectByName(selector,
tagChild);
if (result != null)
return result;
@@ -307,20 +406,20 @@
MappingModel mapping = new MappingModel(sourceRoot, targetJavaBean);
configList.getMappingModelList().add(mapping);
String namespace = config.getSelectorNamespace();
- if(namespace != null){
+ if (namespace != null) {
PropertyModel np = new PropertyModel();
np.setName("selector-namespace");
np.setValue(namespace);
mapping.getProperties().add(np);
}
-// String targetProfile = config.getTargetProfile();
-// if(targetProfile != null){
-// PropertyModel np = new PropertyModel();
-// np.setName("targetProfile");
-// np.setValue(targetProfile);
-// mapping.getProperties().add(np);
-// }
-
+ // String targetProfile = config.getTargetProfile();
+ // if(targetProfile != null){
+ // PropertyModel np = new PropertyModel();
+ // np.setName("targetProfile");
+ // np.setValue(targetProfile);
+ // mapping.getProperties().add(np);
+ // }
+
configList.addResourceConfig(config);
this.setSelectorIsUsed(config.getSelector());
@@ -350,6 +449,7 @@
SmooksModelUtils.ATTRIBUTE_SELECTOR);
JavaBeanModel childBean = JavaBeanAnalyzer
.findTheChildJavaBeanModel(property, targetJavaBean);
+ // PENGXUE
processXMLSelector(configList, config, sourceRoot,
childBean, list, selectorStr, binding);
}
@@ -367,7 +467,8 @@
String newSelector = resourceConfig1.getSelector();
if (newSelector == null)
return;
- AbstractXMLObject newRoot = findXMLObjectByName(newSelector, root);
+ AbstractXMLObject newRoot = findChildXMLObjectByName(newSelector,
+ root);
if (newRoot == null) {
// TODO If can't find the element , throw exception
// MODIFY by Dart , 2008.11.07
@@ -378,6 +479,7 @@
createMappingResourceConfigList(configList, listType,
resourceConfig1, newRoot, targetBean);
} else {
+
AbstractXMLObject source = findXMLObjectWithSelectorString(
selector, root);
if (source == null) {
@@ -405,11 +507,25 @@
if (selector == null)
return null;
selector = selector.trim();
- String[] names = selector.split(" ");
+ String[] names = selector.split(SPACE_SPLITER);
if (names == null)
return null;
- AbstractXMLObject current = parent;
- for (int i = 0; i < names.length; i++) {
+ int startIndex = 0;
+ String s = null;
+ if (names.length > 1)
+ s = names[0];
+ else
+ s = selector;
+ AbstractXMLObject current = findChildXMLObjectByName(s, parent);
+ if (current == parent) {
+
+ } else {
+ while (!(parent.getParent() instanceof DocumentObject)) {
+ parent = parent.getParent();
+ }
+ current = parent;
+ }
+ for (int i = startIndex; i < names.length; i++) {
String name = names[i].trim();
if (current instanceof TagObject && isXMLAttributeObject(name)) {
List properties = ((TagObject) current).getProperties();
@@ -418,24 +534,23 @@
.hasNext();) {
TagPropertyObject property = (TagPropertyObject) iterator
.next();
- if (name.equals(property.getName())) {
+ if (name.equalsIgnoreCase(property.getName())) {
current = property;
+ break;
}
}
} else {
- List list = parent.getChildren();
+ List list = current.getChildren();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
AbstractXMLObject child = (AbstractXMLObject) iterator
.next();
- if (name.equals(child.getName())) {
+ if (name.equalsIgnoreCase(child.getName())) {
current = child;
break;
}
}
}
}
- if (current == parent)
- return null;
return current;
}
17 years, 5 months
JBoss Tools SVN: r11896 - trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-11-19 22:24:35 -0500 (Wed, 19 Nov 2008)
New Revision: 11896
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/smooks-wiz.gif
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/sample.gif
Log:
JBIDE-3112
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/sample.gif
===================================================================
(Binary files differ)
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/smooks-wiz.gif
===================================================================
(Binary files differ)
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/smooks-wiz.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 5 months
JBoss Tools SVN: r11895 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui: icons and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-11-19 22:23:32 -0500 (Wed, 19 Nov 2008)
New Revision: 11895
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/smooks-sm.gif
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
Log:
JBIDE-3112
Add new icons and remove the jboss.common.ui dependecy
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/smooks-sm.gif
===================================================================
(Binary files differ)
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/icons/smooks-sm.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-11-20 02:03:22 UTC (rev 11894)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-11-20 03:23:32 UTC (rev 11895)
@@ -1,293 +1,293 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
- <extension-point id="viewerInitor" name="viewerInitor" schema="schema/viewerInitor.exsd"/>
- <extension-point id="analyzer" name="analyzer" schema="schema/analyzer.exsd"/>
- <extension-point id="commandProcessor" name="commandProcessor" schema="schema/commandProcessor.exsd"/>
- <extension point="org.eclipse.emf.ecore.generated_package">
- <package
- uri = "http://www.jboss.org/tools/smooks/graphicalInformation"
- class = "org.jboss.tools.smooks.graphical.GraphicalPackage"
- genModel = "model/graphical.genmodel" />
- </extension>
- <extension
- point="org.eclipse.wst.sse.ui.adapterFactoryDescription">
- <adapterFactoryDescription
- class="org.eclipse.wst.xml.ui.internal.registry.AdapterFactoryProviderForXML">
- <contentType id="org.eclipse.core.runtime.xml" />
- <contentType id="org.jboss.tools.smooks.ui.smooks.contentType" />
- </adapterFactoryDescription>
- </extension>
- <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
- <sourceViewerConfiguration
- class="org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <contentOutlineConfiguration
- class="org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <propertySheetConfiguration
- class="org.eclipse.wst.xml.ui.views.properties.XMLPropertySheetConfiguration"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <documentationTextHover
- class="org.eclipse.wst.xml.ui.internal.taginfo.XMLTagInfoHoverProcessor"
- target="org.eclipse.wst.xml.XML_DEFAULT">
- </documentationTextHover>
- <doubleClickStrategy
- class="org.eclipse.wst.xml.ui.internal.doubleclick.XMLDoubleClickStrategy"
- target="org.eclipse.wst.xml.XML_DEFAULT">
- </doubleClickStrategy>
- <provisionalConfiguration
- type="sourceeditingtexttools"
- class="org.eclipse.wst.xml.ui.internal.provisional.XMLSourceEditingTextTools"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <provisionalConfiguration
- type="characterpairmatcher"
- class="org.eclipse.wst.xml.ui.internal.text.XMLDocumentRegionEdgeMatcher"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <provisionalConfiguration
- type="structuredtextfoldingprovider"
- class="org.eclipse.wst.xml.ui.internal.projection.StructuredTextFoldingProviderXML"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <provisionalConfiguration
- type="org.eclipse.jface.text.quickassist.IQuickAssistProcessor"
- class="org.eclipse.wst.xml.ui.internal.correction.XMLQuickAssistProcessor"
- target="org.eclipse.wst.xml.XML_DEFAULT" />
- <provisionalConfiguration
- type="autoeditstrategy"
- class="org.eclipse.wst.xml.ui.internal.autoedit.StructuredAutoEditStrategyXML"
- target="org.eclipse.wst.xml.XML_DEFAULT" />
- <provisionalDefinition
- type="preferencepages"
- value="org.eclipse.wst.xml.ui.preferences.xml.xml, org.eclipse.wst.sse.ui.preferences.xml.source, org.eclipse.wst.sse.ui.preferences.xml.templates, org.eclipse.wst.sse.ui.preferences.xml.colors"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <provisionalDefinition
- type="spellingregions"
- value="XML_COMMENT_TEXT, XML_CONTENT, XML_DEFAULT"
- target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
- <provisionalDefinition
- type="activecontexts"
- value="org.eclipse.core.runtime.xml, org.eclipse.wst.xml.navigation, org.eclipse.wst.xml.cleanup, org.eclipse.wst.xml.comments, org.eclipse.wst.xml.selection, org.eclipse.wst.xml.dependencies, org.eclipse.wst.xml.grammar, org.eclipse.wst.xml.expand, org.eclipse.wst.xml.occurrences"
- target="org.eclipse.core.runtime.xml" />
- </extension>
- <extension
- point="org.eclipse.ui.editors">
- <editor
- name="Smooks Form Editor"
- extensions="smooks"
- icon="icons/sample.gif"
- class="org.jboss.tools.smooks.ui.editors.SmooksFormEditor"
- id="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
- <contentTypeBinding
- contentTypeId="org.eclipse.core.runtime.xml" />
- <contentTypeBinding
- contentTypeId="org.jboss.tools.smooks.ui.smooks.contentType" />
- </editor>
- </extension>
- <extension
- point="org.eclipse.ui.views.properties.tabbed.propertySections">
- <propertySections
- contributorId="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
- <propertySection
- class="org.jboss.tools.smooks.ui.ConnectionPropertySection"
- id="org.jboss.tools.smooks.ui.connection.propertyTab.Section"
- tab="org.jboss.tools.smooks.ui.connection.propertyTab">
- <input
- type="org.jboss.tools.smooks.ui.gef.model.LineConnectionModel">
- </input>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="viewerInitor" name="viewerInitor" schema="schema/viewerInitor.exsd"/>
+ <extension-point id="analyzer" name="analyzer" schema="schema/analyzer.exsd"/>
+ <extension-point id="commandProcessor" name="commandProcessor" schema="schema/commandProcessor.exsd"/>
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.jboss.org/tools/smooks/graphicalInformation"
+ class = "org.jboss.tools.smooks.graphical.GraphicalPackage"
+ genModel = "model/graphical.genmodel" />
+ </extension>
+ <extension
+ point="org.eclipse.wst.sse.ui.adapterFactoryDescription">
+ <adapterFactoryDescription
+ class="org.eclipse.wst.xml.ui.internal.registry.AdapterFactoryProviderForXML">
+ <contentType id="org.eclipse.core.runtime.xml" />
+ <contentType id="org.jboss.tools.smooks.ui.smooks.contentType" />
+ </adapterFactoryDescription>
+ </extension>
+ <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
+ <sourceViewerConfiguration
+ class="org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <contentOutlineConfiguration
+ class="org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <propertySheetConfiguration
+ class="org.eclipse.wst.xml.ui.views.properties.XMLPropertySheetConfiguration"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <documentationTextHover
+ class="org.eclipse.wst.xml.ui.internal.taginfo.XMLTagInfoHoverProcessor"
+ target="org.eclipse.wst.xml.XML_DEFAULT">
+ </documentationTextHover>
+ <doubleClickStrategy
+ class="org.eclipse.wst.xml.ui.internal.doubleclick.XMLDoubleClickStrategy"
+ target="org.eclipse.wst.xml.XML_DEFAULT">
+ </doubleClickStrategy>
+ <provisionalConfiguration
+ type="sourceeditingtexttools"
+ class="org.eclipse.wst.xml.ui.internal.provisional.XMLSourceEditingTextTools"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <provisionalConfiguration
+ type="characterpairmatcher"
+ class="org.eclipse.wst.xml.ui.internal.text.XMLDocumentRegionEdgeMatcher"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <provisionalConfiguration
+ type="structuredtextfoldingprovider"
+ class="org.eclipse.wst.xml.ui.internal.projection.StructuredTextFoldingProviderXML"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <provisionalConfiguration
+ type="org.eclipse.jface.text.quickassist.IQuickAssistProcessor"
+ class="org.eclipse.wst.xml.ui.internal.correction.XMLQuickAssistProcessor"
+ target="org.eclipse.wst.xml.XML_DEFAULT" />
+ <provisionalConfiguration
+ type="autoeditstrategy"
+ class="org.eclipse.wst.xml.ui.internal.autoedit.StructuredAutoEditStrategyXML"
+ target="org.eclipse.wst.xml.XML_DEFAULT" />
+ <provisionalDefinition
+ type="preferencepages"
+ value="org.eclipse.wst.xml.ui.preferences.xml.xml, org.eclipse.wst.sse.ui.preferences.xml.source, org.eclipse.wst.sse.ui.preferences.xml.templates, org.eclipse.wst.sse.ui.preferences.xml.colors"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <provisionalDefinition
+ type="spellingregions"
+ value="XML_COMMENT_TEXT, XML_CONTENT, XML_DEFAULT"
+ target="org.eclipse.core.runtime.xml, org.jboss.tools.smooks.ui.smooks.contentType" />
+ <provisionalDefinition
+ type="activecontexts"
+ value="org.eclipse.core.runtime.xml, org.eclipse.wst.xml.navigation, org.eclipse.wst.xml.cleanup, org.eclipse.wst.xml.comments, org.eclipse.wst.xml.selection, org.eclipse.wst.xml.dependencies, org.eclipse.wst.xml.grammar, org.eclipse.wst.xml.expand, org.eclipse.wst.xml.occurrences"
+ target="org.eclipse.core.runtime.xml" />
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ name="Smooks Form Editor"
+ extensions="smooks"
+ icon="icons/smooks-sm.gif"
+ class="org.jboss.tools.smooks.ui.editors.SmooksFormEditor"
+ id="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml" />
+ <contentTypeBinding
+ contentTypeId="org.jboss.tools.smooks.ui.smooks.contentType" />
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections
+ contributorId="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
+ <propertySection
+ class="org.jboss.tools.smooks.ui.ConnectionPropertySection"
+ id="org.jboss.tools.smooks.ui.connection.propertyTab.Section"
+ tab="org.jboss.tools.smooks.ui.connection.propertyTab">
+ <input
+ type="org.jboss.tools.smooks.ui.gef.model.LineConnectionModel">
+ </input>
</propertySection>
- <propertySection
- class="org.jboss.tools.smooks.javabean.ui.JavaBeanPropertiesSection"
- filter="org.jboss.tools.smooks.javabean.ui.JavaBeanPropertiesSectonFilter"
- id="org.jboss.tools.smooks.ui.javabean.propertyTab.Section"
+ <propertySection
+ class="org.jboss.tools.smooks.javabean.ui.JavaBeanPropertiesSection"
+ filter="org.jboss.tools.smooks.javabean.ui.JavaBeanPropertiesSectonFilter"
+ id="org.jboss.tools.smooks.ui.javabean.propertyTab.Section"
tab="org.jboss.tools.smooks.ui.javabean.propertyTab">
- </propertySection>
- <propertySection
- class="org.jboss.tools.smooks.xml.ui.XMLPropertiesSection"
- filter="org.jboss.tools.smooks.xml.ui.XMLPropertiesSectionFilter"
- id="org.jboss.tools.smooks.ui.xml.propertySection"
- tab="org.jboss.tools.smooks.ui.xml.propertyTab">
- </propertySection>
- </propertySections>
- </extension>
- <extension
- point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
- <propertyContributor
- contributorId="org.jboss.tools.smooks.ui.editors.SmooksFormEditor"
- typeMapper="org.jboss.tools.smooks.ui.SmooksGraphPropertyTypeMapper">
- <propertyCategory
- category="connection"></propertyCategory>
- </propertyContributor>
- </extension>
- <extension
- point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
- <propertyTabs
- contributorId="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
- <propertyTab
- category="connection"
- id="org.jboss.tools.smooks.ui.connection.propertyTab"
- label="Mapping Properties">
+ </propertySection>
+ <propertySection
+ class="org.jboss.tools.smooks.xml.ui.XMLPropertiesSection"
+ filter="org.jboss.tools.smooks.xml.ui.XMLPropertiesSectionFilter"
+ id="org.jboss.tools.smooks.ui.xml.propertySection"
+ tab="org.jboss.tools.smooks.ui.xml.propertyTab">
+ </propertySection>
+ </propertySections>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
+ <propertyContributor
+ contributorId="org.jboss.tools.smooks.ui.editors.SmooksFormEditor"
+ typeMapper="org.jboss.tools.smooks.ui.SmooksGraphPropertyTypeMapper">
+ <propertyCategory
+ category="connection"></propertyCategory>
+ </propertyContributor>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs
+ contributorId="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
+ <propertyTab
+ category="connection"
+ id="org.jboss.tools.smooks.ui.connection.propertyTab"
+ label="Mapping Properties">
</propertyTab>
<propertyTab
category="connection"
id="org.jboss.tools.smooks.ui.javabean.propertyTab"
label="JavaBean Properties">
- </propertyTab>
- <propertyTab
- category="connection"
- id="org.jboss.tools.smooks.ui.xml.propertyTab"
- label="XML Properties">
- </propertyTab>
- </propertyTabs>
- </extension>
- <extension
- point="org.eclipse.ui.newWizards">
- <category
- id="org.jboss.tools.smooks.ui.wizards"
- name="Smooks">
- </category>
- <wizard
- category="org.jboss.tools.smooks.ui.wizards"
- class="org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard"
- icon="icons/sample.gif"
- id="org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard"
- name="Smooks Configuration File">
- </wizard>
- </extension>
-
- <extension
- point="org.jboss.tools.smooks.ui.viewerInitor">
- <viewerInitor
- contentProvider="org.jboss.tools.smooks.xml.ui.XMLStructuredDataContentProvider"
- creationWizard="org.jboss.tools.smooks.xml.ui.XMLStructuredDataWizard"
- description="XML data type comes from any .xml file."
- labelProvider="org.jboss.tools.smooks.xml.ui.XMLStructuredDataLabelProvider"
- name="XML"
- typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
- </viewerInitor>
- </extension>
- <extension
- point="org.jboss.tools.smooks.ui.analyzer">
- <mappingAnalyzer
- class="org.jboss.tools.smooks.xml2xml.XML2XMLAnalyzer"
- name="XML2XML Analyzer"
- typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
- <targetSourceType
- id="org.jboss.tools.smooks.xml.viewerInitor.xml"
- name="XML">
- </targetSourceType>
- </mappingAnalyzer>
- </extension>
- <extension
- point="org.jboss.tools.smooks.ui.viewerInitor">
- <viewerInitor
- contentProvider="org.jboss.tools.smooks.javabean.model.BeanContentProvider"
- creationWizard="org.jboss.tools.smooks.javabean.ui.NewJavaBeanStrucutredDataWizard"
- description="This data type can get from any Java .class."
- labelProvider="org.jboss.tools.smooks.javabean.model.BeanlabelProvider"
- name="Java"
- typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- </viewerInitor>
- </extension>
- <extension
- point="org.jboss.tools.smooks.ui.analyzer">
- <mappingAnalyzer
- class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
- name="Java"
- typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- <targetSourceType
- id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
- name="java2java">
- </targetSourceType>
- </mappingAnalyzer>
- <sourceModelAnalyzer
- class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
- level="0"
- name="Java"
- typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- </sourceModelAnalyzer>
- <targetModelAnalyzer
- class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
- level="0"
- name="Java"
- typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- </targetModelAnalyzer>
- </extension>
-
- <extension
- point="org.jboss.tools.smooks.ui.analyzer">
- <mappingAnalyzer
- class="org.jboss.tools.smooks.java2xml.analyzer.Java2XMLAnalyzer"
- name="Java"
- typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- <targetSourceType
- id="org.jboss.tools.smooks.xml.viewerInitor.xml"
- name="XML">
- </targetSourceType>
- </mappingAnalyzer>
- </extension>
-
- <extension
- point="org.jboss.tools.smooks.ui.analyzer">
- <mappingAnalyzer
- class="org.jboss.tools.smooks.xml2java.analyzer.XML2JavaAnalyzer"
- name="XML2Java"
- typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
- <targetSourceType
- id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
- name="JavaBean">
- </targetSourceType>
- </mappingAnalyzer>
- <sourceModelAnalyzer
- class="org.jboss.tools.smooks.xml2java.analyzer.XMLSourceModelAnalyzer"
- name="XML"
- typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
- </sourceModelAnalyzer>
- <targetModelAnalyzer
- class="org.jboss.tools.smooks.xml2java.analyzer.XMLTargetModelAnalyzer"
- name="XML"
- typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
- </targetModelAnalyzer>
- </extension>
- <extension
- point="org.jboss.tools.smooks.ui.commandProcessor">
- <commandProcessor
- class="org.jboss.tools.smooks.javabean.commandprocessor.JavaBeanModelCommandProcessor"
- sourceId="org.jboss.tools.smooks.ui.viewerInitor.javabean"
- targetId="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- </commandProcessor>
- <commandProcessor
- class="org.jboss.tools.smooks.javabean.commandprocessor.JavaBeanModelCommandProcessor"
- sourceId="org.jboss.tools.smooks.xml.viewerInitor.xml"
- targetId="org.jboss.tools.smooks.ui.viewerInitor.javabean">
- </commandProcessor>
- </extension>
-
- <extension
- point="org.eclipse.ui.startup">
- <startup
- class="org.jboss.tools.smooks.ui.SmooksListenerRegister">
- </startup>
- </extension>
- <extension
- point="org.eclipse.core.contenttype.contentTypes">
- <content-type
- base-type="org.eclipse.core.runtime.xml"
- file-extensions="smooks"
- id="org.jboss.tools.smooks.ui.smooks.contentType"
- name="Smooks Configuration File"
- priority="normal">
- </content-type>
- </extension>
- <extension
- point="org.eclipse.ui.decorators">
- <decorator
- adaptable="false"
- class="org.jboss.tools.smooks.xml.ui.XMLStructuredDataLabelDecorator"
- id="org.jboss.tools.smooks.ui.xml.decorator"
- label="Smooks XML Data Viewer Decorator"
- lightweight="false"
- objectClass="org.jboss.tools.smooks.xml.model.TagObject"
- state="true">
- </decorator>
- </extension>
-</plugin>
+ </propertyTab>
+ <propertyTab
+ category="connection"
+ id="org.jboss.tools.smooks.ui.xml.propertyTab"
+ label="XML Properties">
+ </propertyTab>
+ </propertyTabs>
+ </extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.jboss.tools.smooks.ui.wizards"
+ name="Smooks">
+ </category>
+ <wizard
+ category="org.jboss.tools.smooks.ui.wizards"
+ class="org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard"
+ icon="icons/smooks-sm.gif"
+ id="org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard"
+ name="Smooks Configuration File">
+ </wizard>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.smooks.ui.viewerInitor">
+ <viewerInitor
+ contentProvider="org.jboss.tools.smooks.xml.ui.XMLStructuredDataContentProvider"
+ creationWizard="org.jboss.tools.smooks.xml.ui.XMLStructuredDataWizard"
+ description="XML data type comes from any .xml file."
+ labelProvider="org.jboss.tools.smooks.xml.ui.XMLStructuredDataLabelProvider"
+ name="XML"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ </viewerInitor>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.xml2xml.XML2XMLAnalyzer"
+ name="XML2XML Analyzer"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ <targetSourceType
+ id="org.jboss.tools.smooks.xml.viewerInitor.xml"
+ name="XML">
+ </targetSourceType>
+ </mappingAnalyzer>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.viewerInitor">
+ <viewerInitor
+ contentProvider="org.jboss.tools.smooks.javabean.model.BeanContentProvider"
+ creationWizard="org.jboss.tools.smooks.javabean.ui.NewJavaBeanStrucutredDataWizard"
+ description="This data type can get from any Java .class."
+ labelProvider="org.jboss.tools.smooks.javabean.model.BeanlabelProvider"
+ name="Java"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </viewerInitor>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ name="Java"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ <targetSourceType
+ id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
+ name="java2java">
+ </targetSourceType>
+ </mappingAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="Java"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </sourceModelAnalyzer>
+ <targetModelAnalyzer
+ class="org.jboss.tools.smooks.javabean.analyzer.JavaBeanAnalyzer"
+ level="0"
+ name="Java"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </targetModelAnalyzer>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.java2xml.analyzer.Java2XMLAnalyzer"
+ name="Java"
+ typeID="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ <targetSourceType
+ id="org.jboss.tools.smooks.xml.viewerInitor.xml"
+ name="XML">
+ </targetSourceType>
+ </mappingAnalyzer>
+ </extension>
+
+ <extension
+ point="org.jboss.tools.smooks.ui.analyzer">
+ <mappingAnalyzer
+ class="org.jboss.tools.smooks.xml2java.analyzer.XML2JavaAnalyzer"
+ name="XML2Java"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ <targetSourceType
+ id="org.jboss.tools.smooks.ui.viewerInitor.javabean"
+ name="JavaBean">
+ </targetSourceType>
+ </mappingAnalyzer>
+ <sourceModelAnalyzer
+ class="org.jboss.tools.smooks.xml2java.analyzer.XMLSourceModelAnalyzer"
+ name="XML"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ </sourceModelAnalyzer>
+ <targetModelAnalyzer
+ class="org.jboss.tools.smooks.xml2java.analyzer.XMLTargetModelAnalyzer"
+ name="XML"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ </targetModelAnalyzer>
+ </extension>
+ <extension
+ point="org.jboss.tools.smooks.ui.commandProcessor">
+ <commandProcessor
+ class="org.jboss.tools.smooks.javabean.commandprocessor.JavaBeanModelCommandProcessor"
+ sourceId="org.jboss.tools.smooks.ui.viewerInitor.javabean"
+ targetId="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </commandProcessor>
+ <commandProcessor
+ class="org.jboss.tools.smooks.javabean.commandprocessor.JavaBeanModelCommandProcessor"
+ sourceId="org.jboss.tools.smooks.xml.viewerInitor.xml"
+ targetId="org.jboss.tools.smooks.ui.viewerInitor.javabean">
+ </commandProcessor>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.jboss.tools.smooks.ui.SmooksListenerRegister">
+ </startup>
+ </extension>
+ <extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.xml"
+ file-extensions="smooks"
+ id="org.jboss.tools.smooks.ui.smooks.contentType"
+ name="Smooks Configuration File"
+ priority="normal">
+ </content-type>
+ </extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ adaptable="false"
+ class="org.jboss.tools.smooks.xml.ui.XMLStructuredDataLabelDecorator"
+ id="org.jboss.tools.smooks.ui.xml.decorator"
+ label="Smooks XML Data Viewer Decorator"
+ lightweight="false"
+ objectClass="org.jboss.tools.smooks.xml.model.TagObject"
+ state="true">
+ </decorator>
+ </extension>
+</plugin>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-11-20 02:03:22 UTC (rev 11894)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-11-20 03:23:32 UTC (rev 11895)
@@ -1,321 +1,320 @@
-package org.jboss.tools.smooks.ui.wizards;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.jboss.tools.common.model.ui.ModelUIImages;
-import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
-import org.jboss.tools.smooks.ui.IStructuredDataCreationWizard;
-import org.jboss.tools.smooks.ui.editors.SmooksFileEditorInput;
-import org.jboss.tools.smooks.ui.editors.SmooksFormEditor;
-import org.jboss.tools.smooks.ui.editors.TypeIDSelectionWizardPage;
-
-/**
- * This is a sample new wizard. Its role is to create a new file resource in the
- * provided container. If the container resource (a folder or a project) is
- * selected in the workspace when the wizard is opened, it will accept it as the
- * target container. The wizard creates one file with the extension "smooks". If
- * a sample multi-page editor (also available as a template) is registered for
- * the same extension, it will be able to open it.
- */
-
-public class SmooksConfigFileNewWizard extends Wizard implements INewWizard,
- ISmooksDataCreationAddtionWizard {
- public static final String PRO_SOURCE_DATA_PATH = "sourceDataPath"; //$NON-NLS-1$
-
- public static final String PRO_TARGET_DATA_PATH = "targetDataPath"; //$NON-NLS-1$
-
- private SmooksConfigFileNewWizardPage page;
- private TypeIDSelectionWizardPage typeIDPage;
-
- private List<IWizardPage> sourceCreationPages = new ArrayList<IWizardPage>();
-
- private List<IWizardPage> targetCreationPages = new ArrayList<IWizardPage>();
-
- private IStructuredSelection selection;
-
- private IWorkbench workbench;
-
- /**
- * Constructor for SmooksConfigFileNewWizard.
- */
- public SmooksConfigFileNewWizard() {
- super();
- setNeedsProgressMonitor(true);
- super.setWindowTitle(Messages.getString("SmooksConfigFileNewWizard.NewConfigFileWizardTitle")); //$NON-NLS-1$
- setDefaultPageImageDescriptor(ModelUIImages
- .getImageDescriptor(ModelUIImages.WIZARD_NEW_PROJECT));
- }
-
- /**
- * Adding the page to the wizard.
- */
- public void addPages() {
- page = new SmooksConfigFileNewWizardPage("newSmooksFile1", //$NON-NLS-1$
- getSelection());
- addPage(page);
- // TODO don't use the WizardSelectionPage
- typeIDPage = new TypeIDSelectionWizardPage("", false); //$NON-NLS-1$
- typeIDPage.setSelection(selection);
- addPage(typeIDPage);
- }
-
- /**
- * This method is called when 'Finish' button is pressed in the wizard. We
- * will create an operation and run it using wizard as execution context.
- */
- public boolean performFinish() {
- // final String containerName = page.getContainerName();
- // final String fileName = page.getFileName();
- final IFile file = page.createNewFile();
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException {
- try {
- doFinish(file, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- };
- try {
- getContainer().run(true, false, op);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- Throwable realException = e.getTargetException();
- MessageDialog.openError(getShell(), Messages.getString("SmooksConfigFileNewWizard.ErrorTitle"), realException //$NON-NLS-1$
- .getMessage());
- return false;
- }
- return true;
- }
-
- /**
- * The worker method. It will find the container, create the file if missing
- * or just replace its contents, and open the editor on the newly created
- * file.
- */
-
- private void doFinish(final IFile file, IProgressMonitor monitor)
- throws CoreException {
- // create a sample file
- final String sourceTypeID = typeIDPage.getSourceID();
- final String targetTypeID = typeIDPage.getTargetID();
- final String[] sourceDataPath = new String[] { null };
- final String[] targetDataPath = new String[] { null };
- try {
- InputStream stream = openContentStream();
- if (file.exists()) {
- file.setContents(stream, true, true, monitor);
- } else {
- file.create(stream, true, monitor);
- }
- stream.close();
- } catch (IOException e) {
- // ignore
- }
- final GraphicalInformationSaver ginforSave = new GraphicalInformationSaver(
- file);
-
- monitor.worked(1);
- monitor.setTaskName("Opening file for editing..."); //$NON-NLS-1$
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- IWorkbenchPage page = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- try {
- SmooksFileEditorInput input = new SmooksFileEditorInput(
- file);
- IWizard sourceWizard = typeIDPage
- .getSourceDataCreationWizard();
- IWizard targetWizard = typeIDPage
- .getTargetDataCreationWizard();
- if (sourceWizard != null) {
- sourceWizard.performFinish();
- }
- if (targetWizard != null) {
- targetWizard.performFinish();
- }
- if (sourceWizard instanceof IStructuredDataCreationWizard) {
- Object sourceObj = ((IStructuredDataCreationWizard) sourceWizard)
- .getTreeViewerInputContents();
- sourceDataPath[0] = ((IStructuredDataCreationWizard) sourceWizard)
- .getStructuredDataSourcePath();
- input.setSourceTreeViewerInputContents(sourceObj);
- }
-
- if (targetWizard instanceof IStructuredDataCreationWizard) {
- Object targetObj = ((IStructuredDataCreationWizard) targetWizard)
- .getTreeViewerInputContents();
- targetDataPath[0] = ((IStructuredDataCreationWizard) targetWizard)
- .getStructuredDataSourcePath();
- input.setTargetTreeViewerInputContents(targetObj);
-
- }
- Properties properties = null;
- if (sourceDataPath[0] != null || targetDataPath[0] != null) {
- properties = new Properties();
- if (sourceDataPath[0] != null) {
- properties.setProperty(PRO_SOURCE_DATA_PATH, sourceDataPath[0]);
- }
- if (targetDataPath[0] != null) {
- properties.setProperty(PRO_TARGET_DATA_PATH, targetDataPath[0]);
- }
- }
- try {
- ginforSave.doSave(null, sourceTypeID, targetTypeID, properties);
- } catch (IOException e) {
- } catch (CoreException e) {
- }
- IDE.openEditor(page, input, SmooksFormEditor.EDITOR_ID,
- true);// openEditor(page, file, true);
- } catch (PartInitException e) {
- }
- }
- });
-
- monitor.worked(1);
- }
-
- /**
- * We will initialize file contents with a sample text.
- */
-
- private InputStream openContentStream() {
- String contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
- + " <smooks-resource-list xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\"/>"; //$NON-NLS-1$
- return new ByteArrayInputStream(contents.getBytes());
- }
-
- private void throwCoreException(String message) throws CoreException {
- IStatus status = new Status(IStatus.ERROR, "org.jboss.tools.smooks.ui", //$NON-NLS-1$
- IStatus.OK, message, null);
- throw new CoreException(status);
- }
-
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.workbench = workbench;
- this.selection = selection;
- }
-
- public IStructuredSelection getSelection() {
- return selection;
- }
-
- public void setSelection(IStructuredSelection selection) {
- this.selection = selection;
- }
-
- public void addSourceWizardPage(IWizardPage page) {
- sourceCreationPages.add(page);
- page.setTitle(Messages.getString("SmooksConfigFileNewWizard.SourceDataTypeSelectionTitle")); //$NON-NLS-1$
- }
-
- public void addTargetWizardPage(IWizardPage page) {
- targetCreationPages.add(page);
- page.setTitle(Messages.getString("SmooksConfigFileNewWizard.TargetDataTypeSelectionTitle")); //$NON-NLS-1$
- }
-
- public void clearSourceWizardPages() {
- // for (Iterator iterator = sourceCreationPages.iterator();
- // iterator.hasNext();) {
- // IWizardPage page = (IWizardPage) iterator.next();
- // if(page != null){
- // page.dispose();
- // }
- // }
- sourceCreationPages.clear();
- }
-
- private IWizardPage getSourceCreationPage(IWizardPage page) {
- if (page == typeIDPage) {
- if (sourceCreationPages.isEmpty())
- return null;
- return (IWizardPage) sourceCreationPages.get(0);
- }
- if (sourceCreationPages.contains(page)) {
- int i = sourceCreationPages.indexOf(page);
- if ((i + 1) >= sourceCreationPages.size()) {
- return null;
- }
- return (IWizardPage) sourceCreationPages.get(i + 1);
- }
- return null;
- }
-
- private IWizardPage getTargetCreationPage(IWizardPage page) {
- if (page == typeIDPage) {
- if (targetCreationPages.isEmpty())
- return null;
- return (IWizardPage) targetCreationPages.get(0);
- }
- if (targetCreationPages.contains(page)) {
- int i = targetCreationPages.indexOf(page);
- if ((i + 1) >= targetCreationPages.size()) {
- return null;
- }
- return (IWizardPage) targetCreationPages.get(i + 1);
- }
- if (sourceCreationPages.contains(page)) {
- if (sourceCreationPages.get(sourceCreationPages.size() - 1) == page) {
- return (IWizardPage) targetCreationPages.get(0);
- }
- }
- return null;
- }
-
- @Override
- public IWizardPage getNextPage(IWizardPage page) {
- IWizardPage p = getSourceCreationPage(page);
- if (p != null)
- return p;
- p = getTargetCreationPage(page);
- if (p != null)
- return p;
- return super.getNextPage(page);
- }
-
- public void clearTargetWizardPages() {
- // for (Iterator iterator = sourceCreationPages.iterator();
- // iterator.hasNext();) {
- // IWizardPage page = (IWizardPage) iterator.next();
- // if(page != null){
- // page.dispose();
- // }
- // }
- targetCreationPages.clear();
- }
-
- public void removeSourceWIzardPage(IWizardPage page) {
- sourceCreationPages.remove(page);
- }
-
- public void removeTargetWIzardPage(IWizardPage page) {
- targetCreationPages.remove(page);
- }
+package org.jboss.tools.smooks.ui.wizards;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
+import org.jboss.tools.smooks.ui.IStructuredDataCreationWizard;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.ui.editors.SmooksFileEditorInput;
+import org.jboss.tools.smooks.ui.editors.SmooksFormEditor;
+import org.jboss.tools.smooks.ui.editors.TypeIDSelectionWizardPage;
+
+/**
+ * This is a sample new wizard. Its role is to create a new file resource in the
+ * provided container. If the container resource (a folder or a project) is
+ * selected in the workspace when the wizard is opened, it will accept it as the
+ * target container. The wizard creates one file with the extension "smooks". If
+ * a sample multi-page editor (also available as a template) is registered for
+ * the same extension, it will be able to open it.
+ */
+
+public class SmooksConfigFileNewWizard extends Wizard implements INewWizard,
+ ISmooksDataCreationAddtionWizard {
+ public static final String PRO_SOURCE_DATA_PATH = "sourceDataPath"; //$NON-NLS-1$
+
+ public static final String PRO_TARGET_DATA_PATH = "targetDataPath"; //$NON-NLS-1$
+
+ private SmooksConfigFileNewWizardPage page;
+ private TypeIDSelectionWizardPage typeIDPage;
+
+ private List<IWizardPage> sourceCreationPages = new ArrayList<IWizardPage>();
+
+ private List<IWizardPage> targetCreationPages = new ArrayList<IWizardPage>();
+
+ private IStructuredSelection selection;
+
+ private IWorkbench workbench;
+
+ /**
+ * Constructor for SmooksConfigFileNewWizard.
+ */
+ public SmooksConfigFileNewWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ super.setWindowTitle(Messages.getString("SmooksConfigFileNewWizard.NewConfigFileWizardTitle")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(SmooksUIActivator.getImageDescriptor("icons/smooks-wiz.gif"));
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+ public void addPages() {
+ page = new SmooksConfigFileNewWizardPage("newSmooksFile1", //$NON-NLS-1$
+ getSelection());
+ addPage(page);
+ // TODO don't use the WizardSelectionPage
+ typeIDPage = new TypeIDSelectionWizardPage("", false); //$NON-NLS-1$
+ typeIDPage.setSelection(selection);
+ addPage(typeIDPage);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in the wizard. We
+ * will create an operation and run it using wizard as execution context.
+ */
+ public boolean performFinish() {
+ // final String containerName = page.getContainerName();
+ // final String fileName = page.getFileName();
+ final IFile file = page.createNewFile();
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException {
+ try {
+ doFinish(file, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), Messages.getString("SmooksConfigFileNewWizard.ErrorTitle"), realException //$NON-NLS-1$
+ .getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * The worker method. It will find the container, create the file if missing
+ * or just replace its contents, and open the editor on the newly created
+ * file.
+ */
+
+ private void doFinish(final IFile file, IProgressMonitor monitor)
+ throws CoreException {
+ // create a sample file
+ final String sourceTypeID = typeIDPage.getSourceID();
+ final String targetTypeID = typeIDPage.getTargetID();
+ final String[] sourceDataPath = new String[] { null };
+ final String[] targetDataPath = new String[] { null };
+ try {
+ InputStream stream = openContentStream();
+ if (file.exists()) {
+ file.setContents(stream, true, true, monitor);
+ } else {
+ file.create(stream, true, monitor);
+ }
+ stream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ final GraphicalInformationSaver ginforSave = new GraphicalInformationSaver(
+ file);
+
+ monitor.worked(1);
+ monitor.setTaskName("Opening file for editing..."); //$NON-NLS-1$
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ SmooksFileEditorInput input = new SmooksFileEditorInput(
+ file);
+ IWizard sourceWizard = typeIDPage
+ .getSourceDataCreationWizard();
+ IWizard targetWizard = typeIDPage
+ .getTargetDataCreationWizard();
+ if (sourceWizard != null) {
+ sourceWizard.performFinish();
+ }
+ if (targetWizard != null) {
+ targetWizard.performFinish();
+ }
+ if (sourceWizard instanceof IStructuredDataCreationWizard) {
+ Object sourceObj = ((IStructuredDataCreationWizard) sourceWizard)
+ .getTreeViewerInputContents();
+ sourceDataPath[0] = ((IStructuredDataCreationWizard) sourceWizard)
+ .getStructuredDataSourcePath();
+ input.setSourceTreeViewerInputContents(sourceObj);
+ }
+
+ if (targetWizard instanceof IStructuredDataCreationWizard) {
+ Object targetObj = ((IStructuredDataCreationWizard) targetWizard)
+ .getTreeViewerInputContents();
+ targetDataPath[0] = ((IStructuredDataCreationWizard) targetWizard)
+ .getStructuredDataSourcePath();
+ input.setTargetTreeViewerInputContents(targetObj);
+
+ }
+ Properties properties = null;
+ if (sourceDataPath[0] != null || targetDataPath[0] != null) {
+ properties = new Properties();
+ if (sourceDataPath[0] != null) {
+ properties.setProperty(PRO_SOURCE_DATA_PATH, sourceDataPath[0]);
+ }
+ if (targetDataPath[0] != null) {
+ properties.setProperty(PRO_TARGET_DATA_PATH, targetDataPath[0]);
+ }
+ }
+ try {
+ ginforSave.doSave(null, sourceTypeID, targetTypeID, properties);
+ } catch (IOException e) {
+ } catch (CoreException e) {
+ }
+ IDE.openEditor(page, input, SmooksFormEditor.EDITOR_ID,
+ true);// openEditor(page, file, true);
+ } catch (PartInitException e) {
+ }
+ }
+ });
+
+ monitor.worked(1);
+ }
+
+ /**
+ * We will initialize file contents with a sample text.
+ */
+
+ private InputStream openContentStream() {
+ String contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
+ + " <smooks-resource-list xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\"/>"; //$NON-NLS-1$
+ return new ByteArrayInputStream(contents.getBytes());
+ }
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR, "org.jboss.tools.smooks.ui", //$NON-NLS-1$
+ IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
+
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ public void addSourceWizardPage(IWizardPage page) {
+ sourceCreationPages.add(page);
+ page.setTitle(Messages.getString("SmooksConfigFileNewWizard.SourceDataTypeSelectionTitle")); //$NON-NLS-1$
+ }
+
+ public void addTargetWizardPage(IWizardPage page) {
+ targetCreationPages.add(page);
+ page.setTitle(Messages.getString("SmooksConfigFileNewWizard.TargetDataTypeSelectionTitle")); //$NON-NLS-1$
+ }
+
+ public void clearSourceWizardPages() {
+ // for (Iterator iterator = sourceCreationPages.iterator();
+ // iterator.hasNext();) {
+ // IWizardPage page = (IWizardPage) iterator.next();
+ // if(page != null){
+ // page.dispose();
+ // }
+ // }
+ sourceCreationPages.clear();
+ }
+
+ private IWizardPage getSourceCreationPage(IWizardPage page) {
+ if (page == typeIDPage) {
+ if (sourceCreationPages.isEmpty())
+ return null;
+ return (IWizardPage) sourceCreationPages.get(0);
+ }
+ if (sourceCreationPages.contains(page)) {
+ int i = sourceCreationPages.indexOf(page);
+ if ((i + 1) >= sourceCreationPages.size()) {
+ return null;
+ }
+ return (IWizardPage) sourceCreationPages.get(i + 1);
+ }
+ return null;
+ }
+
+ private IWizardPage getTargetCreationPage(IWizardPage page) {
+ if (page == typeIDPage) {
+ if (targetCreationPages.isEmpty())
+ return null;
+ return (IWizardPage) targetCreationPages.get(0);
+ }
+ if (targetCreationPages.contains(page)) {
+ int i = targetCreationPages.indexOf(page);
+ if ((i + 1) >= targetCreationPages.size()) {
+ return null;
+ }
+ return (IWizardPage) targetCreationPages.get(i + 1);
+ }
+ if (sourceCreationPages.contains(page)) {
+ if (sourceCreationPages.get(sourceCreationPages.size() - 1) == page) {
+ return (IWizardPage) targetCreationPages.get(0);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public IWizardPage getNextPage(IWizardPage page) {
+ IWizardPage p = getSourceCreationPage(page);
+ if (p != null)
+ return p;
+ p = getTargetCreationPage(page);
+ if (p != null)
+ return p;
+ return super.getNextPage(page);
+ }
+
+ public void clearTargetWizardPages() {
+ // for (Iterator iterator = sourceCreationPages.iterator();
+ // iterator.hasNext();) {
+ // IWizardPage page = (IWizardPage) iterator.next();
+ // if(page != null){
+ // page.dispose();
+ // }
+ // }
+ targetCreationPages.clear();
+ }
+
+ public void removeSourceWIzardPage(IWizardPage page) {
+ sourceCreationPages.remove(page);
+ }
+
+ public void removeTargetWIzardPage(IWizardPage page) {
+ targetCreationPages.remove(page);
+ }
}
\ No newline at end of file
17 years, 5 months
JBoss Tools SVN: r11894 - trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-11-19 21:03:22 -0500 (Wed, 19 Nov 2008)
New Revision: 11894
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
Log:
JBIDE-2760 - null check if the JMX object has no description
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2008-11-20 01:48:57 UTC (rev 11893)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2008-11-20 02:03:22 UTC (rev 11894)
@@ -161,7 +161,8 @@
String type = attrInfo.getType();
nameLabel.setText(attrInfo.getName());
typeLabel.setText(StringUtils.toString(type));
- descriptionText.setText(attrInfo.getDescription());
+ if( attrInfo.getDescription() != null)
+ descriptionText.setText(attrInfo.getDescription());
boolean writable = attrInfo.isWritable();
boolean readable = attrInfo.isReadable();
17 years, 5 months