diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse')
20 files changed, 0 insertions, 2344 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/IJSPCoreConstants.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/IJSPCoreConstants.java deleted file mode 100644 index 0a7f05376..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/IJSPCoreConstants.java +++ /dev/null @@ -1,279 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core; - -/** - * @author mengbo - * @version 1.5 - */ -public interface IJSPCoreConstants -{ - /** - * JSP tag name - */ - final static public String TAG_ATTRIBUTE = "attribute"; - - /** - * JSP tag name - */ - final static public String TAG_BODY = "body"; - - /** - * JSP tag name - */ - final static public String TAG_ELEMENT = "element"; - - /** - * JSP tag name - */ - final static public String TAG_EXPRESSION = "expression"; - - /** - * JSP tag name - */ - final static public String TAG_DECLARATION = "declaration"; - - /** - * JSP tag name - */ - final static public String TAG_DIRECTIVE_INCLUDE = "directive.include"; - - /** - * JSP tag name - */ - final static public String TAG_DIRECTIVE_PAGE = "directive.page"; - - /** - * JSP tag name - */ - final static public String TAG_DIRECTIVE_TAGLIB = "directive.taglib"; - - /** - * JSP tag name - */ - final static public String TAG_DOBODY = "doBody"; - - /** - * JSP tag name - */ - final static public String TAG_FORWARD = "forward"; - - /** - * JSP tag name - */ - final static public String TAG_GETPROPERTY = "getProperty"; - - /** - * JSP tag name - */ - final static public String TAG_INCLUDE = "include"; - - /** - * JSP tag name - */ - final static public String TAG_INVOKE = "invoke"; - - /** - * JSP tag name - */ - final static public String TAG_OUTPUT = "output"; - - /** - * JSP tag name - */ - final static public String TAG_PLUGIN = "plugin"; - - /** - * JSP tag name - */ - final static public String TAG_ROOT = "root"; - - /** - * JSP tag name - */ - final static public String TAG_SCRIPTLET = "scriptlet"; - - /** - * JSP tag name - */ - final static public String TAG_SETPROPERTY = "setProperty"; - - /** - * JSP tag name - */ - final static public String TAG_TEXT = "text"; - - /** - * JSP tag name - */ - final static public String TAG_USEBEAN = "useBean"; - - /** - * JSP tag name - */ - final static public String TAG_LEADING_DIRECTIVE = "directive."; - - /** - * JSP tag attribute name - */ - final static public String ATTR_ALIGN = "align"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_ARCHIVE = "archive"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_BEANNAME = "beanName"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_CLASS = "class"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_CODE = "code"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_CODEBASE = "codebase"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_DOCTYPEROOTELEMENT = "doctype-root-element"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_DOCTYPESYSTEM = "doctype-system"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_DOCTYPEPUBLIC = "doctype-public"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_FILE = "file"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_FRAGMENT = "fragment"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_HEIGHT = "height"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_HSPACE = "hspace"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_ID = "id"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_IEPLUGINURL = "iepluginurl"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_JREVERSION = "jreversion"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_NAME = "name"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_NSPLUGINURL = "nspluginurl"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_OMITXMLDECLARATION = "omit-xml-declaration"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_PAGE = "page"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_PROPERTY = "property"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_SCOPE = "scope"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_TRIM = "trim"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_TYPE = "type"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_URI = "uri"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_VALUE = "value"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_VAR = "var"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_VARREADER = "varReader"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_VERSION = "version"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_XMLNSJSP = "xmlns:jsp"; - - /** - * JSP tag attribute name - */ - final static public String ATTR_XMLNSTAGLIBPREFIX = "xmlns:taglibPrefix"; -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/JSPCorePlugin.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/JSPCorePlugin.java deleted file mode 100644 index c31be115b..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/JSPCorePlugin.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class JSPCorePlugin extends Plugin { - // The shared instance. - private static JSPCorePlugin plugin; - - // Resource bundle. - private ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public JSPCorePlugin() { - super(); - plugin = this; - try { - resourceBundle = ResourceBundle - .getBundle("org.eclipse.jst.pagedesigner.jsp.core.JSPCorePluginResources"); - } catch (MissingResourceException x) { - resourceBundle = null; - } - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - } - - /** - * Returns the shared instance. - * @return the default plugin instance - */ - public static JSPCorePlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, or 'key' if not - * found. - * @param key - * @return the string for key or 'key' if not found in the default resource bundle - */ - public static String getResourceString(String key) { - ResourceBundle bundle = JSPCorePlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - * @return the resource bundle - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } - - /** - * @return the plugin id - */ - public static String getPluginId() { - return getDefault().getBundle().getSymbolicName(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/ListenerList.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/ListenerList.java deleted file mode 100644 index 9596f97d8..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/ListenerList.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core; - -/** - * Local version of org.eclipse.jface.util.ListenerList (modified) - * @author mengbo - * @version 1.5 - */ -public class ListenerList { - /** - * The current number of listeners. Maintains invariant: 0 <= fSize <= - * listeners.length. - */ - private int _size; - - /** - * The list of listeners. Initially <code>null</code> but initialized to - * an array of size capacity the first time a listener is added. Maintains - * invariant: listeners != null if and only if fSize != 0 - */ - private Object[] _listeners = null; - - /** - * The empty array singleton instance, returned by getListeners() when size == - * 0. - */ - private static final Object[] EmptyArray = new Object[0]; - - /** - * Creates a listener list with the given initial capacity. - * - * @param capacity - * the number of listeners which this list can initially accept - * without growing its internal representation; must be at least - * 1 - */ - public ListenerList(int capacity) { - if (capacity < 1) { - throw new IllegalArgumentException(); - } - _listeners = new Object[capacity]; - _size = 0; - } - - /** - * Adds a listener to the list. Has no effect if an identical listener is - * already registered. - * - * @param listener - * a listener - */ - public synchronized void add(Object listener) { - if (listener == null) { - throw new IllegalArgumentException(); - } - // check for duplicates using identity - for (int i = 0; i < _size; ++i) { - if (_listeners[i] == listener) { - return; - } - } - // grow array if necessary - if (_size == _listeners.length) { - Object[] temp = new Object[(_size * 2) + 1]; - System.arraycopy(_listeners, 0, temp, 0, _size); - _listeners = temp; - } - _listeners[_size++] = listener; - } - - /** - * Returns an array containing all the registered listeners. The resulting - * array is unaffected by subsequent adds or removes. If there are no - * listeners registered, the result is an empty array singleton instance (no - * garbage is created). Use this method when notifying listeners, so that - * any modifications to the listener list during the notification will have - * no effect on the notification itself. - * @return the array of registered listeners - */ - public synchronized Object[] getListeners() { - if (_size == 0) { - return EmptyArray; - } - Object[] result = new Object[_size]; - System.arraycopy(_listeners, 0, result, 0, _size); - return result; - } - - /** - * Removes a listener from the list. Has no effect if an identical listener - * was not already registered. - * - * @param listener - * a listener - */ - public synchronized void remove(Object listener) { - if (listener == null) { - throw new IllegalArgumentException(); - } - - for (int i = 0; i < _size; ++i) { - if (_listeners[i] == listener) { - if (--_size == 0) { - _listeners = new Object[1]; - } else { - if (i < _size) { - _listeners[i] = _listeners[_size]; - } - _listeners[_size] = null; - } - return; - } - } - } - - /** - * Removes all the listeners from the list. - */ - public void removeAll() { - _listeners = new Object[0]; - _size = 0; - } - - /** - * Returns the number of registered listeners - * - * @return the number of registered listeners - */ - public int size() { - return _size; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/el/ELParser.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/el/ELParser.java deleted file mode 100644 index 9c3ee7f64..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/el/ELParser.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.el; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.el.ComplexValue; -import org.apache.commons.el.NamedValue; - -/** - * - * @author mengbo - * @version 1.5 - */ -public class ELParser { - private String _jsfExpression; - - private List _expressionList; - - /** - * @param expression - * - */ - public ELParser(String expression) { - super(); - _jsfExpression = expression; - init(); - } - - /** - * - */ - private void init() { - Object parsedExpression = JSFELParserHelper - .parseExpression(_jsfExpression); - - if (parsedExpression instanceof ComplexValue) { - _expressionList = new ArrayList(); - _expressionList.add(((ComplexValue) parsedExpression).getPrefix()); - _expressionList.addAll(((ComplexValue) parsedExpression) - .getSuffixes()); - } else if (parsedExpression instanceof NamedValue) { - _expressionList = new ArrayList(); - _expressionList.add(parsedExpression); - } - - } - - /** - * @return the expression elements of null if none - */ - public Object[] getElements() { - if (_expressionList == null) { - return null; - } - - return _expressionList.toArray(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/el/JSFELParserHelper.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/el/JSFELParserHelper.java deleted file mode 100644 index 296abe696..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/el/JSFELParserHelper.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.el; - -import java.io.StringReader; - -import org.apache.commons.el.Expression; -import org.apache.commons.el.ExpressionString; -import org.apache.commons.el.parser.ELParser; -import org.apache.commons.el.parser.ParseException; - -/** - * Utility class to implement support functionality to "morph" JSP EL into JSF - * EL - * - * @author mengbo - * @version 1.5 - */ -public final class JSFELParserHelper { - /** - * an EL left brace - */ - public static String JSF_EL_LEFT_BRACE = "#{"; - - /** - * an EL right brace - */ - public static String JSF_EL_RIGHT_BRACE = "}"; - - private JSFELParserHelper() { - // util class, do not instantiate - } - - /** - * Gets the parsed form of the given expression string. Returns either an - * Expression or ExpressionString. - * @param expressionString - * @return the result of parsing expressionString - */ - public static Object parseExpression(String expressionString) { - expressionString = toJspElExpression(expressionString); - - ELParser parser = new ELParser(new StringReader(expressionString)); - try { - Object expression = parser.ExpressionString(); - if (!(expression instanceof Expression) - && !(expression instanceof ExpressionString)) { - return null; - } - - return expression; - } catch (ParseException e) { - - // String msg = "Invalid expression: '" + expressionString + "'"; - // log.debug(msg, e); - // throw new ReferenceSyntaxException(msg, e); - } - return null; - } - - /** - * @param expressionString - * @return true if the expression is 'valid' - */ - public static boolean isValidEL(String expressionString) { - if (expressionString == null || expressionString.length() == 0) { - return false; - } - - return expressionString.startsWith(JSF_EL_LEFT_BRACE) - && expressionString.endsWith(JSF_EL_RIGHT_BRACE); - } - - /** - * @param expressionString - * @return expressionString with the left and right braces removed - * or the original string if isValidEL(expression) == false - */ - public static String trimELBrace(String expressionString) { - if (!isValidEL(expressionString)) { - return expressionString; - } - String trimedExpression = null; - - trimedExpression = expressionString.substring(JSF_EL_LEFT_BRACE - .length(), expressionString.length() - - JSF_EL_RIGHT_BRACE.length()); - - return trimedExpression; - } - - /** - * Convert ValueBinding syntax #{ } to JSP EL syntax ${ } - * - * @param expressionString - * <code>ValueBinding</code> reference expression - * - * @return JSP EL compatible expression - */ - public static String toJspElExpression(String expressionString) { - StringBuffer sb = new StringBuffer(expressionString.length()); - int remainsPos = 0; - - for (int posOpenBrace = expressionString.indexOf('{'); posOpenBrace >= 0; posOpenBrace = expressionString - .indexOf('{', remainsPos)) { - if (posOpenBrace > 0) { - if (posOpenBrace - 1 > remainsPos) - sb.append(expressionString.substring(remainsPos, - posOpenBrace - 1)); - - if (expressionString.charAt(posOpenBrace - 1) == '$') { - sb.append("${'${'}"); - remainsPos = posOpenBrace + 1; - continue; - } else if (expressionString.charAt(posOpenBrace - 1) == '#') { - // TODO: should use \\ as escape for \ always, not just when - // before #{ - // allow use of '\' as escape symbol for #{ (for - // compatibility with Sun's extended implementation) - /* - * if (isEscaped(expressionString, posOpenBrace - 1)) { - * escapes: { for (int i = sb.length() - 1; i >= 0; i--) { - * if (sb.charAt(i) != '\\') { sb.setLength( sb.length() - - * (sb.length() - i) / 2); break escapes; } } - * sb.setLength(sb.length() / 2); } sb.append("#{"); } else { - */ - sb.append("${"); - int posCloseBrace = indexOfMatchingClosingBrace( - expressionString, posOpenBrace); - sb.append(expressionString.substring(posOpenBrace + 1, - posCloseBrace + 1)); - remainsPos = posCloseBrace + 1; - continue; - // } - } else { - if (posOpenBrace > remainsPos) - sb.append(expressionString.charAt(posOpenBrace - 1)); - } - } - - // Standalone brace - sb.append('{'); - remainsPos = posOpenBrace + 1; - } - - sb.append(expressionString.substring(remainsPos)); - - // Create a new String to shrink mem size since we are caching - return new String(sb.toString()); - } - - private static int findQuote(String expressionString, int start) { - int indexofSingleQuote = expressionString.indexOf('\'', start); - int indexofDoubleQuote = expressionString.indexOf('"', start); - return minIndex(indexofSingleQuote, indexofDoubleQuote); - } - - /** - * Return the index of the matching closing brace, skipping over quoted text - * - * @param expressionString - * string to search - * @param indexofOpeningBrace - * the location of opening brace to match - * - * @return the index of the matching closing brace - * - * @throws ReferenceSyntaxException - * if matching brace cannot be found - */ - private static int indexOfMatchingClosingBrace(String expressionString, - int indexofOpeningBrace) { - int len = expressionString.length(); - int i = indexofOpeningBrace + 1; - - // Loop through quoted strings - for (;;) { - if (i >= len) { - throw new IllegalStateException( - "Missing closing brace. Expression: '" - + expressionString + "'"); - } - - int indexofClosingBrace = expressionString.indexOf('}', i); - i = minIndex(indexofClosingBrace, findQuote(expressionString, i)); - - if (i < 0) { - // No delimiter found - throw new IllegalStateException( - "Missing closing brace. Expression: '" - + expressionString + "'"); - } - - // 1. If quoted literal, find closing quote - if (i != indexofClosingBrace) { - i = indexOfMatchingClosingQuote(expressionString, i) + 1; - if (i == 0) { - // Note: if no match, i==0 because -1 + 1 = 0 - throw new IllegalStateException( - "Missing closing quote. Expression: '" - + expressionString + "'"); - } - } else { - // Closing brace - return i; - } - } - } - - /** - * Returns the index of the matching closing quote, skipping over escaped - * quotes - * - * @param expressionString - * string to scan - * @param indexOfOpeningQuote - * start from this position in the string - * @return -1 if no match, the index of closing quote otherwise - */ - private static int indexOfMatchingClosingQuote(String expressionString, - int indexOfOpeningQuote) { - char quote = expressionString.charAt(indexOfOpeningQuote); - for (int i = expressionString.indexOf(quote, indexOfOpeningQuote + 1); i >= 0; i = expressionString - .indexOf(quote, i + 1)) { - if (!isEscaped(expressionString, i)) { - return i; - } - } - - // No matching quote found - return -1; - } - - private static boolean isEscaped(String expressionString, int i) { - int escapeCharCount = 0; - while ((--i >= 0) && (expressionString.charAt(i) == '\\')) { - escapeCharCount++; - } - - return (escapeCharCount % 2) != 0; - } - - /** - * Returns the minimum index >= 0, if any - * - * <p> - * Use to find the first of two characters in a string:<br> - * <code>minIndex(s.indexOf('/'), indexOf('\'))</code> - * </p> - * @param a - * @param b - * @return the minimum index >= 0, if any - * - */ - public static int minIndex(int a, int b) { - return (a < 0) ? b : (b < 0) ? a : (a < b) ? a : b; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/JSPContentModelMetaDataTranslator.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/JSPContentModelMetaDataTranslator.java deleted file mode 100644 index d3b9c8dbc..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/JSPContentModelMetaDataTranslator.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are 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: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.metadata; - -import org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataTranslator; -import org.eclipse.wst.html.core.internal.contentmodel.JSPCMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; - -/** - * Translates the JSP CMDocument to standard metadata model entities and traits - */ -public class JSPContentModelMetaDataTranslator extends AbstractTagLibDomainContentModelMetaDataTranslator implements IMetaDataTranslator { - - public void translate(final IMetaDataModelMergeAssistant assistant) { - setAssistant(assistant); - CMDocument doc = getSourceModel(); - if (doc!= null && doc instanceof JSPCMDocument){ - doTranslate(doc); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator#getURIDescription() - */ - protected String getURIDescription() { - return "JSP Tags"; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator#getURIDisplayLabel() - */ - protected String getURIDisplayLabel() { - return "JSP"; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/TaglibMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/TaglibMetaDataLocator.java deleted file mode 100644 index 78c7802e8..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/TaglibMetaDataLocator.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are 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: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.metadata; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.common.metadata.internal.AbstractMetaDataLocator; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.IPathSensitiveMetaDataLocator; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD; -import org.eclipse.jst.jsp.core.taglib.ITaglibRecord; -import org.eclipse.jst.jsp.core.taglib.TaglibIndex; -import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocumentFactory; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMDocType; - -/** - * Locator of tag library meta data - * - */ -public class TaglibMetaDataLocator extends AbstractMetaDataLocator implements IPathSensitiveMetaDataLocator{ - //project must be set to the current project context during locate only... should not be used when noifying observers - private IProject project; - private TaglibMetaDataSource source; - - /** - * Constructor - */ - public TaglibMetaDataLocator(){ - super(); - } - - public List/*<IMetaDataModelProvider>*/ locateMetaDataModelProviders(String uri) { - List ret = new ArrayList(); - CMDocument doc = null; - - if (uri == null){ - return ret; - } - else if (uri.equalsIgnoreCase(CMDocType.HTML_DOC_TYPE)){ - doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE); - } - else if (uri.equalsIgnoreCase(CMDocType.JSP11_DOC_TYPE)){ - doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.JSP11_DOC_TYPE); - } - else if (uri.equalsIgnoreCase(CMDocType.JSP12_DOC_TYPE)){ - doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.JSP12_DOC_TYPE); - } - else if (uri.equalsIgnoreCase(CMDocType.JSP20_DOC_TYPE)){ - doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.JSP20_DOC_TYPE); - } - else if (project != null ){//TLD - CMDocumentFactoryTLD factory = new CMDocumentFactoryTLD(); - ITaglibRecord[] tldRecs = TaglibIndex.getAvailableTaglibRecords(project.getFullPath()); - ITaglibRecord tldRec = findTLD(tldRecs, uri); - if (tldRec != null) - doc = factory.createCMDocument(tldRec); - } - - if (doc != null){ - source = new TaglibMetaDataSource(doc); - ret.add(source); - } - - return ret; - } - - private ITaglibRecord findTLD(ITaglibRecord[] tldRecs, String uri) { - for (int i=0;i<tldRecs.length;i++){ - ITaglibRecord tld = tldRecs[i]; - if (uri.equals(tld.getDescriptor().getURI())) - return tld; - } - return null; - } - - public void startLocating() { -// TaglibIndex.addTaglibIndexListener(this); - } - public void stopLocating() { -// TaglibIndex.removeTaglibIndexListener(this);//non-api call.... danger - } - - //not currently listening, so will not be called -// public void indexChanged(ITaglibDescriptor event) { -// if (event.getURI() != null && event.getURI().equals(uri)){ -// if (!_notificationEventOccuring){ -// _notificationEventOccuring = true; -// int type = adaptTagLibEvent(event); -// IMetaDataChangeNotificationEvent mdEvent = new MetaDataChangeNotificationEvent(this, uri, type); -// fireEvent(mdEvent); -// _notificationEventOccuring = false; -// } -// } -// } - -// private int adaptTagLibEvent(ITaglibRecordEvent event) { -// switch (event.getType()){ -// case ITaglibRecordEvent.ADDED: -// return IMetaDataChangeNotificationEvent.ADDED; -// case ITaglibRecordEvent.REMOVED: -// return IMetaDataChangeNotificationEvent.REMOVED; -// default: -// return IMetaDataChangeNotificationEvent.CHANGED; -// } -// } - -// private void fireEvent(final IMetaDataChangeNotificationEvent event) { -// SafeRunnable.run(new ISafeRunnable(){ -// -// public void handleException(Throwable exception) { -// // TODO Auto-generated method stub -// } -// -// public void run() throws Exception { -// Iterator it = getObservers().iterator(); -// while (it.hasNext()){ -// IMetaDataObserver observer = (IMetaDataObserver)it.next(); -// observer.notifyMetadataChanged(event); -// } -// } -// -// }); -// -// } - - public void setProjectContext(IProject project) { - this.project = project; - } - - private class TaglibMetaDataSource implements IMetaDataSourceModelProvider{ - - private CMDocument doc; - private IMetaDataLocator locator; - - TaglibMetaDataSource(CMDocument doc){ - super(); - this.doc = doc; - } - - public Object getSourceModel() { - return doc; - } - - public IMetaDataLocator getLocator() { - return locator; - } - - public void setLocator(IMetaDataLocator locator) { - this.locator = locator; - } - - public Object getAdapter(Class klass) { - return null; - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/TaglibMetaDataTLDTranslator.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/TaglibMetaDataTLDTranslator.java deleted file mode 100644 index a438b3e53..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/metadata/TaglibMetaDataTLDTranslator.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are 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: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.metadata; - -import org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataTranslator; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; - -/** - * Translates a TLD CMDocument to standard metadata model entities and traits - * - */ -public class TaglibMetaDataTLDTranslator extends AbstractTagLibDomainContentModelMetaDataTranslator implements IMetaDataTranslator { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataTranslator#translate(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant) - */ - public void translate(final IMetaDataModelMergeAssistant assistant) { - setAssistant(assistant); - CMDocument doc = getSourceModel(); - if (doc != null && doc instanceof TLDDocument){ - doTranslate(doc); - - } - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.AbstractTagLibDomainContentModelMetaDataTranslator#getURIDefaultPrefix() - */ - protected String getURIDefaultPrefix(){ - return getTLDDocument().getShortname(); - } - - /** - * @param tag - * @return the tag.getDisplayName() if available - */ - protected String getTagDisplayLabel(CMElementDeclaration tag){ - String label = ((TLDElementDeclaration)tag).getDisplayName(); - if (label == null) - label = super.getTagDisplayName(tag); - return label; - } - - /** - * @param tag - * @return the tag.getDescription() if available - */ - protected String getTagDescription(CMElementDeclaration tag){ - String desc = ((TLDElementDeclaration)tag).getDescription(); - if (desc == null) - desc = super.getTagDescription(tag); - return desc; - } - - /** - * @param tag - * @return the tag.getSmallIcon() if available - */ - protected String getTagSmallIcon(CMElementDeclaration tag){ - String smallIcon = ((TLDElementDeclaration)tag).getSmallIcon(); - if (smallIcon == null) - smallIcon = super.getTagSmallIcon(tag); - return smallIcon; - } - - /** - * @param tag - * @return the tag.getLargeIcon() if available - */ - protected String getTagLargeIcon(CMElementDeclaration tag){ - String largeIcon = ((TLDElementDeclaration)tag).getLargeIcon(); - if (largeIcon == null) - largeIcon = super.getTagLargeIcon(tag); - return largeIcon; - } - - /** - * @return the tag.getDescription() if available - */ - protected String getURIDescription() { - return getTLDDocument().getDescription(); - } - - /** - * @return the tag.getDisplayName() - */ - protected String getURIDisplayLabel() { - return getTLDDocument().getDisplayName(); - } - - /** - * @return the tld document for the source model - */ - protected TLDDocument getTLDDocument(){ - return (TLDDocument)getSourceModel(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter.java deleted file mode 100644 index ebd93fe44..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jst.pagedesigner.jsp.core.ListenerList; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IChangeListener; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IDocumentPageVariableAdapter; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * This adapter will be adapted on the JSP document. - * - * @author mengbo - * @version 1.5 - */ -public class DocumentPageVariableAdapter implements - IDocumentPageVariableAdapter { - private IDOMDocument _document; - - private ListenerList _changeListeners = new ListenerList(2); - - private List _variableInfos = new ArrayList(); - - private boolean _readingInfo = false; - - /** - * @param doc - * - */ - public DocumentPageVariableAdapter(IDOMDocument doc) { - super(); - this._document = doc; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider#getBeanInfos() - */ - public IVariableInfo[] getBeanInfos() { - IVariableInfo[] ret = new IVariableInfo[_variableInfos.size()]; - return (IVariableInfo[]) _variableInfos.toArray(ret); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider#addChangeListener(org.eclipse.jst.pagedesigner.jsp.core.pagevar.IChangeListener) - */ - public void addChangeListener(IChangeListener listener) { - this.reReadInfo(); - _changeListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider#removeChangeListener(org.eclipse.jst.pagedesigner.jsp.core.pagevar.IChangeListener) - */ - public void removeChangeListener(IChangeListener listener) { - _changeListeners.remove(listener); - } - - /** - * fire change events on all listeners - */ - protected void fireChanged() { - Object[] listeners = _changeListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - IChangeListener l = (IChangeListener) listeners[i]; - l.changed(); - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.internal.provisional.INodeAdapter#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object type) { - return IDocumentPageVariableAdapter.class.equals(type); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.internal.provisional.INodeAdapter#notifyChanged(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier, - * int, java.lang.Object, java.lang.Object, java.lang.Object, int) - */ - public void notifyChanged(INodeNotifier notifier, int eventType, - Object changedFeature, Object oldValue, Object newValue, int pos) { - switch (eventType) { - case INodeNotifier.STRUCTURE_CHANGED: - case INodeNotifier.CONTENT_CHANGED: - case INodeNotifier.CHANGE: - refresh(); - break; - default: - // skip. Ignore other kinds of change. - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider#refresh() - */ - public void refresh() { - reReadInfo(); - } - - /** - * re-read page variable info - */ - protected void reReadInfo() { - if (this._readingInfo) { - return; - } - try { - List oldInfo = this._variableInfos; - this._variableInfos = new ArrayList(); - readNode(_document); - if (!isSame(oldInfo, this._variableInfos)) { - fireChanged(); - } - } finally { - this._readingInfo = false; - } - } - - /** - * compare two variable info list. - * - * @param oldInfo - * @param list - * @return true if same. - */ - private boolean isSame(List oldInfo, List list) { - if (oldInfo.size() != list.size()) { - return false; - } - for (int i = 0, size = oldInfo.size(); i < size; i++) { - IVariableInfo info1 = (IVariableInfo) oldInfo.get(i); - IVariableInfo info2 = (IVariableInfo) list.get(i); - if (info1 == null) { - return false;// should not happen - } - if (!info1.equals(info2)) { - return false; - } - } - return true; - } - - /** - * recursively read all element, and see whether they have - * IPageVariableAdapter, and then get variable info. - * - * @param element - */ - private void readNode(Node node) { - if (node instanceof INodeNotifier && node instanceof Element) { - Element element = (Element) node; - Object obj = ((INodeNotifier) element) - .getAdapterFor(IPageVariableAdapter.class); - if (obj instanceof IPageVariableAdapter) { - IPageVariableAdapter adapter = (IPageVariableAdapter) obj; - if (adapter.supportMultipleVariable(element)) { - List infos = ((IPageVariableAdapter) obj) - .getVariableInfos(element); - if (infos != null) { - this._variableInfos.addAll(infos); - } - } else { - // hope not doing addAll could improve some performance. - IVariableInfo info = adapter.getVariableInfo(element); - if (info != null) { - this._variableInfos.add(info); - } - } - } - } - - NodeList childNodes = node.getChildNodes(); - if (childNodes != null) { - for (int i = 0, length = childNodes.getLength(); i < length; i++) { - Node childNode = childNodes.item(i); - readNode(childNode); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/PageVariableAdapter.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/PageVariableAdapter.java deleted file mode 100644 index 40e01b5ab..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/PageVariableAdapter.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IDocumentPageVariableAdapter; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Element; - -/** - * @author mengbo - * @version 1.5 - */ -public class PageVariableAdapter implements IPageVariableAdapter { - static final PageVariableAdapter _instance = new PageVariableAdapter(); - - /** - * @return the singleton instance - */ - public static PageVariableAdapter getInstance() { - return _instance; - } - - /** - * no external instatiation - */ - private PageVariableAdapter() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.internal.provisional.INodeAdapter#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object type) { - return IPageVariableAdapter.class.equals(type); - } - - private IDocumentPageVariableAdapter getDocumentAdapter( - INodeNotifier notifier) { - if (notifier instanceof IDOMNode) { - IDOMModel model = ((IDOMNode) notifier).getModel(); - if (model != null) { - IDOMDocument document = model.getDocument(); - if (document != null) { - return (IDocumentPageVariableAdapter) document - .getAdapterFor(IDocumentPageVariableAdapter.class); - } - } - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.internal.provisional.INodeAdapter#notifyChanged(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier, - * int, java.lang.Object, java.lang.Object, java.lang.Object, int) - */ - public void notifyChanged(INodeNotifier notifier, int eventType, - Object changedFeature, Object oldValue, Object newValue, int pos) { - IDocumentPageVariableAdapter docadapter = getDocumentAdapter(notifier); - - switch (eventType) { - case INodeNotifier.STRUCTURE_CHANGED: - docadapter.refresh(); - break; - case INodeNotifier.CONTENT_CHANGED: - case INodeNotifier.CHANGE: - // only this node changed, only refresh if this node is page - // variable node - if (notifier instanceof Element - && supportVariableInfo((Element) notifier)) { - docadapter.refresh(); - } - break; - default: - // skip. Ignore other kinds of change. - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter#supportMultipleVariable(org.w3c.dom.Element) - */ - public boolean supportMultipleVariable(Element element) { - return false; - } - - /** - * @param element - * @return - */ - private boolean supportVariableInfo(Element element) { - return PageVariableAdatperRegistry.getInstance().getTagVarDescriptor( - element) != null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter#getVariableInfo(org.w3c.dom.Element) - */ - public IVariableInfo getVariableInfo(Element element) { - TagVarDescriptor desc = PageVariableAdatperRegistry.getInstance() - .getTagVarDescriptor(element); - if (desc == null) { - return null; - } - String name; - if (desc.isVarNameIsAttr()) { - name = element.getAttribute(desc.getVarName()); - if (name == null || name.length() == 0) { - return null; // missing name. - } - } else { - name = desc.getVarName(); - } - String type; - if (desc.isVarTypeStringIsAttr()) { - type = element.getAttribute(desc.getVarTypeString()); - if (type == null || type.length() == 0) { - return null; // missing type - } - } else { - type = desc.getVarTypeString(); - } - return new VariableInfo(name, desc.getVarTypeMode(), type); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter#getVariableInfos(org.w3c.dom.Element) - */ - public List getVariableInfos(Element element) { - IVariableInfo info = getVariableInfo(element); - if (info == null) { - return Collections.EMPTY_LIST; - } - List ret = new ArrayList(1); - ret.add(info); - return ret; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/PageVariableAdatperRegistry.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/PageVariableAdatperRegistry.java deleted file mode 100644 index 3226c9d10..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/PageVariableAdatperRegistry.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.pagedesigner.jsp.core.IJSPCoreConstants; -import org.eclipse.jst.pagedesigner.jsp.core.JSPCorePlugin; -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo; -import org.eclipse.jst.pagedesigner.jsp.core.util.CMUtil; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.w3c.dom.Element; - -/** - * @author mengbo - * @version 1.5 - */ -public class PageVariableAdatperRegistry { - /** - * pageVar - */ - public static final String PAGEVAR = "pageVar"; - - /** - * taglib - */ - public static final String TAGLIB = "taglib"; - - /** - * tag - */ - public static final String TAG = "tag"; - - /** - * varName - */ - public static final String VARNAME = "varName"; - - /** - * varNameIsAttr - */ - public static final String VARNAMEISATTR = "varNameIsAttr"; - - /** - * varTypeMode - */ - public static final String VARTYPEMODE = "varTypeMode"; - - /** - * tagName - */ - public static final String TAGNAME = "tagName"; - - /** - * varTypeString - */ - public static final String VARTYPESTRING = "varTypeString"; - - /** - * varTypeStringIsAttr - */ - public static final String VARTYPESTRINGISATTR = "varTypeStringIsAttr"; - - /** - * uri - */ - public static final String URI = "uri"; - - private static PageVariableAdatperRegistry _instance = null; - - private Map _registry; - - private TagVarDescriptor _useBeanDescriptor; - - /** - * @return the singleton instance - */ - public static PageVariableAdatperRegistry getInstance() { - if (_instance == null) { - _instance = new PageVariableAdatperRegistry(); - } - return _instance; - } - - private PageVariableAdatperRegistry() { - _registry = readAllDescriptors(); - } - - // public IPageVariableAdapter createAdapter(IDOMElement ele, String uri, - // String tagname) - // { - // String key = uri + "#" + tagname; - // TagVarDescriptor desc = (TagVarDescriptor) _registry.get(key); - // if (desc != null) - // { - // PageVariableAdapter adapter = new PageVariableAdapter(ele); - // adapter.setVarName(desc.getVarName()); - // adapter.setVarNameAttrName(desc.isVarNameIsAttr()); - // adapter.setVarTypeString(desc.getVarTypeString()); - // adapter.setVarTypeAttrName(desc.isVarTypeStringIsAttr()); - // adapter.setVarTypeMode(desc.getVarTypeMode()); - // return adapter; - // } - // else - // { - // return null; - // } - // } - - private Map readAllDescriptors() { - Map map = new HashMap(); - - IExtensionPoint extensionPoint = Platform.getExtensionRegistry() - .getExtensionPoint(JSPCorePlugin.getPluginId(), PAGEVAR); - IExtension[] extensions = extensionPoint.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IExtension ext = extensions[i]; - IConfigurationElement[] facs = ext.getConfigurationElements(); - - for (int j = 0; j < facs.length; j++) { - if (facs[j].getName().equals(TAGLIB)) { - String uri = facs[j].getAttribute(URI); - if (uri == null || uri.length() == 0) { - continue; - } - IConfigurationElement[] tags = facs[j].getChildren(TAG); - for (int k = 0; k < tags.length; k++) { - TagVarDescriptor desc = new TagVarDescriptor(); - - String tag = tags[k].getAttribute(TAGNAME); - String varName = tags[k].getAttribute(VARNAME); - boolean varNameIsAttr = "true".equalsIgnoreCase(tags[k] - .getAttribute(VARNAMEISATTR)); - String varTypeString = tags[k] - .getAttribute(VARTYPESTRING); - boolean varTypeStringIsAttr = "true" - .equalsIgnoreCase(tags[k] - .getAttribute(VARTYPESTRINGISATTR)); - String varTypeModeString = tags[k] - .getAttribute(VARTYPEMODE); - int varTypeMode = toVarTypeMode(varTypeModeString); - - desc.setVarName(varName); - desc.setVarNameIsAttr(varNameIsAttr); - desc.setVarTypeMode(varTypeMode); - desc.setVarTypeString(varTypeString); - desc.setVarTypeStringIsAttr(varTypeStringIsAttr); - desc.setTagName(tag); - - // Use uri#tag as key. - map.put(uri + "#" + tag, desc); - } - } - } - } - - return map; - } - - /** - * @param varTypeModeString - * @return variable typemode - */ - public static int toVarTypeMode(String varTypeModeString) { - if ("CLASSNAME".equalsIgnoreCase(varTypeModeString)) { - return IVariableInfo.CLASSNAME; - } else if ("EXPRESSION".equalsIgnoreCase(varTypeModeString)) { - return IVariableInfo.EXPRESSION; - } else if ("EXPRESSION_COLLECTION_ITEM" - .equalsIgnoreCase(varTypeModeString)) { - return IVariableInfo.EXPRESSION_LISTITEM; - } else if ("BUNDLE".equalsIgnoreCase(varTypeModeString)) { - return IVariableInfo.RESOURCEBUNDLE; - } else { - return IVariableInfo.EXPRESSION; // default - } - } - - /** - * @param uri - * @param tagname - * @return the tag variable descriptor for the given tag (may be null) - */ - public TagVarDescriptor getTagVarDescriptor(String uri, String tagname) { - String key = uri + "#" + tagname; - return (TagVarDescriptor) _registry.get(key); - } - - /** - * @param localName - * @return - */ - private TagVarDescriptor getJSPTagVarDescriptor(String localName) { - if (IJSPCoreConstants.TAG_USEBEAN.equals(localName)) { - if (_useBeanDescriptor == null) { - _useBeanDescriptor = new TagVarDescriptor(); - _useBeanDescriptor.setVarName(IJSPCoreConstants.ATTR_ID); - _useBeanDescriptor.setVarNameIsAttr(true); - _useBeanDescriptor.setVarTypeMode(IVariableInfo.CLASSNAME); - _useBeanDescriptor - .setVarTypeString(IJSPCoreConstants.ATTR_CLASS); - _useBeanDescriptor.setVarTypeStringIsAttr(true); - } - - return _useBeanDescriptor; - } - - return null; - } - - /** - * @param target - * @return the tag variable descriptor for the target - */ - public TagVarDescriptor getTagVarDescriptor(Element target) { - if (target instanceof IDOMElement) { - IDOMElement xmlEle = (IDOMElement) target; - CMElementDeclaration decl = CMUtil.getElementDeclaration(xmlEle); - if (decl != null) { - if (CMUtil.isJSP(decl)) { - return getJSPTagVarDescriptor(xmlEle.getLocalName()); - } - String uri = CMUtil.getTagURI(decl); - if (uri != null) { - return getTagVarDescriptor(uri, xmlEle.getLocalName()); - } - } - } - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/TagVarDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/TagVarDescriptor.java deleted file mode 100644 index 8e5b649e2..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/TagVarDescriptor.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar; - -/** - * @author mengbo - * @version 1.5 - */ -public class TagVarDescriptor { - private String _varName; - - private boolean _varNameIsAttr; - - private String _varTypeString; - - private boolean _varTypeStringIsAttr; - - private int _varTypeMode; - - private String _tagName; - - /** - * @return the varName - */ - public String getVarName() { - return _varName; - } - - /** - * @param varName - */ - public void setVarName(String varName) { - this._varName = varName; - } - - /** - * @return true if var name is attribute - */ - public boolean isVarNameIsAttr() { - return _varNameIsAttr; - } - - /** - * @param varNameIsAttr - */ - public void setVarNameIsAttr(boolean varNameIsAttr) { - this._varNameIsAttr = varNameIsAttr; - } - - /** - * @return the variable type mode - */ - public int getVarTypeMode() { - return _varTypeMode; - } - - /** - * @param varTypeMode - */ - public void setVarTypeMode(int varTypeMode) { - this._varTypeMode = varTypeMode; - } - - /** - * @return the variable type string - */ - public String getVarTypeString() { - return _varTypeString; - } - - /** - * @param varTypeString - */ - public void setVarTypeString(String varTypeString) { - this._varTypeString = varTypeString; - } - - /** - * @return true if variable type string is attr - */ - public boolean isVarTypeStringIsAttr() { - return _varTypeStringIsAttr; - } - - /** - * @param varTypeStringIsAttr - */ - public void setVarTypeStringIsAttr(boolean varTypeStringIsAttr) { - this._varTypeStringIsAttr = varTypeStringIsAttr; - } - - /** - * @param tag - */ - public void setTagName(String tag) { - this._tagName = tag; - } - - /** - * @return the tag name - */ - public String getTagName() { - return this._tagName; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/VariableInfo.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/VariableInfo.java deleted file mode 100644 index 6b29b9a95..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/VariableInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar; - -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo; - -/** - * @author mengbo - * @version 1.5 - */ -public class VariableInfo implements IVariableInfo { - private String _typeInfo; - - private int _mode; - - private String _name; - - /** - * @param name - * @param mode - * @param typeInfo - * - */ - public VariableInfo(String name, int mode, String typeInfo) { - this._name = name; - this._mode = mode; - this._typeInfo = typeInfo; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo#getName() - */ - public String getName() { - return _name; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo#getMode() - */ - public int getMode() { - return _mode; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo#getTypeInfoString() - */ - public String getTypeInfoString() { - return _typeInfo; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - // TODO: no hashcode override? - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof VariableInfo) { - VariableInfo info = (VariableInfo) obj; - return this._mode == info._mode && equals(this._name, info._name) - && equals(this._typeInfo, info._typeInfo); - } - return false; - } - - private boolean equals(String s1, String s2) { - if (s1 == null) { - return s2 == null; - } - return s1.equals(s2); - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IChangeListener.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IChangeListener.java deleted file mode 100644 index 9196d0c13..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IChangeListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.pagevar; - -import java.util.EventListener; - -/** - * @author mengbo - * @version 1.5 - */ -public interface IChangeListener extends EventListener { - /** - * fire a changed indication - */ - public void changed(); -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IPageVariablesProvider.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IPageVariablesProvider.java deleted file mode 100644 index a538ec83e..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IPageVariablesProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.pagevar; - -/** - * @author mengbo - * @version 1.5 - */ -public interface IPageVariablesProvider { - /** - * - */ - public void refresh(); - - /** - * @return the bean infos - */ - public IVariableInfo[] getBeanInfos(); - - /** - * @param listener - */ - public void addChangeListener(IChangeListener listener); - - /** - * @param listener - */ - public void removeChangeListener(IChangeListener listener); -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IVariableInfo.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IVariableInfo.java deleted file mode 100644 index a491de057..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/IVariableInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.pagevar; - -/** - * @author mengbo - * @version 1.5 - */ -public interface IVariableInfo { - /** - * @return the name - */ - public String getName(); - - /** - * TODO - */ - public static final int CLASSNAME = 0; - - /** - * TODO - */ - public static final int EXPRESSION = 1; - - /** - * TODO - */ - public static final int EXPRESSION_LISTITEM = 2; - - /** - * TODO - */ - public static final int RESOURCEBUNDLE = 3; - - /** - * @return one of CLASSNAME, EXPRESSION, EXPRESSION_LISTITEM, RESOURCEBUNDLE - */ - public int getMode(); - - /** - * type info string will have different meaning for different mode. - * - * @return the type info string - */ - public String getTypeInfoString(); - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/IDocumentPageVariableAdapter.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/IDocumentPageVariableAdapter.java deleted file mode 100644 index 31979ef9b..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/IDocumentPageVariableAdapter.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter; - -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; - -/** - * IDocumentPageVariableAdapter will be adapted to the jsp document. - * - * @author mengbo - * @version 1.5 - */ -public interface IDocumentPageVariableAdapter extends IPageVariablesProvider, - INodeAdapter { - // TODO: what's this for? -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/IPageVariableAdapter.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/IPageVariableAdapter.java deleted file mode 100644 index 158799f86..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/IPageVariableAdapter.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter; - -import java.util.List; - -import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.w3c.dom.Element; - -/** - * A IPageVariableAdapter normally will be adapted to an JSP tag. - * - * @author mengbo - * @version 1.5 - */ -public interface IPageVariableAdapter extends INodeAdapter { - /** - * most JSP tags will only support a single variable. - * @param element - * - * @return true if the tag supports multiple variables - */ - public boolean supportMultipleVariable(Element element); - - /** - * If only support single variable, this method will return the variable - * info. This method is provided for better performance. - * - * @param element - * @return null means no variable info provided. - */ - public IVariableInfo getVariableInfo(Element element); - - /** - * should return a list of IVariableInfo - * @param element - * - * @return the list of variable infos - */ - public List getVariableInfos(Element element); -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/PageVariableAdapterFactory.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/PageVariableAdapterFactory.java deleted file mode 100644 index 1c6c64d7c..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/pagevar/adapter/PageVariableAdapterFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter; - -import org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.PageVariableAdapter; -import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; - -/** - * @author mengbo - * @version 1.5 - */ -public class PageVariableAdapterFactory extends AbstractAdapterFactory { - /** - * - */ - public PageVariableAdapterFactory() { - super(IPageVariableAdapter.class, true); - } - - /* - * (non-Javadoc) - * @seeorg.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory#createAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier) - */ - protected INodeAdapter createAdapter(INodeNotifier target) { - if (target instanceof IDOMElement) { - return PageVariableAdapter.getInstance(); - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/util/CMUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/util/CMUtil.java deleted file mode 100644 index fd299aa88..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner.jsp.core/src/org/eclipse/jst/pagedesigner/jsp/core/util/CMUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.jsp.core.util; - -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration; -import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; -import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMNodeWrapper; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter; - -/** - * Utility class to content model related information. - * - * @author mengbo - */ -public class CMUtil { - /** - * If the element is a custom tag, get the URI of it. If the element is a - * standard JSP tag, return null. If is not jsp tag, then return null - * @param decl - * @return the tag uri for decl - */ - public static String getTagURI(CMElementDeclaration decl) { - if (decl instanceof CMNodeWrapper) { - decl = (CMElementDeclaration) ((CMNodeWrapper) decl) - .getOriginNode(); - } - if (decl instanceof TLDElementDeclaration) { - CMDocument doc = ((TLDElementDeclaration) decl).getOwnerDocument(); - if (doc instanceof TLDDocument) { - return ((TLDDocument) doc).getUri(); - } - } - return null; - } - - /** - * get element declaration of specified element - * - * @param element - * @return null if can't get it. - */ - public static CMElementDeclaration getElementDeclaration(IDOMElement element) { - INodeNotifier notifier = (INodeNotifier) element.getOwnerDocument(); - if (notifier == null) { - return null; - } - ModelQueryAdapter mqa = (ModelQueryAdapter) notifier - .getAdapterFor(ModelQueryAdapter.class); - if (mqa == null) { - return null; - } - return mqa.getModelQuery().getCMElementDeclaration(element); - } - - /** - * @param element - * @return the tld element declaration for element - */ - public static TLDElementDeclaration getTLDElementDeclaration( - IDOMElement element) { - CMNode decl = getElementDeclaration(element); - if (decl instanceof CMNodeWrapper) { - decl = ((CMNodeWrapper) decl).getOriginNode(); - } - if (decl instanceof TLDElementDeclaration) { - return (TLDElementDeclaration) decl; - } - return null; - } - - /** - * @param decl - * @return true if decl is a JSP tag - */ - public static boolean isJSP(CMElementDeclaration decl) { - if (!decl.supports(HTMLCMProperties.IS_JSP)) { - return false; - } - return ((Boolean) decl.getProperty(HTMLCMProperties.IS_JSP)) - .booleanValue(); - } -} |