JBoss Tools SVN: r37120 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-12-08 10:55:45 -0500 (Thu, 08 Dec 2011)
New Revision: 37120
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java
Log:
https://issues.jboss.org/browse/JBIDE-10351 : test failure in org.jboss.tools.jsf.vpe.jsf.test
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java 2011-12-08 15:33:38 UTC (rev 37119)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java 2011-12-08 15:55:45 UTC (rev 37120)
@@ -184,9 +184,9 @@
TestUtil.delay();
}
- // wait
- TestUtil.delay(700);
- // wait
+ TestUtil.delay(VpeController.DEFAULT_UPDATE_DELAY_TIME * 2); // ensure that vpe is started to update
+ TestUtil.waitForJobs();
+
assertNotNull(xulRunnerEditor.getSelectedElement());
}
}
14 years
JBoss Tools SVN: r37119 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-12-08 10:33:38 -0500 (Thu, 08 Dec 2011)
New Revision: 37119
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
Log:
JBIDE-10412 - Fix VpeDomMapping to use HashMap in clear(nsIDOMNode except) method.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2011-12-08 15:05:25 UTC (rev 37118)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2011-12-08 15:33:38 UTC (rev 37119)
@@ -57,17 +57,19 @@
}
}
+ /**
+ * Clear maps of source and visual nodes with their mappings,
+ * except for the specified visual node.
+ *
+ * @param except the node with its mapping to remain in visual map.
+ */
public void clear(nsIDOMNode except) {
- Set<Map.Entry<nsIDOMNode, VpeNodeMapping>> entrySet = visualMap.entrySet();
- Iterator<Map.Entry<nsIDOMNode, VpeNodeMapping>> iter = entrySet.iterator();
- while (iter.hasNext()) {
- Map.Entry<nsIDOMNode, VpeNodeMapping> entry = iter.next();
- nsIDOMNode visualNode = entry.getKey();
- if (!visualNode.equals(except)) {
- iter.remove();
- }
+ sourceMap.clear();
+ VpeNodeMapping exceptMapping = visualMap.get(except);
+ visualMap.clear();
+ if (exceptMapping != null) {
+ visualMap.put(except, exceptMapping);
}
- sourceMap.clear();
}
public VpeNodeMapping getNodeMapping(Node node) {
14 years
JBoss Tools SVN: r37118 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: template and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-12-08 10:05:25 -0500 (Thu, 08 Dec 2011)
New Revision: 37118
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java
Log:
https://issues.jboss.org/browse/JBIDE-10315 - VpeDefineContainerTemplate was adjusted.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-12-08 14:42:10 UTC (rev 37117)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-12-08 15:05:25 UTC (rev 37118)
@@ -452,6 +452,10 @@
setTooltip((Element) sourceNode, queryInterface(visualNewNode, nsIDOMElement.class));
}
VpeElementMapping elementMapping = null;
+ /*
+ * Even when 'visualNewNode=null' VpeElementMapping
+ * should be created. It influences on the visual refresh.
+ */
if (onlyOneIncludeStack) {
final VpeElementData data = creationData.getElementData();
if ((sourceNodeProxy != null) && (data != null)
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2011-12-08 14:42:10 UTC (rev 37117)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2011-12-08 15:05:25 UTC (rev 37118)
@@ -34,7 +34,10 @@
public abstract class VpeDefineContainerTemplate extends VpeAbstractTemplate {
private static Set<Node> defineContainer = new HashSet<Node>();
-
+ private static final Pattern CURLY_BRACKET_PATTERN =
+ Pattern.compile("(" + Pattern.quote("#") + "\\{(.+?)\\})+?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Pattern WORD_PATTERN = Pattern.compile("((\\w+)([\\.\\[\\]]*))"); //$NON-NLS-1$
+
@Override
protected void init(Element templateElement) {
children = true;
@@ -43,55 +46,60 @@
}
public VpeCreationData createTemplate(String includedFileName,
- VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- VpeCreationData creationData = null;
- if (includedFileName != null && includedFileName.trim().length() > 0) {
- IFile file = VpeCreatorUtil.getFile(includedFileName, pageContext);
- if (file != null) {
- if (!pageContext.getVisualBuilder().isFileInIncludeStack(file)) {
- registerDefine(pageContext, sourceNode);
- Document document = pageContext.getVisualBuilder()
- .getIncludeDocuments().get(file);
- if (document == null) {
- document = VpeCreatorUtil.getDocumentForRead(file);
- if (document != null)
- pageContext.getVisualBuilder()
- .getIncludeDocuments().put(file, document);
- }
- // Document document =
- // VpeCreatorUtil.getDocumentForRead(file, pageContext);
- if (document != null) {
- creationData = createInclude(document, visualDocument);
- creationData.setData(new TemplateFileInfo(file));
- pageContext.getVisualBuilder().pushIncludeStack(
- new VpeIncludeInfo((Element) sourceNode, file,
- document));
- /*
- * we should add only real node, sourceNode can be a
- * proxy so
- */
- if (sourceNode.getFirstChild() != null) {
- defineContainer.add(sourceNode.getFirstChild()
- .getParentNode());
- }
- return creationData;
- }
- }
- }
- }
+ VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ VpeCreationData creationData = null;
+ if (includedFileName != null && includedFileName.trim().length() > 0) {
+ IFile file = VpeCreatorUtil.getFile(includedFileName, pageContext);
+ if ((file != null) && !pageContext.getVisualBuilder().isFileInIncludeStack(file)) {
+ Document document = pageContext.getVisualBuilder()
+ .getIncludeDocuments().get(file);
+ if (document == null) {
+ document = VpeCreatorUtil.getDocumentForRead(file);
+ }
+ // Document document = VpeCreatorUtil.getDocumentForRead(file, pageContext);
+ if (document != null) {
+ /*
+ * Putting include document
+ */
+ pageContext.getVisualBuilder()
+ .getIncludeDocuments().put(file, document);
+ creationData = createInclude(document, visualDocument);
+ creationData.setData(new TemplateFileInfo(file));
+ /*
+ * Pushing include stack and right after that --
+ * registering <UI:DEFINE> element.
+ */
+ pageContext.getVisualBuilder().pushIncludeStack(
+ new VpeIncludeInfo((Element) sourceNode, file, document));
+ registerDefine(pageContext, sourceNode);
+ /*
+ * we should add only real node, sourceNode can be a proxy,
+ * so there is a trick to get the node:
+ * get the parent of the first child.
+ */
+ if (sourceNode.getFirstChild() != null) {
+ defineContainer.add(sourceNode.getFirstChild().getParentNode());
+ } else {
+ /*
+ * Then it helps to detect DefineContainer in
+ * "isDefineContainer(Node sourceNode)" method.
+ */
+ defineContainer.add(sourceNode);
+ }
+ return creationData;
+ }
+ }
+ }
/*
* Create a stub when creationData is null.
*/
- creationData = createStub(includedFileName, (Element) sourceNode,
- visualDocument);
+ creationData = createStub(includedFileName, (Element) sourceNode,visualDocument);
creationData.setData(null);
return creationData;
}
- private String replacePattern(String origStr, String target,
- String replacement) {
-
+ private String replacePattern(String origStr, String target, String replacement) {
/*
* https://jira.jboss.org/jira/browse/JBIDE-4311
* target string could be null in some case.
@@ -101,11 +109,9 @@
}
StringBuilder sb = new StringBuilder();
- String word = "((\\w+)([\\.\\[\\]]*))"; //$NON-NLS-1$
- Matcher m;
String variable;
String signs;
- m = Pattern.compile(word).matcher(origStr);
+ Matcher m = WORD_PATTERN.matcher(origStr);
// everything must be found here
int endIndex = 0;
@@ -140,172 +146,157 @@
return origStr;
}
- private void updateNodeValue(nsIDOMNode node, Map<String, String> paramsMap) {
- Set<String> keys = paramsMap.keySet();
- if (null != node) {
- String nodeValue = node.getNodeValue();
- String curlyBracketResultPattern = "(" + Pattern.quote("#") //$NON-NLS-1$ //$NON-NLS-2$
- + "\\{(.+?)\\})+?"; //$NON-NLS-1$
- int matcherGroupWithVariable = 2;
+ private void updateNodeValue(nsIDOMNode node, Map<String, String> paramsMap) {
+ Set<String> keys = paramsMap.keySet();
+ if (null != node) {
+ String nodeValue = node.getNodeValue();
+ int matcherGroupWithVariable = 2;
- if ((null != nodeValue) && (!"".equals(nodeValue))) { //$NON-NLS-1$
- for (String key : keys) {
- Matcher curlyBracketMatcher = Pattern.compile(
- curlyBracketResultPattern).matcher(nodeValue);
+ if ((null != nodeValue) && (!"".equals(nodeValue))) { //$NON-NLS-1$
+ for (String key : keys) {
+ Matcher curlyBracketMatcher = CURLY_BRACKET_PATTERN.matcher(nodeValue);
- String replacement = paramsMap.get(key);
- if (replacement.startsWith("#{") //$NON-NLS-1$
- && replacement.endsWith("}")) { //$NON-NLS-1$
- // remove first 2 signs '#{'
- replacement = replacement.substring(2);
- // remove last '}' sign
- replacement = replacement.substring(0, replacement
- .length() - 1);
- }
+ String replacement = paramsMap.get(key);
+ if (replacement.startsWith("#{") //$NON-NLS-1$
+ && replacement.endsWith("}")) { //$NON-NLS-1$
+ // remove first 2 signs '#{'
+ replacement = replacement.substring(2);
+ // remove last '}' sign
+ replacement = replacement.substring(0,
+ replacement.length() - 1);
+ }
- int lastPos = 0;
- StringBuilder sb = new StringBuilder();
- curlyBracketMatcher.reset(nodeValue);
- boolean firstFind = false;
- boolean find = curlyBracketMatcher.find();
- while (find) {
- if (!firstFind) {
- firstFind = true;
+ int lastPos = 0;
+ StringBuilder sb = new StringBuilder();
+ curlyBracketMatcher.reset(nodeValue);
+ boolean firstFind = false;
+ boolean find = curlyBracketMatcher.find();
+ while (find) {
+ if (!firstFind) {
+ firstFind = true;
+ }
+ int start = curlyBracketMatcher.start(matcherGroupWithVariable);
+ int end = curlyBracketMatcher.end(matcherGroupWithVariable);
+ String group = replacePattern(
+ curlyBracketMatcher.group(matcherGroupWithVariable),
+ key, replacement);
+ sb.append(nodeValue.substring(lastPos, start));
+ sb.append(group);
+ lastPos = end;
+ find = curlyBracketMatcher.find();
+ }
+ if (firstFind) {
+ sb.append(nodeValue.substring(lastPos,
+ nodeValue.length()));
+ nodeValue = sb.toString();
+ node.setNodeValue(nodeValue);
+ }
+ }
}
- int start = curlyBracketMatcher
- .start(matcherGroupWithVariable);
- int end = curlyBracketMatcher
- .end(matcherGroupWithVariable);
- String group = replacePattern(curlyBracketMatcher
- .group(matcherGroupWithVariable), key,
- replacement);
- sb.append(nodeValue.substring(lastPos, start));
- sb.append(group);
- lastPos = end;
- find = curlyBracketMatcher.find();
- }
- if (firstFind) {
- sb.append(nodeValue.substring(lastPos, nodeValue
- .length()));
- nodeValue = sb.toString();
- node.setNodeValue(nodeValue);
- }
}
- }
}
- }
private void insertParam(nsIDOMNode node, Map<String, String> paramsMap) {
+ // update current node value
+ updateNodeValue(node, paramsMap);
- // update current node value
- updateNodeValue(node, paramsMap);
+ nsIDOMNamedNodeMap attributes = node.getAttributes();
+ if (null != attributes) {
+ long len = attributes.getLength();
+ for (int i = 0; i < len; i++) {
+ nsIDOMNode item = attributes.item(i);
+ // update attributes node
+ updateNodeValue(item, paramsMap);
+ }
+ }
- nsIDOMNamedNodeMap attributes = node.getAttributes();
- if (null != attributes) {
- long len = attributes.getLength();
- for (int i = 0; i < len; i++) {
- nsIDOMNode item = attributes.item(i);
- // update attributes node
- updateNodeValue(item, paramsMap);
- }
- }
-
- nsIDOMNodeList children = node.getChildNodes();
- if (null != children) {
- long len = children.getLength();
- for (int i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- // update child node
- insertParam(child, paramsMap);
- }
- }
+ nsIDOMNodeList children = node.getChildNodes();
+ if (null != children) {
+ long len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ // update child node
+ insertParam(child, paramsMap);
+ }
+ }
}
@Override
public void validate(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData creationData) {
+ nsIDOMDocument visualDocument, VpeCreationData creationData) {
- Map<String, String> paramsMap = new HashMap<String, String>();
- NodeList sourceChildren = sourceNode.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- Node sourceChild = sourceChildren.item(i);
- if (sourceChild.getNodeType() == Node.ELEMENT_NODE
- && "param".equals(sourceChild.getLocalName())) { //$NON-NLS-1$
- String name = ((Element) sourceChild)
- .getAttribute(HTML.ATTR_NAME);
- String value = ((Element) sourceChild)
- .getAttribute(HTML.ATTR_VALUE);
- paramsMap.put(name, value);
- }
- }
- nsIDOMNode node = creationData.getNode();
- insertParam(node, paramsMap);
+ Map<String, String> paramsMap = new HashMap<String, String>();
+ NodeList sourceChildren = sourceNode.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ Node sourceChild = sourceChildren.item(i);
+ if (sourceChild.getNodeType() == Node.ELEMENT_NODE
+ && "param".equals(sourceChild.getLocalName())) { //$NON-NLS-1$
+ String name = ((Element) sourceChild)
+ .getAttribute(HTML.ATTR_NAME);
+ String value = ((Element) sourceChild)
+ .getAttribute(HTML.ATTR_VALUE);
+ paramsMap.put(name, value);
+ }
+ }
+ nsIDOMNode node = creationData.getNode();
+ insertParam(node, paramsMap);
- TemplateFileInfo templateFileInfo = (TemplateFileInfo) creationData
- .getData();
- if (templateFileInfo != null) {
- pageContext.getVisualBuilder().popIncludeStack();
- }
- defineContainer.remove(sourceNode);
+ TemplateFileInfo templateFileInfo = (TemplateFileInfo) creationData.getData();
+ if (templateFileInfo != null) {
+ pageContext.getVisualBuilder().popIncludeStack();
+ }
+ defineContainer.remove(sourceNode);
}
@Override
public void beforeRemove(VpePageContext pageContext, Node sourceNode,
- nsIDOMNode visualNode, Object data) {
- TemplateFileInfo templateFileInfo = (TemplateFileInfo) data;
- if (templateFileInfo != null && templateFileInfo.templateFile != null) {
- pageContext.getEditPart().getController().getIncludeList()
- .removeIncludeModel(templateFileInfo.templateFile);
- }
+ nsIDOMNode visualNode, Object data) {
+ TemplateFileInfo templateFileInfo = (TemplateFileInfo) data;
+ if (templateFileInfo != null && templateFileInfo.templateFile != null) {
+ pageContext.getEditPart().getController().getIncludeList()
+ .removeIncludeModel(templateFileInfo.templateFile);
+ }
}
- @Override
- public boolean recreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
-
- return true;
- }
-
- private void registerDefine(VpePageContext pageContext, Node defineContainer) {
- VpeTemplate template = null;
- NodeList sourceChildren = defineContainer.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- Node sourceChild = sourceChildren.item(i);
- if (sourceChild.getNodeType() == Node.ELEMENT_NODE
- && "define".equals(sourceChild.getLocalName())) { //$NON-NLS-1$
- if (template == null) {
- VpeTemplateManager templateManager = pageContext
- .getVisualBuilder().getTemplateManager();
- template = templateManager.getTemplate(pageContext,
- (Element) sourceChild, null);
- if (template == null) {
- break;
- }
+ private void registerDefine(VpePageContext pageContext, Node defineContainer) {
+ VpeTemplate template = null;
+ NodeList sourceChildren = defineContainer.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ Node sourceChild = sourceChildren.item(i);
+ if (sourceChild.getNodeType() == Node.ELEMENT_NODE
+ && "define".equals(sourceChild.getLocalName())) { //$NON-NLS-1$
+ if (template == null) {
+ VpeTemplateManager templateManager = pageContext
+ .getVisualBuilder().getTemplateManager();
+ template = templateManager.getTemplate(
+ pageContext, (Element) sourceChild, null);
+ if (template == null) {
+ break;
+ }
+ }
+ pageContext.getVisualBuilder().registerNodes(
+ new VpeElementMapping(sourceChild, null, template, null, null, null));
+ }
}
- pageContext.getVisualBuilder().registerNodes(
- new VpeElementMapping((Element) sourceChild, null, template, null, null));
- }
}
- }
- private VpeCreationData createInclude(Document sourceDocument,
- nsIDOMDocument visualDocument) {
- nsIDOMElement visualNewElement = visualDocument
- .createElement(HTML.TAG_DIV);
- VpeVisualDomBuilder.markIncludeElement(visualNewElement);
- VpeCreationData creationData = new VpeCreationData(visualNewElement);
- VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualNewElement);
- NodeList sourceChildren = sourceDocument.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- childrenInfo.addSourceChild(sourceChildren.item(i));
+ private VpeCreationData createInclude(Document sourceDocument,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement visualNewElement = visualDocument.createElement(HTML.TAG_DIV);
+ VpeVisualDomBuilder.markIncludeElement(visualNewElement);
+ VpeCreationData creationData = new VpeCreationData(visualNewElement);
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualNewElement);
+ NodeList sourceChildren = sourceDocument.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ childrenInfo.addSourceChild(sourceChildren.item(i));
+ }
+ creationData.addChildrenInfo(childrenInfo);
+ return creationData;
}
- creationData.addChildrenInfo(childrenInfo);
- return creationData;
- }
@Override
public boolean containsText() {
@@ -313,67 +304,64 @@
}
public static boolean isDefineContainer(Node sourceNode) {
-
- // FIX https://jira.jboss.org/jira/browse/JBIDE-3187 by sdzmitrovich
- // TODO: it is necessary to refactor facelet templates
- // return defineContainer.contains(sourceNode);
- while (sourceNode != null) {
- if (defineContainer.contains(sourceNode))
- return true;
-
- sourceNode = sourceNode.getParentNode();
- }
-
- return false;
-
+ // FIX https://jira.jboss.org/jira/browse/JBIDE-3187 by sdzmitrovich
+ // TODO: it is necessary to refactor facelet templates
+ // return defineContainer.contains(sourceNode);
+ while (sourceNode != null) {
+ if (defineContainer.contains(sourceNode)) {
+ return true;
+ }
+ sourceNode = sourceNode.getParentNode();
+ }
+ return false;
}
protected VpeCreationData createStub(String fileName,
- Node sourceElement, nsIDOMDocument visualDocument) {
-
- nsIDOMElement container = visualDocument.createElement(HTML.TAG_DIV);
- container.setAttribute("style", "border: 1px dashed #2A7F00"); //$NON-NLS-1$ //$NON-NLS-2$
- VpeVisualDomBuilder.markIncludeElement(container);
+ Node sourceElement, nsIDOMDocument visualDocument) {
- nsIDOMElement title = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement tag = visualDocument.createElement(HTML.TAG_SPAN);
- tag.setAttribute("class", "__any__tag__caption"); //$NON-NLS-1$ //$NON-NLS-2$
- tag.appendChild(visualDocument.createTextNode(sourceElement.getNodeName()));
- title.appendChild(tag);
- if (fileName != null) {
- title.appendChild(visualDocument.createTextNode(fileName));
- }
- container.appendChild(title);
-
- VpeCreationData creationData = new VpeCreationData(container);
+ nsIDOMElement container = visualDocument.createElement(HTML.TAG_DIV);
+ container.setAttribute("style", "border: 1px dashed #2A7F00"); //$NON-NLS-1$ //$NON-NLS-2$
+ VpeVisualDomBuilder.markIncludeElement(container);
- VpeChildrenInfo childrenInfo = new VpeChildrenInfo(container);
- NodeList sourceChildren = sourceElement.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- Node sourceChild = sourceChildren.item(i);
- if (sourceChild.getNodeType() == Node.ELEMENT_NODE
- && "define".equals(sourceChild.getLocalName())) { //$NON-NLS-1$
- childrenInfo.addSourceChild(sourceChild);
- }
- }
- creationData.addChildrenInfo(childrenInfo);
- return creationData;
+ nsIDOMElement title = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement tag = visualDocument.createElement(HTML.TAG_SPAN);
+ tag.setAttribute("class", "__any__tag__caption"); //$NON-NLS-1$ //$NON-NLS-2$
+ tag.appendChild(visualDocument.createTextNode(sourceElement.getNodeName()));
+ title.appendChild(tag);
+ if (fileName != null) {
+ title.appendChild(visualDocument.createTextNode(fileName));
+ }
+ container.appendChild(title);
+
+ VpeCreationData creationData = new VpeCreationData(container);
+
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(container);
+ NodeList sourceChildren = sourceElement.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ Node sourceChild = sourceChildren.item(i);
+ if (sourceChild.getNodeType() == Node.ELEMENT_NODE
+ && "define".equals(sourceChild.getLocalName())) { //$NON-NLS-1$
+ childrenInfo.addSourceChild(sourceChild);
+ }
+ }
+ creationData.addChildrenInfo(childrenInfo);
+ return creationData;
}
static class TemplateFileInfo {
- private IFile templateFile;
+ private IFile templateFile;
- TemplateFileInfo(IFile templateFile) {
- this.templateFile = templateFile;
- }
+ TemplateFileInfo(IFile templateFile) {
+ this.templateFile = templateFile;
+ }
- public IFile getTemplateFile() {
- return templateFile;
- }
+ public IFile getTemplateFile() {
+ return templateFile;
+ }
- public void setTemplateFile(IFile templateFile) {
- this.templateFile = templateFile;
- }
+ public void setTemplateFile(IFile templateFile) {
+ this.templateFile = templateFile;
+ }
}
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java 2011-12-08 14:42:10 UTC (rev 37117)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java 2011-12-08 15:05:25 UTC (rev 37118)
@@ -81,15 +81,13 @@
public boolean isELNode(Node sourceNode) {
boolean rst = false;
if (isInCustomElementsAttributes(sourceNode)) {
- return true;
- }
- if (isAvailableForNode(sourceNode)
+ rst = true;
+ } else if (isAvailableForNode(sourceNode)
|| BundleMapUtil.isInResourcesBundle(pageContext.getBundle(), sourceNode)) {
rst = true;
} else if (Jsf2ResourceUtil.isContainJSFContextPath(sourceNode)) {
rst = true;
- }
- if (Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
+ } else if (Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
// added by Maksim Areshkau, see JBIDE-4812
rst = true;
}
@@ -154,10 +152,16 @@
* @return
*/
protected boolean findForNode(Node sourceNode) {
+ /*
+ * Case 1
+ */
final ResourceReference[] references = getResourceReferences();
if (references == null || references.length == 0) {
return false;
}
+ /*
+ * Case 2
+ */
String textValue = null;
if (sourceNode.getNodeType() == Node.TEXT_NODE) {
textValue = sourceNode.getNodeValue();
@@ -165,6 +169,9 @@
return true;
}
}
+ /*
+ * Case 3
+ */
final NamedNodeMap nodeMap = sourceNode.getAttributes();
if (nodeMap != null) {
for (int i = 0; i < nodeMap.getLength(); i++) {
14 years
JBoss Tools SVN: r37117 - trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-12-08 09:42:10 -0500 (Thu, 08 Dec 2011)
New Revision: 37117
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java
Log:
https://issues.jboss.org/browse/JBIDE-10277
print the exception to console
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2011-12-08 14:37:49 UTC (rev 37116)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2011-12-08 14:42:10 UTC (rev 37117)
@@ -130,6 +130,7 @@
if (ex != null) {
String out = NLS.bind(ConsoleTestMessages.OpenMappingFileTest_mapping_file_for_not_opened_package,
new Object[]{selection, testPackage.getElementName(), ex.getMessage()});
+ ex.printStackTrace();
fail(out);
}
}
14 years
JBoss Tools SVN: r37116 - trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-12-08 09:37:49 -0500 (Thu, 08 Dec 2011)
New Revision: 37116
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Log:
JBIDE-10408 : fix maven archetype property overriding
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-12-08 14:36:47 UTC (rev 37115)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-12-08 14:37:49 UTC (rev 37116)
@@ -95,14 +95,16 @@
//redefine all required properties in project-examples-maven-xxx.xml
Properties defaultRequiredProperties = getRequiredProperties(archetype, archetypeModel.getArchetypeRepository());
Properties properties = new Properties();
- for (Object key : archetypeModel.getArchetypeProperties().keySet()) {
- properties.put(key, archetypeModel.getArchetypeProperties().get(key));
- }
- //Add remaining requiredProperties not defined by default in the example project
for (Object key : defaultRequiredProperties.keySet()) {
properties.put(key, defaultRequiredProperties.get(key));
}
+
+ //Override default required properties with our specific JBoss Tools values
+ for (Object key : archetypeModel.getArchetypeProperties().keySet()) {
+ properties.put(key, archetypeModel.getArchetypeProperties().get(key));
+ }
+
archetype.setProperties(properties);
setArchetype(archetype);
14 years
JBoss Tools SVN: r37115 - branches/jbosstools-3.3.0.M5/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-12-08 09:36:47 -0500 (Thu, 08 Dec 2011)
New Revision: 37115
Modified:
branches/jbosstools-3.3.0.M5/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Log:
JBIDE-10408 : fix maven archetype property overriding
Modified: branches/jbosstools-3.3.0.M5/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
--- branches/jbosstools-3.3.0.M5/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-12-08 14:35:04 UTC (rev 37114)
+++ branches/jbosstools-3.3.0.M5/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-12-08 14:36:47 UTC (rev 37115)
@@ -95,14 +95,16 @@
//redefine all required properties in project-examples-maven-xxx.xml
Properties defaultRequiredProperties = getRequiredProperties(archetype, archetypeModel.getArchetypeRepository());
Properties properties = new Properties();
- for (Object key : archetypeModel.getArchetypeProperties().keySet()) {
- properties.put(key, archetypeModel.getArchetypeProperties().get(key));
- }
- //Add remaining requiredProperties not defined by default in the example project
for (Object key : defaultRequiredProperties.keySet()) {
properties.put(key, defaultRequiredProperties.get(key));
}
+
+ //Override default required properties with our specific JBoss Tools values
+ for (Object key : archetypeModel.getArchetypeProperties().keySet()) {
+ properties.put(key, archetypeModel.getArchetypeProperties().get(key));
+ }
+
archetype.setProperties(properties);
setArchetype(archetype);
14 years
JBoss Tools SVN: r37114 - in trunk/hibernatetools/plugins: org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-12-08 09:35:04 -0500 (Thu, 08 Dec 2011)
New Revision: 37114
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
Log:
https://issues.jboss.org/browse/JBIDE-10277
Fix zip file closed problem which appeared because of redundant reinitialization of class loader
Also there is a problem with orm.xml validation
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2011-12-08 14:34:41 UTC (rev 37113)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2011-12-08 14:35:04 UTC (rev 37114)
@@ -367,7 +367,7 @@
}
if (configXMLFile == null) {
URL url = null;
- reinitClassLoader();
+ //reinitClassLoader();
if (classLoader != null) {
url = classLoader.findResource("hibernate.cfg.xml"); //$NON-NLS-1$
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java 2011-12-08 14:34:41 UTC (rev 37113)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtils.java 2011-12-08 14:35:04 UTC (rev 37114)
@@ -396,9 +396,10 @@
List<Throwable> errors = new ArrayList<Throwable>();
XMLHelper helper = new XMLHelper();
SAXReader saxReader = helper.createSAXReader(configXMLFile.getPath(), errors, entityResolver);
+ saxReader.setValidation(false);
doc = saxReader.read(new InputSource( stream));
if (errors.size() != 0) {
- HibernateConsolePlugin.getDefault().logErrorMessage("invalid configuration", (Throwable)null); //$NON-NLS-1$
+ HibernateConsolePlugin.getDefault().logErrorMessage("invalid configuration", (Throwable[])errors.toArray(new Throwable[0])); //$NON-NLS-1$
}
}
catch (DocumentException e) {
14 years
JBoss Tools SVN: r37112 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal: utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-12-08 08:46:32 -0500 (Thu, 08 Dec 2011)
New Revision: 37112
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java
Log:
[JBIDE-10395] corrected url detection when you click on a link
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java 2011-12-08 13:46:11 UTC (rev 37111)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java 2011-12-08 13:46:32 UTC (rev 37112)
@@ -33,20 +33,21 @@
import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.common.StringUtils;
-import org.jboss.tools.openshift.express.internal.utils.UrlUtils;
/**
* @author André Dietisheim
*/
public class CreationLogDialog extends TitleAreaDialog {
- private static final Pattern HTTP_LINK_REGEX = Pattern.compile("http[^ |\n]+");
-
+ private static final Pattern HTTP_LINK_REGEX = Pattern.compile("(http[^ |\n]+)");
+
private LogEntry[] logEntries;
+ private List<LinkSubstring> linkSubstrings;
public CreationLogDialog(Shell parentShell, LogEntry... logEntries) {
super(parentShell);
this.logEntries = logEntries;
+ this.linkSubstrings = new ArrayList<LinkSubstring>();
}
@Override
@@ -84,8 +85,7 @@
public void handleEvent(Event event) {
try {
String url = getUrl(logText, event);
- if (url != null
- && url.length() > 0) {
+ if (url != null && url.length() > 0) {
BrowserUtil.checkedCreateExternalBrowser(
url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
}
@@ -97,14 +97,12 @@
private String getUrl(StyledText logText, Event event) {
int offset = logText.getOffsetAtLocation(new Point(event.x, event.y));
StyleRange style = logText.getStyleRangeAtOffset(offset);
- if (style == null
+ if (style == null
|| !style.underline) {
return null;
}
- return UrlUtils.getUrl(offset, logText.getText());
+ return CreationLogDialog.this.getUrl(offset);
}
-
-
};
}
@@ -132,18 +130,26 @@
appendLog(logEntry, builder, styles);
}
- private void appendLog(LogEntry logEntry, StringBuilder builder, List<StyleRange> styles) {
+ private void appendLog(LogEntry logEntry, StringBuilder builder,
+ List<StyleRange> styles) {
String log = logEntry.getLog();
- createLinkStyles(log, builder.length(), styles);
+ createLinks(log, builder.length(), styles);
builder.append(log);
builder.append(StringUtils.getLineSeparator());
}
- private void createLinkStyles(String log, int baseIndex, List<StyleRange> styles) {
+ private void createLinks(String log, int baseIndex, List<StyleRange> styles) {
Matcher matcher = HTTP_LINK_REGEX.matcher(log);
- while (matcher.find()) {
- StyleRange linkStyle = createLinkStyleRange(matcher.start() + baseIndex, matcher.end() + baseIndex);
+ while (matcher.find()
+ && matcher.groupCount() == 1) {
+ int linkStart = matcher.start() + baseIndex;
+ int linkStop = matcher.end() + baseIndex;
+ StyleRange linkStyle = createLinkStyleRange(linkStart, linkStop);
styles.add(linkStyle);
+ String url = matcher.group(1);
+ LinkSubstring linkEntry =
+ new LinkSubstring(linkStart, linkStop, url);
+ linkSubstrings.add(linkEntry);
}
}
@@ -204,4 +210,54 @@
}
}
+ /**
+ * Gets the url at the given index within the log. Returns <code>null</code>
+ * if none was found. Looks through the links that were found when parsing
+ * the log.
+ *
+ * @param offset
+ * @return the link
+ *
+ * @see #createLinks
+ */
+ private String getUrl(int offset) {
+ String url = null;
+ for (LinkSubstring linkSubstring : linkSubstrings) {
+ if (offset < linkSubstring.getStopOffset()
+ && offset > linkSubstring.getStartOffset()) {
+ url = linkSubstring.getUrl();
+ break;
+ }
+ }
+ return url;
+ }
+
+ /**
+ * A link within the log text.
+ */
+ private static class LinkSubstring {
+
+ private int startOffset;
+ private int stopOffset;
+ private String url;
+
+ public LinkSubstring(int startOffset, int stopOffset, String url) {
+ this.startOffset = startOffset;
+ this.stopOffset = stopOffset;
+ this.url = url;
+ }
+
+ private int getStartOffset() {
+ return startOffset;
+ }
+
+ private int getStopOffset() {
+ return stopOffset;
+ }
+
+ private String getUrl() {
+ return url;
+ }
+ }
+
}
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java 2011-12-08 13:46:11 UTC (rev 37111)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java 2011-12-08 13:46:32 UTC (rev 37112)
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.utils;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author André Dietisheim
- */
-public class UrlUtils {
-
- private static final int HTTP_SCHEME_MAX_LENGTH = 8;
- private static final char HTTP_SCHEME_START_CHAR = 'h';
- private static final Pattern HTTP_SCHEME_REGEX = Pattern.compile("http[s]{0,1}://");
-
- /**
- * Returns an url that was found in the given text. It starts looking
- * backwards from the given offset within the given string. Returns
- * <code>null</code> if none was found.
- *
- * @param offset
- * starting point to look back in the given text.
- * @param text
- * the text to search for an url
- * @return the url that was found in the text
- */
- public static String getUrl(int offset, String text) {
- int start = getUrlStart(offset, text);
- if (start == -1) {
- return null;
- }
- int stop = getUrlStop(offset, text);
- if (stop == -1) {
- return null;
- }
- return text.substring(start, stop);
-
- }
-
- /**
- * Steps back in the given text until the beginning of the text or an
- * occurrence of http(s):// is found.
- *
- * @param offset the offset to start with stepping backwards
- * @param text the text to search
- * @return the index at which http(s):// was found
- */
- private static int getUrlStart(int offset, String text) {
- for (int i = offset; i > 0; --i) {
- if (text.charAt(i) == HTTP_SCHEME_START_CHAR
- && (i + HTTP_SCHEME_MAX_LENGTH < text.length())) {
- Matcher matcher = HTTP_SCHEME_REGEX.matcher(text.substring(i, i + HTTP_SCHEME_MAX_LENGTH));
- if (matcher.find()) {
- return i;
- }
- }
- }
- return -1;
- }
-
- private static int getUrlStop(int offset, String text) {
- for (int i = offset; i < text.length(); ++i) {
- if (' ' == text.charAt(i)
- || '\n' == text.charAt(i)) {
- return i;
- }
- }
- return -1;
- }
-
-}
14 years
JBoss Tools SVN: r37111 - in branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal: utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-12-08 08:46:11 -0500 (Thu, 08 Dec 2011)
New Revision: 37111
Removed:
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
Modified:
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java
Log:
[JBIDE-10395] corrected url detection when you click on a link
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java 2011-12-08 13:15:14 UTC (rev 37110)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreationLogDialog.java 2011-12-08 13:46:11 UTC (rev 37111)
@@ -33,20 +33,21 @@
import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.common.StringUtils;
-import org.jboss.tools.openshift.express.internal.utils.UrlUtils;
/**
* @author André Dietisheim
*/
public class CreationLogDialog extends TitleAreaDialog {
- private static final Pattern HTTP_LINK_REGEX = Pattern.compile("http[^ |\n]+");
-
+ private static final Pattern HTTP_LINK_REGEX = Pattern.compile("(http[^ |\n]+)");
+
private LogEntry[] logEntries;
+ private List<LinkSubstring> linkSubstrings;
public CreationLogDialog(Shell parentShell, LogEntry... logEntries) {
super(parentShell);
this.logEntries = logEntries;
+ this.linkSubstrings = new ArrayList<LinkSubstring>();
}
@Override
@@ -84,8 +85,7 @@
public void handleEvent(Event event) {
try {
String url = getUrl(logText, event);
- if (url != null
- && url.length() > 0) {
+ if (url != null && url.length() > 0) {
BrowserUtil.checkedCreateExternalBrowser(
url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
}
@@ -97,14 +97,12 @@
private String getUrl(StyledText logText, Event event) {
int offset = logText.getOffsetAtLocation(new Point(event.x, event.y));
StyleRange style = logText.getStyleRangeAtOffset(offset);
- if (style == null
+ if (style == null
|| !style.underline) {
return null;
}
- return UrlUtils.getUrl(offset, logText.getText());
+ return CreationLogDialog.this.getUrl(offset);
}
-
-
};
}
@@ -132,18 +130,26 @@
appendLog(logEntry, builder, styles);
}
- private void appendLog(LogEntry logEntry, StringBuilder builder, List<StyleRange> styles) {
+ private void appendLog(LogEntry logEntry, StringBuilder builder,
+ List<StyleRange> styles) {
String log = logEntry.getLog();
- createLinkStyles(log, builder.length(), styles);
+ createLinks(log, builder.length(), styles);
builder.append(log);
builder.append(StringUtils.getLineSeparator());
}
- private void createLinkStyles(String log, int baseIndex, List<StyleRange> styles) {
+ private void createLinks(String log, int baseIndex, List<StyleRange> styles) {
Matcher matcher = HTTP_LINK_REGEX.matcher(log);
- while (matcher.find()) {
- StyleRange linkStyle = createLinkStyleRange(matcher.start() + baseIndex, matcher.end() + baseIndex);
+ while (matcher.find()
+ && matcher.groupCount() == 1) {
+ int linkStart = matcher.start() + baseIndex;
+ int linkStop = matcher.end() + baseIndex;
+ StyleRange linkStyle = createLinkStyleRange(linkStart, linkStop);
styles.add(linkStyle);
+ String url = matcher.group(1);
+ LinkSubstring linkEntry =
+ new LinkSubstring(linkStart, linkStop, url);
+ linkSubstrings.add(linkEntry);
}
}
@@ -204,4 +210,54 @@
}
}
+ /**
+ * Gets the url at the given index within the log. Returns <code>null</code>
+ * if none was found. Looks through the links that were found when parsing
+ * the log.
+ *
+ * @param offset
+ * @return the link
+ *
+ * @see #createLinks
+ */
+ private String getUrl(int offset) {
+ String url = null;
+ for (LinkSubstring linkSubstring : linkSubstrings) {
+ if (offset < linkSubstring.getStopOffset()
+ && offset > linkSubstring.getStartOffset()) {
+ url = linkSubstring.getUrl();
+ break;
+ }
+ }
+ return url;
+ }
+
+ /**
+ * A link within the log text.
+ */
+ private static class LinkSubstring {
+
+ private int startOffset;
+ private int stopOffset;
+ private String url;
+
+ public LinkSubstring(int startOffset, int stopOffset, String url) {
+ this.startOffset = startOffset;
+ this.stopOffset = stopOffset;
+ this.url = url;
+ }
+
+ private int getStartOffset() {
+ return startOffset;
+ }
+
+ private int getStopOffset() {
+ return stopOffset;
+ }
+
+ private String getUrl() {
+ return url;
+ }
+ }
+
}
Deleted: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java 2011-12-08 13:15:14 UTC (rev 37110)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java 2011-12-08 13:46:11 UTC (rev 37111)
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.utils;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author André Dietisheim
- */
-public class UrlUtils {
-
- private static final int HTTP_SCHEME_MAX_LENGTH = 8;
- private static final char HTTP_SCHEME_START_CHAR = 'h';
- private static final Pattern HTTP_SCHEME_REGEX = Pattern.compile("http[s]{0,1}://");
-
- /**
- * Returns an url that was found in the given text. It starts looking
- * backwards from the given offset within the given string. Returns
- * <code>null</code> if none was found.
- *
- * @param offset
- * starting point to look back in the given text.
- * @param text
- * the text to search for an url
- * @return the url that was found in the text
- */
- public static String getUrl(int offset, String text) {
- int start = getUrlStart(offset, text);
- if (start == -1) {
- return null;
- }
- int stop = getUrlStop(offset, text);
- if (stop == -1) {
- return null;
- }
- return text.substring(start, stop);
-
- }
-
- /**
- * Steps back in the given text until the beginning of the text or an
- * occurrence of http(s):// is found.
- *
- * @param offset the offset to start with stepping backwards
- * @param text the text to search
- * @return the index at which http(s):// was found
- */
- private static int getUrlStart(int offset, String text) {
- for (int i = offset; i > 0; --i) {
- if (text.charAt(i) == HTTP_SCHEME_START_CHAR
- && (i + HTTP_SCHEME_MAX_LENGTH < text.length())) {
- Matcher matcher = HTTP_SCHEME_REGEX.matcher(text.substring(i, i + HTTP_SCHEME_MAX_LENGTH));
- if (matcher.find()) {
- return i;
- }
- }
- }
- return -1;
- }
-
- private static int getUrlStop(int offset, String text) {
- for (int i = offset; i < text.length(); ++i) {
- if (' ' == text.charAt(i)
- || '\n' == text.charAt(i)) {
- return i;
- }
- }
- return -1;
- }
-
-}
14 years