JBoss Tools SVN: r34351 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-26 21:26:49 -0400 (Fri, 26 Aug 2011)
New Revision: 34351
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
Log:
WebKbPlugin.getDefault() can return null if plugin is stopped. Setting singleton instance of plugin to null at stopping is a common practice in Eclipse.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2011-08-27 01:10:10 UTC (rev 34350)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2011-08-27 01:26:49 UTC (rev 34351)
@@ -432,10 +432,14 @@
*/
private File getStorageFile() {
WebKbPlugin plugin = WebKbPlugin.getDefault();
- //The plug-in instance can be null at shutdown, when the plug-in is stopped.
- IPath path = plugin.getStateLocation();
- File file = new File(path.toFile(), "projects/" + project.getName() + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- return file;
+ if( plugin != null) {
+ //The plug-in instance can be null at shutdown, when the plug-in is stopped.
+ IPath path = plugin.getStateLocation();
+ File file = new File(path.toFile(), "projects/" + project.getName() + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ return file;
+ } else {
+ return null;
+ }
}
public void clearStorage() {
14 years, 3 months
JBoss Tools SVN: r34350 - in trunk: jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-08-26 21:10:10 -0400 (Fri, 26 Aug 2011)
New Revision: 34350
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
Log:
https://issues.jboss.org/browse/JBIDE-1636 Code Review
code cleanup for KB plugin
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -100,7 +100,7 @@
}
ITagLibrary[] libraries = TagLibraryManager.getLibraries(file.getProject());
- if (libraries == null)
+ if (libraries.length==0)
return Collections.emptyList();;
List<IJSFVariable> result = new ArrayList<IJSFVariable>();
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -152,22 +152,13 @@
}
private void saveConvext(ELContext context) {
- if (context != null && context.getResource() != null) {
+ if (context.getResource() != null) {
synchronized (cache) {
cache.put(context.getResource(), context);
}
}
}
- private ELContext removeSavedContext(IFile resource) {
- ELContext removedContext = null;
-
- synchronized (cache) {
- removedContext = cache.remove(resource);
- }
- return removedContext;
- }
-
/**
* Creates a page context for the specified context file
*
@@ -187,7 +178,7 @@
* @return
*/
public static ELContext createPageContext(IFile file, String contextType) {
- return getInstance().createPageContext(file, null, contextType);
+ return getInstance().createPageContext(file, new ArrayList<String>(), contextType);
}
/**
@@ -196,19 +187,17 @@
* @param file
*/
public void cleanUp(IFile file) {
- if (file == null)
- return;
synchronized (cache) {
- ELContext removedContext = removeSavedContext(file);
+ ELContext removedContext = cache.remove(file);
if (removedContext == null || removedContext.getResource() == null)
return;
-
+ ELContext[] contexts = null;
// Remove all the contexts that are parent to the removed context
- ELContext[] contexts = cache.values().toArray(new ELContext[0]);
+ contexts = cache.values().toArray(new ELContext[cache.values().size()]);
if (contexts != null) {
for (ELContext context : contexts) {
if (isDependencyContext(context, file)) {
- removeSavedContext(file);
+ cache.remove(file);
}
}
}
@@ -221,16 +210,12 @@
* @param file
*/
public void cleanUp(IProject project) {
- if (project == null)
- return;
synchronized (cache) {
// Remove all the contexts that are parent to the removed context
- IFile[] files = cache.keySet().toArray(new IFile[0]);
- if (files != null) {
- for (IFile file : files) {
- if (project.equals(file.getProject())) {
- cleanUp(file);
- }
+ IFile[] files = cache.keySet().toArray(new IFile[cache.size()]);
+ for (IFile file : files) {
+ if (project.equals(file.getProject())) {
+ cleanUp(file);
}
}
}
@@ -243,9 +228,9 @@
*/
public void cleanUp(IResourceDelta delta) {
synchronized (cache) {
- if(cache.size() == 0) return;
- if(!checkDelta(delta)) return;
- processDelta(delta);
+ if(!cache.isEmpty() && checkDelta(delta)) {
+ processDelta(delta);
+ }
}
}
@@ -254,10 +239,7 @@
context.setResource(file);
context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
String content = FileUtil.getContentFromEditorOrFile(file);
- int startEl = content.indexOf("#{"); //$NON-NLS-1$
- if(startEl<0)
- startEl = content.indexOf("${"); //$NON-NLS-1$
- if(startEl>-1) {
+ if(content.indexOf('{')>-1 && content.indexOf("#{") >-1 || content.indexOf("${")>-1 ) { //$NON-NLS-1$
ELParser parser = ELParserUtil.getJbossFactory().createParser();
ELModel model = parser.parse(content);
List<SyntaxError> errors = model.getSyntaxErrors();
@@ -282,7 +264,7 @@
return context;
}
- private ELContext createJavaContext(IFile file) {
+ private static ELContext createJavaContext(IFile file) {
ELContextImpl context = new ELContextImpl();
context.setResource(file);
context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
@@ -344,121 +326,68 @@
* @return
*/
private ELContext createPageContext(IFile file, List<String> parents, String defaultContextType) {
- boolean isContextCachingAllowed = !EclipseUIUtil.isOpenInActiveEditor(file) && file != null;
+ boolean isContextCachingAllowed = !EclipseUIUtil.isOpenInActiveEditor(file);
ELContext context = isContextCachingAllowed ? getSavedContext(file) : null;
- if (context != null) {
- return context;
- }
- if (file == null)
- return createContextInstanceOfType(defaultContextType);
-
- IContentType type = IDE.getContentType(file);
- String typeId = (type == null ? null : type.getId());
-
- if(JavaCore.JAVA_SOURCE_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
- context = createJavaContext(file);
- } else if(JAVA_PROPERTIES_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
- context = createPropertiesContext(file);
-// } else if (typeId != null) {
-// context = defaultContextType == null ?
-// createPageContextInstance(typeId) :
-// createContextInstanceOfType(defaultContextType);
-// if (context == null)
-// return null;
-//
-// context.setResource(file);
-// context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
-//
-// if (context instanceof JspContextImpl && !(context instanceof FaceletPageContextImpl)) {
-// // Fill JSP namespaces defined in TLDCMDocumentManager
-// fillJSPNameSpaces((JspContextImpl)context);
-// }
-//
-// // The subsequently called functions may use the file and document
-// // already stored in context for their needs
-// if (context instanceof FaceletPageContextImpl) {
-// IModelManager manager = StructuredModelManager.getModelManager();
-// if(manager == null) {
-// return context;
-// }
-// IStructuredModel model = null;
-// try {
-// model = manager.getModelForRead(file);
-// if (model instanceof IDOMModel) {
-// IDOMModel domModel = (IDOMModel) model;
-// IDOMDocument document = domModel.getDocument();
-// fillContextForChildNodes(document, context, parents);
-// }
-// } catch (CoreException e) {
-// WebKbPlugin.getDefault().logError(e);
-// } catch (IOException e) {
-// WebKbPlugin.getDefault().logError(e);
-// } finally {
-// if (model != null) {
-// model.releaseFromRead();
-// }
-// }
-// }
- } else {
- // ctm = System.currentTimeMillis();
- // System.out.println("Create Context : " + file.getFullPath().toString() + ", Totals: " + cache.size());
- IModelManager manager = StructuredModelManager.getModelManager();
- if(manager == null) {
- // this may happen if plug-in org.eclipse.wst.sse.core
+ if (context == null) {
+ IContentType type = IDE.getContentType(file);
+ String typeId = (type == null ? null : type.getId());
+
+ if(JavaCore.JAVA_SOURCE_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
+ context = createJavaContext(file);
+ } else if(JAVA_PROPERTIES_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
+ context = createPropertiesContext(file);
+ } else {
+ IModelManager manager = StructuredModelManager.getModelManager();
+ // manager==null if plug-in org.eclipse.wst.sse.core
// is stopping or un-installed, that is Eclipse is shutting down.
// there is no need to report it, just stop validation.
- return context;
- }
-
- IStructuredModel model = null;
- try {
- model = manager.getModelForRead(file);
- if (model instanceof IDOMModel) {
- IDOMModel domModel = (IDOMModel) model;
- IDOMDocument document = domModel.getDocument();
-
- context = defaultContextType == null ?
- createPageContextInstance(domModel.getContentTypeIdentifier()) :
- createContextInstanceOfType(defaultContextType);
- if (context == null)
- return null;
-
- context.setResource(file);
- context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
-
- if (context instanceof JspContextImpl && !(context instanceof FaceletPageContextImpl)) {
- // Fill JSP namespaces defined in TLDCMDocumentManager
- fillJSPNameSpaces((JspContextImpl)context);
+ if(manager != null) {
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ IDOMModel domModel = (IDOMModel) model;
+ context = defaultContextType == null ?
+ createPageContextInstance(domModel.getContentTypeIdentifier()) :
+ createContextInstanceOfType(defaultContextType);
+ if (context != null) {
+ IDOMDocument document = domModel.getDocument();
+ context.setResource(file);
+ context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
+ if (context instanceof JspContextImpl && !(context instanceof FaceletPageContextImpl)) {
+ // Fill JSP namespaces defined in TLDCMDocumentManager
+ fillJSPNameSpaces((JspContextImpl)context);
+ }
+ // The subsequently called functions may use the file and document
+ // already stored in context for their needs
+ fillContextForChildNodes(model.getStructuredDocument(), document, context, parents);
+ }
+ }
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ } catch (IOException e) {
+ WebKbPlugin.getDefault().logError(e);
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
}
-
- // The subsequently called functions may use the file and document
- // already stored in context for their needs
- fillContextForChildNodes(model.getStructuredDocument(), document, context, parents);
}
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
}
+
+ if (context != null && isContextCachingAllowed) {
+ saveConvext(context);
+ }
}
-
- if (context != null && isContextCachingAllowed) {
- saveConvext(context);
- }
-
return context;
}
- private ELContext createPageContextInstance(String contentType) {
+ private static ELContext createPageContextInstance(String contentType) {
String contextType = IncludeContextBuilder.getContextType(contentType);
return createContextInstanceOfType(contextType);
}
- private ELContext createContextInstanceOfType(String contextType) {
+ private static ELContext createContextInstanceOfType(String contextType) {
if (JSP_PAGE_CONTEXT_TYPE.equals(contextType)) {
return new JspContextImpl();
} else if (FACELETS_PAGE_CONTEXT_TYPE.equals(contextType)) {
@@ -474,7 +403,7 @@
* @param context
*/
@SuppressWarnings({ "unchecked" })
- private void fillJSPNameSpaces(JspContextImpl context) {
+ private static void fillJSPNameSpaces(JspContextImpl context) {
TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(context.getDocument());
List trackers = (manager == null? null : manager.getCMDocumentTrackers(context.getDocument().getLength() - 1));
for (int i = 0; trackers != null && i < trackers.size(); i++) {
@@ -542,7 +471,7 @@
}
}
- private void fillVarsForNode (IDOMElement node, ELContextImpl context) {
+ private static void fillVarsForNode (IDOMElement node, ELContextImpl context) {
Var var = ElVarSearcher.findVar(node, ELParserUtil.getJbossFactory());
if (var != null) {
int start = ((IndexedRegion) node).getStartOffset();
@@ -557,7 +486,7 @@
}
}
- private void fillElReferencesForNode(IDocument document, IDOMNode node, XmlContextImpl context) {
+ private static void fillElReferencesForNode(IDocument document, IDOMNode node, XmlContextImpl context) {
if(Node.ELEMENT_NODE == node.getNodeType() || Node.TEXT_NODE == node.getNodeType()) {
IStructuredDocumentRegion regionNode = node.getFirstStructuredDocumentRegion();
if (regionNode == null)
@@ -567,38 +496,29 @@
ITextRegion region = regions.get(i);
if(region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE || region.getType() == DOMRegionContext.XML_CONTENT) {
String text = regionNode.getFullText(region);
- if(text.indexOf("{")>-1) { //$NON-NLS-1$
+ if(text.indexOf('{')>-1 && (text.indexOf("#{") > -1 || text.indexOf("${") > -1)) { //$NON-NLS-1$
int offset = regionNode.getStartOffset() + region.getStart();
- int startEl = text.indexOf("#{"); //$NON-NLS-1$
- if(startEl==-1) {
- startEl = text.indexOf("${"); //$NON-NLS-1$
- }
- if(startEl>-1) {
- ELParser parser = ELParserUtil.getJbossFactory().createParser();
- ELModel model = parser.parse(text);
- List<ELInstance> is = model.getInstances();
-
- ELReference elReference = new ValidationELReference();
- elReference.setResource(context.getResource());
- elReference.setEl(is);
- elReference.setLength(text.length());
- elReference.setStartPosition(offset);
- try {
- if(Node.TEXT_NODE == node.getNodeType()) {
- if(is.size()==1) {
- elReference.setLineNumber(document.getLineOfOffset(elReference.getStartPossitionOfFirstEL()) + 1);
- }
- } else {
- elReference.setLineNumber(document.getLineOfOffset(offset) + 1);
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(text);
+ List<ELInstance> is = model.getInstances();
+ ELReference elReference = new ValidationELReference();
+ elReference.setResource(context.getResource());
+ elReference.setEl(is);
+ elReference.setLength(text.length());
+ elReference.setStartPosition(offset);
+ try {
+ if(Node.TEXT_NODE == node.getNodeType()) {
+ if(is.size()==1) {
+ elReference.setLineNumber(document.getLineOfOffset(elReference.getStartPossitionOfFirstEL()) + 1);
}
- } catch (BadLocationException e) {
- WebKbPlugin.getDefault().logError(e);
+ } else {
+ elReference.setLineNumber(document.getLineOfOffset(offset) + 1);
}
-
- elReference.setSyntaxErrors(model.getSyntaxErrors());
-
- context.addELReference(elReference);
+ } catch (BadLocationException e) {
+ WebKbPlugin.getDefault().logError(e);
}
+ elReference.setSyntaxErrors(model.getSyntaxErrors());
+ context.addELReference(elReference);
}
}
}
@@ -611,66 +531,50 @@
Map<String, List<INameSpace>> nsMap = context.getNameSpaces(node.getStartOffset());
String[] uris = getUrisByPrefix(nsMap, prefix);
- if (uris != null) {
- for (String uri : uris) {
- if (context instanceof IIncludedContextSupport) {
- String[] includeAttributes = IncludeContextBuilder.getIncludeAttributes(uri, tagName);
- if (includeAttributes != null) {
- List<String> newParentList = parents == null ? new ArrayList<String>() : new ArrayList<String>(parents);
- newParentList.add(context.getResource().getFullPath().toString());
-
- for (String attr : includeAttributes) {
- String fileName = node.getAttribute(attr);
- if (fileName == null || fileName.trim().length() == 0)
- continue;
-
+ for (String uri : uris) {
+ if (context instanceof IIncludedContextSupport) {
+ String[] includeAttributes = IncludeContextBuilder.getIncludeAttributes(uri, tagName);
+ if (includeAttributes.length > 0) {
+ List<String> newParentList = parents == null ? new ArrayList<String>() : new ArrayList<String>(parents);
+ newParentList.add(context.getResource().getFullPath().toString());
+ for (String attr : includeAttributes) {
+ String fileName = node.getAttribute(attr);
+ if (fileName != null && !fileName.trim().isEmpty()) {
IFile file = getFileFromProject(fileName, context.getResource());
- if (file == null)
- continue;
-
- // Fix for JBIDE-5083 >>>
- if (!checkCycling(parents, file))
- continue;
- // Fix for JBIDE-5083 <<<
-
- ELContext includedContext = createPageContext(file, newParentList, null);
- if (includedContext != null)
- ((IIncludedContextSupport)context).addIncludedContext(includedContext);
+ if (file != null && checkCycling(parents, file)) { // checkCycling is to fix for JBIDE-5083
+ ELContext includedContext = createPageContext(file, newParentList, null);
+ if (includedContext != null)
+ ((IIncludedContextSupport)context).addIncludedContext(includedContext);
+ }
}
}
}
- if (context instanceof ICSSContainerSupport) {
- if(IncludeContextBuilder.isCSSStyleSheetContainer(uri, tagName)) {
- fillCSSStyleSheetFromElement(node, (ICSSContainerSupport)context, false);
- } else if(IncludeContextBuilder.isJSF2CSSStyleSheetContainer(uri, tagName)) {
- fillCSSStyleSheetFromElement(node, (ICSSContainerSupport)context, true);
- } else {
- String[] cssAttributes = IncludeContextBuilder.getCSSStyleSheetAttributes(uri, tagName);
- if (cssAttributes != null) {
- for (String attr : cssAttributes) {
- fillCSSStyleSheetFromAttribute(node, attr, (ICSSContainerSupport)context, false);
- }
- }
- cssAttributes = IncludeContextBuilder.getJSF2CSSStyleSheetAttributes(uri, tagName);
- if (cssAttributes != null) {
- for (String attr : cssAttributes) {
- fillCSSStyleSheetFromAttribute(node, attr, (ICSSContainerSupport)context, true);
- }
- }
-
+ }
+ if (context instanceof ICSSContainerSupport) {
+ if(IncludeContextBuilder.isCSSStyleSheetContainer(uri, tagName)) {
+ fillCSSStyleSheetFromElement(node, (ICSSContainerSupport)context, false);
+ } else if(IncludeContextBuilder.isJSF2CSSStyleSheetContainer(uri, tagName)) {
+ fillCSSStyleSheetFromElement(node, (ICSSContainerSupport)context, true);
+ } else {
+ String[] cssAttributes = IncludeContextBuilder.getCSSStyleSheetAttributes(uri, tagName);
+ for (String attr : cssAttributes) {
+ fillCSSStyleSheetFromAttribute(node, attr, (ICSSContainerSupport)context, false);
}
+ cssAttributes = IncludeContextBuilder.getJSF2CSSStyleSheetAttributes(uri, tagName);
+ for (String attr : cssAttributes) {
+ fillCSSStyleSheetFromAttribute(node, attr, (ICSSContainerSupport)context, true);
+ }
+
}
}
}
}
- private boolean checkCycling(List<String> parents, IFile resource) {
+ private static boolean checkCycling(List<String> parents, IFile resource) {
String resourceId = resource.getFullPath().toString();
- if (parents != null) {
- for (String parentId : parents) {
- if (resourceId.equals(parentId))
- return false;
- }
+ for (String parentId : parents) {
+ if (resourceId.equals(parentId))
+ return false;
}
return true;
}
@@ -684,7 +588,7 @@
* @param node
* @param context
*/
- private void fillXMLNamespacesForNode(Element node, XmlContextImpl context) {
+ private static void fillXMLNamespacesForNode(Element node, XmlContextImpl context) {
NamedNodeMap attrs = node.getAttributes();
boolean mainNnIsRedefined = false;
for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
@@ -741,35 +645,33 @@
}
}
- private void fillResourceBundlesForNode(IDOMElement node, JspContextImpl context) {
+ private static void fillResourceBundlesForNode(IDOMElement node, JspContextImpl context) {
String name = node.getNodeName();
- if (name == null) return;
- if (!name.endsWith("loadBundle")) return; //$NON-NLS-1$
- if (name.indexOf(':') == -1) return;
+ if (name == null || !name.endsWith("loadBundle") || name.indexOf(':') == -1) //$NON-NLS-1$
+ return;
String prefix = name.substring(0, name.indexOf(':'));
Map<String, List<INameSpace>> ns = context.getNameSpaces(node.getStartOffset());
if (!containsPrefix(ns, prefix)) return;
NamedNodeMap attributes = node.getAttributes();
- if (attributes == null) return;
String basename = (attributes.getNamedItem("basename") == null ? null : attributes.getNamedItem("basename").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
String var = (attributes.getNamedItem("var") == null ? null : attributes.getNamedItem("var").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
- if (basename == null || basename.length() == 0 ||
- var == null || var.length() == 0)
+ if (basename == null || basename.length() == 0 || var == null || var.length() == 0)
return;
context.addResourceBundle(new ResourceBundle(basename, var));
}
- private void fillCSSStyleSheetFromAttribute(IDOMElement node,
+ private static void fillCSSStyleSheetFromAttribute(IDOMElement node,
String attribute, ICSSContainerSupport context, boolean jsf2Source) {
CSSStyleSheetDescriptor descr = getSheetForTagAttribute(node, attribute, jsf2Source);
- if (descr != null)
+ if (descr != null) {
context.addCSSStyleSheetDescriptor(descr);
+ }
}
- private void fillCSSStyleSheetFromElement(IDOMElement node,
+ private static void fillCSSStyleSheetFromElement(IDOMElement node,
ICSSContainerSupport context, boolean jsf2Source) {
CSSStyleSheet sheet = getSheetForTag(node);
if (sheet != null) {
@@ -826,7 +728,7 @@
* @param stylesContainer
* @return
*/
- private CSSStyleSheetDescriptor getSheetForTagAttribute(final Node stylesContainer, String attribute, boolean jsf2Source) {
+ private static CSSStyleSheetDescriptor getSheetForTagAttribute(final Node stylesContainer, String attribute, boolean jsf2Source) {
INodeNotifier notifier = (INodeNotifier) stylesContainer;
CSSStyleSheet sheet = null;
String source = null;
@@ -869,7 +771,7 @@
* @param stylesContainer
* @return
*/
- private CSSStyleSheet getSheetForTag(final Node stylesContainer) {
+ private static CSSStyleSheet getSheetForTag(final Node stylesContainer) {
INodeNotifier notifier = (INodeNotifier) stylesContainer;
CSSStyleSheet sheet = null;
@@ -884,7 +786,7 @@
return sheet;
}
- private boolean containsPrefix(Map<String, List<INameSpace>> ns, String prefix) {
+ private static boolean containsPrefix(Map<String, List<INameSpace>> ns, String prefix) {
for (List<INameSpace> n: ns.values()) {
for (INameSpace nameSpace : n) {
if(prefix.equals(nameSpace.getPrefix())) return true;
@@ -901,8 +803,9 @@
* @return
*/
public static String[] getUrisByPrefix(Map<String, List<INameSpace>> nsMap, String prefix) {
- if(nsMap == null || nsMap.isEmpty())
- return null;
+ if(nsMap.isEmpty()) {
+ return new String[0];
+ }
Set<String> uris = new HashSet<String>();
for (List<INameSpace> nsList : nsMap.values()) {
for (INameSpace ns : nsList) {
@@ -971,7 +874,7 @@
IPath projectPath = project.getLocation();
IFile member = null;
- for (int i = 0; resources != null && i < resources.length; i++) {
+ for (int i = 0; i < resources.length; i++) {
IPath runtimePath = resources[i].getRuntimePath();
IPath sourcePath = resources[i].getSourcePath();
@@ -1067,11 +970,11 @@
private static ResourceReference[] sortReferencesByScope(ResourceReference[] references) {
ResourceReference[] sortedReferences = references.clone();
- Arrays.sort(sortedReferences, new Comparator<ResourceReference>() {
+ Arrays.sort(sortedReferences, new Comparator<ResourceReference>() {
public int compare(ResourceReference r1, ResourceReference r2) {
return r1.getScope() - r2.getScope();
}
- });
+ });
return sortedReferences;
}
@@ -1101,13 +1004,12 @@
@Override
protected boolean isValidAttribute() {
- if (super.isValidAttribute())
- return true;
-
- String href = getElement().getAttribute(hrefAttrName);
- if (href == null || href.length() == 0)
- return false;
- return true;
+ boolean result = true;
+ if (!super.isValidAttribute()) {
+ String href = getElement().getAttribute(hrefAttrName);
+ result = href != null && !href.isEmpty();
+ }
+ return result;
}
/**
@@ -1202,9 +1104,8 @@
cleanUp(event.getDelta());
}
- private boolean checkDelta(IResourceDelta delta) {
+ private static boolean checkDelta(IResourceDelta delta) {
IResource resource = delta.getResource();
- if(resource == null) return false;
if(resource instanceof IWorkspaceRoot) {
IResourceDelta[] d = delta.getAffectedChildren();
return (d.length > 0 && checkDelta(d[0]));
@@ -1213,58 +1114,40 @@
}
private void processDelta(IResourceDelta delta) {
- if(delta == null) return;
- int kind = delta.getKind();
- IResource resource = delta.getResource();
-
- if(resource instanceof IProject &&
- kind == IResourceDelta.REMOVED) {
- cleanUp((IProject)resource);
- } else if (resource instanceof IFile && (
- kind == IResourceDelta.CHANGED ||
- kind == IResourceDelta.ADDED ||
- kind == IResourceDelta.REMOVED ||
- kind == IResourceDelta.CONTENT)) {
- cleanUp((IFile)resource);
+ if(delta!= null) {
+ int kind = delta.getKind();
+ IResource resource = delta.getResource();
+
+ if(resource instanceof IProject &&
+ kind == IResourceDelta.REMOVED) {
+ cleanUp((IProject)resource);
+ } else if (resource instanceof IFile && (
+ kind == IResourceDelta.CHANGED ||
+ kind == IResourceDelta.ADDED ||
+ kind == IResourceDelta.REMOVED ||
+ kind == IResourceDelta.CONTENT)) {
+ cleanUp((IFile)resource);
+ }
+
+ IResourceDelta[] cs = delta.getAffectedChildren();
+ for (int i = 0; i < cs.length; i++) {
+ processDelta(cs[i]);
+ }
}
-
- IResourceDelta[] cs = delta.getAffectedChildren();
- for (int i = 0; cs != null && i < cs.length; i++) {
- processDelta(cs[i]);
- }
- return;
}
- private boolean isDependencyContext(ELContext context, IFile resource) {
+ private static boolean isDependencyContext(ELContext context, IFile resource) {
if (resource.equals(context.getResource())) {
return true;
}
if(context instanceof IIncludedContextSupport) {
List<ELContext> includedContexts = ((IIncludedContextSupport)context).getIncludedContexts();
- if (includedContexts != null) {
- for (ELContext includedContext : includedContexts) {
- if (isDependencyContext(includedContext, resource))
- return true;
- }
+ for (ELContext includedContext : includedContexts) {
+ if (isDependencyContext(includedContext, resource))
+ return true;
}
}
return false;
}
-
- @Override
- protected void finalize() throws Throwable {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- if (workspace != null) workspace.removeResourceChangeListener(this);
-
- synchronized (cache) {
- // Remove all the contexts that are parent to the removed context
- ELContext[] contexts = cache.values().toArray(new ELContext[0]);
- if (contexts != null) {
- for (ELContext context : contexts) {
- removeSavedContext(context.getResource());
- }
- }
- }
- }
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/action/EnableKBOnProject.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -41,8 +41,7 @@
public void run(IMarker marker) {
IResource resource = marker.getResource();
- IProject project = resource instanceof IProject ? (IProject)resource :
- resource != null ? resource.getProject() : null;
+ IProject project = resource instanceof IProject ? (IProject)resource : resource != null ? resource.getProject() : null;
if (project == null)
return;
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -27,6 +27,9 @@
*
*/
public class IncludeContextBuilder extends RegistryReader {
+
+ public static final String[] EMPTY = new String[0];
+
// extension point ID
public static final String PL_INCLUDE = "KbIncludeContext"; //$NON-NLS-1$
@@ -129,9 +132,6 @@
* @return
*/
private IncludeContextDefinition getIncludeContextDefinition(String uri) {
- if (fIncludeContextDefs == null || uri == null)
- return null;
-
for (IncludeContextDefinition def : fIncludeContextDefs) {
if (uri.equals(def.getUri())) {
return def;
@@ -214,9 +214,7 @@
if (fCurrentIncludeDefinition != null) {
readElementChildren(element);
}
- return true;
- }
- else if (tag.equals(TAG_TAG)) {
+ } else if (tag.equals(TAG_TAG)) {
processTagElement(element);
// make sure processing of current open on tag resulted in a current definition
@@ -224,13 +222,9 @@
if (fCurrentIncludeDefinition != null) {
readElementChildren(element);
}
- return true;
- }
- else if (tag.equals(TAG_ATTRIBUTE)) {
+ } else if (tag.equals(TAG_ATTRIBUTE)) {
processAttributeElement(element);
- return true;
- }
- else if (tag.equals(TAG_CONTEXTTYPE)) {
+ } else if (tag.equals(TAG_CONTEXTTYPE)) {
processContextTypeElement(element);
// make sure processing of current open on tag resulted in a current definition
@@ -238,13 +232,13 @@
if (fCurrentIncludeDefinition != null) {
readElementChildren(element);
}
- return true;
- }
- else if (tag.equals(TAG_CONTENTTYPE)) {
+ } else if (tag.equals(TAG_CONTENTTYPE)) {
return processContentTypeElement(element);
+ } else {
+ return false;
}
- return false;
+ return true;
}
private void initCache() {
@@ -283,25 +277,27 @@
* @return
*/
public static String[] getIncludeAttributes(String uri, String tagName) {
- if (uri == null)
- return null;
-
List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
- if (defs == null)
- return null;
-
- List<String> attrs = new ArrayList<String>();
-
- for (IncludeContextDefinition def : defs) {
- if (uri.equals(def.getUri())) {
- String[] defAttrs = def.getIncludeTagAttributes(tagName);
- if (defAttrs != null) {
- for (String attr : defAttrs) attrs.add(attr);
+ String[] result = EMPTY;
+ if(!defs.isEmpty()) {
+ List<String> attrs = new ArrayList<String>();
+
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ String[] defAttrs = def.getIncludeTagAttributes(tagName);
+ if (defAttrs != null) {
+ for (String attr : defAttrs) {
+ attrs.add(attr);
+ }
+ }
}
}
- }
- return attrs.size() == 0 ? null : attrs.toArray(new String[attrs.size()]);
+ if(!attrs.isEmpty()) {
+ result = attrs.toArray(new String[attrs.size()]);
+ }
+ }
+ return result;
}
/**
@@ -311,19 +307,15 @@
* @return
*/
public static String getContextType(String contentType) {
- if (contentType == null)
- return null;
-
- List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
- if (defs == null)
- return null;
-
- for (IncludeContextDefinition def : defs) {
- String contextType = def.getContextType(contentType);
- if (contextType != null)
- return contextType;
+ if (contentType != null) {
+ List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+ for (IncludeContextDefinition def : defs) {
+ String contextType = def.getContextType(contentType);
+ if (contextType != null)
+ return contextType;
+ }
}
-
+
return null;
}
@@ -335,18 +327,13 @@
* @return
*/
public static boolean isCSSStyleSheetContainer(String uri, String tagName) {
- if (uri == null)
- return false;
-
- List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
- if (defs == null)
- return false;
-
boolean isHolder = false;
- for (IncludeContextDefinition def : defs) {
- if (uri.equals(def.getUri())) {
- String[] defTags = def.getCSSTags();
- if (defTags != null) {
+ if (uri != null) {
+ List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ String[] defTags = def.getCSSTags();
for (String tag : defTags) {
if (tagName.equals(tag) || ("".equals(uri) && tagName.equalsIgnoreCase(tag))) { //$NON-NLS-1$
isHolder = true;
@@ -360,7 +347,6 @@
}
}
}
-
return isHolder;
}
@@ -372,18 +358,13 @@
* @return
*/
public static boolean isJSF2CSSStyleSheetContainer(String uri, String tagName) {
- if (uri == null)
- return false;
-
- List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
- if (defs == null)
- return false;
-
boolean isHolder = false;
- for (IncludeContextDefinition def : defs) {
- if (uri.equals(def.getUri())) {
- String[] defTags = def.getJSF2CSSTags();
- if (defTags != null) {
+ if (uri != null) {
+ List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ String[] defTags = def.getJSF2CSSTags();
for (String tag : defTags) {
if (tagName.equals(tag) || ("".equals(uri) && tagName.equalsIgnoreCase(tag))) { //$NON-NLS-1$
isHolder = true;
@@ -397,7 +378,6 @@
}
}
}
-
return isHolder;
}
@@ -409,26 +389,23 @@
* @return
*/
public static String[] getCSSStyleSheetAttributes(String uri, String tagName) {
- if (uri == null)
- return null;
-
+ String[] result = EMPTY;
List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
- if (defs == null)
- return null;
-
- List<String> attrs = new ArrayList<String>();
-
- for (IncludeContextDefinition def : defs) {
- if (uri.equals(def.getUri())) {
- String[] defAttrs = def.getCSSTagAttributes(tagName);
- if (defAttrs != null) {
- for (String attr : defAttrs) attrs.add(attr);
+ if(!defs.isEmpty()) {
+ List<String> attrs = new ArrayList<String>();
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ String[] defAttrs = def.getCSSTagAttributes(tagName);
+ for (String attr : defAttrs) {
+ attrs.add(attr);
+ }
}
}
+ if(!attrs.isEmpty()) {
+ result = attrs.toArray(new String[attrs.size()]);
+ }
}
-
- return attrs.size() == 0 ? null : attrs.toArray(new String[attrs.size()]);
-
+ return result;
}
/**
@@ -439,25 +416,20 @@
* @return
*/
public static String[] getJSF2CSSStyleSheetAttributes(String uri, String tagName) {
- if (uri == null)
- return null;
-
- List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
- if (defs == null)
- return null;
-
- List<String> attrs = new ArrayList<String>();
-
- for (IncludeContextDefinition def : defs) {
- if (uri.equals(def.getUri())) {
- String[] defAttrs = def.getJSF2CSSTagAttributes(tagName);
- if (defAttrs != null) {
- for (String attr : defAttrs) attrs.add(attr);
+ String[] result = EMPTY;
+ if (uri != null) {
+ List<IncludeContextDefinition> defs = IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+ List<String> attrs = new ArrayList<String>();
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ String[] defAttrs = def.getJSF2CSSTagAttributes(tagName);
+ if (defAttrs != null) {
+ for (String attr : defAttrs) attrs.add(attr);
+ }
}
}
+ result = attrs.toArray(new String[attrs.size()]);
}
-
- return attrs.size() == 0 ? null : attrs.toArray(new String[attrs.size()]);
-
+ return result;
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -32,15 +32,12 @@
* @author Alexey Kazakov
*/
public class JspContextImpl extends XmlContextImpl implements IPageContext, IIncludedContextSupport, ICSSContainerSupport {
- protected List<IResourceBundle> bundles;
+ protected List<IResourceBundle> bundles = new ArrayList<IResourceBundle>();
- protected List<ELContext> fIncludedContexts = null;
- protected List<CSSStyleSheetDescriptor> fCSSStyleSheetDescriptors = null;
+ protected List<ELContext> fIncludedContexts = new ArrayList<ELContext>();
+ protected List<CSSStyleSheetDescriptor> fCSSStyleSheetDescriptors = new ArrayList<CSSStyleSheetDescriptor>();;
public void addIncludedContext(ELContext includedContext) {
- if (fIncludedContexts == null) {
- fIncludedContexts = new ArrayList<ELContext>();
- }
fIncludedContexts.add(includedContext);
}
@@ -109,23 +106,18 @@
for (INameSpace ns : nsMap.values()) {
if (ns instanceof INameSpaceExtended) {
ITagLibrary[] libs = ((INameSpaceExtended)ns).getTagLibraries();
- if (libs != null) {
- for(ITagLibrary lib : libs) {
- libraries.add(lib);
- }
+ for(ITagLibrary lib : libs) {
+ libraries.add(lib);
}
}
}
}
- List<ELContext> includedContexts = getIncludedContexts();
- if (includedContexts != null) {
- for (ELContext includedContext : includedContexts) {
- ITagLibrary[] includedLibraries = includedContext instanceof IPageContext ? ((IPageContext)includedContext).getLibraries() : null;
- if (includedLibraries != null) {
- for (ITagLibrary lib : includedLibraries) {
- libraries.add(lib);
- }
+ for (ELContext includedContext : this.fIncludedContexts) {
+ if (includedContext instanceof IPageContext) {
+ ITagLibrary[] includedLibraries = ((IPageContext)includedContext).getLibraries();
+ for (ITagLibrary lib : includedLibraries) {
+ libraries.add(lib);
}
}
}
@@ -139,26 +131,17 @@
* @param bundle
*/
public void addResourceBundle(IResourceBundle bundle) {
- if (bundles == null) {
- bundles = new ArrayList<IResourceBundle>();
- }
bundles.add(bundle);
}
public IResourceBundle[] getResourceBundles() {
Set<IResourceBundle> resourceBundles = new HashSet<IResourceBundle>();
- if (bundles != null) {
- resourceBundles.addAll(bundles);
- }
-
- List<ELContext> includedContexts = getIncludedContexts();
- if (includedContexts != null) {
- for (ELContext includedContext : includedContexts) {
- IResourceBundle[] includedBundles = includedContext instanceof IPageContext ? ((IPageContext)includedContext).getResourceBundles() : null;
- if (includedBundles != null) {
- for (IResourceBundle b : includedBundles) {
- resourceBundles.add(b);
- }
+ resourceBundles.addAll(bundles);
+
+ for (ELContext includedContext : this.fIncludedContexts) {
+ if (includedContext instanceof IPageContext) {
+ for (IResourceBundle b : ((IPageContext)includedContext).getResourceBundles()) {
+ resourceBundles.add(b);
}
}
}
@@ -167,30 +150,17 @@
}
public void addCSSStyleSheetDescriptor(CSSStyleSheetDescriptor cssStyleSheetDescriptor) {
- if (fCSSStyleSheetDescriptors == null) {
- fCSSStyleSheetDescriptors = new ArrayList<CSSStyleSheetDescriptor>();
- }
fCSSStyleSheetDescriptors.add(cssStyleSheetDescriptor);
}
public List<CSSStyleSheetDescriptor> getCSSStyleSheetDescriptors() {
List<CSSStyleSheetDescriptor> descrs = new ArrayList<CSSStyleSheetDescriptor>();
- if (fCSSStyleSheetDescriptors != null) {
- for (CSSStyleSheetDescriptor descr : fCSSStyleSheetDescriptors) {
- descrs.add(descr);
- }
- }
+ descrs.addAll(fCSSStyleSheetDescriptors);
- List<ELContext> includedContexts = getIncludedContexts();
- if (includedContexts != null) {
- for (ELContext includedContext : includedContexts) {
- if (includedContext instanceof ICSSContainerSupport) {
- List<CSSStyleSheetDescriptor> includedSheetDescriptors = ((ICSSContainerSupport)includedContext).getCSSStyleSheetDescriptors();
- if (includedSheetDescriptors != null) {
- descrs.addAll(includedSheetDescriptors);
- }
- }
+ for (ELContext includedContext : this.fIncludedContexts) {
+ if (includedContext instanceof ICSSContainerSupport) {
+ descrs.addAll(((ICSSContainerSupport)includedContext).getCSSStyleSheetDescriptors());
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -108,7 +108,7 @@
*/
public ITagLibrary[] getTagLibraries(String uri) {
ITagLibrary[] result = libraries.getLibrariesArray(uri);
- if(result == null || result.length == 0) {
+ if(result.length == 0) {
result = StaticLibraries.instance.getLibraries(uri);
}
return result;
@@ -408,7 +408,7 @@
try {
if(!project.hasNature(IKbProject.NATURE_ID)) return;
} catch (CoreException e) {
- //ignore
+ WebKbPlugin.getDefault().logError(e);
}
File file = getStorageFile();
if(file != null) {
@@ -432,19 +432,14 @@
*/
private File getStorageFile() {
WebKbPlugin plugin = WebKbPlugin.getDefault();
- if( plugin != null) {
- //The plug-in instance can be null at shutdown, when the plug-in is stopped.
- IPath path = plugin.getStateLocation();
- File file = new File(path.toFile(), "projects/" + project.getName() + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- return file;
- } else {
- return null;
- }
+ //The plug-in instance can be null at shutdown, when the plug-in is stopped.
+ IPath path = plugin.getStateLocation();
+ File file = new File(path.toFile(), "projects/" + project.getName() + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ return file;
}
public void clearStorage() {
- File f = getStorageFile();
- if(f != null && f.isFile()) f.delete();
+ getStorageFile().delete();
}
/*
@@ -810,7 +805,7 @@
List<Change> changes = null;
Set<ITagLibrary> ls = libraries.removePath(source);
- if(ls != null) for (ITagLibrary l: ls) {
+ for (ITagLibrary l: ls) {
changes = Change.addChange(changes, new Change(this, null, l, null));
if(l.getResource() != null && l.getResource().getProject() == project) modifications++;
}
@@ -827,7 +822,7 @@
* @param cs
*/
public void updateChildPaths(IPath path, Collection<IPath> cs) {
- IPath[] ps = sourcePaths2.keySet().toArray(new IPath[0]);
+ IPath[] ps = sourcePaths2.keySet().toArray(new IPath[sourcePaths2.keySet().size()]);
for (IPath p: ps) {
if(!cs.contains(p) && !p.equals(path) && path.isPrefixOf(p)) {
pathRemoved(p);
@@ -854,7 +849,7 @@
public Map<Object,ITagLibrary> findLibraryDeclarations(IPath source) {
Map<Object,ITagLibrary> map = new HashMap<Object, ITagLibrary>();
Set<ITagLibrary> fs = libraries.getLibrariesBySource(source);
- if(fs != null) for (ITagLibrary c: fs) {
+ for (ITagLibrary c: fs) {
KbObject ci = (KbObject)c;
map.put(ci.getId(), c);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -24,71 +25,62 @@
*
*/
public class LibraryStorage {
+
+ private static final Set<ITagLibrary> EMPTY_SET = Collections.emptySet();
+ private static final ITagLibrary[] EMPTY_LIB_ARRAY = new ITagLibrary[0];
+
private Set<ITagLibrary> allLibraries = new HashSet<ITagLibrary>();
- private ITagLibrary[] allLibrariesArray = null;
- Map<IPath, Set<ITagLibrary>> librariesBySource = new HashMap<IPath, Set<ITagLibrary>>();
- Map<String, Set<ITagLibrary>> librariesByUri = new HashMap<String, Set<ITagLibrary>>();
+ private ITagLibrary[] allLibrariesArray = EMPTY_LIB_ARRAY;
+ private Map<IPath, Set<ITagLibrary>> librariesBySource = new HashMap<IPath, Set<ITagLibrary>>();
+ private Map<String, Set<ITagLibrary>> librariesByUri = new HashMap<String, Set<ITagLibrary>>();
private Map<String,ITagLibrary[]> librariesByUriArray = new HashMap<String, ITagLibrary[]>();
- public void clear() {
- synchronized(allLibraries) {
- allLibraries.clear();
- allLibrariesArray = null;
- }
+ public synchronized void clear() {
+ allLibraries.clear();
+ allLibrariesArray = EMPTY_LIB_ARRAY;
librariesBySource.clear();
- synchronized (librariesByUri) {
- librariesByUri.clear();
- librariesByUriArray.clear();
- }
+ librariesByUri.clear();
+ librariesByUriArray.clear();
}
- public ITagLibrary[] getAllLibrariesArray() {
- if(allLibrariesArray == null) {
- synchronized(allLibraries) {
- allLibrariesArray = allLibraries.toArray(new ITagLibrary[0]);
- }
+ public synchronized ITagLibrary[] getAllLibrariesArray() {
+ if(allLibrariesArray.length == 0) {
+ allLibrariesArray = allLibraries.toArray(new ITagLibrary[allLibraries.size()]);
}
return allLibrariesArray;
}
- private static final ITagLibrary[] EMPTY_LIB_ARRAY = new ITagLibrary[0];
-
- public ITagLibrary[] getLibrariesArray(String uri) {
+ public synchronized ITagLibrary[] getLibrariesArray(String uri) {
ITagLibrary[] result = librariesByUriArray.get(uri);
if(result == null) {
- synchronized(librariesByUri) {
- Set<ITagLibrary> libs = librariesByUri.get(uri);
- if(libs!=null) {
- result = libs.toArray(new ITagLibrary[0]);
- } else {
- result = EMPTY_LIB_ARRAY;
- }
- librariesByUriArray.put(uri, result);
+ Set<ITagLibrary> libs = librariesByUri.get(uri);
+ if(libs!=null) {
+ result = libs.toArray(new ITagLibrary[libs.size()]);
+ } else {
+ result = EMPTY_LIB_ARRAY;
}
+ librariesByUriArray.put(uri, result);
}
return result;
}
- public Set<ITagLibrary> getLibrariesBySource(IPath path) {
- return librariesBySource.get(path);
+ public synchronized Set<ITagLibrary> getLibrariesBySource(IPath path) {
+ Set<ITagLibrary> set = librariesBySource.get(path);
+ return set != null ? set : EMPTY_SET;
}
- public ITagLibrary[] getLibrariesArray(IPath path) {
+ public synchronized ITagLibrary[] getLibrariesArray(IPath path) {
ITagLibrary[] result = EMPTY_LIB_ARRAY;
- synchronized(librariesBySource) {
- Set<ITagLibrary> libs = librariesBySource.get(path);
- if(libs!=null) {
- result = libs.toArray(new ITagLibrary[0]);
- }
+ Set<ITagLibrary> libs = librariesBySource.get(path);
+ if(libs!=null) {
+ result = libs.toArray(new ITagLibrary[0]);
}
return result;
}
- public void addLibrary(ITagLibrary f) {
- synchronized(allLibraries) {
- allLibraries.add(f);
- allLibrariesArray = null;
- }
+ public synchronized void addLibrary(ITagLibrary f) {
+ allLibraries.add(f);
+ allLibrariesArray = EMPTY_LIB_ARRAY;
IPath path = f.getSourcePath();
if(path != null) {
Set<ITagLibrary> fs = librariesBySource.get(path);
@@ -99,22 +91,18 @@
fs.add(f);
}
String uri = f.getURI();
- synchronized (librariesByUri) {
- librariesByUriArray.remove(uri);
- Set<ITagLibrary> ul = librariesByUri.get(uri);
- if (ul == null) {
- ul = new HashSet<ITagLibrary>();
- librariesByUri.put(uri, ul);
- }
- ul.add(f);
+ librariesByUriArray.remove(uri);
+ Set<ITagLibrary> ul = librariesByUri.get(uri);
+ if (ul == null) {
+ ul = new HashSet<ITagLibrary>();
+ librariesByUri.put(uri, ul);
}
+ ul.add(f);
}
- public void removeLibrary(ITagLibrary f) {
- synchronized(allLibraries) {
- allLibraries.remove(f);
- allLibrariesArray = null;
- }
+ public synchronized void removeLibrary(ITagLibrary f) {
+ allLibraries.remove(f);
+ allLibrariesArray = EMPTY_LIB_ARRAY;
IPath path = f.getSourcePath();
if(path != null) {
Set<ITagLibrary> fs = librariesBySource.get(path);
@@ -126,36 +114,35 @@
}
}
String uri = f.getURI();
- synchronized (librariesByUri) {
- Set<ITagLibrary> ul = librariesByUri.get(uri);
- librariesByUriArray.remove(uri);
- if (ul != null) {
- ul.remove(f);
- if (ul.isEmpty()) {
- librariesByUri.remove(uri);
- }
+ Set<ITagLibrary> ul = librariesByUri.get(uri);
+ librariesByUriArray.remove(uri);
+ if (ul != null) {
+ ul.remove(f);
+ if (ul.isEmpty()) {
+ librariesByUri.remove(uri);
}
}
}
- public Set<ITagLibrary> removePath(IPath path) {
+ public synchronized Set<ITagLibrary> removePath(IPath path) {
Set<ITagLibrary> fs = librariesBySource.get(path);
- if(fs == null) return null;
- for (ITagLibrary f: fs) {
- synchronized(allLibraries) {
+ if(fs == null) {
+ fs = EMPTY_SET;
+ } else {
+ for (ITagLibrary f: fs) {
allLibraries.remove(f);
- allLibrariesArray = null;
- }
- synchronized (librariesByUri) {
+ allLibrariesArray = EMPTY_LIB_ARRAY;
Set<ITagLibrary> s = librariesByUri.get(f.getURI());
- if(s != null) s.remove(f);
- if(s != null && s.isEmpty()) {
- librariesByUri.remove(f.getURI());
+ if(s != null) {
+ s.remove(f);
+ if(s.isEmpty()) {
+ librariesByUri.remove(f.getURI());
+ }
}
librariesByUriArray.remove(f.getURI());
}
+ librariesBySource.remove(path);
}
- librariesBySource.remove(path);
return fs;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -112,13 +112,17 @@
* @param name space
*/
public void addNameSpace(IRegion region, INameSpace nameSpace) {
- if (nameSpaces.get(region) == null) {
- Map<String, INameSpace> nameSpaceMap = new HashMap<String, INameSpace>();
+ Map<String, INameSpace> nameSpaceMap = nameSpaces.get(region);
+
+ if (nameSpaceMap == null) {
+ nameSpaceMap = new HashMap<String, INameSpace>();
nameSpaces.put(region, nameSpaceMap);
}
- nameSpaces.get(region).put(nameSpace.getPrefix(), nameSpace); // Fix for JBIDE-5097
+
+ nameSpaceMap.put(nameSpace.getPrefix(), nameSpace); // Fix for JBIDE-5097
+
String uri = nameSpace.getURI();
- if(uri!=null && uri.length()>0) {
+ if(!uri.isEmpty()) {
uris.add(uri);
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -44,6 +44,7 @@
* Abstract implementation of ITagLibrary
* @author Alexey Kazakov
*/
+
public abstract class AbstractTagLib extends KbObject implements ITagLibrary {
public static String URI = "uri"; //$NON-NLS-1$
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -33,7 +33,7 @@
* @param prefix
*/
public NameSpace(String uri, String prefix) {
- this(uri, prefix, null);
+ this(uri, prefix, new ITagLibrary[0]);
}
/**
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2011-08-27 00:46:51 UTC (rev 34349)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2011-08-27 01:10:10 UTC (rev 34350)
@@ -243,7 +243,6 @@
}
protected void searchInCach(IFile file){
- if(file == null) return;
ELResolver[] resolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
ELContext context = PageContextFactory.createPageContext(file);
@@ -252,44 +251,37 @@
return;
ELReference[] references = context.getELReferences();
- resolvers = context.getElResolvers();
- IRelevanceCheck[] checks = getRelevanceChecks(resolvers);
-
+
if(javaElement != null){
+ resolvers = context.getElResolvers();
+ IRelevanceCheck[] checks = getRelevanceChecks(resolvers);
List<MatchArea> areas = new ArrayList<MatchArea>();
for(ELReference reference : references){
int offset = reference.getStartPosition();
for(ELExpression operand : reference.getEl()){
for (int i = 0; i < resolvers.length; i++) {
ELResolver resolver = resolvers[i];
- if (!(resolver instanceof ELCompletionEngine))
+ if (!(resolver instanceof ELCompletionEngine) || !checks[i].isRelevant(operand.getText()))
continue;
- if(checks[i] != null && !checks[i].isRelevant(operand.getText()))
- continue;
ELResolution resolution = resolver.resolve(context, operand, offset);
- if(resolution == null)
- continue;
-
- List<ELSegment> segments = resolution.findSegmentsByJavaElement(javaElement);
-
- if(segments == null)
- continue;
-
- for(ELSegment segment : segments){
- int o = offset+segment.getSourceReference().getStartPosition();
- int l = segment.getSourceReference().getLength();
-
- if(!contains(areas, o, l)){
- match(file, o, l);
- areas.add(new MatchArea(o, l));
+ if(resolution != null) {
+ List<ELSegment> segments = resolution.findSegmentsByJavaElement(javaElement);
+ for(ELSegment segment : segments){
+ int o = offset+segment.getSourceReference().getStartPosition();
+ int l = segment.getSourceReference().getLength();
+
+ if(!contains(areas, o, l)){
+ match(file, o, l);
+ areas.add(new MatchArea(o, l));
+ }
}
}
}
}
}
- }else{
+ } else {
for(ELReference reference : references){
int offset = reference.getStartPosition();
ELExpression[] expressions = reference.getEl();
@@ -324,7 +316,6 @@
}
protected IRelevanceCheck[] getRelevanceChecks(ELResolver[] resolvers) {
- if(resolvers == null) return new IRelevanceCheck[0];
IRelevanceCheck[] checks = new IRelevanceCheck[resolvers.length];
for (int i = 0; i < checks.length; i++) {
checks[i] = resolvers[i].createRelevanceCheck(javaElement);
14 years, 3 months
JBoss Tools SVN: r34349 - in trunk/jsf/tests/org.jboss.tools.jsf.ui.test: src/org/jboss/tools/jsf/ui/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-08-26 20:46:51 -0400 (Fri, 26 Aug 2011)
New Revision: 34349
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
Log:
fixed, jsf.ui.tests JSPProblemMarkerResolutionTest failure https://issues.jboss.org/browse/JBIDE-9532
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2011-08-27 00:18:39 UTC (rev 34348)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2011-08-27 00:46:51 UTC (rev 34349)
@@ -34,6 +34,8 @@
org.jboss.tools.vpe.ui.palette,
org.eclipse.gef,
org.eclipse.pde.ui,
- org.eclipse.wst.validation
+ org.eclipse.wst.validation,
+ org.eclipse.wst.html.core;bundle-version="1.1.500",
+ org.eclipse.wst.html.ui;bundle-version="1.0.600"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java 2011-08-27 00:18:39 UTC (rev 34348)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JSPProblemMarkerResolutionTest.java 2011-08-27 00:46:51 UTC (rev 34349)
@@ -1,17 +1,32 @@
package org.jboss.tools.jsf.ui.test;
+import java.util.List;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jst.jsp.ui.internal.validation.JSPContentSourceValidator;
import org.eclipse.ui.IMarkerResolution;
-import org.jboss.tools.common.base.test.validation.TestUtil;
+import org.eclipse.wst.html.internal.validation.HTMLValidator;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
+import org.eclipse.wst.validation.internal.MarkerManager;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.jst.web.ui.action.JSPProblemMarkerResolutionGenerator;
import org.jboss.tools.tests.AbstractResourceMarkerTest;
public class JSPProblemMarkerResolutionTest extends AbstractResourceMarkerTest{
IProject project = null;
+ private static final String JSP_MARKER_TYPE = "org.eclipse.jst.jsp.core.validationMarker";
+ private static final String XHTML_MARKER_TYPE = "org.eclipse.wst.html.core.validationMarker";
+ private static final String JSP_EXT = "jsp";
+ private static final String XHTML_EXT = "xhtml";
public JSPProblemMarkerResolutionTest() {
super("JSP Problem Marker Resolution Tests");
@@ -25,13 +40,72 @@
protected void setUp() throws Exception {
project = ResourcesPlugin.getWorkspace().getRoot().getProject("test_jsf_project");
}
-
+
+ private void validate(IFile file) throws CoreException{
+ MarkerManager manager = MarkerManager.getDefault();
+
+ if(JSP_EXT.equals(file.getFileExtension())){
+ file.deleteMarkers(JSP_MARKER_TYPE, true, IResource.DEPTH_INFINITE);
+ JSPContentSourceValidator validator = new JSPContentSourceValidator();
+
+ ValidationResult result = validator.validate(file, 0, new ValidationState(), new NullProgressMonitor());
+
+ IReporter reporter = result.getReporter(new NullProgressMonitor());
+ List messages = reporter.getMessages();
+ for(Object m : messages){
+ if(m instanceof Message){
+ Message message = (Message)m;
+ IMarker marker = file.createMarker(JSP_MARKER_TYPE);
+ marker.setAttributes(message.getAttributes());
+ marker.setAttribute(IMarker.MESSAGE, message.getText());
+ int markerSeverity = IMarker.SEVERITY_INFO;
+ int sev = message.getSeverity();
+ if ((sev & IMessage.HIGH_SEVERITY) != 0)markerSeverity = IMarker.SEVERITY_ERROR;
+ else if ((sev & IMessage.NORMAL_SEVERITY) != 0)markerSeverity = IMarker.SEVERITY_WARNING;
+ marker.setAttribute(IMarker.SEVERITY, markerSeverity);
+ marker.setAttribute(IMarker.LINE_NUMBER, message.getLineNumber());
+ marker.setAttribute(IMarker.CHAR_START, message.getOffset());
+ marker.setAttribute(IMarker.CHAR_END, message.getOffset()+message.getLength());
+ }
+ }
+ }else if(XHTML_EXT.equals(file.getFileExtension())){
+ file.deleteMarkers(XHTML_MARKER_TYPE, true, IResource.DEPTH_INFINITE);
+
+ HTMLValidator validator = new HTMLValidator();
+
+ ValidationResult result = validator.validate(file, 0, new ValidationState(), new NullProgressMonitor());
+
+ IReporter reporter = result.getReporter(new NullProgressMonitor());
+ List messages = reporter.getMessages();
+ for(Object m : messages){
+ if(m instanceof Message){
+ Message message = (Message)m;
+ IMarker marker = file.createMarker(XHTML_MARKER_TYPE);
+ marker.setAttributes(message.getAttributes());
+ marker.setAttribute(IMarker.MESSAGE, message.getText());
+ int markerSeverity = IMarker.SEVERITY_INFO;
+ int sev = message.getSeverity();
+ if ((sev & IMessage.HIGH_SEVERITY) != 0)markerSeverity = IMarker.SEVERITY_ERROR;
+ else if ((sev & IMessage.NORMAL_SEVERITY) != 0)markerSeverity = IMarker.SEVERITY_WARNING;
+ marker.setAttribute(IMarker.SEVERITY, markerSeverity);
+ marker.setAttribute(IMarker.LINE_NUMBER, message.getLineNumber());
+ marker.setAttribute(IMarker.CHAR_START, message.getOffset());
+ marker.setAttribute(IMarker.CHAR_END, message.getOffset()+message.getLength());
+ }
+ }
+ }
+ }
+
public void testProblemMarkerResolutionInJSP() throws CoreException {
IFile jspFile = project.getFile("WebContent/pages/test_page1.jsp");
+
+ assertTrue("File must be exists.",jspFile.exists());
+
+ validate(jspFile);
- assertMarkerIsCreated(jspFile, "org.eclipse.jst.jsp.core.validationMarker", "Unknown tag (h:commandButton).", true, 8);
+ assertMarkerIsCreated(jspFile, JSP_MARKER_TYPE, "Unknown tag (h:commandButton).", true, 8);
- IMarker[] markers = findMarkers(jspFile, "org.eclipse.jst.jsp.core.validationMarker", "Unknown tag (h:commandButton).");
+ IMarker[] markers = findMarkers(jspFile, JSP_MARKER_TYPE, "Unknown tag (h:commandButton).");
assertEquals(1, markers.length);
@@ -45,17 +119,21 @@
}
}
- TestUtil.validate(jspFile);
+ validate(jspFile);
- assertMarkerIsNotCreated(jspFile, "org.eclipse.jst.jsp.core.validationMarker", "Unknown tag (h:commandButton).");
+ assertMarkerIsNotCreated(jspFile, JSP_MARKER_TYPE, "Unknown tag (h:commandButton).");
}
public void testProblemMarkerResolutionInXHTML() throws CoreException {
IFile jspFile = project.getFile("WebContent/pages/test_page2.xhtml");
+
+ assertTrue("File must be exists.",jspFile.exists());
+
+ validate(jspFile);
- assertMarkerIsCreated(jspFile, "org.eclipse.wst.html.core.validationMarker", "Unknown tag (ui:insert).", true, 8, 17, 31);
+ assertMarkerIsCreated(jspFile, XHTML_MARKER_TYPE, "Unknown tag (ui:insert).", true, 8, 17, 31);
- IMarker[] markers = findMarkers(jspFile, "org.eclipse.wst.html.core.validationMarker", "Unknown tag (ui:insert).");
+ IMarker[] markers = findMarkers(jspFile, XHTML_MARKER_TYPE, "Unknown tag (ui:insert).");
assertEquals(3, markers.length);
@@ -69,8 +147,8 @@
}
}
- TestUtil.validate(jspFile);
+ validate(jspFile);
- assertMarkerIsNotCreated(jspFile, "org.eclipse.wst.html.core.validationMarker", "Unknown tag (ui:insert).");
+ assertMarkerIsNotCreated(jspFile, XHTML_MARKER_TYPE, "Unknown tag (ui:insert).");
}
}
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2011-08-27 00:18:39 UTC (rev 34348)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2011-08-27 00:46:51 UTC (rev 34349)
@@ -92,10 +92,10 @@
"org.jboss.tools.jsf.ui.test",
new String[]{"projects/test_add_jsf_capabilities"},
new String[]{"test_add_jsf_capabilities"}));
-// suite.addTest(new ValidationProjectTestSetup(new TestSuite(JSPProblemMarkerResolutionTest.class),
-// "org.jboss.tools.jsf.ui.test",
-// new String[]{"projects/test_jsf_project"},
-// new String[]{"test_jsf_project"}));
+ suite.addTest(new ValidationProjectTestSetup(new TestSuite(JSPProblemMarkerResolutionTest.class),
+ "org.jboss.tools.jsf.ui.test",
+ new String[]{"projects/test_jsf_project"},
+ new String[]{"test_jsf_project"}));
suite.addTest(
new ProjectImportTestSetup(new TestSuite(TestPalette.class),
"org.jboss.tools.jsf.ui.test",
14 years, 3 months
JBoss Tools SVN: r34348 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-08-26 20:18:39 -0400 (Fri, 26 Aug 2011)
New Revision: 34348
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferenceInitializer.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencesUtils.java
Log:
fix for preferences loading. DefaultScope should be asked for default values because it enables:
1. PreferenceIntializer to be called for default initialization
2. plugin_customization.ini values to be applied for usage preferences
Everything else stays the same
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferenceInitializer.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferenceInitializer.java 2011-08-26 21:34:23 UTC (rev 34347)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferenceInitializer.java 2011-08-27 00:18:39 UTC (rev 34348)
@@ -22,9 +22,5 @@
UsageReportPreferencesUtils.getStore().setDefault(
IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID,
IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_DEFAULTVALUE);
-
- UsageReportPreferencesUtils.getStore().setDefault(
- IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID,
- IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_DEFAULTVALUE);
}
}
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java 2011-08-26 21:34:23 UTC (rev 34347)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java 2011-08-27 00:18:39 UTC (rev 34348)
@@ -41,7 +41,8 @@
/**
* Returns <code>true</code> if the usage reporting enablement is set in the
- * preferences. Returns <code>false</code> otherwise.
+ * preferences. Returns <code>false</code> otherwise. It is intentionally not set
+ * by UsageReportPreferenceInitializer
*
* @return
*/
@@ -60,7 +61,7 @@
public static boolean isEnabled() {
return UsageReportPreferencesUtils.getPreferences().getBoolean(
IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID,
- IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_DEFAULTVALUE);
+ getEnabledDefault());
}
/**
@@ -71,10 +72,33 @@
public static boolean isAskUser() {
return UsageReportPreferencesUtils.getPreferences().getBoolean(
IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID,
+ getAskUserDefault());
+ }
+
+ /**
+ * Get default value for isAskUser preference
+ *
+ * @return default value set by UsageReportPreferenceInitializer
+ */
+ static boolean getAskUserDefault() {
+ return UsageReportPreferencesUtils.getDefaultPreferences().getBoolean(
+ IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_ID,
IUsageReportPreferenceConstants.ASK_USER_USAGEREPORT_DEFAULTVALUE);
}
/**
+ * Get default value for isEnabled preference
+ *
+ * @return default value that is set in plugin_customization.ini file or
+ * IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_DEFAULTVALUE otherwise
+ *
+ */
+ public static boolean getEnabledDefault() {
+ return UsageReportPreferencesUtils.getDefaultPreferences().getBoolean(
+ IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID,
+ IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_DEFAULTVALUE);
+ }
+ /**
* Sets the ask user.
*
* @param askUser
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencesUtils.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencesUtils.java 2011-08-26 21:34:23 UTC (rev 34347)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferencesUtils.java 2011-08-27 00:18:39 UTC (rev 34348)
@@ -13,6 +13,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
@@ -30,11 +31,15 @@
}
public static IEclipsePreferences getPreferences() {
- return new ConfigurationScope().getNode(JBossToolsUsageActivator.PLUGIN_ID);
+ return ConfigurationScope.INSTANCE.getNode(JBossToolsUsageActivator.PLUGIN_ID);
}
-
+
+ public static IEclipsePreferences getDefaultPreferences() {
+ return DefaultScope.INSTANCE.getNode(JBossToolsUsageActivator.PLUGIN_ID);
+ }
+
public static IPersistentPreferenceStore getStore() {
- return new ScopedPreferenceStore(new ConfigurationScope(), JBossToolsUsageActivator.PLUGIN_ID);
+ return new ScopedPreferenceStore(ConfigurationScope.INSTANCE, JBossToolsUsageActivator.PLUGIN_ID);
}
public static void checkedSavePreferences(IEclipsePreferences preferences, Plugin plugin, String message) {
14 years, 3 months
JBoss Tools SVN: r34347 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-08-26 17:34:23 -0400 (Fri, 26 Aug 2011)
New Revision: 34347
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
Log:
fixed deprecation warning
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2011-08-26 18:19:47 UTC (rev 34346)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2011-08-26 21:34:23 UTC (rev 34347)
@@ -27,7 +27,7 @@
*/
@Override
public void initializeDefaultPreferences() {
- IEclipsePreferences defaultPreferences = ((IScopeContext) new DefaultScope()).getNode(CDICorePlugin.PLUGIN_ID);
+ IEclipsePreferences defaultPreferences = ((IScopeContext)DefaultScope.INSTANCE).getNode(CDICorePlugin.PLUGIN_ID);
defaultPreferences.putBoolean(SeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME, true);
defaultPreferences.put(SeverityPreferences.WRONG_BUILDER_ORDER_PREFERENCE_NAME, CDIPreferences.ERROR);
for (String name : CDIPreferences.SEVERITY_OPTION_NAMES) {
14 years, 4 months
JBoss Tools SVN: r34346 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-08-26 14:19:47 -0400 (Fri, 26 Aug 2011)
New Revision: 34346
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
Log:
https://issues.jboss.org/browse/JBIDE-9588 Added subtasks to Progress View for XHTML Syntax validation
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java 2011-08-26 16:25:05 UTC (rev 34345)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java 2011-08-26 18:19:47 UTC (rev 34346)
@@ -13,6 +13,8 @@
public static String VALIDATING_RESOURCE;
public static String VALIDATING_PROJECT;
+ public static String XHTML_VALIDATION;
+
static {
NLS.initializeMessages(BUNDLE_NAME, JSFValidationMessage.class);
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java 2011-08-26 16:25:05 UTC (rev 34345)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java 2011-08-26 18:19:47 UTC (rev 34346)
@@ -17,11 +17,15 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
+import java.text.MessageFormat;
import java.util.ArrayList;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.xml.core.internal.validation.ValidatorHelper;
import org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration;
import org.eclipse.wst.xml.core.internal.validation.XMLValidationInfo;
@@ -44,20 +48,50 @@
* @author Victor Rubezhny
*/
public class XHTMLSyntaxValidator extends Validator {
+
+ IProgressMonitor monitor;
+
+ public void validationStarting(IProject project, ValidationState state, IProgressMonitor monitor) {
+ super.validationStarting(project, state, monitor);
+ this.monitor = monitor;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
+ displaySubtask(monitor, JSFValidationMessage.XHTML_VALIDATION, resource.getFullPath());
+ return super.validate(resource, kind, state, monitor);
+ }
+
+ private void displaySubtask(String message, Object... arguments) {
+ displaySubtask(monitor, MessageFormat.format(message, arguments));
+ }
+
+ private void displaySubtask(IProgressMonitor monitor, String message, Object... arguments) {
+ if(monitor!=null) {
+ monitor.subTask(MessageFormat.format(message, arguments));
+ }
+ }
+
/**
* The method is overridden to setup our own XMLValidator to be used
*/
@Override
public ValidationReport validate(String uri, InputStream inputstream,
NestedValidatorContext context, ValidationResult result) {
-
+
+ displaySubtask(JSFValidationMessage.XHTML_VALIDATION, uri);
+
long ct = 0;
if (JSFModelPlugin.getDefault().isDebugging()) {
ct = System.currentTimeMillis();
}
-
+
XMLValidator validator = XMLValidator.getInstance();
-
+
XMLValidationConfiguration configuration = new XMLValidationConfiguration();
try {
configuration.setFeature(
@@ -79,7 +113,7 @@
} else {
valreport = validator.validate(uri, null, configuration, context, result);
}
-
+
if (JSFModelPlugin.getDefault().isDebugging()) {
long et = System.currentTimeMillis() - ct;
System.out.println("XHTMLSyntaxValidator: Elapsed time = " + (et) + " ms for " + uri);
@@ -87,14 +121,13 @@
return valreport;
}
-
/**
* An XML validator specific to XHTML-files validation. This validator will wrap the internal
* XML syntax validator.
*/
public static class XMLValidator extends org.eclipse.wst.xml.core.internal.validation.XMLValidator {
private static XMLValidator instance = null;
-
+
/**
* Return the one and only instance of the XML validator. The validator
* can be reused and cannot be customized so there should only be one instance of it.
@@ -273,4 +306,4 @@
}
}
}
-}
+}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties 2011-08-26 16:25:05 UTC (rev 34345)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties 2011-08-26 18:19:47 UTC (rev 34346)
@@ -5,4 +5,6 @@
#Messages for Progress Monitor
SEARCHING_RESOURCES=project "{0}"; searching resources for validation (JSF Validator)
VALIDATING_RESOURCE=project "{0}"; resource "{1}" (JSF Validator)
-VALIDATING_PROJECT=project "{0}" (JSF Validator)
\ No newline at end of file
+VALIDATING_PROJECT=project "{0}" (JSF Validator)
+
+XHTML_VALIDATION=XHTML Syntax Validation: {0}
\ No newline at end of file
14 years, 4 months
JBoss Tools SVN: r34345 - trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-08-26 12:25:05 -0400 (Fri, 26 Aug 2011)
New Revision: 34345
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
Log:
temporary commented, jsf.ui.tests JSPProblemMarkerResolutionTest failure https://issues.jboss.org/browse/JBIDE-9532
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2011-08-26 16:13:13 UTC (rev 34344)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2011-08-26 16:25:05 UTC (rev 34345)
@@ -92,10 +92,10 @@
"org.jboss.tools.jsf.ui.test",
new String[]{"projects/test_add_jsf_capabilities"},
new String[]{"test_add_jsf_capabilities"}));
- suite.addTest(new ValidationProjectTestSetup(new TestSuite(JSPProblemMarkerResolutionTest.class),
- "org.jboss.tools.jsf.ui.test",
- new String[]{"projects/test_jsf_project"},
- new String[]{"test_jsf_project"}));
+// suite.addTest(new ValidationProjectTestSetup(new TestSuite(JSPProblemMarkerResolutionTest.class),
+// "org.jboss.tools.jsf.ui.test",
+// new String[]{"projects/test_jsf_project"},
+// new String[]{"test_jsf_project"}));
suite.addTest(
new ProjectImportTestSetup(new TestSuite(TestPalette.class),
"org.jboss.tools.jsf.ui.test",
14 years, 4 months
JBoss Tools SVN: r34344 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-08-26 12:13:13 -0400 (Fri, 26 Aug 2011)
New Revision: 34344
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java
Log:
code clean up
1. new String("string") replaced with just "string"
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java 2011-08-26 15:07:45 UTC (rev 34343)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/UsageReportPreferences.java 2011-08-26 16:13:13 UTC (rev 34344)
@@ -46,7 +46,7 @@
* @return
*/
public static boolean isEnablementSet() {
- String defaultValue = new String("undefinedValue");
+ String defaultValue = "undefinedValue";
String value = UsageReportPreferencesUtils.getPreferences().get(
IUsageReportPreferenceConstants.USAGEREPORT_ENABLED_ID, defaultValue);
return value != defaultValue;
14 years, 4 months
JBoss Tools SVN: r34343 - trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/dialog.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-08-26 11:07:45 -0400 (Fri, 26 Aug 2011)
New Revision: 34343
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/dialog/ForgeCommandListDialog.java
Log:
JBIDE-9543
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/dialog/ForgeCommandListDialog.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/dialog/ForgeCommandListDialog.java 2011-08-26 15:06:00 UTC (rev 34342)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/dialog/ForgeCommandListDialog.java 2011-08-26 15:07:45 UTC (rev 34343)
@@ -1,5 +1,6 @@
package org.jboss.tools.forge.ui.dialog;
+import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.StringTokenizer;
@@ -10,6 +11,8 @@
import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
@@ -21,8 +24,6 @@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -33,10 +34,15 @@
private ForgeRuntime runtime = null;
+ private SortedMap<String, SortedSet<String>> allCandidates = null;
+
private Tree tree;
private Text filterText;
- private TreeItem selectedItem;
+// private TreeItem selectedItem;
+
+ private String selectedPlugin = "";
+ private String selectedCommand = "";
public ForgeCommandListDialog(IWorkbenchWindow window, ForgeRuntime runtime) {
super(window.getShell(),
@@ -49,9 +55,10 @@
"Select the command you want Forge to execute",
"Start typing to filter the list");
this.runtime = runtime;
+ this.allCandidates = getAllCandidates();
}
- private SortedMap<String, SortedSet<String>> getCandidates() {
+ private SortedMap<String, SortedSet<String>> getAllCandidates() {
SortedMap<String, SortedSet<String>> result = new TreeMap<String, SortedSet<String>>();
String pluginCandidates = runtime.sendCommand("plugin-candidates-query");
SortedSet<String> currentCommands = null;
@@ -72,12 +79,30 @@
}
return result;
}
-
- protected Control createDialogArea(Composite parent) {
- Composite result = (Composite)super.createDialogArea(parent);
- result.setLayout(new FillLayout());
- tree = new Tree(result, SWT.SINGLE | SWT.V_SCROLL);
- SortedMap<String, SortedSet<String>> candidates = getCandidates();
+
+ private void refreshTree() {
+ String filter = filterText.getText();
+ if ("".equals(filter)) {
+ createTree(allCandidates, false);
+ } else {
+ SortedMap<String, SortedSet<String>> candidates = new TreeMap<String, SortedSet<String>>();
+ for (Entry<String, SortedSet<String>> entry : allCandidates.entrySet()) {
+ SortedSet<String> set = new TreeSet<String>();
+ for (String candidate : entry.getValue()) {
+ if (candidate.indexOf(filter) != -1) {
+ set.add(candidate);
+ }
+ }
+ if ((entry.getKey().indexOf(filter) != -1 || !set.isEmpty())) {
+ candidates.put(entry.getKey(), set);
+ }
+ }
+ createTree(candidates, true);
+ }
+ }
+
+ private void createTree(SortedMap<String, SortedSet<String>> candidates, boolean expand) {
+ tree.removeAll();
for (String plugin : candidates.keySet()) {
TreeItem pluginItem = new TreeItem(tree, SWT.NONE);
pluginItem.setText(plugin);
@@ -86,19 +111,29 @@
TreeItem commandItem = new TreeItem(pluginItem, SWT.NONE);
commandItem.setText(command);
}
- pluginItem.addListener(SWT.MouseDoubleClick, new Listener() {
-
- @Override
- public void handleEvent(Event event) {
- System.out.println("plugin item doubleclicked :" + event.widget);
- }
- });
+ pluginItem.setExpanded(expand);
}
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite result = (Composite)super.createDialogArea(parent);
+ result.setLayout(new FillLayout());
+ tree = new Tree(result, SWT.SINGLE | SWT.V_SCROLL);
tree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.item instanceof TreeItem) {
- selectedItem = (TreeItem)e.item;
+ TreeItem selectedItem = (TreeItem)e.item;
+ if (selectedItem.getParentItem() != null) {
+ selectedPlugin = selectedItem.getParentItem().getText();
+ selectedCommand = selectedItem.getText();
+ if (selectedPlugin.equals(selectedCommand)) {
+ selectedCommand = "";
+ }
+ } else {
+ selectedPlugin = selectedItem.getText();
+ selectedCommand = "";
+ }
}
}
});
@@ -108,22 +143,13 @@
insertCommand();
}
});
+ refreshTree();
return result;
}
private void insertCommand() {
- String str = "";
- if (selectedItem != null && selectedItem.getText() != null) {
- str = selectedItem.getText();
- }
- TreeItem parentItem = selectedItem.getParentItem();
- if (parentItem != null) {
- String parentString = parentItem.getText();
- if (parentString != null && !parentString.equals(str)) {
- str = parentString + " " + str;
- }
- }
- runtime.sendInput(str);
+ String str = selectedPlugin + " " + selectedCommand;
+ runtime.sendInput(str.trim());
close();
}
@@ -150,49 +176,19 @@
protected Control createTitleControl(Composite parent) {
filterText = new Text(parent, SWT.NONE);
-
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
- .applyTo(filterText);
+ .applyTo(filterText);
+ filterText.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ refreshTree();
+ }
+ });
+ return filterText;
+ }
-// filterText.addKeyListener(getKeyAdapter());
-// filterText.addKeyListener(new KeyListener() {
-// public void keyPressed(KeyEvent e) {
-// switch (e.keyCode) {
-// case SWT.CR:
-// case SWT.KEYPAD_CR:
-// handleSelection();
-// break;
-// case SWT.ARROW_DOWN:
-// int index = table.getSelectionIndex();
-// if (index != -1 && table.getItemCount() > index + 1) {
-// table.setSelection(index + 1);
-// }
-// table.setFocus();
-// break;
-// case SWT.ARROW_UP:
-// index = table.getSelectionIndex();
-// if (index != -1 && index >= 1) {
-// table.setSelection(index - 1);
-// table.setFocus();
-// }
-// break;
-// case SWT.ESC:
-// close();
-// break;
-// }
-// }
-//
-// public void keyReleased(KeyEvent e) {
-// // do nothing
-// }
-// });
-// filterText.addModifyListener(new ModifyListener() {
-// public void modifyText(ModifyEvent e) {
-// String text = ((Text) e.widget).getText().toLowerCase();
-// refresh(text);
-// }
-// });
-
+ protected Control getFocusControl() {
return filterText;
}
14 years, 4 months
JBoss Tools SVN: r34342 - trunk/forge/plugins/org.jboss.tools.forge.runtime.ext.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-08-26 11:06:00 -0400 (Fri, 26 Aug 2011)
New Revision: 34342
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/
Log:
*.index files should not be in svn
Property changes on: trunk/forge/plugins/org.jboss.tools.forge.runtime.ext
___________________________________________________________________
Modified: svn:ignore
- bin
+ bin
*.index
14 years, 4 months