protected void validateXPathAndUpdateUI()

in taverna-xpath-activity-ui/src/main/java/org/apache/taverna/activities/xpath/ui/config/XPathActivityConfigurationPanel.java [1013:1072]


	protected void validateXPathAndUpdateUI() {
		String candidatePath = tfXPathExpression.getText();
		int xpathStatus = XPathActivityConfigurationBean
				.validateXPath(candidatePath);

		switch (xpathStatus) {
		case XPathActivityConfigurationBean.XPATH_VALID:
			// success: expression is correct
			jlXPathExpressionStatus.setIcon(XPathActivityIcon
					.getIconById(XPathActivityIcon.XPATH_STATUS_OK_ICON));
			jlXPathExpressionStatus
					.setToolTipText("Current XPath expression is well-formed and valid");

			// could allow to execute against example XML, with only condition:
			// XML tree must be populated
			// (that is, there should be something to run the expression
			// against)
			if (xmlTree != null) {
				this.bRunXPath.setEnabled(true);
				this.bRunXPath
						.setToolTipText("<html>Evaluate current XPath expression against the XML document<br>"
								+ "whose structure is shown in the tree view above.</html>");
			} else {
				this.bRunXPath.setEnabled(false);
				this.bRunXPath
						.setToolTipText("<html>No XML document to evaluate the current XPath expression against.<br><br>"
								+ "Paste some example XML into the area in the top-left section of the<br>"
								+ "window, then parse it by clicking on the button with the green arrow<br>"
								+ "in order to test your XPath expression.</html>");
			}
			break;

		case XPathActivityConfigurationBean.XPATH_EMPTY:
			// no XPath expression - can't tell if it is correct + nothing to
			// execute
			jlXPathExpressionStatus.setIcon(XPathActivityIcon
					.getIconById(XPathActivityIcon.XPATH_STATUS_UNKNOWN_ICON));
			jlXPathExpressionStatus
					.setToolTipText("<html>There is no XPath expression to validate.<br><br>"
							+ "<b>Hint:</b> select something in the tree view showing the structure<br>"
							+ "of the XML document that you have pasted (or type the XPath<br>"
							+ "expression manually).</html>");
			this.bRunXPath.setEnabled(false);
			this.bRunXPath.setToolTipText("No XPath expression to execute");
			break;

		case XPathActivityConfigurationBean.XPATH_INVALID:
			// failed to parse the XPath expression: notify of the error
			jlXPathExpressionStatus.setIcon(XPathActivityIcon
					.getIconById(XPathActivityIcon.XPATH_STATUS_ERROR_ICON));
			jlXPathExpressionStatus
					.setToolTipText(getXPathValidationErrorMessage());

			this.bRunXPath.setEnabled(false);
			this.bRunXPath
					.setToolTipText("Cannot execute invalid XPath expression");
			break;
		}

	}