JBoss Tools SVN: r6725 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-06 14:28:18 -0500 (Thu, 06 Mar 2008)
New Revision: 6725
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperties.java
Log:
throws proper NPEs. Also formatting
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperties.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperties.java 2008-03-06 19:26:15 UTC (rev 6724)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperties.java 2008-03-06 19:28:18 UTC (rev 6725)
@@ -31,18 +31,15 @@
private PropertiesExt properties;
- public XbProperties ()
- {
+ public XbProperties () {
super();
this.properties = new PropertiesExt();
}
- public XbProperties (XbProperties props)
- {
+ public XbProperties (XbProperties props) {
super(props);
this.properties = new PropertiesExt();
- for (Iterator iter = getChildren(XbProperty.class).iterator(); iter.hasNext(); )
- {
+ for (Iterator iter = getChildren(XbProperty.class).iterator(); iter.hasNext(); ) {
XbProperty element = (XbProperty) iter.next();
addProperty(element);
}
@@ -56,21 +53,29 @@
private static final long serialVersionUID = 1L;
private Hashtable propertyElements;
- public PropertiesExt ()
- {
+ public PropertiesExt () {
propertyElements = new Hashtable();
}
+ /**
+ * Will map String key -> XbProperty element(key,value) in the local structure
+ * and map String key -> String value in the superclass
+ *
+ * @return The String value held previously
+ */
public synchronized Object put(Object key, Object value) {
- if (!propertyElements.containsKey(key))
- {
+ if( key == null )
+ throw new NullPointerException("Key is null in " + getClass().getName());
+
+ if( value == null )
+ throw new NullPointerException("Value is null in " + getClass().getName());
+
+ if (!propertyElements.containsKey(key)) {
XbProperty element = new XbProperty();
element.setName((String)key);
element.setValue((String)value);
propertyElements.put(key, element);
-
- }
- else {
+ } else {
XbProperty element = (XbProperty)propertyElements.get(key);
element.setValue((String)value);
}
@@ -80,28 +85,23 @@
public synchronized Object remove(Object key) {
propertyElements.remove(key);
-
return super.remove(key);
}
- public Collection getPropertyElements ()
- {
+ public Collection getPropertyElements () {
return propertyElements.values();
}
}
- public PropertiesExt getProperties ()
- {
+ public PropertiesExt getProperties () {
return properties;
}
- public void addProperty (Object property)
- {
+ public void addProperty (Object property) {
addProperty((XbProperty)property);
}
- public void addProperty (XbProperty property)
- {
+ public void addProperty (XbProperty property) {
properties.setProperty(property.getName(), property.getValue());
addChild(property);
}
16 years, 2 months
JBoss Tools SVN: r6724 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-06 14:26:15 -0500 (Thu, 06 Mar 2008)
New Revision: 6724
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackagesObjectProvider.java
Log:
theoretical support for actions added
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackagesObjectProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackagesObjectProvider.java 2008-03-06 19:25:53 UTC (rev 6723)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackagesObjectProvider.java 2008-03-06 19:26:15 UTC (rev 6724)
@@ -70,10 +70,9 @@
}
- public Object getAttributeValue(Object object, MarshallingContext context, String namespaceURI, String localName)
- {
- if (object instanceof XbPackage)
- {
+ public Object getAttributeValue(Object object, MarshallingContext context,
+ String namespaceURI, String localName) {
+ if (object instanceof XbPackage) {
XbPackage pkg = (XbPackage)object;
if("id".equals(localName))
return pkg.getId();
@@ -88,14 +87,12 @@
else if ("inWorkspace".equals(localName))
return ""+pkg.isInWorkspace();
}
- else if (object instanceof XbFolder)
- {
+ else if (object instanceof XbFolder) {
XbFolder folder = (XbFolder) object;
if ("name".equals(localName))
return folder.getName();
}
- else if (object instanceof XbFileSet)
- {
+ else if (object instanceof XbFileSet) {
XbFileSet fileset = (XbFileSet)object;
if ("dir".equals(localName))
return fileset.getDir();
@@ -106,19 +103,25 @@
else if ("inWorkspace".equals(localName))
return "" + fileset.isInWorkspace();
else if("flatten".equals(localName))
- return "" + fileset.isFlattened();
+ return new Boolean(fileset.isFlattened()).toString();
}
- else if (object instanceof XbProperty)
- {
+ else if (object instanceof XbProperty) {
XbProperty prop = (XbProperty) object;
if ("name".equals(localName))
return prop.getName();
else if ("value".equals(localName))
return prop.getValue();
+ } else if( object instanceof XbAction ) {
+ XbAction action = (XbAction)object;
+ if("time".equals(localName))
+ return action.getTime();
+ if("type".equals(localName))
+ return action.getType();
}
return null;
}
+ // do not care ;)
public Object getElementValue(Object object, MarshallingContext context, String namespaceURI, String localName) {
return null;
}
16 years, 2 months
JBoss Tools SVN: r6723 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-06 14:25:53 -0500 (Thu, 06 Mar 2008)
New Revision: 6723
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java
Log:
made model's constructor more specific
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2008-03-06 19:24:33 UTC (rev 6722)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2008-03-06 19:25:53 UTC (rev 6723)
@@ -34,8 +34,8 @@
private IPath project;
private IArchiveModelListenerManager manager;
- public ArchiveModelNode(IPath project,
- XbPackageNodeWithProperties node, IArchiveModelListenerManager manager) {
+ public ArchiveModelNode(IPath project, XbPackages node,
+ IArchiveModelListenerManager manager) {
super(node);
this.project = project;
this.manager = manager;
@@ -48,6 +48,7 @@
public IArchiveModelListenerManager getManager() {
return manager;
}
+
/*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#getProject()
16 years, 2 months
JBoss Tools SVN: r6722 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-06 14:24:33 -0500 (Thu, 06 Mar 2008)
New Revision: 6722
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
Log:
javadoc fix
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-03-06 19:21:55 UTC (rev 6721)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-03-06 19:24:33 UTC (rev 6722)
@@ -153,7 +153,7 @@
public IArchiveModelNode getModel();
/**
- * Is the root of this node a PackageModelNode and registered in PackagesModel?
+ * Is the root of this node a PackageModelNode and registered in ArchivesModel?
* @return
*/
public boolean connectedToModel();
16 years, 2 months
JBoss Tools SVN: r6721 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-06 14:21:55 -0500 (Thu, 06 Mar 2008)
New Revision: 6721
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
Log:
event methods should fire to listeners for it's node's model if it exists, rather than the generic model.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-03-06 19:12:00 UTC (rev 6720)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-03-06 19:21:55 UTC (rev 6721)
@@ -68,7 +68,7 @@
}
public static void startedBuildingArchive(IArchive archive) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(archive);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].startedBuildingArchive(archive);
@@ -77,7 +77,7 @@
}
public static void finishedBuildingArchive(IArchive archive) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(archive);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].finishedBuildingArchive(archive);
@@ -88,7 +88,7 @@
public static void startedCollectingFileSet(IArchiveFileSet fileset) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(fileset);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].startedCollectingFileSet(fileset);
@@ -96,7 +96,7 @@
}
}
public static void finishedCollectingFileSet(IArchiveFileSet fileset) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(fileset);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].finishedCollectingFileSet(fileset);
@@ -119,7 +119,7 @@
}
public static void fileUpdated(IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(topLevelArchive);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].fileUpdated(topLevelArchive, fileset, filePath);
@@ -128,7 +128,7 @@
}
public static void fileRemoved(IArchive topLevelArchive, IArchiveFileSet fileset, IPath filePath) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(topLevelArchive);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].fileRemoved(topLevelArchive, fileset, filePath);
@@ -150,7 +150,7 @@
}
public static void buildFailed(IArchive pkg, IStatus status) {
- IArchiveBuildListener[] listeners = getBuildListeners();
+ IArchiveBuildListener[] listeners = getBuildListeners(pkg);
for( int i = 0; i < listeners.length; i++ ) {
try {
listeners[i].buildFailed(pkg, status);
16 years, 2 months
JBoss Tools SVN: r6720 - in trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-06 14:12:00 -0500 (Thu, 06 Mar 2008)
New Revision: 6720
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
Log:
Moved the xb wrapper function to a util class so its not only possible to use via the model.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2008-03-06 18:50:34 UTC (rev 6719)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2008-03-06 19:12:00 UTC (rev 6720)
@@ -32,21 +32,13 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFolderImpl;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveModelNode;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFolder;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
-import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding.XbException;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
/**
* The root model which keeps track of registered projects
@@ -253,7 +245,7 @@
ArchiveModelNode oldRoot = archivesRoot.get(project);
xbPackages.put(project, packages);
archivesRoot.put(project, root);
- createPackageNodeImpl(project, packages, null);
+ ModelUtil.createPackagesNodeImpl(project, packages, (ArchiveModelNode)getRoot(project));
root.clearDeltas();
fireRegisterProjectEvent(oldRoot, root);
monitor.worked(1);
@@ -284,40 +276,7 @@
EventManager.fireDelta(delta);
}
- public ArchiveNodeImpl createPackageNodeImpl (IPath project, XbPackageNode node, IArchiveNode parent) {
-
- if( node instanceof XbPackages ) {
- ArchiveModelNode impl = (ArchiveModelNode)getRoot(project);
- for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
- XbPackageNode child = (XbPackageNode) iter.next();
- ArchiveNodeImpl childImpl = createPackageNodeImpl(project, child, impl);
- if (impl != null && childImpl != null) {
- impl.addChild(childImpl, false);
- }
- }
- return null;
- }
-
- ArchiveNodeImpl nodeImpl = null;
- if (node instanceof XbPackage) {
- nodeImpl = new ArchiveImpl((XbPackage)node);
- } else if (node instanceof XbFolder) {
- nodeImpl = new ArchiveFolderImpl((XbFolder)node);
- } else if (node instanceof XbFileSet) {
- nodeImpl = new ArchiveFileSetImpl((XbFileSet)node);
- }
-
- for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
- XbPackageNode child = (XbPackageNode) iter.next();
- ArchiveNodeImpl childImpl = createPackageNodeImpl(project, child, nodeImpl);
- if (nodeImpl != null && childImpl != null) {
- nodeImpl.addChild(childImpl, false);
- }
- }
-
- return nodeImpl;
- }
-
+
public void saveModel (IPath project, IProgressMonitor monitor) {
// get a list of dirty nodes
@@ -346,7 +305,8 @@
// fire delta events
EventManager.fireDelta(delta);
}
-
+
+ // TODO: This requires massive help and new API's as well.
public void attach(IArchiveNode parent, IArchiveNode child, IProgressMonitor monitor) {
parent.addChild(child);
if( parent.connectedToModel() && parent.getProjectPath() != null) {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-03-06 18:50:34 UTC (rev 6719)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-03-06 19:12:00 UTC (rev 6720)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Iterator;
import org.eclipse.core.runtime.IPath;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
@@ -31,9 +32,20 @@
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFolderImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveModelNode;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbAction;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFolder;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
/**
* Utility class for matching model elements and stuff
@@ -209,4 +221,41 @@
if( projectPath == null ) return null;
return projectPath.append(workspacePath.removeFirstSegments(1));
}
+
+ public static ArchiveNodeImpl createPackagesNodeImpl (IPath project, XbPackages node, IArchiveModelNode modelNode) {
+ for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
+ XbPackageNode child = (XbPackageNode) iter.next();
+ ArchiveNodeImpl childImpl = (ArchiveNodeImpl)createPackageNodeImpl(child, modelNode);
+ if (modelNode != null && childImpl != null) {
+ if( modelNode instanceof ArchiveNodeImpl )
+ ((ArchiveNodeImpl)modelNode).addChild(childImpl, false);
+ else
+ modelNode.addChild(childImpl);
+ }
+ }
+ return null;
+ }
+
+ protected static IArchiveNode createPackageNodeImpl (XbPackageNode node, IArchiveNode parent) {
+ ArchiveNodeImpl nodeImpl = null;
+ if (node instanceof XbPackage) {
+ nodeImpl = new ArchiveImpl((XbPackage)node);
+ } else if (node instanceof XbFolder) {
+ nodeImpl = new ArchiveFolderImpl((XbFolder)node);
+ } else if (node instanceof XbFileSet) {
+ nodeImpl = new ArchiveFileSetImpl((XbFileSet)node);
+ } else if( node instanceof XbAction ) {
+ nodeImpl = null; // TODO
+ }
+
+ for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
+ XbPackageNode child = (XbPackageNode) iter.next();
+ ArchiveNodeImpl childImpl = (ArchiveNodeImpl)createPackageNodeImpl(child, nodeImpl);
+ if (nodeImpl != null && childImpl != null) {
+ nodeImpl.addChild(childImpl, false);
+ }
+ }
+ return nodeImpl;
+ }
+
}
16 years, 2 months
JBoss Tools SVN: r6719 - branches.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2008-03-06 13:50:34 -0500 (Thu, 06 Mar 2008)
New Revision: 6719
Removed:
branches/jbosstools_ve_codeassistant/
Log:
Removed jbosstools_ve_codeassist branch. No more relevant.
16 years, 2 months
JBoss Tools SVN: r6718 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2008-03-06 13:39:10 -0500 (Thu, 06 Mar 2008)
New Revision: 6718
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1410
Rollback previous changes.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2008-03-06 18:20:37 UTC (rev 6717)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2008-03-06 18:39:10 UTC (rev 6718)
@@ -229,7 +229,7 @@
* JBIDE-1410
*/
protected String resolveEL(String value) {
- String resolvedValue = value.replace("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ String resolvedValue = value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
return resolvedValue;
}
16 years, 2 months
JBoss Tools SVN: r6717 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2008-03-06 13:20:37 -0500 (Thu, 06 Mar 2008)
New Revision: 6717
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
Log:
JBIDE-1410
Code adjusting.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2008-03-06 18:10:12 UTC (rev 6716)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2008-03-06 18:20:37 UTC (rev 6717)
@@ -226,9 +226,10 @@
/*
* temporary solution to solve #{facesContext.externalContext.requestContextPath}
+ * JBIDE-1410
*/
protected String resolveEL(String value) {
- String resolvedValue = value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ String resolvedValue = value.replace("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$
return resolvedValue;
}
16 years, 2 months
JBoss Tools SVN: r6716 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-06 13:10:12 -0500 (Thu, 06 Mar 2008)
New Revision: 6716
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
JBIDE-1785 Optimization of searching methods used in starting Seam model.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2008-03-06 18:08:22 UTC (rev 6715)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2008-03-06 18:10:12 UTC (rev 6716)
@@ -261,6 +261,7 @@
} else if(declaration instanceof ISeamPropertiesDeclaration) {
propertyDeclarations.add((ISeamPropertiesDeclaration)declaration);
}
+ ((SeamComponentDeclaration)declaration).bindToComponent(this);
}
public void removeDeclaration(ISeamComponentDeclaration declaration) {
@@ -273,6 +274,7 @@
} else if(declaration instanceof ISeamPropertiesDeclaration) {
propertyDeclarations.remove(declaration);
}
+ ((SeamComponentDeclaration)declaration).unbindFromComponent(this);
}
@Override
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2008-03-06 18:08:22 UTC (rev 6715)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2008-03-06 18:10:12 UTC (rev 6716)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -36,6 +37,23 @@
}
/**
+ * Components that use this declaration
+ */
+ protected Set<SeamComponent> components = new HashSet<SeamComponent>();
+
+ public Set<SeamComponent> getComponents() {
+ return components;
+ }
+
+ public void bindToComponent(SeamComponent c) {
+ components.add(c);
+ }
+
+ public void unbindFromComponent(SeamComponent c) {
+ components.remove(c);
+ }
+
+ /**
* Merges loaded data into currently used declaration.
* If changes were done returns a list of changes.
* @param d
@@ -65,6 +83,7 @@
public SeamComponentDeclaration clone() throws CloneNotSupportedException {
SeamComponentDeclaration c = (SeamComponentDeclaration)super.clone();
+ c.components = new HashSet<SeamComponent>();
return c;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2008-03-06 18:08:22 UTC (rev 6715)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2008-03-06 18:10:12 UTC (rev 6716)
@@ -456,7 +456,7 @@
SeamCorePlugin.getPluginLog().logError(e);
}
}
-
+
public SeamJavaComponentDeclaration clone() throws CloneNotSupportedException {
SeamJavaComponentDeclaration c = (SeamJavaComponentDeclaration)super.clone();
if(types != null) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-03-06 18:08:22 UTC (rev 6715)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-03-06 18:10:12 UTC (rev 6716)
@@ -39,7 +39,6 @@
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamContextVariable;
-import org.jboss.tools.seam.core.ISeamElement;
import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamPackage;
@@ -93,17 +92,14 @@
createScopes();
}
- Map<String, SeamComponent> allComponents = new HashMap<String, SeamComponent>();
+ ComponentStorage components = new ComponentStorage();
+ FactoryStorage factories = new FactoryStorage();
- protected Set<ISeamFactory> allFactories = new HashSet<ISeamFactory>();
-
Set<ISeamContextVariable> allVariables = new HashSet<ISeamContextVariable>();
Set<ISeamContextVariable> allVariablesCopy = null;
Set<ISeamContextVariable> allVariablesPlusShort = null;
- Map<String, SeamJavaComponentDeclaration> javaDeclarations = new HashMap<String, SeamJavaComponentDeclaration>();
-
Map<String, ISeamPackage> packages = new HashMap<String, ISeamPackage>();
List<ISeamProjectChangeListener> listeners = new ArrayList<ISeamProjectChangeListener>();
@@ -428,13 +424,12 @@
isStorageResolved = false;
dependsOn.clear();
usedBy.clear();
- allComponents.clear();
- allFactories.clear();
+ components.clear();
+ factories.clear();
allVariables.clear();
allVariablesCopy = null;
allVariablesPlusShort = null;
imports.clear();
- javaDeclarations.clear();
packages.clear();
createScopes();
@@ -712,16 +707,14 @@
* @return
*/
public ISeamComponent getComponentByName(String name) {
- return allComponents.get(name);
+ return components.getByName(name);
}
/**
*
*/
public Set<ISeamComponent> getComponents() {
- Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- result.addAll(allComponents.values());
- return result;
+ return components.allComponentsSet;
}
/**
@@ -769,9 +762,14 @@
}
String oldClassName = c == null ? null : c.getClassName();
+ String loadedClassName = getClassName(loaded);
if(current != null) {
+ String currentClassName = getClassName(current);
List<Change> changes = current.merge(loaded);
+ if(isClassNameChanged(currentClassName, loadedClassName)) {
+ this.components.onClassNameChanged(currentClassName, loadedClassName, current);
+ }
if(changes != null && changes.size() > 0) {
Change cc = new Change(c, null, null, null);
cc.addChildren(changes);
@@ -798,11 +796,13 @@
}
}
+ this.components.addDeclaration(loaded);
+
if(c == null && name != null) {
ScopeType scopeType = loaded.getScope();
c = newComponent(name, scopeType);
affectedComponents.add(c);
- allComponents.put(name, c);
+ this.components.addComponent(c);
addVariable(c);
c.addDeclaration(loaded);
addedComponents = Change.addChange(addedComponents, new Change(this, null, null, c));
@@ -811,11 +811,9 @@
List<Change> changes = Change.addChange(null, new Change(c, null, null, loaded));
fireChanges(changes);
}
-
+
if(loaded instanceof ISeamJavaComponentDeclaration) {
SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)loaded;
- javaDeclarations.put(jd.getClassName(), jd);
- for (ISeamContextVariable v: jd.getDeclaredVariables()) addVariable(v);
Set<ISeamComponent> cs = getComponentsByClass(jd.getClassName());
for (ISeamComponent ci: cs) {
if(ci == c) continue;
@@ -855,8 +853,7 @@
if(factories[i].getParent() == null) {
adopt(factories[i]);
}
- allFactories.add(factories[i]);
- addVariable(factories[i]);
+ this.factories.addFactory(factories[i]);
addedFactories = Change.addChange(addedFactories, new Change(this, null, null, loaded));
}
fireChanges(addedFactories);
@@ -870,6 +867,15 @@
}
}
+ private static String getClassName(ISeamComponentDeclaration d) {
+ if(d instanceof ISeamJavaComponentDeclaration) {
+ return ((ISeamJavaComponentDeclaration)d).getClassName();
+ } else if(d instanceof ISeamXmlComponentDeclaration) {
+ return ((ISeamXmlComponentDeclaration)d).getClassName();
+ }
+ return null;
+ }
+
/**
*
* @param ds
@@ -932,7 +938,7 @@
changes = Change.addChange(changes, new Change(c, null, jcd, null));
}
}
- SeamJavaComponentDeclaration j = javaDeclarations.get(className);
+ SeamJavaComponentDeclaration j = components.getJavaDeclaration(className);
if(j != null && !c.getAllDeclarations().contains(j)) {
c.addDeclaration(j);
changes = Change.addChange(changes, new Change(c, null, null, j));
@@ -950,49 +956,34 @@
sourcePaths.remove(source);
sourcePaths2.remove(source);
removeImports(source.toString());
- Iterator<SeamComponent> iterator = allComponents.values().iterator();
- while(iterator.hasNext()) {
- List<Change> changes = null;
- SeamComponent c = iterator.next();
- ISeamComponentDeclaration[] ds = c.getAllDeclarations().toArray(new ISeamComponentDeclaration[0]);
- for (int i = 0; i < ds.length; i++) {
- if(ds[i].getSourcePath().equals(source)) {
- c.removeDeclaration(ds[i]);
- if(ds[i] instanceof ISeamJavaComponentDeclaration) {
- SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)ds[i];
- String className = jd.getClassName();
- javaDeclarations.remove(className);
- for (ISeamContextVariable v: jd.getDeclaredVariables()) removeVariable(v);
- }
- changes = Change.addChange(changes, new Change(c, null, ds[i], null));
+
+ List<Change> changes = null;
+
+ Set<SeamComponentDeclaration> ds = components.getDeclarationsBySource(source);
+ if(ds != null) for (SeamComponentDeclaration d: ds) {
+ Set<SeamComponent> cs = new HashSet<SeamComponent>();
+ cs.addAll(d.getComponents());
+ for (SeamComponent c: cs) {
+ c.removeDeclaration(d);
+ changes = Change.addChange(changes, new Change(c, null, d, null));
+ if(isComponentEmpty(c)) {
+ changes = removeEmptyComponent(c);
}
}
- if(isComponentEmpty(c)) {
- iterator.remove();
- changes = removeEmptyComponent(c);
- }
- fireChanges(changes);
}
- Iterator<String> it = javaDeclarations.keySet().iterator();
- while(it.hasNext()) {
- String cn = it.next();
- SeamJavaComponentDeclaration d = javaDeclarations.get(cn);
- if(source.equals(d.getSourcePath())) {
- it.remove();
- }
- }
+
+ components.removePath(source);
+
+ fireChanges(changes);
+
// revalidate();
- Iterator<ISeamFactory> factories = allFactories.iterator();
- while(factories.hasNext()) {
- AbstractContextVariable f = (AbstractContextVariable)factories.next();
- if(source.equals(f.getSourcePath())) {
- List<Change> changes = Change.addChange(null, new Change(this, null, f, null));
- factories.remove();
- removeVariable(f);
- fireChanges(changes);
- }
+ changes = null;
+ Set<ISeamFactory> fs = this.factories.removePath(source);
+ if(fs != null) for (ISeamFactory f: fs) {
+ changes = Change.addChange(changes, new Change(this, null, f, null));
}
+ fireChanges(changes);
firePathRemovedToDependentProjects(source);
}
@@ -1014,12 +1005,11 @@
*/
public Map<Object,ISeamComponentDeclaration> findComponentDeclarations(IPath source) {
Map<Object,ISeamComponentDeclaration> map = new HashMap<Object, ISeamComponentDeclaration>();
- for (SeamComponent c: allComponents.values()) {
- for (ISeamComponentDeclaration d: c.getAllDeclarations()) {
- SeamComponentDeclaration di = (SeamComponentDeclaration)d;
- if(source.equals(di.getSourcePath())) map.put(di.getId(), di);
- }
- }
+ Set<SeamComponentDeclaration> ds = components.getDeclarationsBySource(source);
+ if(ds != null) for (ISeamComponentDeclaration d: ds) {
+ SeamComponentDeclaration di = (SeamComponentDeclaration)d;
+ map.put(di.getId(), di);
+ }
return map;
}
@@ -1028,44 +1018,30 @@
* @param removed
*/
void componentDeclarationsRemoved(Map<Object,ISeamComponentDeclaration> removed) {
- Collection<ISeamComponentDeclaration> declarations = removed.values();
- for (ISeamComponentDeclaration declaration: declarations) {
- if(declaration instanceof ISeamJavaComponentDeclaration) {
- SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)declaration;
- String className = jd.getClassName();
- if(javaDeclarations.get(className) == jd) {
- javaDeclarations.remove(className);
+ if(removed == null || removed.isEmpty()) return;
+ List<Change> changes = null;
+ for (ISeamComponentDeclaration declaration: removed.values()) {
+ SeamComponentDeclaration d = (SeamComponentDeclaration)declaration;
+ components.removeDeclaration(d);
+ Set<SeamComponent> sc = new HashSet<SeamComponent>();
+ sc.addAll(d.getComponents());
+ for (SeamComponent c: sc) {
+ c.removeDeclaration(d);
+ changes = Change.addChange(changes, new Change(c, null, d, null));
+ if(isComponentEmpty(c)) {
+ changes = removeEmptyComponent(c);
}
- for (ISeamContextVariable v: jd.getDeclaredVariables()) removeVariable(v);
}
}
-
- Iterator<SeamComponent> iterator = allComponents.values().iterator();
- while(iterator.hasNext()) {
- List<Change> changes = null;
- SeamComponent c = iterator.next();
- ISeamComponentDeclaration[] ds = c.getAllDeclarations().toArray(new ISeamComponentDeclaration[0]);
- for (int i = 0; i < ds.length; i++) {
- if(removed.containsKey(((SeamObject)ds[i]).getId())) {
- c.removeDeclaration(ds[i]);
- changes = Change.addChange(changes, new Change(c, null, ds[i], null));
- }
- }
- if(isComponentEmpty(c)) {
- iterator.remove();
- changes = removeEmptyComponent(c);
- }
- fireChanges(changes);
- }
+ fireChanges(changes);
}
/*
*
*/
private List<Change> removeEmptyComponent(SeamComponent c) {
- List<Change> changes = null;
- ISeamElement p = c.getParent();
- changes = c.removeFromModel(changes);
+ components.removeComponent(c);
+ List<Change> changes = c.removeFromModel(null);
removeVariable(c);
changes = Change.addChange(changes, new Change(this, null, c, null));
return changes;
@@ -1089,9 +1065,10 @@
*/
public Map<Object,ISeamFactory> findFactoryDeclarations(IPath source) {
Map<Object,ISeamFactory> map = new HashMap<Object, ISeamFactory>();
- for (ISeamFactory c: allFactories) {
+ Set<ISeamFactory> fs = factories.getFactoriesBySource(source);
+ if(fs != null) for (ISeamFactory c: fs) {
AbstractContextVariable ci = (AbstractContextVariable)c;
- if(source.equals(ci.getSourcePath())) map.put(ci.getId(), c);
+ map.put(ci.getId(), c);
}
return map;
}
@@ -1101,15 +1078,14 @@
* @param removed
*/
void factoryDeclarationsRemoved(Map<Object,ISeamFactory> removed) {
- Iterator<ISeamFactory> iterator = allFactories.iterator();
+ if(removed == null || removed.isEmpty()) return;
+ Iterator<ISeamFactory> iterator = removed.values().iterator();
List<Change> changes = null;
while(iterator.hasNext()) {
- AbstractContextVariable c = (AbstractContextVariable)iterator.next();
- if(removed.containsKey(c.getId())) {
- iterator.remove();
- removeVariable(c);
- changes = Change.addChange(changes, new Change(this, null, c, null));
- }
+ ISeamFactory c = iterator.next();
+ factories.removeFactory(c);
+ removeVariable(c);
+ changes = Change.addChange(changes, new Change(this, null, c, null));
}
fireChanges(changes);
}
@@ -1119,11 +1095,15 @@
*/
public Set<ISeamComponent> getComponentsByClass(String className) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- for(SeamComponent component: allComponents.values()) {
- if(className.equals(component.getClassName())) {
- result.add(component);
+ Set<SeamComponentDeclaration> ds = components.getDeclarationsByClasName(className);
+ if(ds == null) return result;
+ for (SeamComponentDeclaration d: ds) {
+ for (ISeamComponent c: d.getComponents()) {
+ if(result.contains(c)) continue;
+ if(c.getSeamProject() != this) continue;
+ if(className.equals(c.getClassName())) result.add(c);
}
- }
+ }
return result;
}
@@ -1139,7 +1119,8 @@
*/
public Set<ISeamComponent> getComponentsByScope(ScopeType type, boolean addVisibleScopes) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- for(SeamComponent component: allComponents.values()) {
+ //TODO map needed
+ for(SeamComponent component: components.allComponents.values()) {
if(isVisibleInScope(component, type, addVisibleScopes)) {
result.add(component);
}
@@ -1151,14 +1132,14 @@
* @see org.jboss.tools.seam.core.ISeamProject#addComponent(org.jboss.tools.seam.core.ISeamComponent)
*/
public void addComponent(ISeamComponent component) {
- allComponents.put(component.getName(), (SeamComponent)component);
+ components.addComponent(component);
}
/**
* @see org.jboss.tools.seam.core.ISeamProject#removeComponent(org.jboss.tools.seam.core.ISeamComponent)
*/
public void removeComponent(ISeamComponent component) {
- allComponents.remove(component);
+ components.removeComponent(component);
}
/**
@@ -1177,12 +1158,14 @@
}
public synchronized void addVariable(ISeamContextVariable v) {
+ if(allVariables.contains(v)) return;
allVariablesCopy = null;
allVariablesPlusShort = null;
allVariables.add(v);
}
public synchronized void removeVariable(ISeamContextVariable v) {
+ if(!allVariables.contains(v)) return;
allVariablesCopy = null;
allVariablesPlusShort = null;
allVariables.remove(v);
@@ -1299,14 +1282,14 @@
*
*/
public void addFactory(ISeamFactory factory) {
- allFactories.add(factory);
+ factories.addFactory(factory);
}
/**
*
*/
public Set<ISeamFactory> getFactories() {
- return allFactories;
+ return factories.allFactories;
}
/**
@@ -1314,7 +1297,7 @@
*/
public Set<ISeamFactory> getFactories(String name, ScopeType scope) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
- for (ISeamFactory f: allFactories) {
+ for (ISeamFactory f: factories.allFactories) {
if(name.equals(f.getName()) && scope.equals(f.getScope())) result.add(f);
}
return result;
@@ -1325,7 +1308,7 @@
*/
public Set<ISeamFactory> getFactoriesByName(String name) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
- for (ISeamFactory f: allFactories) {
+ for (ISeamFactory f: factories.allFactories) {
if(name.equals(f.getName())) result.add(f);
}
return result;
@@ -1343,7 +1326,7 @@
*/
public Set<ISeamFactory> getFactoriesByScope(ScopeType scope, boolean addVisibleScopes) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
- for (ISeamFactory f: allFactories) {
+ for (ISeamFactory f: factories.allFactories) {
if(isVisibleInScope(f, scope, addVisibleScopes)) {
result.add(f);
}
@@ -1356,11 +1339,8 @@
*/
public Set<ISeamFactory> getFactoriesByPath(IPath path) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
- for (ISeamFactory f: allFactories) {
- if(path.equals(f.getSourcePath())) {
- result.add(f);
- }
- }
+ Set<ISeamFactory> fs = factories.getFactoriesBySource(path);
+ if(fs != null) result.addAll(fs);
return result;
}
@@ -1368,7 +1348,7 @@
*
*/
public void removeFactory(ISeamFactory factory) {
- allFactories.remove(factory);
+ factories.removeFactory(factory);
removeVariable(factory);
}
@@ -1379,7 +1359,7 @@
* @return
*/
public Map<String, SeamJavaComponentDeclaration> getAllJavaComponentDeclarations() {
- return javaDeclarations;
+ return components.javaDeclarations;
}
/**
@@ -1389,8 +1369,9 @@
* @return
*/
public Set<SeamJavaComponentDeclaration> findJavaDeclarations(IPath source) {
+ //TODO map needed
Set<SeamJavaComponentDeclaration> set = new HashSet<SeamJavaComponentDeclaration>();
- for (SeamJavaComponentDeclaration d: javaDeclarations.values()) {
+ for (SeamJavaComponentDeclaration d: components.javaDeclarations.values()) {
if(source.equals(d.getSourcePath())) set.add(d);
}
return set;
@@ -1400,7 +1381,7 @@
*
*/
public SeamComponent getComponent(String name) {
- return name == null ? null : allComponents.get(name);
+ return components.getByName(name);
}
/**
@@ -1476,13 +1457,11 @@
*/
public Set<ISeamComponent> getComponentsByPath(IPath path) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- for (SeamComponent c: allComponents.values()) {
- for (ISeamComponentDeclaration d: c.getAllDeclarations()) {
- SeamComponentDeclaration di = (SeamComponentDeclaration)d;
- if(path.equals(di.getSourcePath())) {
- result.add(c);
- break;
- }
+ Set<SeamComponentDeclaration> ds = components.getDeclarationsBySource(path);
+ if(ds != null) for (SeamComponentDeclaration d: ds) {
+ Set<SeamComponent> cs = d.getComponents();
+ for (SeamComponent c: cs) {
+ if(c.getSeamProject() == this) result.add(c);
}
}
return result;
@@ -1561,7 +1540,7 @@
*/
Map<IPath, LoadedDeclarations> getAllDeclarations() throws CloneNotSupportedException {
Map<IPath, LoadedDeclarations> map = new HashMap<IPath, LoadedDeclarations>();
- for (ISeamComponent c : allComponents.values()) {
+ for (ISeamComponent c : components.allComponentsSet) {
for (ISeamComponentDeclaration d : c.getAllDeclarations()) {
IPath p = d.getSourcePath();
if(p == null || p.toString().endsWith(".jar")) continue; //$NON-NLS-1$
@@ -1573,7 +1552,7 @@
ds.getComponents().add(d.clone());
}
}
- for (ISeamFactory f : allFactories) {
+ for (ISeamFactory f : factories.allFactories) {
IPath p = f.getSourcePath();
if(p == null || p.toString().endsWith(".jar")) continue; //$NON-NLS-1$
LoadedDeclarations ds = map.get(p);
@@ -1661,4 +1640,188 @@
p.getComponents().add(c);
}
+
+ class ComponentStorage {
+ Set<ISeamComponent> allComponentsSet = new HashSet<ISeamComponent>();
+ Map<String, SeamComponent> allComponents = new HashMap<String, SeamComponent>();
+ Map<String, SeamJavaComponentDeclaration> javaDeclarations = new HashMap<String, SeamJavaComponentDeclaration>();
+
+ Map<IPath, Set<SeamComponentDeclaration>> declarationsBySource = new HashMap<IPath, Set<SeamComponentDeclaration>>();
+ Map<String, Set<SeamComponentDeclaration>> declarationsByClassName = new HashMap<String, Set<SeamComponentDeclaration>>();
+
+ public void clear() {
+ allComponentsSet.clear();
+ allComponents.clear();
+ javaDeclarations.clear();
+ declarationsBySource.clear();
+ declarationsByClassName.clear();
+ }
+
+ public SeamComponent getByName(String name) {
+ return name == null ? null : allComponents.get(name);
+ }
+
+ public void removeComponent(ISeamComponent c) {
+ allComponentsSet.remove(c);
+ allComponents.remove(c.getName());
+ }
+
+ public void addComponent(ISeamComponent c) {
+ allComponentsSet.add(c);
+ allComponents.put(c.getName(), (SeamComponent)c);
+ }
+
+ public void addDeclaration(SeamComponentDeclaration d) {
+ IPath path = d.getSourcePath();
+ Set<SeamComponentDeclaration> sc = declarationsBySource.get(path);
+ if(sc == null) {
+ sc = new HashSet<SeamComponentDeclaration>();
+ declarationsBySource.put(path, sc);
+ }
+ sc.add(d);
+ if(d instanceof ISeamJavaComponentDeclaration) {
+ SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)d;
+ for (ISeamContextVariable v: jd.getDeclaredVariables()) addVariable(v);
+ javaDeclarations.put(jd.getClassName(), jd);
+ addDeclaration(jd.getClassName(), jd);
+ } else if(d instanceof ISeamXmlComponentDeclaration) {
+ ISeamXmlComponentDeclaration xd = (ISeamXmlComponentDeclaration)d;
+ String className = xd.getClassName();
+ if(className != null && className.length() > 0) {
+ addDeclaration(className, d);
+ }
+ }
+ }
+
+ public void removeDeclaration(SeamComponentDeclaration d) {
+ IPath path = d.getSourcePath();
+ Set<SeamComponentDeclaration> sc = declarationsBySource.get(path);
+ if(sc != null) {
+ sc.remove(d);
+ if(sc.isEmpty()) declarationsBySource.remove(path);
+ }
+ removeDeclarationWithClass(d);
+ }
+
+ public Set<SeamComponentDeclaration> getDeclarationsBySource(IPath path) {
+ return declarationsBySource.get(path);
+ }
+
+ public SeamJavaComponentDeclaration getJavaDeclaration(String className) {
+ return javaDeclarations.get(className);
+ }
+
+ public Set<SeamComponentDeclaration> getDeclarationsByClasName(String className) {
+ return declarationsByClassName.get(className);
+ }
+
+ public void removePath(IPath path) {
+ Set<SeamComponentDeclaration> sd = declarationsBySource.get(path);
+ if(sd == null) return;
+ for (SeamComponentDeclaration d: sd) {
+ removeDeclarationWithClass(d);
+ }
+ declarationsBySource.remove(path);
+ }
+
+ private void removeDeclarationWithClass(SeamComponentDeclaration d) {
+ if(d instanceof ISeamJavaComponentDeclaration) {
+ SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)d;
+ javaDeclarations.remove(jd.getClassName());
+ for (ISeamContextVariable v: jd.getDeclaredVariables()) removeVariable(v);
+ removeDeclaration(jd.getClassName(), d);
+ } else if(d instanceof ISeamXmlComponentDeclaration) {
+ ISeamXmlComponentDeclaration xd = (ISeamXmlComponentDeclaration)d;
+ String className = xd.getClassName();
+ if(className != null && className.length() > 0) {
+ removeDeclaration(className, d);
+ }
+ }
+ }
+
+ public void onClassNameChanged(String oldClassName, String newClassName, SeamComponentDeclaration d) {
+ if(oldClassName != null) {
+ removeDeclaration(oldClassName, d);
+ }
+ if(newClassName != null) {
+ addDeclaration(newClassName, d);
+ }
+ }
+
+ private void addDeclaration(String className, SeamComponentDeclaration d) {
+ Set<SeamComponentDeclaration> sc = declarationsByClassName.get(className);
+ if(sc == null) {
+ sc = new HashSet<SeamComponentDeclaration>();
+ declarationsByClassName.put(className, sc);
+ }
+ sc.add(d);
+ }
+
+ private void removeDeclaration(String className, SeamComponentDeclaration d) {
+ Set<SeamComponentDeclaration> sc = declarationsByClassName.get(className);
+ if(sc != null) {
+ sc.remove(d);
+ if(sc.isEmpty()) {
+ declarationsByClassName.remove(className);
+ }
+ }
+ }
+
+ }
+
+ class FactoryStorage {
+ protected Set<ISeamFactory> allFactories = new HashSet<ISeamFactory>();
+ Map<IPath, Set<ISeamFactory>> factoriesBySource = new HashMap<IPath, Set<ISeamFactory>>();
+
+ public void clear() {
+ allFactories.clear();
+ factoriesBySource.clear();
+ }
+
+ public Set<ISeamFactory> getFactoriesBySource(IPath path) {
+ return factoriesBySource.get(path);
+ }
+
+ public void addFactory(ISeamFactory f) {
+ allFactories.add(f);
+ IPath path = f.getSourcePath();
+ if(path != null) {
+ Set<ISeamFactory> fs = factoriesBySource.get(path);
+ if(fs == null) {
+ fs = new HashSet<ISeamFactory>();
+ factoriesBySource.put(path, fs);
+ }
+ fs.add(f);
+ }
+ addVariable(f);
+ }
+
+ public void removeFactory(ISeamFactory f) {
+ allFactories.remove(f);
+ IPath path = f.getSourcePath();
+ if(path != null) {
+ Set<ISeamFactory> fs = factoriesBySource.get(path);
+ if(fs != null) {
+ fs.remove(f);
+ }
+ if(fs.isEmpty()) {
+ factoriesBySource.remove(fs);
+ }
+ }
+ removeVariable(f);
+ }
+
+ public Set<ISeamFactory> removePath(IPath path) {
+ Set<ISeamFactory> fs = factoriesBySource.get(path);
+ if(fs == null) return null;
+ for (ISeamFactory f: fs) {
+ allFactories.remove(f);
+ removeVariable(f);
+ }
+ factoriesBySource.remove(path);
+ return fs;
+ }
+
+ }
+
}
16 years, 2 months