Author: scabanovich
Date: 2007-07-17 08:33:41 -0400 (Tue, 17 Jul 2007)
New Revision: 2462
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
Log:
EXIN-217 seam.properties files processed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-17
12:32:44 UTC (rev 2461)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-17
12:33:41 UTC (rev 2462)
@@ -29,12 +29,6 @@
public class SeamCoreBuilder extends IncrementalProjectBuilder {
public static String BUILDER_ID = "org.jboss.tools.seam.core.seambuilder";
- static IFileScanner[] FILE_SCANNERS = {
- new JavaScanner(),
- new XMLScanner(),
-// new LibraryScanner()
- };
-
SeamResourceVisitor resourceVisitor = null;
SeamProject getSeamProject() {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-17
12:32:44 UTC (rev 2461)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamResourceVisitor.java 2007-07-17
12:33:41 UTC (rev 2462)
@@ -18,12 +18,11 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
+import org.jboss.tools.seam.internal.core.scanner.xml.PropertiesScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
/**
@@ -33,6 +32,7 @@
static IFileScanner[] FILE_SCANNERS = {
new JavaScanner(),
new XMLScanner(),
+ new PropertiesScanner(),
};
SeamProject p;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-17
12:32:44 UTC (rev 2461)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-17
12:33:41 UTC (rev 2462)
@@ -11,9 +11,6 @@
package org.jboss.tools.seam.internal.core.scanner.lib;
import java.io.ByteArrayInputStream;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -27,7 +24,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
@@ -36,9 +32,9 @@
import org.jboss.tools.common.model.util.XModelObjectUtil;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.InnerModelHelper;
-import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.xml.PropertiesScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
/**
@@ -113,26 +109,9 @@
if(ds1 != null) ds.add(ds1);
}
if(seamProperties != null) {
- XModelObject[] properties = seamProperties.getChildren();
- Map<String, SeamPropertiesDeclaration> ds1 = new HashMap<String,
SeamPropertiesDeclaration>();
- for (int i = 0; i < properties.length; i++) {
- String name = properties[i].getAttributeValue("name");
- String value = properties[i].getAttributeValue("value");
- int q = name.lastIndexOf('.');
- if(q < 0) continue;
- String componentName = name.substring(0, q);
- String propertyName = name.substring(q + 1);
- SeamPropertiesDeclaration d = ds1.get(componentName);
- if(d == null) {
- d = new SeamPropertiesDeclaration();
- d.setId(properties[i]);
- d.setSourcePath(path);
- d.setName(componentName);
- ds1.put(componentName, d);
- }
- d.addStringProperty(propertyName, value);
- }
- ds.getComponents().addAll(ds1.values());
+ PropertiesScanner scanner = new PropertiesScanner();
+ LoadedDeclarations ds1 = scanner.parse(seamProperties, path);
+ if(ds1 != null) ds.add(ds1);
}
return ds;
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2007-07-17
12:33:41 UTC (rev 2462)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.scanner.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.internal.core.InnerModelHelper;
+import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
+import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+
+public class PropertiesScanner implements IFileScanner {
+
+ public PropertiesScanner() {}
+
+ /**
+ * 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("seam.properties")) return true;
+ 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;
+ if(f.getName().equals("seam.properties")) return true;
+ return false;
+ }
+
+ /**
+ * Returns list of components
+ * @param f
+ * @return
+ * @throws Exception
+ */
+ public LoadedDeclarations parse(IFile f) throws Exception {
+ XModel model = InnerModelHelper.createXModel(f.getProject());
+ if(model == null) return null;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
+ return parse(o, f.getFullPath());
+ }
+
+ public LoadedDeclarations parse(XModelObject o, IPath source) {
+ if(o == null) return null;
+ LoadedDeclarations ds = new LoadedDeclarations();
+
+ XModelObject[] properties = o.getChildren();
+ Map<String, SeamPropertiesDeclaration> ds1 = new HashMap<String,
SeamPropertiesDeclaration>();
+ for (int i = 0; i < properties.length; i++) {
+ String name = properties[i].getAttributeValue("name");
+ String value = properties[i].getAttributeValue("value");
+ int q = name.lastIndexOf('.');
+ if(q < 0) continue;
+ String componentName = name.substring(0, q);
+ String propertyName = name.substring(q + 1);
+ SeamPropertiesDeclaration d = ds1.get(componentName);
+ if(d == null) {
+ d = new SeamPropertiesDeclaration();
+ d.setId(properties[i]);
+ d.setSourcePath(source);
+ d.setName(componentName);
+ ds1.put(componentName, d);
+ }
+ d.addStringProperty(propertyName, value);
+ }
+ return ds;
+ }
+
+}