Author: scabanovich
Date: 2009-05-15 10:23:50 -0400 (Fri, 15 May 2009)
New Revision: 15291
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.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/scanner/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/IFileScanner.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LoadedDeclarations.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ScannerException.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/build.properties
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/taglib/ITagLibrary.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-05-15 14:19:46
UTC (rev 15290)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-05-15 14:23:50
UTC (rev 15291)
@@ -2,7 +2,9 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.jboss.tools.jst.web.kb;singleton:=true
+Bundle-Localization: plugin
Bundle-Version: 1.0.0
+Bundle-ClassPath: webKb.jar
Bundle-Activator: org.jboss.tools.jst.web.kb.WebKbPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -13,4 +15,5 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Export-Package: org.jboss.tools.jst.web.kb,
+ org.jboss.tools.jst.web.kb.internal,
org.jboss.tools.jst.web.kb.taglib
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/build.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/build.properties 2009-05-15 14:19:46 UTC
(rev 15290)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/build.properties 2009-05-15 14:23:50 UTC
(rev 15291)
@@ -1,4 +1,5 @@
-bin.includes = META-INF/,\
+bin.includes = plugin.xml,\
+ META-INF/,\
plugin.properties,\
webKb.jar,\
about.html
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-05-15 14:23:50 UTC (rev
15291)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+ <extension
+ id="kbbuilder"
+ name="KB Builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ hasNature="false">
+ <run
+ class="org.jboss.tools.jst.web.kb.internal.KbBuilder">
+ </run>
+ </builder>
+ </extension>
+ <extension
+ id="kbnature"
+ name="KB Project Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.jboss.tools.jst.web.kb.internal.KbProject">
+ </run>
+ </runtime>
+ <builder
+ id="org.jboss.tools.jst.web.kb.kbbuilder">
+ </builder>
+ </extension>
+
+</plugin>
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb;
+
+import org.eclipse.core.resources.IProjectNature;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public interface IKbProject extends IProjectNature {
+ public static String NATURE_ID = Activator.PLUGIN_ID + ".kbnature";
//$NON-NLS-1$
+
+ public ITagLibrary[] getTagLibraries();
+
+ public void resolve();
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,40 @@
+package org.jboss.tools.jst.web.kb;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.jst.web.WebModelPlugin;
+
+public class KbProjectFactory {
+
+ /**
+ * Factory method creating seam project instance by project resource.
+ * Returns null if
+ * (1) project does not exist
+ * (2) project is closed
+ * (3) project has no seam nature
+ * (4) creating seam project failed.
+ * @param project
+ * @param resolve if true and results of last build have not been resolved they are
loaded.
+ * @return
+ */
+ public static IKbProject getSeamProject(IProject project, boolean resolve) {
+ if(project == null || !project.exists() || !project.isOpen()) return null;
+ try {
+ if(!project.hasNature(IKbProject.NATURE_ID)) return null;
+ } catch (CoreException e) {
+ //ignore - all checks are done above
+ return null;
+ }
+
+ IKbProject kbProject;
+ try {
+ kbProject = (IKbProject)project.getNature(IKbProject.NATURE_ID);
+ if(resolve) kbProject.resolve();
+ return kbProject;
+ } catch (CoreException e) {
+ WebModelPlugin.getPluginLog().logError(e);
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.tools.jst.web.kb.Activator;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class KbBuilder extends IncrementalProjectBuilder {
+ public static String BUILDER_ID = Activator.PLUGIN_ID + ".kbbuilder";
//$NON-NLS-1$
+
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
+ throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.WebModelPlugin;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.internal.scanner.ClassPathMonitor;
+import org.jboss.tools.jst.web.kb.internal.scanner.LoadedDeclarations;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class KbProject implements IKbProject {
+ IProject project;
+
+ ClassPathMonitor classPath = new ClassPathMonitor(this);
+
+ Set<IPath> sourcePaths = new HashSet<IPath>();
+
+ Map<IPath, LoadedDeclarations> sourcePaths2 = new HashMap<IPath,
LoadedDeclarations>();
+
+ private boolean isStorageResolved = false;
+
+ Set<KbProject> dependsOn = new HashSet<KbProject>();
+
+ Set<KbProject> usedBy = new HashSet<KbProject>();
+
+ LibraryStorage libraries = new LibraryStorage();
+
+ public ITagLibrary[] getTagLibraries() {
+ return libraries.getAllFactoriesArray();
+ }
+
+ public void configure() throws CoreException {
+ addToBuildSpec(KbBuilder.BUILDER_ID);
+ }
+
+ public void deconfigure() throws CoreException {
+ removeFromBuildSpec(KbBuilder.BUILDER_ID);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public IPath getSourcePath() {
+ return project == null ? null : project.getFullPath();
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ /**
+ *
+ * @param p
+ */
+ public void addSeamProject(KbProject p) {
+ if(dependsOn.contains(p)) return;
+ dependsOn.add(p);
+ p.addDependentSeamProject(this);
+ if(!p.isStorageResolved) {
+ p.resolve();
+ } else {
+ Map<IPath,LoadedDeclarations> map = null;
+ try {
+ map = p.getAllDeclarations();
+ } catch (CloneNotSupportedException e) {
+ WebModelPlugin.getPluginLog().logError(e);
+ }
+ for (IPath source : map.keySet()) {
+ LoadedDeclarations ds = map.get(source);
+ registerComponents(ds, source);
+ }
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Set<KbProject> getSeamProjects() {
+ return dependsOn;
+ }
+
+ /**
+ *
+ * @param p
+ */
+ public void addDependentSeamProject(KbProject p) {
+ usedBy.add(p);
+ }
+
+ /**
+ *
+ * @param p
+ */
+ public void removeSeamProject(KbProject p) {
+ if(!dependsOn.contains(p)) return;
+ p.usedBy.remove(this);
+ dependsOn.remove(p);
+ IPath[] ps = sourcePaths2.keySet().toArray(new IPath[0]);
+ for (int i = 0; i < ps.length; i++) {
+ IPath pth = ps[i];
+ if(p.getSourcePath().isPrefixOf(pth) || (p.isPathLoaded(pth) &&
!EclipseResourceUtil.isJar(pth.toString()))) {
+ pathRemoved(pth);
+ }
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public ClassPathMonitor getClassPath() {
+ return classPath;
+ }
+
+ /**
+ *
+ * @param load
+ */
+ public void resolveStorage(boolean load) {
+ if(isStorageResolved) return;
+ if(load) {
+ load();
+ } else {
+ isStorageResolved = true;
+ }
+ }
+
+ /**
+ *
+ */
+ public void resolve() {
+ resolveStorage(true);
+ }
+
+ /**
+ * Loads results of last build, which are considered
+ * actual until next build.
+ */
+ public void load() {
+ if(isStorageResolved) return;
+ isStorageResolved = true;
+
+ //TODO
+ }
+
+ /**
+ *
+ * @return
+ * @throws CloneNotSupportedException
+ */
+ Map<IPath, LoadedDeclarations> getAllDeclarations() throws
CloneNotSupportedException {
+ Map<IPath, LoadedDeclarations> map = new HashMap<IPath,
LoadedDeclarations>();
+ for (ITagLibrary f : getTagLibraries()) {
+ IPath p = f.getSourcePath();
+ if(p == null || EclipseResourceUtil.isJar(p.toString())) continue;
+ LoadedDeclarations ds = map.get(p);
+ if(ds == null) {
+ ds = new LoadedDeclarations();
+ map.put(p, ds);
+ }
+ ds.getLibraries().add(f.clone());
+ }
+ return map;
+ }
+
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
+ protected void addToBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand command = null;
+ ICommand commands[] = description.getBuildSpec();
+ for (int i = 0; i < commands.length && command == null; ++i) {
+ if (commands[i].getBuilderName().equals(builderID))
+ command = commands[i];
+ }
+ if (command == null) {
+ command = description.newCommand();
+ command.setBuilderName(builderID);
+ ICommand[] oldCommands = description.getBuildSpec();
+ ICommand[] newCommands = new ICommand[oldCommands.length + 1];
+ System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
+ newCommands[oldCommands.length] = command;
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ }
+ }
+
+ static String EXTERNAL_TOOL_BUILDER =
"org.eclipse.ui.externaltools.ExternalToolBuilder";
+ static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle";
+
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
+ protected void removeFromBuildSpec(String builderID) throws CoreException {
+ IProjectDescription description = getProject().getDescription();
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ String builderName = commands[i].getBuilderName();
+ if (!builderName.equals(builderID)) {
+ if(!builderName.equals(EXTERNAL_TOOL_BUILDER)) continue;
+ Object handle = commands[i].getArguments().get(LAUNCH_CONFIG_HANDLE);
+ if(handle == null || handle.toString().indexOf(builderID) < 0) continue;
+ }
+ ICommand[] newCommands = new ICommand[commands.length - 1];
+ System.arraycopy(commands, 0, newCommands, 0, i);
+ System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
+ description.setBuildSpec(newCommands);
+ getProject().setDescription(description, null);
+ return;
+ }
+ }
+
+ /**
+ * Package local method called by builder.
+ * @param component
+ * @param source
+ */
+ public void registerComponents(LoadedDeclarations ds, IPath source) {
+ //TODO
+ }
+
+ public boolean isPathLoaded(IPath source) {
+ return sourcePaths2.containsKey(source);
+ }
+
+
+ /**
+ * Package local method called by builder.
+ * @param source
+ */
+ public void pathRemoved(IPath source) {
+ //TODO
+ }
+
+
+ class LibraryStorage {
+ private Set<ITagLibrary> allFactories = new HashSet<ITagLibrary>();
+ private ITagLibrary[] allFactoriesArray = null;
+ Map<IPath, Set<ITagLibrary>> factoriesBySource = new HashMap<IPath,
Set<ITagLibrary>>();
+
+ public void clear() {
+ synchronized(allFactories) {
+ allFactories.clear();
+ allFactoriesArray = null;
+ }
+ factoriesBySource.clear();
+ }
+
+ public ITagLibrary[] getAllFactoriesArray() {
+ ITagLibrary[] result = allFactoriesArray;
+ if(result == null) {
+ synchronized(allFactories) {
+ allFactoriesArray = allFactories.toArray(new ITagLibrary[0]);
+ result = allFactoriesArray;
+ }
+ }
+ return result;
+ }
+
+ public Set<ITagLibrary> getFactoriesBySource(IPath path) {
+ return factoriesBySource.get(path);
+ }
+
+ public void addFactory(ITagLibrary f) {
+ synchronized(allFactories) {
+ allFactories.add(f);
+ allFactoriesArray = null;
+ }
+ IPath path = f.getSourcePath();
+ if(path != null) {
+ Set<ITagLibrary> fs = factoriesBySource.get(path);
+ if(fs == null) {
+ fs = new HashSet<ITagLibrary>();
+ factoriesBySource.put(path, fs);
+ }
+ fs.add(f);
+ }
+ }
+
+ public void removeFactory(ITagLibrary f) {
+ synchronized(allFactories) {
+ allFactories.remove(f);
+ allFactoriesArray = null;
+ }
+ IPath path = f.getSourcePath();
+ if(path != null) {
+ Set<ITagLibrary> fs = factoriesBySource.get(path);
+ if(fs != null) {
+ fs.remove(f);
+ }
+ if(fs.isEmpty()) {
+ factoriesBySource.remove(fs);
+ }
+ }
+ }
+
+ public Set<ITagLibrary> removePath(IPath path) {
+ Set<ITagLibrary> fs = factoriesBySource.get(path);
+ if(fs == null) return null;
+ for (ITagLibrary f: fs) {
+ synchronized(allFactories) {
+ allFactories.remove(f);
+ allFactoriesArray = null;
+ }
+ }
+ factoriesBySource.remove(path);
+ return fs;
+ }
+
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.scanner;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FileSystemsLoader;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.XModelObjectUtil;
+import org.jboss.tools.jst.web.WebModelPlugin;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.internal.KbProject;
+import org.jboss.tools.jst.web.model.helpers.InnerModelHelper;
+
+/**
+ * Monitors class path of project and loads seam components of it.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class ClassPathMonitor {
+ KbProject project;
+ XModel model = null;
+
+ List<String> paths = null;
+ Map<IPath, String> paths2 = new HashMap<IPath, String>();
+
+ Set<String> processedPaths = new HashSet<String>();
+
+ /**
+ * Creates instance of class path for seam project
+ * @param project
+ */
+ public ClassPathMonitor(KbProject project) {
+ this.project = project;
+ }
+
+ /**
+ * Returns seam project
+ * @return
+ */
+ public KbProject getProject() {
+ return project;
+ }
+
+ /**
+ * Initialization of inner model.
+ */
+ public void init() {
+ model = InnerModelHelper.createXModel(project.getProject());
+ }
+
+ static String[] SYSTEM_JARS = {"rt.jar", "jsse.jar",
"jce.jar", "charsets.jar"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ static Set<String> SYSTEM_JAR_SET = new HashSet<String>();
+
+ static {
+ for (int i = 0; i < SYSTEM_JARS.length; i++) SYSTEM_JAR_SET.add(SYSTEM_JARS[i]);
+ }
+
+ /**
+ * Returns true if class path was up-to-date.
+ * Otherwise, updates inner model and disables class loader.
+ * @return
+ */
+ public boolean update() {
+ List<String> newPaths = null;
+ try {
+ newPaths = EclipseResourceUtil.getClassPath(project.getProject());
+ List<String> jre = EclipseResourceUtil.getJREClassPath(project.getProject());
+ if(jre != null) newPaths.removeAll(jre);
+ } catch (CoreException e) {
+ //TODO
+ WebModelPlugin.getDefault().logError(e);
+ } catch(IOException e) {
+ WebModelPlugin.getDefault().logError(e);
+ }
+ if(paths == null && newPaths == null) return false;
+ if((newPaths == null || paths == null) || (paths.size() != newPaths.size())) {
+ paths = newPaths;
+ } else {
+ boolean b = false;
+ for (int i = 0; i < paths.size() && !b; i++) {
+ if(!paths.get(i).equals(newPaths.get(i))) b = true;
+ }
+ if(!b) return false;
+ paths = newPaths;
+ }
+ createMap();
+ XModelObject object = model.getByPath("FileSystems"); //$NON-NLS-1$
+ XModelObject[] fs = object.getChildren("FileSystemJar"); //$NON-NLS-1$
+ Set<XModelObject> fss = new HashSet<XModelObject>();
+ for (int i = 0; i < fs.length; i++) fss.add(fs[i]);
+
+ for (int i = 0; i < paths.size(); i++) {
+ String path = paths.get(i);
+ if(!EclipseResourceUtil.isJar(path)) continue;
+ String fileName = new File(path).getName();
+ if(SYSTEM_JAR_SET.contains(fileName)) continue;
+ String jsname = "lib-" + fileName; //$NON-NLS-1$
+ XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname);
//$NON-NLS-1$
+ if(o != null) {
+ fss.remove(o);
+ } else {
+ o = object.getModel().createModelObject("FileSystemJar", null);
//$NON-NLS-1$
+ o.setAttributeValue("name", jsname); //$NON-NLS-1$
+ o.setAttributeValue("location", path); //$NON-NLS-1$
+ o.set(FileSystemsLoader.IS_ADDED_TO_CLASSPATH, "true"); //$NON-NLS-1$
+ object.addChild(o);
+// object.setModified(true);
+ }
+ }
+
+ for (XModelObject o: fss) {
+ String path = XModelObjectUtil.expand(o.getAttributeValue("location"),
o.getModel(), null); //$NON-NLS-1$
+ if("true".equals(o.get(FileSystemsLoader.IS_ADDED_TO_CLASSPATH))) {
//$NON-NLS-1$
+ o.removeFromParent();
+ } else if(!new File(path).exists()) {
+ o.removeFromParent();
+ }
+ }
+
+ return true;
+ }
+
+ private void createMap() {
+ paths2.clear();
+ if(paths != null) {
+ for (String p : paths) {
+ paths2.put(new Path(p), p);
+ }
+ }
+ }
+
+ /**
+ * Loads seam components from items recently added to class path.
+ */
+ public void process() {
+ Iterator<String> it = processedPaths.iterator();
+ while(it.hasNext()) {
+ String p = it.next();
+ if(paths.contains(p)) continue;
+ project.pathRemoved(new Path(p));
+ it.remove();
+ }
+ for (int i = 0; i < paths.size(); i++) {
+ String p = paths.get(i);
+ if(processedPaths.contains(p)) continue;
+ processedPaths.add(p);
+
+ LibraryScanner scanner = new LibraryScanner();
+ scanner.setClassPath(this);
+
+ String fileName = new File(p).getName();
+ if(SYSTEM_JAR_SET.contains(fileName)) continue;
+ String jsname = "lib-" + fileName; //$NON-NLS-1$
+ XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname);
//$NON-NLS-1$
+ if(o == null) continue;
+
+ LoadedDeclarations c = null;
+ try {
+ if(scanner.isLikelyComponentSource(o)) {
+ c = scanner.parse(o, new Path(p), project);
+ }
+ } catch (ScannerException e) {
+ WebModelPlugin.getDefault().logError(e);
+ }
+ if(c == null) {
+ c = new LoadedDeclarations();
+ }
+ if(c != null) {
+ componentsLoaded(c, new Path(p));
+ }
+ }
+
+ validateProjectDependencies();
+ }
+
+ public void validateProjectDependencies() {
+ List<KbProject> ps = null;
+
+ try {
+ ps = getSeamProjects(project.getProject());
+ } catch (CoreException e) {
+ WebModelPlugin.getPluginLog().logError(e);
+ }
+ if(ps != null) {
+ Set<KbProject> set = project.getSeamProjects();
+ Set<KbProject> removable = new HashSet<KbProject>();
+ removable.addAll(set);
+ removable.removeAll(ps);
+ ps.removeAll(set);
+ for (KbProject p : ps) {
+ project.addSeamProject(p);
+ }
+ for (KbProject p : removable) {
+ project.removeSeamProject(p);
+ }
+ }
+ }
+
+ public boolean hasToUpdateProjectDependencies() {
+ List<KbProject> ps = null;
+
+ try {
+ ps = getSeamProjects(project.getProject());
+ } catch (CoreException e) {
+ WebModelPlugin.getPluginLog().logError(e);
+ }
+ if(ps != null) {
+ Set<KbProject> set = project.getSeamProjects();
+ Set<KbProject> removable = new HashSet<KbProject>();
+ removable.addAll(set);
+ removable.removeAll(ps);
+ ps.removeAll(set);
+ for (KbProject p : ps) {
+ return true;
+ }
+ for (KbProject p : removable) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void componentsLoaded(LoadedDeclarations c, IPath path) {
+ if(c == null) return;
+ project.registerComponents(c, path);
+ }
+
+ List<KbProject> getSeamProjects(IProject project) throws CoreException {
+ List<KbProject> list = new ArrayList<KbProject>();
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
+ for (int i = 0; i < es.length; i++) {
+ if(es[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IProject p =
ResourcesPlugin.getWorkspace().getRoot().getProject(es[i].getPath().lastSegment());
+ if(p == null || !p.isAccessible()) continue;
+ IKbProject sp = KbProjectFactory.getSeamProject(p, false);
+ if(sp != null) list.add((KbProject)sp);
+ }
+ }
+ return list;
+ }
+
+ public void pathLoaded(IPath path) {
+ String p = paths2.get(path);
+ if(p != null) {
+ processedPaths.add(p);
+ }
+ }
+
+ public boolean hasPath(IPath path) {
+ return paths2.get(path) != null;
+ }
+
+ public void clean() {
+ paths = null;
+ if(paths2 != null) paths2.clear();
+ processedPaths.clear();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/IFileScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/IFileScanner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/IFileScanner.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.scanner;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.jst.web.kb.IKbProject;
+
+public interface IFileScanner {
+
+ /**
+ * First, the most trivial check by file mask.
+ * If it returns false, other scanners will be invoked.
+ * If it returns true, other scanners will NOT be invoked.
+ * @param resource
+ * @return
+ */
+ public boolean isRelevant(IFile resource);
+
+ /**
+ * Second, more detailed check of file content.
+ * @param f
+ * @return
+ */
+ public boolean isLikelyComponentSource(IFile f);
+
+ /**
+ * Loading components declared in resource.
+ * @param f
+ * @return
+ * @throws ScannerException
+ */
+ public LoadedDeclarations parse(IFile f, IKbProject sp) throws ScannerException;
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/IFileScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.scanner;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IParent;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.XModelObjectUtil;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.model.helpers.InnerModelHelper;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class LibraryScanner implements IFileScanner {
+ ClassPathMonitor classPath = null;
+
+ //Now it is absolute file on disk
+ IPath sourcePath = null;
+
+ public LibraryScanner() {}
+
+ public void setClassPath(ClassPathMonitor classPath) {
+ this.classPath = classPath;
+ }
+
+ public boolean isRelevant(IFile f) {
+ if(EclipseResourceUtil.isJar(f.getName())) return true;
+ return false;
+ }
+
+ public boolean isLikelyComponentSource(IFile f) {
+ XModel model = InnerModelHelper.createXModel(f.getProject());
+ if(model == null) return false;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
+ if(o == null) return false;
+ if(!o.getModelEntity().getName().equals("FileSystemJar")) { //$NON-NLS-1$
+ ((FileSystemsImpl)o.getModel().getByPath("FileSystems")).updateOverlapped();
//$NON-NLS-1$
+ o = EclipseResourceUtil.getObjectByResource(f);
+ if(o == null || !o.getModelEntity().getName().equals("FileSystemJar"))
return false; //$NON-NLS-1$
+ }
+ return isLikelyComponentSource(o);
+ }
+
+ public LoadedDeclarations parse(IFile f, IKbProject sp) throws ScannerException {
+ XModel model = InnerModelHelper.createXModel(f.getProject());
+ if(model == null) return null;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
+ if(o == null) return null;
+ if(!o.getModelEntity().getName().equals("FileSystemJar")) { //$NON-NLS-1$
+ ((FileSystemsImpl)o.getModel().getByPath("FileSystems")).updateOverlapped();
//$NON-NLS-1$
+ o = EclipseResourceUtil.getObjectByResource(f);
+ if(o == null || !o.getModelEntity().getName().equals("FileSystemJar"))
return null; //$NON-NLS-1$
+ }
+ return parse(o, f.getFullPath(), sp);
+ }
+
+ public boolean isLikelyComponentSource(XModelObject o) {
+ if(o == null) return false;
+ if(o.getChildByPath("seam.properties") != null) return true; //$NON-NLS-1$
+ if(o.getChildByPath("META-INF/seam.properties") != null) return true;
//$NON-NLS-1$
+ if(o.getChildByPath("META-INF/components.xml") != null) return true;
//$NON-NLS-1$
+ return false;
+ }
+
+ public LoadedDeclarations parse(XModelObject o, IPath path, IKbProject sp) throws
ScannerException {
+ if(o == null) return null;
+ sourcePath = path;
+ XModelObject seamProperties = o.getChildByPath("META-INF/seam.properties");
//$NON-NLS-1$
+ if(seamProperties == null) seamProperties =
o.getChildByPath("seam.properties"); //$NON-NLS-1$
+ XModelObject componentsXML = o.getChildByPath("META-INF/components.xml");
//$NON-NLS-1$
+ if(componentsXML == null && seamProperties == null) return null;
+
+ LoadedDeclarations ds = new LoadedDeclarations();
+
+ if(componentsXML != null) {
+ LoadedDeclarations ds1 = new XMLScanner().parse(componentsXML, path, sp);
+ if(ds1 != null) ds.add(ds1);
+ }
+
+ return ds;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LoadedDeclarations.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LoadedDeclarations.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LoadedDeclarations.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.scanner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ * This object keeps all declarations loaded from one source.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class LoadedDeclarations {
+ List<ITagLibrary> libraries = new ArrayList<ITagLibrary>();
+
+ public List<ITagLibrary> getLibraries() {
+ return libraries;
+ }
+
+ public void add(LoadedDeclarations ds) {
+ if(ds == null) return;
+ libraries.addAll(ds.libraries);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LoadedDeclarations.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ScannerException.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ScannerException.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ScannerException.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jst.web.kb.internal.scanner;
+
+public class ScannerException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public ScannerException() {
+ }
+
+ public ScannerException(Throwable cause) {
+ super(cause);
+ }
+
+ public ScannerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ScannerException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.scanner;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.NamespaceMapping;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.model.helpers.InnerModelHelper;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class XMLScanner implements IFileScanner {
+
+ public XMLScanner() {}
+
+ /**
+ * Returns true if file is probable component source -
+ * has components.xml name or *.component.xml mask.
+ * @param resource
+ * @return
+ */
+ public boolean isRelevant(IFile resource) {
+ if(resource.getName().equals("components.xml")) return true; //$NON-NLS-1$
+ if(resource.getName().endsWith(".component.xml")) return true; //$NON-NLS-1$
+ return false;
+ }
+
+ /**
+ * This method should be called only if isRelevant returns true;
+ * Makes simple check if this java file contains annotation Name.
+ * @param resource
+ * @return
+ */
+ public boolean isLikelyComponentSource(IFile f) {
+ if(!f.isSynchronized(IFile.DEPTH_ZERO) || !f.exists()) return false;
+ XModel model = InnerModelHelper.createXModel(f.getProject());
+ if(model == null) return false;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
+ if(o == null) return false;
+ if(o.getModelEntity().getName().startsWith("FileSeamComponent")) return true;
//$NON-NLS-1$
+ return false;
+ }
+
+ /**
+ * Returns list of components
+ * @param f
+ * @return
+ * @throws ScannerException
+ */
+ public LoadedDeclarations parse(IFile f, IKbProject sp) throws ScannerException {
+ XModel model = InnerModelHelper.createXModel(f.getProject());
+ if(model == null) return null;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
+ return parse(o, f.getFullPath(), sp);
+ }
+
+ static Set<String> INTERNAL_ATTRIBUTES = new HashSet<String>();
+
+ static {
+ INTERNAL_ATTRIBUTES.add("NAME"); //$NON-NLS-1$
+ INTERNAL_ATTRIBUTES.add("EXTENSION"); //$NON-NLS-1$
+ INTERNAL_ATTRIBUTES.add("#comment"); //$NON-NLS-1$
+ }
+
+ public LoadedDeclarations parse(XModelObject o, IPath source, IKbProject sp) {
+ if(o == null) return null;
+
+ if(o.getParent() instanceof FolderImpl) {
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
+ if(f != null && f.exists()) {
+ try {
+ ((FolderImpl)o.getParent()).updateChildFile(o, f.getLocation().toFile());
+ } catch (XModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ if(o.getParent() == null) {
+ boolean b = isLikelyComponentSource(f);
+ if(!b) return null;
+ o = EclipseResourceUtil.getObjectByResource(o.getModel(), f);
+ if(o == null) return null;
+ }
+ }
+ }
+
+ LoadedDeclarations ds = new LoadedDeclarations();
+ XModelObject[] os = o.getChildren();
+ for (int i = 0; i < os.length; i++) {
+ XModelEntity componentEntity = os[i].getModelEntity();
+ //TODO
+// if(os[i].getModelEntity().getName().startsWith("SeamFactory")) {
//$NON-NLS-1$
+// SeamXmlFactory factory = new SeamXmlFactory();
+// factory.setId(os[i]);
+// factory.setSourcePath(source);
+// factory.setName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.NAME));
+// factory.setValue(new XMLValueInfo(os[i], "value")); //$NON-NLS-1$
+// factory.setMethod(new XMLValueInfo(os[i], "method")); //$NON-NLS-1$
+// ds.getLibraries().add(factory);
+// }
+ }
+ return ds;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-05-15
14:19:46 UTC (rev 15290)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -17,6 +17,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -100,6 +101,14 @@
this.components = components;
}
+ public IPath getSourcePath() {
+ //TODO
+ if(resource != null) {
+ return resource.getFullPath();
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.TagLibrary#getResource()
*/
@@ -176,4 +185,11 @@
}
return proposals.toArray(new TextProposal[proposals.size()]);
}
+
+ public AbstractTagLib clone() throws CloneNotSupportedException {
+ AbstractTagLib t = (AbstractTagLib)super.clone();
+ t.components = new HashMap<String, IComponent>();
+ t.components.putAll(components);
+ return t;
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java 2009-05-15
14:19:46 UTC (rev 15290)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java 2009-05-15
14:23:50 UTC (rev 15291)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.kb.taglib;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IProposalProcessor;
@@ -21,6 +22,8 @@
*/
public interface ITagLibrary extends IProposalProcessor {
+ public IPath getSourcePath();
+
/**
* @return URI of the tag lib.
*/
@@ -54,4 +57,7 @@
* @return components
*/
public IComponent[] getComponents(KbQuery query, IPageContext context);
-}
\ No newline at end of file
+
+ public ITagLibrary clone() throws CloneNotSupportedException;
+
+}