Author: rob.stryker(a)jboss.com
Date: 2007-05-21 15:51:45 -0400 (Mon, 21 May 2007)
New Revision: 2037
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/LICENSE-truezip.txt
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/concurrent.jar
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/jboss-common-4.0.4.jar
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/jbossxb-1.0.1.TEST.jar
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.jar
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/xercesImpl.jar
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/log4j.xml
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/archiveTypes.exsd
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCore.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/Trace.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchiveNodeFactory.java
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/ArchivesModelCore.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFolder.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelListenerManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelNode.java
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/IArchiveNodeDelta.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeVisitor.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/events/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/events/EventManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveDeltaPreNodeFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFolderImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
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/ArchiveNodeDeltaImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFileSet.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFolder.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackage.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNode.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNodeWithProperties.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java
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/XbProperties.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperty.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveBuildListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveModelListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IExtensionManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IPreferenceManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IRuntimeVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/StandaloneVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/AbstractArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/JARArchiveType.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesNature.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/
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/internal/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/xml/
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/xml/packages.xsd
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath
Log:
project rebuilt
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath 2007-05-21 19:50:52
UTC (rev 2036)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/.classpath 2007-05-21 19:51:45
UTC (rev 2037)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="src/main"/>
<classpathentry exported="true" kind="lib"
path="lib/jboss-common-4.0.4.jar"
sourcepath="C:/Users/Marshall/Downloads/jbossxb-1.0.1.TEST-sources.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/jbossxb-1.0.1.TEST.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/xercesImpl.jar"/>
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/LICENSE-truezip.txt
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/LICENSE-truezip.txt
(rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/LICENSE-truezip.txt 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,203 @@
+Updated for release.
+
+ Apache License
+ Version 2.0, January 2004
+
http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/META-INF/MANIFEST.MF 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBossIDE Packages Core Plug-in
+Bundle-SymbolicName: org.jboss.ide.eclipse.archives.core;singleton:=true
+Bundle-Version: 2.0.0
+Bundle-Activator: org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin
+Bundle-Vendor: JBoss, a division of Red Hat
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.filesystem,
+ org.eclipse.core.commands,
+ org.apache.ant,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core
+Eclipse-LazyStart: true
+Bundle-ClassPath: packagescore.jar,
+ lib/concurrent.jar,
+ lib/truezip-6.jar,
+ lib/xercesImpl.jar,
+ lib/jboss-common-4.0.4.jar,
+ lib/jbossxb-1.0.1.TEST.jar
+Export-Package: org.jboss.ide.eclipse.archives.core,
+ org.jboss.ide.eclipse.archives.core.build,
+ org.jboss.ide.eclipse.archives.core.model,
+
org.jboss.ide.eclipse.archives.core.model.events;x-friends:="org.jboss.ide.eclipse.archives.test",
+
org.jboss.ide.eclipse.archives.core.model.internal;x-friends:="org.jboss.ide.eclipse.archives.test",
+
org.jboss.ide.eclipse.archives.core.model.internal.xb;x-friends:="org.jboss.ide.eclipse.archives.test",
+ org.jboss.ide.eclipse.archives.core.model.other,
+
org.jboss.ide.eclipse.archives.core.model.other.internal;x-friends:="org.jboss.ide.eclipse.archives.test",
+
org.jboss.ide.eclipse.archives.core.project;x-friends:="org.jboss.ide.eclipse.archives.test",
+
org.jboss.ide.eclipse.archives.core.util;x-friends:="org.jboss.ide.eclipse.archives.test",
+
org.jboss.ide.eclipse.archives.core.util.internal;x-friends:="org.jboss.ide.eclipse.archives.test"
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties
(rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/build.properties 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,17 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ plugin.xml,\
+ packagescore.jar,\
+ xml/,\
+ lib/,\
+ LICENSE-truezip.txt,\
+ lib/xercesImpl.jar,\
+ lib/jboss-common-4.0.4.jar,\
+ lib/jbossxb-1.0.1.TEST.jar,\
+ log4j.xml
+source.packagescore.jar = src/main/
+src.includes = LICENSE-truezip.txt,\
+ src/,\
+ xml/,\
+ plugin.xml,\
+ META-INF/
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/concurrent.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/concurrent.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/jboss-common-4.0.4.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/jboss-common-4.0.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/jbossxb-1.0.1.TEST.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/jbossxb-1.0.1.TEST.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/truezip-6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/xercesImpl.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/lib/xercesImpl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/log4j.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/log4j.xml
(rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/log4j.xml 2007-05-21 19:51:45
UTC (rev 2037)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 1903 2007-04-18 21:07:54Z rawb $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite:
http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
+
+
+ <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="TRACE"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p
[%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.jboss.xb">
+
+ </category>
+
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+</log4j:configuration>
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
(rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml 2007-05-21 19:51:45
UTC (rev 2037)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="archiveTypes" name="JBossIDE Package Type"
schema="schema/archiveTypes.exsd"/>
+ <extension
+ id="archivesNature"
+ name="JBossIDE Packages Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
class="org.jboss.ide.eclipse.archives.core.project.ArchivesNature"/>
+ </runtime>
+ <builder
id="org.jboss.ide.eclipse.archives.core.archivesBuilder"/>
+ </extension>
+ <extension
+ id="archivesBuilder"
+ name="JBossIDE Packages Builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ hasNature="true"
+ >
+ <run
class="org.jboss.ide.eclipse.archives.core.project.ArchivesBuilder"/>
+ </builder>
+ </extension>
+ <extension
+ point="org.jboss.ide.eclipse.archives.core.archiveTypes">
+ <packageType
+
class="org.jboss.ide.eclipse.archives.core.model.types.JARArchiveType"
+ id="jar"
+ label="JAR"/>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
class="org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspacePreferenceManager"/>
+ </extension>
+
+</plugin>
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/archiveTypes.exsd
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/archiveTypes.exsd
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/schema/archiveTypes.exsd 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.ide.eclipse.archives.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.ide.eclipse.archives.core"
id="packageTypes" name="JBossIDE Package Type"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="packageType"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="packageType">
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn="org.jboss.ide.eclipse.archives.core.model.types.IPackageType"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCore.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCore.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCore.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,54 @@
+package org.jboss.ide.eclipse.archives.core;
+
+import org.jboss.ide.eclipse.archives.core.model.other.IExtensionManager;
+import org.jboss.ide.eclipse.archives.core.model.other.IPreferenceManager;
+import org.jboss.ide.eclipse.archives.core.model.other.IRuntimeVariables;
+import
org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceExtensionManager;
+import
org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspacePreferenceManager;
+import org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariables;
+
+public class ArchivesCore {
+
+ private static ArchivesCore instance;
+ public static ArchivesCore getInstance() {
+ if( instance == null )
+ instance = new ArchivesCore(WORKSPACE);
+ return instance;
+ }
+ public static void create(int type) {
+ instance = new ArchivesCore(type);
+ }
+
+ public static final int STANDALONE = 0;
+ public static final int WORKSPACE = 1;
+
+ private int runType;
+ private IRuntimeVariables variables;
+ private IExtensionManager extensionManager;
+ private IPreferenceManager preferenceManager;
+
+ public ArchivesCore(int runType) {
+ this.runType = runType;
+ if( this.runType == STANDALONE) {
+ //variables = new StandaloneVariables();
+ } else {
+ variables = new WorkspaceVariables();
+ extensionManager = new WorkspaceExtensionManager();
+ preferenceManager = new WorkspacePreferenceManager();
+ }
+ }
+
+ public boolean isWorkspaceRuntype() {
+ return runType == WORKSPACE;
+ }
+
+ public IRuntimeVariables getVariables() {
+ return variables;
+ }
+ public IExtensionManager getExtensionManager() {
+ return extensionManager;
+ }
+ public IPreferenceManager getPreferenceManager() {
+ return preferenceManager;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ArchivesCorePlugin.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core;
+
+import org.eclipse.core.runtime.Plugin;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ * @author rstryker
+ *
+ */public class ArchivesCorePlugin extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.ide.eclipse.archives.core";
+
+ // The shared instance
+ private static ArchivesCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ArchivesCorePlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ // force JBossXB initialization
+ XMLBinding.init();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ArchivesCorePlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/Trace.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/Trace.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/Trace.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core;
+
+
+public class Trace {
+
+ public static final String DEBUG_OPTION_ROOT =
"org.jboss.ide.eclipse.packages.core/debug/";
+ public static final String DEBUG_OPTION_STREAM_CLOSE = DEBUG_OPTION_ROOT +
"streamClose";
+
+ public static boolean isDebugging(String option) {
+ return ArchivesCore.getInstance().getVariables().isDebugging(option);
+ }
+
+ public static void trace (Class caller, String message) {
+ trace(caller, message, null);
+ }
+
+ public static void trace (Class caller, String message, String option) {
+ trace(caller, message, null, option);
+ }
+
+ public static void trace (Class caller, Throwable t) {
+ trace(caller, t, null);
+ }
+
+ public static void trace (Class caller, Throwable t, String option) {
+ trace(caller, t.getMessage(), t, option);
+ }
+
+ public static void trace (Class caller, String message, Throwable t, String option) {
+ if (!isDebugging(null))
+ return;
+
+ if (option != null) {
+ if (!isDebugging(option))
+ return;
+ }
+
+ System.out.println("[" + caller.getName() + "] " + message);
+
+ if (t != null) {
+ t.printStackTrace();
+ }
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.build;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+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.events.EventManager;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+
+/**
+ * This delegate will either build from the model completely
+ * (if the builder has been given a full build request) or
+ * incrementally update the changed files in
+ * **ANY AND ALL** filesets that they match, regardless of project.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ArchiveBuildDelegate {
+
+ public ArchiveBuildDelegate() {
+ }
+
+
+ /**
+ * A full project build has been requested.
+ * @param project The project containing the archive model
+ */
+ public void fullProjectBuild(IPath project) {
+ EventManager.cleanProjectBuild(project);
+ EventManager.startedBuild(project);
+
+ IArchiveModelNode root = ArchivesModel.instance().getRoot(project);
+ IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for( int i = 0; i < nodes.length; i++ ) {
+ fullArchiveBuild(((IArchive)nodes[i]));
+ }
+
+ EventManager.finishedBuild(project);
+ }
+
+ /**
+ * Builds an archive entirely, overwriting whatever was in the output destination.
+ * @param pkg The archive to build
+ */
+ public void fullArchiveBuild(IArchive pkg) {
+ EventManager.cleanArchiveBuild(pkg);
+ EventManager.startedBuildingArchive(pkg);
+
+ ModelTruezipBridge.deleteArchive(pkg);
+ ModelTruezipBridge.createFile(pkg);
+
+ // force create all folders
+ IArchiveFolder[] folders = ModelUtil.findAllDescendentFolders(pkg);
+ for( int i = 0; i < folders.length; i++ ) {
+ ModelTruezipBridge.createFile(folders[i]);
+ }
+
+ // build the filesets
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(pkg);
+ for( int i = 0; i < filesets.length; i++ ) {
+ fullFilesetBuild(filesets[i], pkg);
+ }
+
+ EventManager.finishedBuildingArchive(pkg);
+ }
+
+ /**
+ * Build the given fileset
+ * @param fileset The fileset to match
+ * @param topLevel The top level archive that the fileset belongs to
+ */
+ public void fullFilesetBuild(IArchiveFileSet fileset, IArchive topLevel) {
+ EventManager.startedCollectingFileSet(fileset);
+
+ // reset the scanner. It *is* a full build afterall
+ fileset.resetScanner();
+ IPath[] paths = fileset.findMatchingPaths();
+ ModelTruezipBridge.fullFilesetBuild(fileset);
+
+ EventManager.filesUpdated(topLevel, fileset, paths);
+ EventManager.finishedCollectingFileSet(fileset);
+ }
+
+
+
+
+ /**
+ * Incremental Build!!
+ * Parameters are instances of changed IPath objects.
+ * Will search the entire model for matching filesets.
+ *
+ * @param addedChanged Set of changed / added resources
+ * @param setRemoved Set of removed resources
+ */
+ public void projectIncrementalBuild(Set addedChanged, Set removed) {
+ incrementalBuild(null, addedChanged, removed);
+ }
+
+ /**
+ * Incremental build.
+ * Parameters are instance sof changed IPath objects
+ * Will search only the given node for descendent filesets
+ * @param archive An archive to limit the scope to, or null if the entire model
+ * @param addedChanged A list of added or changed resource paths
+ * @param removed A list of removed resource paths
+ */
+ public void incrementalBuild(IArchive archive, Set addedChanged, Set removed) {
+
+ // find any and all filesets that match each file
+ Iterator i = addedChanged.iterator();
+ IPath path;
+ IArchiveFileSet[] matchingFilesets;
+ ArrayList topPackagesChanged = new ArrayList();
+ while(i.hasNext()) {
+ path = ((IPath)i.next());
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
+ localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
+ ModelTruezipBridge.copyFiles(matchingFilesets, new IPath[] { path }, false);
+ EventManager.fileUpdated(path, matchingFilesets);
+ }
+
+ i = removed.iterator();
+ while(i.hasNext()) {
+ path = ((IPath)i.next());
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
+ localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
+ ModelTruezipBridge.deleteFiles(matchingFilesets, new IPath[] { path }, false);
+ EventManager.fileRemoved(path, matchingFilesets);
+ }
+
+ TrueZipUtil.sync();
+
+ i = topPackagesChanged.iterator();
+ while(i.hasNext()) {
+ EventManager.finishedBuildingArchive((IArchive)i.next());
+ }
+ }
+
+ private void localFireAffectedTopLevelPackages(ArrayList affected, IArchiveFileSet[]
filesets) {
+ for( int i = 0; i < filesets.length; i++ ) {
+ if( !affected.contains(filesets[i].getRootArchive())) {
+ affected.add(filesets[i].getRootArchive());
+ EventManager.startedBuildingArchive(filesets[i].getRootArchive());
+ }
+ }
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.build;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.events.EventManager;
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
+
+/**
+ * This class responds to model change events.
+ * It is given a delta as to what nodes are added, removed, or changed.
+ * It then keeps the output file for the top level archive in sync with
+ * the changes to the model.
+ *
+ * If the automatic builder is not enabled for this project, the listener
+ * does nothing.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ModelChangeListener implements IArchiveModelListener {
+
+ /**
+ * This is the entry point for model change events.
+ * It immediately passes the delta to be handled.
+ */
+ public void modelChanged(IArchiveNodeDelta delta) {
+ // if we're not building, get out
+ if(
!ArchivesCore.getInstance().getPreferenceManager().isBuilderEnabled(delta.getPostNode().getProjectPath()))
+ return;
+
+ try {
+ handle(delta);
+ } catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This can handle any type of node / delta, not just
+ * root elements. If the node is added or removed, it
+ * will handle those segments and return without checking
+ * the children at all. IT is the responsibility of the add
+ * and remove methods to go through the children.
+ *
+ * Otherwise, it will simply handle attribute children and then
+ * move on to the children.
+ *
+ * @param delta
+ */
+ private void handle(IArchiveNodeDelta delta) {
+ if( (delta.getKind() & IArchiveNodeDelta.REMOVED) != 0 ) {
+ nodeRemoved(delta.getPreNode());
+ return;
+ } else if( (delta.getKind() & IArchiveNodeDelta.ADDED) != 0 ) {
+ nodeAdded(delta.getPostNode());
+ return;
+ } else if( (delta.getKind() & IArchiveNodeDelta.ATTRIBUTE_CHANGED) != 0) {
+ boolean shouldHandleChildren = handleAttributeChange(delta);
+ if( shouldHandleChildren ) {
+ IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
+ for( int i = 0; i < children.length; i++ ) {
+ handle(children[i]);
+ }
+ }
+ } else if( descendentChanged(delta.getKind()) ) {
+ IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
+ for( int i = 0; i < children.length; i++ ) {
+ handle(children[i]);
+ }
+ }
+ }
+ protected boolean descendentChanged(int kind) {
+ return (kind & IArchiveNodeDelta.DESCENDENT_CHANGED) != 0 ||
+ (kind & IArchiveNodeDelta.CHILD_ADDED) != 0 ||
+ (kind & IArchiveNodeDelta.CHILD_REMOVED) != 0;
+ }
+
+ /**
+ * Handle changes in this node
+ * @param delta
+ * @return Whether or not the caller should also handle the children
+ */
+ private boolean handleAttributeChange(IArchiveNodeDelta delta) {
+ switch( delta.getPostNode().getNodeType()) {
+ case IArchiveNode.TYPE_ARCHIVE_FOLDER:
+ return handleFolderAttributeChanged(delta);
+ case IArchiveNode.TYPE_ARCHIVE_FILESET:
+ return handleFilesetAttributeChanged(delta);
+ case IArchiveNode.TYPE_ARCHIVE:
+ return handlePackageAttributeChanged(delta);
+ }
+ return false;
+ }
+
+ private boolean handleFolderAttributeChanged(IArchiveNodeDelta delta) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ return false;
+ }
+
+ private boolean handleFilesetAttributeChanged(IArchiveNodeDelta delta) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ return false;
+ }
+
+ private boolean handlePackageAttributeChanged(IArchiveNodeDelta delta) {
+ nodeRemoved(delta.getPreNode());
+ nodeAdded(delta.getPostNode());
+ return false;
+ }
+
+
+
+
+ private void nodeAdded(IArchiveNode added) {
+ if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ // create the package
+ ModelTruezipBridge.createFile(added);
+ } else if( added.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
+ // create hte folder
+ ModelTruezipBridge.createFile(added);
+ }
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(added);
+ for( int i = 0; i < filesets.length; i++ ) {
+ ModelTruezipBridge.fullFilesetBuild(filesets[i]);
+ IPath[] paths = filesets[i].findMatchingPaths();
+ EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], paths);
+ }
+ refreshLocal(added);
+ }
+
+
+ private void nodeRemoved(IArchiveNode removed) {
+ if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ ModelTruezipBridge.deleteArchive((IArchive)removed);
+ refreshLocal(removed);
+ return;
+ } else if( removed.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ){
+ IArchiveFileSet[] filesets =
ModelUtil.findAllDescendentFilesets(((IArchiveFolder)removed));
+ for( int i = 0; i < filesets.length; i++ ) {
+ IPath[] removedPaths =
ModelTruezipBridge.fullFilesetRemove(((IArchiveFileSet)removed), false);
+ EventManager.filesRemoved(removedPaths, ((IArchiveFileSet)removed));
+ }
+ refreshLocal(removed);
+ return;
+ }
+
+ IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(removed);
+ for( int i = 0; i < filesets.length; i++ ) {
+ IPath[] removedPaths =
ModelTruezipBridge.fullFilesetRemove(((IArchiveFileSet)removed), false);
+ EventManager.filesRemoved(removedPaths, ((IArchiveFileSet)removed));
+ }
+ refreshLocal(removed);
+ }
+
+
+ // refresh the file tree structure
+ private void refreshLocal(IArchiveNode node) {
+ IArchive pack = node.getRootArchive();
+ if( pack != null && pack.isDestinationInWorkspace() ) {
+ // refresh the root package node
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource res = root.getContainerForLocation(pack.getDestinationPath());
+ if( res != null ) {
+ try {
+ res.getParent().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ }
+ }
+ }
+
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchiveNodeFactory.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchiveNodeFactory.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchiveNodeFactory.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,45 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+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;
+
+/**
+ * Just a factory for extenders to access our secret internals
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ArchiveNodeFactory {
+ public static IArchive createArchive() {
+ return new ArchiveImpl();
+ }
+
+ public static IArchiveFileSet createFileset() {
+ return new ArchiveFileSetImpl();
+ }
+
+ public static IArchiveFolder createFolder() {
+ return new ArchiveFolderImpl();
+ }
+}
Added:
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
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.Trace;
+import org.jboss.ide.eclipse.archives.core.build.ModelChangeListener;
+import org.jboss.ide.eclipse.archives.core.model.events.EventManager;
+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.other.IArchiveBuildListener;
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.project.ProjectUtils;
+
+/**
+ * The root model which keeps track of registered projects
+ * and what archives / model nodes they contain.
+ *
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ */
+public class ArchivesModel implements IArchiveModelListenerManager {
+
+ /**
+ * The packages file name
+ */
+ public static final String PROJECT_PACKAGES_FILE = ".packages";
+
+ /**
+ * Singleton instance
+ */
+ protected static ArchivesModel instance;
+ public static ArchivesModel instance() {
+ if( instance == null )
+ instance = new ArchivesModel();
+ return instance;
+ }
+
+ private HashMap xbPackages; // maps an IPath (of a project) to XbPackages
+ private HashMap archivesRoot; // maps an IPath (of a project) to PackageModelNode, aka
root
+ private ArrayList buildListeners, modelListeners;
+ public ArchivesModel() {
+ xbPackages = new HashMap();
+ archivesRoot = new HashMap();
+ buildListeners = new ArrayList();
+ modelListeners = new ArrayList();
+ addModelListener(new ModelChangeListener());
+ }
+
+
+
+ /*
+ * Listeners
+ */
+ public void addBuildListener(IArchiveBuildListener listener) {
+ if( !buildListeners.contains(listener))
+ buildListeners.add(listener);
+ }
+ public void removeBuildListener(IArchiveBuildListener listener) {
+ if( buildListeners.contains(listener))
+ buildListeners.remove(listener);
+ }
+ public IArchiveBuildListener[] getBuildListeners() {
+ return (IArchiveBuildListener[]) buildListeners.toArray(new
IArchiveBuildListener[buildListeners.size()]);
+ }
+
+ public void addModelListener(IArchiveModelListener listener) {
+ if( !modelListeners.contains(listener))
+ modelListeners.add(listener);
+ }
+ public void removeModelListener(IArchiveModelListener listener) {
+ if( modelListeners.contains(listener))
+ modelListeners.remove(listener);
+ }
+ public IArchiveModelListener[] getModelListeners() {
+ return (IArchiveModelListener[]) modelListeners.toArray(new
IArchiveModelListener[modelListeners.size()]);
+ }
+
+
+
+
+
+
+ public XbPackages getXbPackages(IPath project) {
+ return (XbPackages)(xbPackages.get(project));
+ }
+
+ /**
+ * If the project hasn't been registered, register it
+ * @param project
+ * @param monitor
+ * @return
+ */
+ public XbPackages getXbPackages(IPath project, IProgressMonitor monitor) {
+ if( !xbPackages.containsKey(project))
+ registerProject(project, monitor);
+ return (XbPackages)(xbPackages.get(project));
+ }
+
+ /**
+ * Accept a visitor
+ */
+ public boolean accept(IArchiveNodeVisitor visitor) {
+ IArchiveNode children[] = getAllArchives();
+ boolean keepGoing = true;
+
+ if (keepGoing) {
+ for (int i = 0; i < children.length; i++) {
+ if (keepGoing) {
+ keepGoing = children[i].accept(visitor);
+ }
+ }
+ }
+
+ return keepGoing;
+ }
+
+ /**
+ * Gets every single *registered* model
+ * @return
+ */
+ protected ArchiveModelNode[] getAllArchives() {
+ ArchiveModelNode[] ret = new ArchiveModelNode[archivesRoot.keySet().size()];
+ Iterator i = archivesRoot.keySet().iterator();
+ int x = 0;
+ while(i.hasNext()) {
+ ret[x++] = (ArchiveModelNode)archivesRoot.get(i.next());
+ }
+ return ret;
+ }
+
+ /**
+ * Get the root node for this object
+ * @param project
+ * @return
+ */
+ public IArchiveModelNode getRoot(IPath project) {
+ return getRoot(project, false, new NullProgressMonitor());
+ }
+
+ public IArchiveModelNode getRoot(IPath project, boolean register, IProgressMonitor
monitor) {
+ if( archivesRoot.get(project) == null && register ) {
+ registerProject(project, monitor);
+ }
+ return (IArchiveModelNode)(archivesRoot.get(project));
+ }
+
+ public IArchive[] getProjectArchives(IPath project) {
+ return getProjectArchives(project, false, new NullProgressMonitor());
+ }
+ public IArchive[] getProjectArchives(IPath project, boolean register, IProgressMonitor
monitor) {
+ IArchiveModelNode root = getRoot(project);
+ if( root != null ) {
+ List list = Arrays.asList( getRoot(project).getAllChildren());
+ return (IArchive[]) list.toArray(new IArchive[list.size()]);
+ } else {
+ registerProject(project, monitor);
+ List list = Arrays.asList( getRoot(project).getAllChildren());
+ return (IArchive[]) list.toArray(new IArchive[list.size()]);
+ }
+ }
+
+ // to make sure the node root is actually in the model
+ public boolean containsRoot(ArchiveModelNode node) {
+ return archivesRoot.containsValue(node);
+ }
+
+ private void addNature(IPath project) {
+ try {
+ ProjectUtils.addProjectNature(project);
+ } catch(Exception e) {
+ }
+ }
+ public void registerProject(IPath project, IProgressMonitor monitor) {
+ // if the file exists, read it in
+ monitor.beginTask("Loading configuration...",
XMLBinding.NUM_UNMARSHAL_MONITOR_STEPS + 2);
+
+ if( ArchivesCore.getInstance().isWorkspaceRuntype()) {
+ addNature(project);
+ }
+
+ ArchiveModelNode root;
+ IPath packagesFile = project.append(PROJECT_PACKAGES_FILE);
+ if (packagesFile.toFile().exists())
+ {
+ try {
+ FileInputStream is = new FileInputStream(packagesFile.toFile());
+ XbPackages packages = XMLBinding.unmarshal(is, monitor);
+ monitor.worked(1);
+
+ if (packages == null) {
+ // Empty / non-working XML file loaded
+ Trace.trace(getClass(), "WARNING: .packages file for project " +
project.lastSegment() + " is empty or contains the wrong content");
+ return;
+ }
+ root = new ArchiveModelNode(project, packages, this);
+ xbPackages.put(project, packages);
+ archivesRoot.put(project, root);
+ createPackageNodeImpl(project, packages, null);
+ root.clearDeltas();
+ monitor.worked(1);
+ } catch (FileNotFoundException e) {
+ Trace.trace(getClass(), e);
+ }
+ } else {
+ // file not found, just create some default xbpackages and insert them
+ XbPackages packages = new XbPackages();
+ xbPackages.put(project, packages);
+ archivesRoot.put(project, new ArchiveModelNode(project, packages, this));
+ }
+ }
+
+ protected 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
+
+ try {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ OutputStreamWriter writer = new OutputStreamWriter(bytesOut);
+ XbPackages packs = getXbPackages(project);
+ XMLBinding.marshal(packs, writer, monitor);
+ writer.close();
+
+ ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut.toByteArray());
+ IPath packagesFile = project.append(ArchivesModel.PROJECT_PACKAGES_FILE);
+ OutputStream out = new FileOutputStream(packagesFile.toFile());
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = bytesIn.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ out.close();
+ bytesIn.close();
+ bytesOut.close();
+
+ // get deltas
+ try {
+ ArchiveModelNode root = (ArchiveModelNode)getRoot(project);
+ IArchiveNodeDelta delta = root.getDelta();
+
+ // clear deltas
+ root.clearDeltas();
+
+ // fire delta events
+ EventManager.fireDelta(delta);
+ } catch( Exception e ) {
+ e.printStackTrace();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void attach(IArchiveNode parent, IArchiveNode child, IProgressMonitor monitor) {
+ parent.addChild(child);
+ if( parent.connectedToModel() && parent.getProjectPath() != null) {
+ // save
+ saveModel(parent.getProjectPath(), monitor);
+ }
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.apache.tools.ant.DirectoryScanner;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+
+/**
+ * Utility methods and entry points for model-related APIs
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ArchivesModelCore {
+
+
+ /**
+ * Builds all of a project's packages. Note that this does not call any builders
before or after the package builder (i.e. the JDT builder).
+ * If you are looking to run all the builders on a project use project.build()
+ * @param project The project to build
+ * @param buildType FULL_BUILD, INCREMENTAL_BUILD, CLEAN_BUILD, etc
+ * @param monitor A progress monitor
+ */
+ public static void buildProject (IPath project, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+ new ArchiveBuildDelegate().fullProjectBuild(project);
+ }
+
+ /**
+ * Build the passed-in package.
+ * @param pkg The package to build
+ */
+ public static void buildArchive (IArchive pkg, IProgressMonitor monitor) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+ new ArchiveBuildDelegate().fullArchiveBuild(pkg);
+ }
+
+ public static IArchive[] getProjectPackages (IPath project, IProgressMonitor monitor,
boolean forceInit) {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Fetching packages for \"" + project.lastSegment() +
"\"...", 2);
+ IArchive[] packages = ArchivesModel.instance().getProjectArchives(project);
+ monitor.worked(1);
+
+ if (packages == null) {
+ if (forceInit && packageFileExists(project)) {
+ ArchivesModel.instance().registerProject(project, monitor);
+ packages = ArchivesModel.instance().getProjectArchives(project);
+ }
+
+ if (packages == null) return new IArchive[0];
+ }
+
+ monitor.worked(1);
+ monitor.done();
+ return packages;
+ }
+
+ public static boolean packageFileExists (IPath project) {
+ return project.append(ArchivesModel.PROJECT_PACKAGES_FILE).toFile().exists();
+ }
+
+ public static boolean projectRegistered(IPath project) {
+ return ArchivesModel.instance().getRoot(project) == null ? false : true;
+ }
+
+
+ /**
+ * Visit all of the top-level packages in the passed in project with the passed in node
visitor
+ * @param project The project whose packages to visit
+ * @param visitor The visitor
+ */
+ public static void visitProjectArchives (IPath project, IArchiveNodeVisitor visitor) {
+ if (packageFileExists(project)) {
+ IArchive packages[] = getProjectPackages(project, null, false);
+ if( packages == null ) return;
+ for (int i = 0; i < packages.length; i++) {
+ boolean keepGoing = packages[i].accept(visitor);
+ if (!keepGoing) break;
+ }
+ }
+ }
+
+
+ public static IPath[] findMatchingPaths(IPath root, String includes, String excludes) {
+ DirectoryScanner scanner =
+ DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
+ String[] files = scanner.getIncludedFiles();
+ IPath[] paths = new IPath[files.length];
+ for( int i = 0; i < files.length; i++ ) {
+ paths[i] = new Path(files[i]);
+ }
+ return paths;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,62 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import java.io.File;
+
+import org.apache.tools.ant.DirectoryScanner;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Utility methods to create scanners for matching
+ * @author rob.stryker(a)jboss.com
+ */
+public class DirectoryScannerFactory {
+
+ public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder,
String includes, String excludes, boolean scan) {
+ if (includes == null) includes = "";
+ if (excludes == null) excludes = "";
+
+ DirectoryScannerExtension scanner = new DirectoryScannerExtension();
+ String excludesList[] = excludes.split(" ?, ?");
+ String includesList[] = includes.split(" ?, ?");
+
+ File basedir = filesystemFolder.toFile();
+ scanner.setBasedir(basedir);
+ scanner.setExcludes(excludesList);
+ scanner.setIncludes(includesList);
+ if (scan)
+ scanner.scan();
+
+ return scanner;
+ }
+
+ /**
+ * Exposes the isIncluded method so that entire scans do not need to occur
+ * to find matches.
+ */
+ public static class DirectoryScannerExtension extends DirectoryScanner {
+ public boolean isIncluded(String name) {
+ return super.isIncluded(name);
+ }
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * <p>
+ * This interface represents an archive definition.
+ * An archive definition consists of a list of folders, filesets, and sub-packages
+ * </p>
+ *
+ * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ * @version $Revision: 1939 $
+ */
+public interface IArchive extends IArchiveNode {
+ public static final String ATTRIBUTE_PREFIX =
"org.jboss.ide.eclipse.archives.core.model.IPackage.";
+ public static final String PACKAGE_TYPE_ATTRIBUTE = ATTRIBUTE_PREFIX +
"packageType";
+ public static final String EXPLODED_ATTRIBUTE = ATTRIBUTE_PREFIX +
"exploded";
+ public static final String DESTINATION_ATTRIBUTE = ATTRIBUTE_PREFIX +
"destination";
+ public static final String NAME_ATTRIBUTE = ATTRIBUTE_PREFIX + "name";
+ public static final String IN_WORKSPACE_ATTRIBUTE = ATTRIBUTE_PREFIX +
"inWorkspace";
+
+
+ /**
+ * @return The package type of this package.
+ */
+ public IArchiveType getArchiveType();
+
+ /**
+ * return the raw string from the delegate even if the type is not found
+ * @return
+ */
+ public String getArchiveTypeId();
+
+ /**
+ * @return The name (with extension) of this package.
+ */
+ public String getName();
+
+ /**
+ * @return Whether or not this package will be build exploded, or as a directory instead
of a ZIP/JAR
+ */
+ public boolean isExploded();
+
+ /**
+ * @return Whether or not this package is a "top-level" package aka, not a
child of another folder or package
+ */
+ public boolean isTopLevel();
+
+ /**
+ * If this package is top-level, there are two types of destinations it can have.
+ * "Inside" the workspace, and "outside" the workspace.
+ * @return Whether or not the destination of this package is in the workspace
+ */
+ public boolean isDestinationInWorkspace();
+
+ /**
+ * @return A list of sub-archives contained in this package
+ */
+ public IArchive[] getArchives();
+
+ /**
+ * @return A list of folders contained in this package
+ */
+ public IArchiveFolder[] getFolders();
+
+ /**
+ * @return A list of filesets contained in this package
+ */
+ public IArchiveFileSet[] getFileSets();
+
+ /**
+ * Get The path to this package's output file.
+ * This path should be GLOBAL
+ * @return the path
+ */
+ public IPath getArchiveFilePath();
+
+ /**
+ * The absolute raw file system path to the
+ * destination (containing folder) of this archive
+ * @return An IPath to this package's destination folder
+ */
+ public IPath getDestinationPath();
+
+ /**
+ * Set the package type of this package
+ * @param type The package type
+ */
+ public void setArchiveType(IArchiveType type);
+
+ /**
+ * Set the package type via ID.
+ * @param type
+ */
+ public void setArchiveType(String type);
+ /**
+ * Set the name of this package
+ * @param name This package's name
+ */
+ public void setName(String name);
+
+ /**
+ * Set whether or not this package is generated as a folder
+ * @param exploded
+ */
+ public void setExploded(boolean exploded);
+
+ /**
+ * Sets the destination path for this package.
+ * In workspace paths are relative to workspace root.
+ * Out of workspace paths are file-system absolute
+ * @param path The path where this archive will be built.
+ */
+ public void setDestinationPath (IPath path);
+
+ /**
+ * Set's whether the destination is workspace relative or not
+ */
+ public void setInWorkspace(boolean inWorkspace);
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * <p>
+ * This interface represents a file set inside of a package definition or folder.
+ * </p>
+ *
+ * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ * @version $Revision: 1930 $
+ */
+public interface IArchiveFileSet extends IArchiveNode {
+ public static final String ATTRIBUTE_PREFIX =
"org.jboss.ide.eclipse.archives.core.model.IPackageFileSet.";
+ public static final String INCLUDES_ATTRIBUTE = ATTRIBUTE_PREFIX +
"includes";
+ public static final String EXCLUDES_ATTRIBUTE = ATTRIBUTE_PREFIX +
"excludes";
+ public static final String IN_WORKSPACE_ATTRIBUTE = ATTRIBUTE_PREFIX +
"inWorkspace";
+ public static final String SOURCE_PATH_ATTRIBUTE = ATTRIBUTE_PREFIX +
"sourcePath";
+
+
+
+ /**
+ * @return Whether or not this fileset's basedir is inside the workspace
+ */
+ public boolean isInWorkspace();
+
+ /**
+ * Returns the absolute file-system relative source path
+ * @return The path to the source folder ("basedir" in ant terminology) for
this fileset.
+ */
+ public IPath getGlobalSourcePath();
+
+ /**
+ * @return the source path from the delegate (file-system or workspace-relative)
+ */
+ public IPath getSourcePath();
+
+ /**
+ * Force the scanner to check for matched files again
+ */
+ public void resetScanner();
+
+ /**
+ * @return The includes pattern for this fileset
+ */
+ public String getIncludesPattern();
+
+ /**
+ * @return The excludes pattern for this fileset
+ */
+ public String getExcludesPattern();
+
+ /**
+ * @return An array of matching IPath's in the filesystem (for external filesystem
filesets)
+ */
+ public IPath[] findMatchingPaths();
+
+ /**
+ * @param path The absolute path on the filesystem to check
+ * @return Whether or not this fileset matches the passed-in path
+ */
+ public boolean matchesPath(IPath path);
+
+ /**
+ * Sets the "root" or "source" of this fileset (file-system or
workspace relative)
+ * @param path The absolute path that is the source of this fileset
+ */
+ public void setSourcePath(IPath path);
+
+ /**
+ * Set the includes pattern for this fileset. This pattern uses the same syntax as
Ant's include pattern.
+ * @param includes The includes pattern for this fileset
+ */
+ public void setIncludesPattern(String includes);
+
+ /**
+ * Set the excludes pattern for this fileset. This pattern uses the same syntax as
Ant's exclude pattern.
+ * @param excludes The excludes pattern for this fileset
+ */
+ public void setExcludesPattern(String excludes);
+
+ /**
+ * Set whether or not this fileset's source is in the workspace. This will
automatically be handled if you
+ * use setSingleFile, setSourceProject, setSourceContainer, or setSourceFolder.
+ * @param isInWorkspace Whether or not this fileset's source is in the workspace
+ */
+ public void setInWorkspace(boolean isInWorkspace);
+
+ /**
+ * Get the relative path of the input file to the root archive
+ * @param inputFile
+ * @return
+ */
+ public IPath getRootArchiveRelativePath(IPath inputFile);
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFolder.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFolder.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFolder.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+
+/**
+ * <p>
+ * This interface represents a folder inside a package definition.
+ * A folder can contain packages, filesets, and sub-folders.
+ * </p>
+ *
+ * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ * @version $Revision: 1929 $
+ */
+public interface IArchiveFolder extends IArchiveNode {
+
+ public static final String ATTRIBUTE_PREFIX =
"org.jboss.ide.eclipse.archives.core.model.IPackageFolder.";
+ public static final String NAME_ATTRIBUTE = ATTRIBUTE_PREFIX + "name";
+
+
+ /**
+ * @return The name of this folder
+ */
+ public String getName();
+
+ /**
+ * Set the name of this folder
+ * @param name The name of this folder
+ */
+ public void setName(String name);
+
+ /**
+ * @return An array of sub-packages of this folder
+ */
+ public IArchive[] getArchives();
+
+ /**
+ * @return An array of sub-folders of this folder
+ */
+ public IArchiveFolder[] getFolders();
+
+ /**
+ * @return An array of filesets whose destination is this folder
+ */
+ public IArchiveFileSet[] getFileSets();
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelListenerManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelListenerManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelListenerManager.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,21 @@
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveBuildListener;
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveModelListener;
+
+/**
+ * Manages Archive Model Listeners, build and model changes, for changes
+ * in the model
+ * @author rstryker
+ *
+ */
+public interface IArchiveModelListenerManager {
+
+ public void addBuildListener(IArchiveBuildListener listener);
+ public void removeBuildListener(IArchiveBuildListener listener);
+ public IArchiveBuildListener[] getBuildListeners();
+ public void addModelListener(IArchiveModelListener listener);
+ public void removeModelListener(IArchiveModelListener listener);
+ public IArchiveModelListener[] getModelListeners();
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelNode.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelNode.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelNode.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+/**
+ * An interface for methods relevent to a model's root node.
+ * Only a label interface thus far
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public interface IArchiveModelNode extends IArchiveNode {
+ public IArchiveModelListenerManager getManager();
+}
Added:
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
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * The super type of all package nodes (IPackage, IPackageFileSet, IPackageFolder)
+ *
+ * Each node in a package may have arbitrary properties that can be reflected upon by
other plug-ins
+ *
+ * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ * @version $Revision: 1929 $
+ */
+public interface IArchiveNode extends IAdaptable {
+ /**
+ * The node type that represents the model
+ */
+ public static final int TYPE_MODEL = -1;
+
+ /**
+ * The node type that represents an IPackage
+ */
+ public static final int TYPE_ARCHIVE = 0;
+
+ /**
+ * The node type that represents an IPackageReference
+ */
+ public static final int TYPE_ARCHIVE_REFERENCE = 1;
+
+ /**
+ * The node type that represents an IPackageFileSet
+ */
+ public static final int TYPE_ARCHIVE_FILESET = 2;
+
+ /**
+ * The node type that represents an IPackageFolder
+ */
+ public static final int TYPE_ARCHIVE_FOLDER = 3;
+
+ /**
+ * @return The parent of this package node, or null if this node is top level
+ */
+ public IArchiveNode getParent();
+
+ /**
+ * Set the parent of this package node
+ * @param parent The new parent of this node
+ */
+ public void setParent(IArchiveNode parent);
+
+ /**
+ * @param type TYPE_PACKAGE, TYPE_PACKAGE_FILESET, or TYPE_PACKAGE_FOLDER
+ * @return An array of child nodes of the passed in type
+ */
+ public IArchiveNode[] getChildren(int type);
+
+ /**
+ * @return An array of all children nodes
+ */
+ public IArchiveNode[] getAllChildren();
+
+ /**
+ * @return Whether or not this node has children
+ */
+ public boolean hasChildren();
+
+ /**
+ * @param child A possible child node
+ * @return Whether or not the passed-in node is a child of this node
+ */
+ public boolean hasChild(IArchiveNode child);
+
+ /**
+ * @return The type of this package node
+ */
+ public int getNodeType();
+
+ /**
+ * @param property The name of the property to fetch
+ * @return The value of the specified property
+ */
+ public String getProperty(String property);
+
+ /**
+ * Set a property on this package node
+ * @param property The name of the property to set
+ * @param value The new value of the property
+ */
+ public void setProperty(String property, String value);
+
+ /**
+ * @return The project that this node is defined in (not necessarily the project where
this is based if this is a fileset)
+ */
+ public IPath getProjectPath();
+
+ /**
+ * Recursively visit the package node tree below this node with the passed-in package
node visitor.
+ * @param visitor A package node visitor
+ * @return Whether or not the entire sub-tree was visited
+ */
+ public boolean accept(IArchiveNodeVisitor visitor);
+
+ /**
+ * Recursively visit the package node tree below this node with the passed-in package
node visitor, using depth-first ordering
+ * @param visitor A package node visitor
+ * @return Whether or not the entire sub-tree was visited
+ */
+ public boolean accept(IArchiveNodeVisitor visitor, boolean depthFirst);
+
+ /**
+ * Add a child node to this node
+ * @param child The child to add
+ */
+ public void addChild(IArchiveNode child);
+
+ /**
+ * Remove a child node from this node
+ * @param child The child to remove
+ */
+ public void removeChild(IArchiveNode child);
+
+ /**
+ * Get the highest parent that is not null.
+ * @return
+ */
+ public IArchiveNode getRoot();
+
+ /**
+ * Get the model this node is attached to, or null if none
+ * @return
+ */
+ public IArchiveModelNode getModel();
+
+ /**
+ * Is the root of this node a PackageModelNode and registered in PackagesModel?
+ * @return
+ */
+ public boolean connectedToModel();
+
+ /**
+ * Get the path relative to the root archive
+ * @return
+ */
+ public IPath getRootArchiveRelativePath();
+
+ /**
+ * Get the root top-level package for this node
+ * @return
+ */
+ public IArchive getRootArchive();
+ /**
+ * Get the current delta
+ * @return
+ */
+ public IArchiveNodeDelta getDelta();
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeDelta.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeDelta.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeDelta.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+/**
+ * Node delta interface
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public interface IArchiveNodeDelta {
+
+ /**
+ * There is no change to this node or any of it's children
+ */
+ public static final int NO_CHANGE = 0;
+
+ /**
+ * I have been added
+ */
+ public static final int ADDED = 0x1;
+
+ /**
+ * I have been removed
+ */
+ public static final int REMOVED = 0x2;
+
+
+
+ /**
+ * Used to designate that a sub-property within
+ * a <property> tag has been added.
+ */
+ public static final int PROPERTY_ADDED = 0x10;
+
+ /**
+ * Used to designate that a sub-property within
+ * a <property> tag has been removed.
+ */
+ public static final int PROPERTY_REMOVED = 0x20;
+
+ /**
+ * Used to designate that a sub-property within
+ * a <property> tag has been changed.
+ */
+ public static final int PROPERTY_CHANGED = 0x40;
+
+ /**
+ * Used to designate that an primary property of the node,
+ * such as inWorkspace or exploded, has changed.
+ */
+ public static final int ATTRIBUTE_CHANGED = 0x80;
+
+ /**
+ * A child has been added directly to me
+ */
+ public static final int CHILD_ADDED = 0x100;
+
+ /**
+ * A child has been removed directly from me
+ */
+ public static final int CHILD_REMOVED = 0x200;
+
+ /**
+ * Some other change has occurred, most likely a
+ * grand-child added or a child's property changed.
+ */
+ public static final int DESCENDENT_CHANGED = 0x400;
+
+ /**
+ * Return the delta kind
+ * @return
+ */
+ public int getKind();
+
+ /**
+ * Return the affected node after changes
+ * @return
+ */
+ public IArchiveNode getPostNode();
+
+ /**
+ * Return the affected node before changes, or null if the node is an {@link
IArchiveModelNode}
+ * @return
+ */
+ public IArchiveNode getPreNode();
+
+ /**
+ * Get a list of property keys for changed properties
+ * @return
+ */
+ public String[] getPropertiesWithDeltas();
+
+ /**
+ * Get the property node delta for the given property key
+ * @param key
+ * @return
+ */
+ public INodeDelta getPropertyDelta(String key);
+
+ /**
+ * Get a list of attribute keys for changed attributes
+ * @return
+ */
+ public String[] getAttributesWithDeltas();
+
+ /**
+ * Get the attribute node delta for a given attribute key
+ * @param key
+ * @return
+ */
+ public INodeDelta getAttributeDelta(String key);
+
+ /**
+ * Get the array of added children
+ * @return
+ */
+ public IArchiveNodeDelta[] getAddedChildrenDeltas();
+
+ /**
+ * Get the array of removed Children
+ * @return
+ */
+ public IArchiveNodeDelta[] getRemovedChildrenDeltas();
+
+ /**
+ * Get only deltas where descendent changed
+ * @return
+ */
+ public IArchiveNodeDelta[] getChangedDescendentDeltas();
+
+ /**
+ * Get the children that have been changed
+ * @return
+ */
+ public IArchiveNodeDelta[] getAllAffectedChildren();
+
+
+
+ public interface INodeDelta {
+ public Object getBefore();
+ public Object getAfter();
+ public int getKind();
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeVisitor.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeVisitor.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNodeVisitor.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+/**
+ * The interface for visiting through nodes
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ */
+public interface IArchiveNodeVisitor {
+
+ public boolean visit (IArchiveNode node);
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveType.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveType.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveType.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,62 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * This interface represents a package type (i.e. JAR,WAR,SAR etc).
+ *
+ * A package type's main focus right now is to provide a default "template"
Package for a given Project, making it easier
+ * for users and adopters to automatically adapt projects into a deployable package
type.
+ *
+ * @author Marshall
+ */
+public interface IArchiveType {
+
+ /**
+ * @return The ID for this PackageType, i.e. "jar", "war" etc
+ */
+ public String getId();
+
+ /**
+ * @return The label for this PackageType (usually shown in UI)
+ */
+ public String getLabel();
+
+ /**
+ * This will create a "default" packaging configuration for this project using
this package type.
+ *
+ * If the passed-in project does not support this package type, a null IPackage should
be returned.
+ *
+ * @param project The project to create the packages configuration for
+ * @return The top level package that was created
+ */
+ public IArchive createDefaultConfiguration(IProject project, IProgressMonitor monitor);
+
+ /**
+ * Fill an archive type with some filesets and folders that are required
+ */
+ public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel,
IProgressMonitor monitor);
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/events/EventManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/events/EventManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/events/EventManager.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.events;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+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.IArchiveModelNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveBuildListener;
+import org.jboss.ide.eclipse.archives.core.model.other.IArchiveModelListener;
+
+/**
+ * The event manager to fire events
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ */
+public class EventManager {
+
+ public static void cleanProjectBuild(IPath project) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners();
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].cleanProject(project);
+ } catch(Exception e ) {}
+ }
+
+ public static void cleanArchiveBuild(IArchive archive) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(archive);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].cleanArchive(archive);
+ } catch(Exception e ) {}
+ }
+
+ public static void startedBuild(IPath project) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners();
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].startedBuild(project);
+ } catch(Exception e ) {}
+ }
+
+ public static void finishedBuild(IPath project) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners();
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].finishedBuild(project);
+ } catch(Exception e ) {}
+ }
+
+ public static void startedBuildingArchive(IArchive archive) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(archive);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].startedBuildingArchive(archive);
+ } catch(Exception e ) {}
+ }
+
+ public static void finishedBuildingArchive(IArchive archive) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(archive);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].finishedBuildingArchive(archive);
+ } catch(Exception e ) {}
+ }
+
+
+
+ public static void startedCollectingFileSet(IArchiveFileSet fileset) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(fileset);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].startedCollectingFileSet(fileset);
+ } catch(Exception e ) {}
+ }
+ public static void finishedCollectingFileSet(IArchiveFileSet fileset) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(fileset);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].finishedCollectingFileSet(fileset);
+ } catch(Exception e ) {}
+ }
+
+ // Bulk events
+ public static void filesUpdated(IArchive topLevelArchive, IArchiveFileSet fileset,
IPath[] filePath) {
+ for( int i = 0; i < filePath.length; i++ ) {
+ fileUpdated(topLevelArchive, fileset, filePath[i]);
+ }
+ }
+
+ // one file updated matching multiple filesets
+ public static void fileUpdated(IPath path, IArchiveFileSet[] matchingFilesets) {
+ for( int i = 0; i < matchingFilesets.length; i++ ) {
+ fileUpdated(matchingFilesets[i].getRootArchive(), matchingFilesets[i], path);
+ }
+ }
+
+ public static void fileUpdated(IArchive topLevelArchive, IArchiveFileSet fileset, IPath
filePath) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(topLevelArchive);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].fileUpdated(topLevelArchive, fileset, filePath);
+ } catch(Exception e ) {}
+ }
+
+ public static void fileRemoved(IArchive topLevelArchive, IArchiveFileSet fileset, IPath
filePath) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(topLevelArchive);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].fileRemoved(topLevelArchive, fileset, filePath);
+ } catch(Exception e ) {}
+ }
+
+ // one file removed matching multiple filesets
+ public static void fileRemoved(IPath path, IArchiveFileSet[] matchingFilesets) {
+ for( int i = 0; i < matchingFilesets.length; i++ ) {
+ fileRemoved(matchingFilesets[i].getRootArchive(), matchingFilesets[i], path);
+ }
+ }
+
+ public static void filesRemoved(IPath[] paths, IArchiveFileSet fileset) {
+ for( int i = 0; i < paths.length; i++ ) {
+ fileRemoved(fileset.getRootArchive(), fileset, paths[i]);
+ }
+ }
+
+ public static void buildFailed(IArchive pkg, IStatus status) {
+ try {
+ IArchiveBuildListener[] listeners = getBuildListeners(pkg);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].buildFailed(pkg, status);
+ } catch(Exception e ) {}
+ }
+
+
+
+ /**
+ * Fire events dealing with model changes
+ * @param delta
+ */
+
+ public static void fireDelta(IArchiveNodeDelta delta) {
+ try {
+ IArchiveNode node = delta.getPostNode() == null ? delta.getPreNode() :
delta.getPostNode();
+ IArchiveModelListener[] listeners = getModelListeners(node);
+ for( int i = 0; i < listeners.length; i++ )
+ listeners[i].modelChanged(delta);
+ } catch(Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+
+ private static IArchiveModelListener[] getModelListeners(IArchiveNode node) {
+ IArchiveModelNode model = node.getModel();
+ if( model != null && model.getManager() != null ) {
+ return model.getManager().getModelListeners();
+ }
+ return new IArchiveModelListener[]{};
+ }
+
+ // get workspace default ones
+ private static IArchiveBuildListener[] getBuildListeners() {
+ return ArchivesModel.instance().getBuildListeners();
+ }
+ private static IArchiveBuildListener[] getBuildListeners(IArchiveNode node) {
+ IArchiveModelNode model = node.getModel();
+ if( model != null && model.getManager() != null ) {
+ return model.getManager().getBuildListeners();
+ }
+ return new IArchiveBuildListener[]{};
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveDeltaPreNodeFactory.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveDeltaPreNodeFactory.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveDeltaPreNodeFactory.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+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.IArchiveNode;
+import
org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeDeltaImpl.NodeDelta;
+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.XbPackageNodeWithProperties;
+
+
+/**
+ * This class generates a replica of what an archive
+ * node looked like before the changes that instigated
+ * the delta.
+ *
+ * Because these replica nodes will not be connected ot the model,
+ * they need to know their project and their parent properly
+ * @author rstryker
+ *
+ */
+public class ArchiveDeltaPreNodeFactory {
+
+ // children get added later
+ public static ArchiveNodeImpl createNode(ArchiveNodeDeltaImpl parentDelta,
ArchiveNodeImpl postChange,
+ HashMap attributeChanges, HashMap propertyChanges) {
+
+ switch(postChange.getNodeType()) {
+ case IArchiveNode.TYPE_ARCHIVE_FILESET:
+ XbFileSet fs = createFileset((ArchiveFileSetImpl)postChange, attributeChanges,
propertyChanges);
+ return new DeltaFileset(fs, parentDelta, postChange.getProjectPath());
+ case IArchiveNode.TYPE_ARCHIVE_FOLDER:
+ XbFolder folder = createFolder((ArchiveFolderImpl)postChange, attributeChanges,
propertyChanges);
+ return new DeltaFolder(folder, parentDelta, postChange.getProjectPath());
+ case IArchiveNode.TYPE_ARCHIVE:
+ XbPackage pack = createPackage((ArchiveImpl)postChange, attributeChanges,
propertyChanges);
+ return new DeltaArchive(pack, parentDelta, postChange.getProjectPath());
+ }
+
+ return null;
+ }
+
+
+ protected static XbFileSet createFileset(ArchiveFileSetImpl postChange,HashMap
attributeChanges, HashMap propertyChanges ) {
+ XbFileSet fs = new XbFileSet((XbFileSet)postChange.nodeDelegate);
+// fs.setDir("FILESET TEST CHANGE");
+ if( attributeChanges.containsKey(IArchiveFileSet.INCLUDES_ATTRIBUTE))
+ fs.setIncludes(getBeforeString(attributeChanges,
IArchiveFileSet.INCLUDES_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchiveFileSet.EXCLUDES_ATTRIBUTE))
+ fs.setExcludes(getBeforeString(attributeChanges,
IArchiveFileSet.EXCLUDES_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchiveFileSet.SOURCE_PATH_ATTRIBUTE))
+ fs.setDir(getBeforeString(attributeChanges, IArchiveFileSet.SOURCE_PATH_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchiveFileSet.IN_WORKSPACE_ATTRIBUTE))
+ fs.setInWorkspace(getBeforeBoolean(attributeChanges,
IArchiveFileSet.IN_WORKSPACE_ATTRIBUTE));
+
+ undoPropertyChanges(fs, propertyChanges);
+ return fs;
+ }
+
+ protected static XbFolder createFolder(ArchiveFolderImpl postChange,HashMap
attributeChanges, HashMap propertyChanges ) {
+ XbFolder folder = new XbFolder((XbFolder)postChange.nodeDelegate);
+ if( attributeChanges.containsKey(IArchiveFolder.NAME_ATTRIBUTE))
+ folder.setName(getBeforeString(attributeChanges, IArchiveFolder.NAME_ATTRIBUTE));
+ undoPropertyChanges(folder, propertyChanges);
+ return folder;
+ }
+
+ protected static XbPackage createPackage(ArchiveImpl postChange,HashMap
attributeChanges, HashMap propertyChanges ) {
+ XbPackage pack = new XbPackage((XbPackage)postChange.nodeDelegate);
+ if( attributeChanges.containsKey(IArchive.NAME_ATTRIBUTE))
+ pack.setName(getBeforeString(attributeChanges, IArchive.NAME_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchive.PACKAGE_TYPE_ATTRIBUTE))
+ pack.setPackageType(getBeforeString(attributeChanges,
IArchive.PACKAGE_TYPE_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchive.DESTINATION_ATTRIBUTE))
+ pack.setToDir(getBeforeString(attributeChanges, IArchive.DESTINATION_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchive.IN_WORKSPACE_ATTRIBUTE))
+ pack.setInWorkspace(getBeforeBoolean(attributeChanges,
IArchive.IN_WORKSPACE_ATTRIBUTE));
+ if( attributeChanges.containsKey(IArchive.EXPLODED_ATTRIBUTE))
+ pack.setExploded(getBeforeBoolean(attributeChanges, IArchive.EXPLODED_ATTRIBUTE));
+ undoPropertyChanges(pack, propertyChanges);
+ return pack;
+ }
+
+ protected static boolean getBeforeBoolean(HashMap map, String key) {
+ NodeDelta delta = (NodeDelta)map.get(key);
+ if( delta != null ) {
+ return ((Boolean)delta.getBefore()).booleanValue();
+ }
+ return true;
+ }
+ protected static String getBeforeString(HashMap map, String key) {
+ NodeDelta delta = (NodeDelta)map.get(key);
+ if( delta != null ) {
+ return (String)delta.getBefore();
+ }
+ return null;
+ }
+
+ // set the properties here to what they were before the delta
+ protected static void undoPropertyChanges(XbPackageNodeWithProperties node, HashMap
changes) {
+ String key;
+ NodeDelta val;
+ for( Iterator i = changes.keySet().iterator(); i.hasNext(); ) {
+ key = (String) i.next();
+ val = (NodeDelta)changes.get(key);
+ if( val.getBefore() == null ) {
+ node.getProperties().getProperties().remove(key);
+ } else {
+ node.getProperties().getProperties().setProperty(key, (String)val.getBefore());
+ }
+ }
+
+ }
+
+
+ /*
+ * Delta implementations of the various nodes.
+ * Project is stored because delta nodes (or pre-nodes) are not connected to the model.
+ * Therefore the project must be kept handy.
+ */
+
+ /**
+ * Extending class representing a delta fileset
+ */
+ public static class DeltaFileset extends ArchiveFileSetImpl {
+ // everything goes through the delegate or the parent. Simple
+ private ArchiveNodeDeltaImpl parentDelta;
+ private IPath project;
+ public DeltaFileset(XbFileSet fileset, ArchiveNodeDeltaImpl parentDelta, IPath
project){
+ super(fileset);
+ this.parentDelta = parentDelta;
+ this.project = project;
+ }
+ public IArchiveNode getParent() {
+ return parentDelta == null ? null : parentDelta.getPreNode();
+ }
+ public IPath getProjectPath() {
+ return project;
+ }
+ }
+
+ /**
+ * Extending class representing a delta folder
+ */
+ public static class DeltaFolder extends ArchiveFolderImpl {
+ private ArchiveNodeDeltaImpl parentDelta;
+ private IPath project;
+ public DeltaFolder(XbFolder folder, ArchiveNodeDeltaImpl parentDelta, IPath project){
+ super(folder);
+ this.parentDelta = parentDelta;
+ this.project = project;
+ }
+ public IArchiveNode getParent() {
+ return parentDelta == null ? null : parentDelta.getPreNode();
+ }
+ public IPath getProjectPath() {
+ return project;
+ }
+ }
+
+ /**
+ * Extending class representing a delta archive
+ */
+ public static class DeltaArchive extends ArchiveImpl {
+ private ArchiveNodeDeltaImpl parentDelta;
+ private IPath project;
+ public DeltaArchive(XbPackage pack, ArchiveNodeDeltaImpl parentDelta, IPath project){
+ super(pack);
+ this.parentDelta = parentDelta;
+ this.project = project;
+ }
+ public IArchiveNode getParent() {
+ return parentDelta == null ? null : parentDelta.getPreNode();
+ }
+ public IPath getProjectPath() {
+ return project;
+ }
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
+
+/**
+ * An implementation for filesets
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ArchiveFileSetImpl extends ArchiveNodeImpl implements
+ IArchiveFileSet {
+
+ private XbFileSet filesetDelegate;
+ private DirectoryScannerExtension scanner;
+ private boolean rescanRequired = true;
+
+ public ArchiveFileSetImpl() {
+ this(new XbFileSet());
+ }
+
+ public ArchiveFileSetImpl (XbFileSet delegate) {
+ super(delegate);
+ this.filesetDelegate = delegate;
+ }
+
+ /*
+ * @see IArchiveFileSet#findMatchingPaths()
+ */
+ public IPath[] findMatchingPaths () {
+ DirectoryScannerExtension scanner = getScanner();
+ ArrayList paths = new ArrayList();
+ IPath sp = getGlobalSourcePath();
+ String matched[] = scanner.getIncludedFiles();
+ for (int i = 0; i < matched.length; i++) {
+ IPath path = sp.append(new Path(matched[i]));
+ paths.add(path);
+ }
+
+ return (IPath[])paths.toArray(new IPath[paths.size()]);
+ }
+
+ /*
+ * @see IArchiveFileSet#getExcludesPattern()
+ */
+ public String getExcludesPattern() {
+ return filesetDelegate.getExcludes();
+ }
+
+ /*
+ * @see IArchiveFileSet#isInWorkspace()
+ */
+ public boolean isInWorkspace() {
+ return filesetDelegate.isInWorkspace();
+ }
+
+ /*
+ * @see IArchiveFileSet#getIncludesPattern()
+ */
+ public String getIncludesPattern() {
+ return filesetDelegate.getIncludes();
+ }
+
+ /*
+ * @see IArchiveFileSet#getGlobalSourcePath()
+ */
+ public IPath getGlobalSourcePath() {
+ String path = filesetDelegate.getDir();
+ if (path == null || path.equals(".") || path.equals("")) {
+ return getProjectPath() == null ? null : getProjectPath();
+ } else if( isInWorkspace()){
+ return ArchivesCore.getInstance().getVariables().getWorkspacePath().append(path);
+ } else {
+ return new Path(path);
+ }
+ }
+
+ /*
+ * @see IArchiveFileSet#getSourcePath()
+ */
+ public IPath getSourcePath() {
+ return new Path(filesetDelegate.getDir());
+ }
+
+ /*
+ * @see IArchiveFileSet#matchesPath(IPath)
+ */
+ public boolean matchesPath(IPath path) {
+ return matchesPath(getScanner(), path);
+ }
+
+ private boolean matchesPath(DirectoryScannerExtension scanner, IPath path) {
+ if( getGlobalSourcePath().isPrefixOf(path)) {
+ String s =
path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
+ return scanner.isIncluded(s);
+ }
+ return false;
+ }
+
+ /*
+ * Will re-scan if required, or use cached scanner
+ * @return
+ */
+ private synchronized DirectoryScannerExtension getScanner() {
+ if( scanner == null || rescanRequired) {
+ rescanRequired = false;
+ scanner = DirectoryScannerFactory.createDirectoryScanner(
+ getGlobalSourcePath(), getIncludesPattern(), getExcludesPattern(), true);
+ }
+ return scanner;
+ }
+
+ /*
+ * @see IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return TYPE_ARCHIVE_FILESET;
+ }
+
+ /*
+ * @see IArchiveFileSet#setExcludesPattern(String)
+ */
+ public void setExcludesPattern(String excludes) {
+ attributeChanged(EXCLUDES_ATTRIBUTE, getExcludesPattern(), excludes);
+ filesetDelegate.setExcludes(excludes);
+ rescanRequired = true;
+ }
+
+ /*
+ * @see IArchiveFileSet#setIncludesPattern(String)
+ */
+ public void setIncludesPattern(String includes) {
+ attributeChanged(INCLUDES_ATTRIBUTE, getIncludesPattern(), includes);
+ filesetDelegate.setIncludes(includes);
+ rescanRequired = true;
+ }
+
+ /*
+ * @see IArchiveFileSet#setInWorkspace(boolean)
+ */
+ public void setInWorkspace(boolean isInWorkspace) {
+ attributeChanged(IN_WORKSPACE_ATTRIBUTE, new Boolean(isInWorkspace()), new
Boolean(isInWorkspace));
+ filesetDelegate.setInWorkspace(isInWorkspace);
+ rescanRequired = true;
+ }
+
+ /*
+ * @see IArchiveFileSet#setSourcePath(IPath, boolean)
+ */
+ public void setSourcePath (IPath path) {
+ Assert.isNotNull(path);
+ IPath src = getGlobalSourcePath();
+ attributeChanged(SOURCE_PATH_ATTRIBUTE, src == null ? null : src.toString(), path ==
null ? null : path.toString());
+ filesetDelegate.setDir(path.toString());
+ rescanRequired = true;
+ }
+
+ protected XbFileSet getFileSetDelegate () {
+ return filesetDelegate;
+ }
+
+ /*
+ * filesets have no path of their own
+ * and should not be the parents of any other node
+ * so the parent is their base location
+ * @see IArchiveNode#getRootArchiveRelativePath()
+ */
+ public IPath getRootArchiveRelativePath() {
+ return getParent().getRootArchiveRelativePath();
+ }
+
+ /*
+ * @see IArchiveFileSet#getRootArchiveRelativePath(IPath)
+ */
+ public IPath getRootArchiveRelativePath(IPath inputFile) {
+ if( matchesPath(inputFile)) {
+ String s =
inputFile.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
+ return getParent().getRootArchiveRelativePath().append(s);
+ }
+ return null;
+ }
+
+ /*
+ * @see IArchiveFileSet#resetScanner()
+ */
+ public void resetScanner() {
+ rescanRequired = true;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFolderImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFolderImpl.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFolderImpl.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import org.eclipse.core.runtime.IPath;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFolder;
+
+/**
+ * A PackageFolderImpl.
+ *
+ * @author <a href="marshall(a)jboss.org">Marshall Culpepper</a>
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ * @version $Revision: 1930 $
+ */
+public class ArchiveFolderImpl extends ArchiveNodeImpl implements
+ IArchiveFolder {
+
+ private XbFolder folderDelegate;
+
+ public ArchiveFolderImpl() {
+ this(new XbFolder());
+ }
+ public ArchiveFolderImpl(XbFolder delegate) {
+ super(delegate);
+ this.folderDelegate = delegate;
+ }
+
+ /*
+ * @see IArchiveFolder#getName()
+ */
+ public String getName() {
+ return folderDelegate.getName();
+ }
+
+ /*
+ * @see IArchiveFolder#getFileSets()
+ */
+ public IArchiveFileSet[] getFileSets() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FILESET);
+ IArchiveFileSet filesets[] = new IArchiveFileSet[nodes.length];
+ System.arraycopy(nodes, 0, filesets, 0, nodes.length);
+ return filesets;
+ }
+
+ /*
+ * @see IArchiveFolder#getFolders()
+ */
+ public IArchiveFolder[] getFolders() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FOLDER);
+ IArchiveFolder folders[] = new IArchiveFolder[nodes.length];
+ System.arraycopy(nodes, 0, folders, 0, nodes.length);
+ return folders;
+ }
+
+ /*
+ * @see IArchiveFolder#getArchives()
+ */
+ public IArchive[] getArchives() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE);
+ IArchive pkgs[] = new IArchive[nodes.length];
+ System.arraycopy(nodes, 0, pkgs, 0, nodes.length);
+ return pkgs;
+ }
+
+ /*
+ * @see IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return TYPE_ARCHIVE_FOLDER;
+ }
+
+ /*
+ * @see IArchiveFolder#setName(String)
+ */
+ public void setName(String name) {
+ attributeChanged(NAME_ATTRIBUTE, getName(), name);
+ folderDelegate.setName(name);
+ }
+
+ protected XbFolder getFolderDelegate () {
+ return folderDelegate;
+ }
+
+ public String toString() {
+ return "folder[" + getName() + "]";
+ }
+
+ /*
+ * @see IArchiveNode#getRootArchiveRelativePath()
+ */
+ public IPath getRootArchiveRelativePath() {
+ return getParent().getRootArchiveRelativePath().append(getName());
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
+
+/**
+ * An archive
+ *
+ * @author Rob stryker
+ */
+public class ArchiveImpl extends ArchiveNodeImpl implements IArchive {
+
+ private XbPackage packageDelegate;
+
+ public ArchiveImpl() {
+ this(new XbPackage());
+ }
+ public ArchiveImpl(XbPackage delegate) {
+ super(delegate);
+ this.packageDelegate = delegate;
+ }
+
+ /*
+ * @see IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return TYPE_ARCHIVE;
+ }
+
+ /*
+ * @see IArchive#isDestinationInWorkspace()
+ */
+ public boolean isDestinationInWorkspace() {
+ return packageDelegate.isInWorkspace();
+ }
+
+ /*
+ * @see IArchive#getDestinationPath()
+ */
+ public IPath getDestinationPath () {
+ if (packageDelegate.getToDir() == null ||
packageDelegate.getToDir().equals("."))
+ return getProjectPath() == null ? null : getProjectPath();
+
+ if (isDestinationInWorkspace()) {
+ return ArchivesCore.getInstance().getVariables().getWorkspacePath().append(new
Path(packageDelegate.getToDir()));
+ } else
+ return new Path(packageDelegate.getToDir());
+ }
+
+ /*
+ * @see IArchive#getArchiveFilePath()
+ */
+ public IPath getArchiveFilePath() {
+ return getDestinationPath().append(getName());
+ }
+
+ /*
+ * @see IArchive#getFileSets()
+ */
+ public IArchiveFileSet[] getFileSets() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FILESET);
+ IArchiveFileSet filesets[] = new IArchiveFileSet[nodes.length];
+ System.arraycopy(nodes, 0, filesets, 0, nodes.length);
+ return filesets;
+ }
+
+ /*
+ * @see IArchive#getFolders()
+ */
+ public IArchiveFolder[] getFolders() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE_FOLDER);
+ IArchiveFolder folders[] = new IArchiveFolder[nodes.length];
+ System.arraycopy(nodes, 0, folders, 0, nodes.length);
+ return folders;
+ }
+
+ /*
+ * @see IArchive#getArchives()
+ */
+ public IArchive[] getArchives() {
+ IArchiveNode nodes[] = getChildren(TYPE_ARCHIVE);
+ IArchive pkgs[] = new IArchive[nodes.length];
+ System.arraycopy(nodes, 0, pkgs, 0, nodes.length);
+ return pkgs;
+ }
+
+ /*
+ * @see IArchive#getName()
+ */
+ public String getName() {
+ return packageDelegate.getName();
+ }
+
+ /*
+ * @see IArchive#getArchiveType()
+ */
+ public IArchiveType getArchiveType() {
+ return
ArchivesCore.getInstance().getExtensionManager().getArchiveType(packageDelegate.getPackageType());
+ }
+
+ /*
+ * @see IArchive#isExploded()
+ */
+ public boolean isExploded() {
+ return packageDelegate.isExploded();
+ }
+
+ /*
+ * @see IArchive#isTopLevel()
+ */
+ public boolean isTopLevel() {
+ return (packageDelegate.getParent() instanceof XbPackages);
+ }
+
+ /*
+ * @see IArchive#setDestinationPath(IPath, boolean)
+ */
+ public void setDestinationPath(IPath path) {
+ IPath destPath = getDestinationPath();
+ attributeChanged(DESTINATION_ATTRIBUTE, destPath == null ? null : destPath.toString(),
path == null ? null : path.toString());
+ packageDelegate.setToDir(path.toString());
+ }
+
+ /*
+ * @see IArchive#setInWorkspace(boolean)
+ */
+ public void setInWorkspace(boolean inWorkspace) {
+ attributeChanged(IN_WORKSPACE_ATTRIBUTE, new Boolean(isDestinationInWorkspace()), new
Boolean(inWorkspace));
+ packageDelegate.setInWorkspace(inWorkspace);
+ }
+
+ /*
+ * @see IArchive#setExploded(boolean)
+ */
+ public void setExploded(boolean exploded) {
+ attributeChanged(EXPLODED_ATTRIBUTE, new Boolean(isExploded()), new
Boolean(exploded));
+ packageDelegate.setExploded(exploded);
+ }
+
+ /*
+ * @see IArchive#setName(String)
+ */
+ public void setName(String name) {
+ attributeChanged(NAME_ATTRIBUTE, getName(), name);
+ packageDelegate.setName(name);
+ }
+
+ /*
+ * @see IArchive#setArchiveType(IArchiveType)
+ */
+ public void setArchiveType(IArchiveType type) {
+ attributeChanged(PACKAGE_TYPE_ATTRIBUTE, getArchiveTypeId(), type == null ? null :
type.getId());
+ packageDelegate.setPackageType(type.getId());
+ }
+
+ protected XbPackage getPackageDelegate () {
+ return packageDelegate;
+ }
+
+ /*
+ * @see IArchive#setArchiveType(String)
+ */
+ public void setArchiveType(String type) {
+ attributeChanged(PACKAGE_TYPE_ATTRIBUTE, getArchiveTypeId(), type);
+ packageDelegate.setPackageType(type);
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ /*
+ * @see IArchive#getArchiveTypeId()
+ */
+ public String getArchiveTypeId() {
+ return packageDelegate.getPackageType();
+ }
+
+ /*
+ * @see IArchiveNode#getRootArchiveRelativePath()
+ */
+ public IPath getRootArchiveRelativePath() {
+ if( getParent() == null || getParent().getRootArchiveRelativePath() == null )
+ return new Path(getName());
+ return getParent().getRootArchiveRelativePath().append(getName());
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListenerManager;
+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.internal.xb.XbPackageNodeWithProperties;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
+
+public class ArchiveModelNode extends ArchiveNodeImpl implements IArchiveModelNode {
+ private IPath project;
+ private IArchiveModelListenerManager manager;
+
+ public ArchiveModelNode(IPath project,
+ XbPackageNodeWithProperties node, IArchiveModelListenerManager manager) {
+ super(node);
+ this.project = project;
+ this.manager = manager;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveModelNode#getManager()
+ */
+ public IArchiveModelListenerManager getManager() {
+ return manager;
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#getProject()
+ */
+ public IPath getProjectPath() {
+ return project;
+ }
+
+ public XbPackages getXbPackages() {
+ return (XbPackages)nodeDelegate;
+ }
+
+ /**
+ * The model root can only accept IArchive's as children
+ * @see IArchiveNode#addChild(IArchiveNode)
+ */
+ public void addChild(IArchiveNode child) {
+ if( child instanceof IArchive ) {
+ super.addChild(child);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getNodeType()
+ */
+ public int getNodeType() {
+ return IArchiveNode.TYPE_MODEL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#getRoot()
+ */
+ public IArchiveNode getRoot() {
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#connectedToModel()
+ */
+ public boolean connectedToModel() {
+ return ArchivesModel.instance().containsRoot(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl#getParent()
+ */
+ public IArchiveNode getParent() {
+ return null;
+ }
+
+ /**
+ * No parent allowed for a model node
+ * @see IArchiveNode#setParent(IArchiveNode)
+ */
+ public void setParent(IArchiveNode parent) {
+ }
+
+ /**
+ * I have no relative path. I'm above the root archive
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRootArchiveRelativePath()
+ */
+ public IPath getRootArchiveRelativePath() {
+ return null;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeDeltaImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeDeltaImpl.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeDeltaImpl.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,332 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+
+/**
+ * This class represents changed nodes in the model
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ArchiveNodeDeltaImpl implements IArchiveNodeDelta {
+
+ private ArchiveNodeDeltaImpl parentDelta;
+ private ArchiveNodeImpl postNode, preNode;
+ private HashMap attributes, properties, children;
+ private int kind;
+ private IArchiveNodeDelta[] childrenDeltas;
+
+ /**
+ * Primary constructor
+ * @param parentDelta
+ * @param impl
+ * @param attributeChanges
+ * @param propertyChanges
+ * @param childChanges
+ */
+ public ArchiveNodeDeltaImpl(ArchiveNodeDeltaImpl parentDelta, ArchiveNodeImpl impl,
+ HashMap attributeChanges, HashMap propertyChanges, HashMap childChanges) {
+ this.parentDelta = parentDelta;
+ postNode = impl;
+ kind = 0;
+ properties = propertyChanges;
+ attributes = attributeChanges;
+ children = childChanges;
+
+ // These three lines adjust my "kind" to be accurate
+ ensureAccurateKind();
+
+ // create *my* pre-node
+ // this creates an accurate "old" node but without ANY children at all.
+ preNode = ArchiveDeltaPreNodeFactory.createNode(parentDelta, postNode,
attributeChanges, propertyChanges);
+
+
+ // The children are expected to be added in the loadAllAffectedChildren
+ loadAllAffectedChildren();
+ }
+
+ /**
+ * Constructor that forces a child to be added or removed, as judged by the parent
+ * @param parentDelta
+ * @param impl
+ * @param forcedKind
+ * @param attributeChanges
+ * @param propertyChanges
+ * @param childChanges
+ */
+ public ArchiveNodeDeltaImpl(ArchiveNodeDeltaImpl parentDelta, ArchiveNodeImpl impl,
+ int forcedKind, HashMap attributeChanges,
+ HashMap propertyChanges, HashMap childChanges) {
+ this(parentDelta, impl, attributeChanges, propertyChanges, childChanges);
+ kind = kind | forcedKind; // pre-gaming
+
+ // but if I'm added, I have no pre-node, no changes. All NEW
+ if( (kind & IArchiveNodeDelta.ADDED) == IArchiveNodeDelta.ADDED ) {
+ preNode = null;
+ kind = IArchiveNodeDelta.ADDED;
+ attributes.clear();
+ properties.clear();
+ }
+
+ }
+
+ protected ArchiveNodeDeltaImpl getParentDelta() {
+ return parentDelta;
+ }
+
+ protected void ensureAccurateKind() {
+
+ // Properties First
+ Object key;
+ NodeDelta val;
+ for( Iterator i = properties.keySet().iterator(); i.hasNext(); ) {
+ key = i.next();
+ val = (NodeDelta)properties.get(key);
+ kind = kind | val.getKind();
+ }
+
+ // Attributes Second
+ if( attributes.keySet().size() > 0 )
+ kind = kind | ATTRIBUTE_CHANGED;
+
+ /*
+ * Children third.
+ *
+ * The changed children are saved in a hashmap
+ * Node -> Integer (where int is one of
+ * IPackagesModelDelta.CHILD_ADDED or
+ * IPackagesModelDelta.CHILD_REMOVED
+ */
+ Integer val2;
+ for( Iterator i = children.keySet().iterator(); i.hasNext(); ) {
+ key = i.next();
+ val2 = (Integer)children.get(key);
+ if( val2 != null )
+ kind = kind | val2.intValue();
+ }
+ }
+
+
+ // Forced during constructor, will set the flag for CHILD_CHANGED if a child has changed
at all.
+ public IArchiveNodeDelta[] getAllAffectedChildren() {
+ if( childrenDeltas == null ) {
+ loadAllAffectedChildren();
+ }
+ return childrenDeltas;
+ }
+
+ private void loadAllAffectedChildren() {
+ ArrayList priorChildren = new ArrayList();
+
+ // first add the deltas for things that are currently our children
+ // this includes items that haven't been changed, and items that were added
+ IArchiveNode[] children = postNode.getAllChildren();
+ IArchiveNodeDelta delta;
+ ArrayList deltas = new ArrayList();
+ for( int i = 0; i < children.length; i++ ) {
+ // create our child delta before evaluating whether or not to add it
+ delta = getDelta(children[i]);
+ if( delta.getKind() != IArchiveNodeDelta.NO_CHANGE ) {
+ deltas.add(delta);
+ if( ((delta.getKind() & IArchiveNodeDelta.ADDED) == 0 ) &&
+ ((delta.getKind() & IArchiveNodeDelta.REMOVED) == 0)){
+ kind = kind | DESCENDENT_CHANGED;
+ }
+ }
+
+ // add ALL current nodes, then later remove the added ones
+ priorChildren.add(delta.getPreNode());
+ }
+
+ // now handle the removed ones
+ ArchiveNodeImpl node;
+ for(Iterator i = this.children.keySet().iterator(); i.hasNext(); ) {
+ node = (ArchiveNodeImpl)i.next();
+ int v = ((Integer)this.children.get(node)).intValue();
+
+ if( v == IArchiveNodeDelta.CHILD_REMOVED) {
+ delta = getDelta(node);
+ deltas.add(delta);
+ priorChildren.add(delta.getPreNode());
+ } else if( v == IArchiveNodeDelta.CHILD_ADDED) {
+ delta = getDelta(node);
+ priorChildren.remove(delta.getPreNode());
+ }
+ }
+
+ if( preNode != null ) {
+ // now we've got our list of current children... set them.
+ for( Iterator i = priorChildren.iterator(); i.hasNext(); ) {
+ preNode.addChild((IArchiveNode)i.next());
+ }
+ // now clear pre-node's deltas so it looks shiny
+ preNode.clearDeltas();
+ }
+
+ childrenDeltas = (IArchiveNodeDelta[]) deltas.toArray(new
IArchiveNodeDelta[deltas.size()]);
+ }
+
+
+ private HashMap deltaMap = new HashMap();
+ // local cache
+ private IArchiveNodeDelta getDelta(IArchiveNode child) {
+ if( !deltaMap.containsKey(child)) {
+ deltaMap.put(child, loadDelta(child));
+ }
+ return (IArchiveNodeDelta)deltaMap.get(child);
+ }
+ private IArchiveNodeDelta loadDelta(IArchiveNode child) {
+ if( child instanceof ArchiveNodeImpl ) {
+ int addedOrRemoved = 0;
+ if( children.containsKey(child)) {
+ addedOrRemoved = ((Integer)children.get(child)).intValue() >> 8;
+ }
+ ArchiveNodeImpl impl = (ArchiveNodeImpl)child;
+
+ // Using a different delta constructor here to force
+ // whether this child is added or removed.
+ return new ArchiveNodeDeltaImpl(this, impl, addedOrRemoved,
+ (HashMap)impl.attributeChanges.clone(),
+ (HashMap)impl.propertyChanges.clone(),
+ (HashMap)impl.childChanges.clone());
+ }
+ return child.getDelta();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getKind()
+ */
+ public int getKind() {
+ return kind;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getPostNode()
+ */
+ public IArchiveNode getPostNode() {
+ return postNode;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getPreNode()
+ */
+ public IArchiveNode getPreNode() {
+ return preNode;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getAttributesWithDeltas()
+ */
+ public String[] getAttributesWithDeltas() {
+ Collection atts = attributes.keySet();
+ return (String[]) atts.toArray(new String[atts.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getAttributeDelta(java.lang.String)
+ */
+ public INodeDelta getAttributeDelta(String key) {
+ return (INodeDelta)attributes.get(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getPropertiesWithDeltas()
+ */
+ public String[] getPropertiesWithDeltas() {
+ Collection atts = properties.keySet();
+ return (String[]) atts.toArray(new String[atts.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getPropertyDelta(java.lang.String)
+ */
+ public INodeDelta getPropertyDelta(String key) {
+ return (INodeDelta)properties.get(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getAddedChildrenDeltas()
+ */
+ public IArchiveNodeDelta[] getAddedChildrenDeltas() {
+ return getChangedChildren(IArchiveNodeDelta.ADDED);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta#getRemovedChildrenDeltas()
+ */
+ public IArchiveNodeDelta[] getRemovedChildrenDeltas() {
+ return getChangedChildren(IArchiveNodeDelta.REMOVED);
+ }
+
+ public IArchiveNodeDelta[] getChangedDescendentDeltas() {
+ return getChangedChildren(IArchiveNodeDelta.DESCENDENT_CHANGED);
+ }
+
+ private IArchiveNodeDelta[] getChangedChildren(int type) {
+ ArrayList list = new ArrayList();
+ for( int i = 0; i < childrenDeltas.length; i++ ) {
+ if( (childrenDeltas[i].getKind() & type) != 0 ) {
+ list.add(childrenDeltas[i]);
+ }
+ }
+ return (IArchiveNodeDelta[]) list.toArray(new IArchiveNodeDelta[list.size()]);
+ }
+
+ /**
+ * A quick and dirty class to keep track of changing
+ * values between saves in a model.
+ * Used for property changes and attribute changes
+ * @author rstryker
+ *
+ */
+ protected static class NodeDelta implements INodeDelta {
+ private int kind;
+ private Object before, after;
+ public NodeDelta(Object before, Object after, int kind) {
+ this.before = before;
+ this.after = after;
+ this.kind = kind;
+ }
+ public Object getBefore() { return before; }
+ public Object getAfter() { return after; }
+ public int getKind() {
+ return kind;
+ }
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,417 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+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.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
+import
org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeDeltaImpl.NodeDelta;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNode;
+import
org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackageNodeWithProperties;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
+
+public abstract class ArchiveNodeImpl implements IArchiveNode {
+
+ protected XbPackageNodeWithProperties nodeDelegate;
+ protected IArchiveNode parent;
+ protected ArrayList children;
+
+ // cached data
+ protected HashMap attributeChanges;
+ protected HashMap propertyChanges;
+ protected HashMap childChanges;
+
+
+ public ArchiveNodeImpl (XbPackageNodeWithProperties delegate) {
+ nodeDelegate = delegate;
+ children = new ArrayList();
+
+ // for deltas
+ attributeChanges = new HashMap();
+ propertyChanges = new HashMap();
+ childChanges = new HashMap();
+ }
+
+ public XbPackageNode getNodeDelegate() {
+ return nodeDelegate;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRoot()
+ */
+ public IArchiveNode getRoot() {
+ return parent == null ? this : parent.getRoot();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getModel()
+ */
+ public IArchiveModelNode getModel() {
+ Object root = getRoot();
+ return root instanceof IArchiveModelNode ? (IArchiveModelNode)root : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRootArchive()
+ */
+ public IArchive getRootArchive() {
+ IArchiveNode parent = this.parent;
+ IArchive topArchives = null;
+
+ if( getNodeType() == IArchiveNode.TYPE_ARCHIVE ) topArchives = (IArchive)this;
+ while( parent != null ) {
+ if( parent.getNodeType() == IArchiveNode.TYPE_ARCHIVE )
+ topArchives = (IArchive)parent;
+ parent = parent.getParent();
+ }
+ return topArchives;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getAllChildren()
+ */
+ public IArchiveNode[] getAllChildren () {
+ return (IArchiveNode[]) children.toArray(new IArchiveNode[children.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getChildren(int)
+ */
+ public IArchiveNode[] getChildren(int type) {
+ ArrayList typedChildren = new ArrayList();
+ for (Iterator iter = children.iterator(); iter.hasNext(); ) {
+ IArchiveNode child = (IArchiveNode) iter.next();
+ if (child.getNodeType() == type) {
+ typedChildren.add(child);
+ }
+ }
+
+ return (IArchiveNode[]) typedChildren.toArray(new IArchiveNode[typedChildren.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#hasChildren()
+ */
+ public boolean hasChildren () {
+ return nodeDelegate.hasChildren();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#hasChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public boolean hasChild (IArchiveNode child) {
+ ArchiveNodeImpl childImpl = (ArchiveNodeImpl)child;
+ return nodeDelegate.getAllChildren().contains(childImpl.nodeDelegate);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getParent()
+ */
+ public IArchiveNode getParent() {
+ return parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#setParent(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public void setParent (IArchiveNode parent) {
+ if( getParent() != null && parent != getParent()) {
+ getParent().removeChild(this);
+ }
+
+ if (parent != null && !(parent instanceof ArchiveModelNode)) {
+ this.parent = parent;
+ nodeDelegate.setParent(((ArchiveNodeImpl)parent).getNodeDelegate());
+ } else if (getNodeType() == TYPE_ARCHIVE) {
+ this.parent = parent;
+ XbPackages packages = ArchivesModel.instance().getXbPackages(getProjectPath());
+ nodeDelegate.setParent(packages);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getProject()
+ */
+ public IPath getProjectPath() {
+ IArchiveNode root = getRoot();
+ if( root.getNodeType() != IArchiveNode.TYPE_MODEL)
+ return null;
+ return root.getProjectPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getProperty(java.lang.String)
+ */
+ public String getProperty(String property) {
+ return getProperties().getProperty(property);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#setProperty(java.lang.String,
java.lang.String)
+ */
+ public void setProperty(String property, String value) {
+ if( property == null ) return;
+ propertyChanged(property, getProperty(property), value);
+ if( value == null ) {
+ getProperties().remove(property);
+ } else {
+ getProperties().setProperty(property, value);
+ }
+ }
+
+ /**
+ * @return Get the properties for this object
+ */
+ protected Properties getProperties() {
+ return nodeDelegate.getProperties().getProperties();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor)
+ */
+ public boolean accept(IArchiveNodeVisitor visitor) {
+ return accept(visitor, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#accept(org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor,
boolean)
+ */
+ public boolean accept(IArchiveNodeVisitor visitor, boolean depthFirst) {
+ IArchiveNode children[] = getAllChildren();
+ boolean keepGoing = true;
+
+ if (!depthFirst)
+ keepGoing = visitor.visit(this);
+
+ if (keepGoing) {
+ for (int i = 0; i < children.length; i++) {
+ if (keepGoing) {
+ keepGoing = children[i].accept(visitor, depthFirst);
+ }
+ }
+ }
+
+ if (depthFirst && keepGoing)
+ keepGoing = visitor.visit(this);
+
+ return keepGoing;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#addChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public void addChild(IArchiveNode node) {
+ addChild(node, true);
+ }
+
+ /**
+ * Add a child with the option to skip adding in the delegate
+ * @param child
+ * @param addInDelegate
+ */
+ public void addChild(IArchiveNode child, boolean addInDelegate) {
+ Assert.isNotNull(child);
+ ArchiveNodeImpl childImpl = (ArchiveNodeImpl) child;
+ children.add(childImpl);
+ childImpl.setParent(this);
+ if( addInDelegate )
+ nodeDelegate.addChild(childImpl.nodeDelegate);
+ childChanges(child, IArchiveNodeDelta.CHILD_ADDED);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#removeChild(org.jboss.ide.eclipse.archives.core.model.IArchiveNode)
+ */
+ public void removeChild(IArchiveNode node) {
+ Assert.isNotNull(node);
+ ArchiveNodeImpl impl = (ArchiveNodeImpl) node;
+ boolean removed = false;
+ if (nodeDelegate.getAllChildren().contains(impl.nodeDelegate)) {
+ nodeDelegate.removeChild(impl.nodeDelegate);
+ removed = true;
+ }
+
+ if (children.contains(node)) {
+ children.remove(node);
+ removed = true;
+ }
+ if( removed )
+ childChanges(node, IArchiveNodeDelta.CHILD_REMOVED);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+
+// if (adapter.equals(IProject.class)) {
+// return getProjectPath();
+// } else if (adapter.equals(IArchiveNode.class)) {
+// return this;
+// }
+// else return null;
+ return null;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#connectedToModel()
+ */
+ public boolean connectedToModel() {
+ IArchiveNode root = getRoot();
+ return root instanceof ArchiveModelNode &&
ArchivesModel.instance().containsRoot((ArchiveModelNode)root);
+ }
+
+
+ /**
+ * An attribute has changed. Save the change so it can be represented in a delta
+ */
+ protected void attributeChanged(String key, Object beforeValue, Object afterValue) {
+ int kind = IArchiveNodeDelta.ATTRIBUTE_CHANGED;
+ HashMap map = attributeChanges;
+
+ // short circuit if no change has REALLY occurred
+ if( beforeValue != null && beforeValue.equals(afterValue)) return;
+
+ if( map.containsKey(key)) {
+ Object original = ((NodeDelta)map.get(key)).getBefore();
+ if( original == null && afterValue == null )
+ map.remove(key);
+ else if( original == null )
+ map.put(key, new NodeDelta(original, afterValue, kind));
+ else if( original.equals(afterValue))
+ // value was changed from x to y, then back to x. Therefore, no change
+ map.remove(key);
+ else
+ // value was changed from x to y to z.
+ // Before should remain x, after should become z
+ map.put(key, new NodeDelta(original, afterValue, kind));
+ } else {
+ // added
+ map.put(key, new NodeDelta(beforeValue, afterValue, kind));
+ }
+ }
+
+ /**
+ * A property has changed. Save the change so it can be represented in a delta
+ */
+ protected void propertyChanged(String key, Object beforeValue, Object afterValue) {
+ HashMap changeMap = propertyChanges;
+ // short circuit if no change has REALLY occurred
+ if( beforeValue != null && beforeValue.equals(afterValue)) return;
+
+
+ if( changeMap.containsKey(key)) {
+ // element has already been added, removed, or changed since last save
+ Object original = ((NodeDelta)changeMap.get(key)).getBefore();
+ if( original == null && afterValue == null )
+ changeMap.remove(key);
+ else if( original == null )
+ changeMap.put(key, new NodeDelta(original, afterValue,
IArchiveNodeDelta.PROPERTY_ADDED));
+ else if( original.equals(afterValue))
+ // value was changed from x to y, then back to x. Therefore, no change
+ changeMap.remove(key);
+ else if( afterValue == null ) {
+ // changed from x to y to null, so removed
+ changeMap.put(key, new NodeDelta(original, afterValue,
IArchiveNodeDelta.PROPERTY_REMOVED));
+ } else {
+ // changed from x to y to z, so changed
+ changeMap.put(key, new NodeDelta(original, afterValue,
IArchiveNodeDelta.PROPERTY_CHANGED));
+ }
+ } else {
+ int kind;
+ if( beforeValue == null ) kind = IArchiveNodeDelta.PROPERTY_ADDED;
+ else if( afterValue == null ) kind = IArchiveNodeDelta.PROPERTY_REMOVED;
+ else kind = IArchiveNodeDelta.PROPERTY_CHANGED;
+ changeMap.put(key, new NodeDelta(beforeValue, afterValue, kind));
+ }
+ }
+
+ /**
+ * A child has changed. Save the change
+ * @param node
+ * @param changeType
+ */
+ protected void childChanges(IArchiveNode node, int changeType) {
+ if( childChanges.containsKey(node)) {
+ int lastChange = ((Integer)childChanges.get(node)).intValue();
+ if( lastChange == IArchiveNodeDelta.CHILD_ADDED && changeType ==
IArchiveNodeDelta.CHILD_REMOVED) {
+ childChanges.remove(node);
+ } else if( lastChange == IArchiveNodeDelta.CHILD_REMOVED && changeType ==
IArchiveNodeDelta.CHILD_ADDED) {
+ childChanges.remove(node);
+ }
+ } else {
+ childChanges.put(node, new Integer(changeType));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getDelta()
+ */
+ public IArchiveNodeDelta getDelta() {
+ return new ArchiveNodeDeltaImpl(null, this, (HashMap)attributeChanges.clone(),
+ (HashMap)propertyChanges.clone(), (HashMap)childChanges.clone());
+ }
+
+ /**
+ * Forget all past state
+ */
+ public void clearDeltas() {
+ attributeChanges.clear();
+ propertyChanges.clear();
+ childChanges.clear();
+
+ // clear children
+ IArchiveNode[] children = getAllChildren();
+ for( int i = 0; i < children.length; i++ )
+ ((ArchiveNodeImpl)children[i]).clearDeltas();
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.net.URL;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.Trace;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.xml.sax.SAXException;
+
+public class XMLBinding {
+
+ public static final int NUM_UNMARSHAL_MONITOR_STEPS = 3;
+ public static final int NUM_MARSHALL_MONITOR_STEPS = 2;
+
+ private static URL schema =
ArchivesCore.getInstance().getVariables().getBindingSchema();
+ private static URL log4jxml =
ArchivesCore.getInstance().getVariables().getBindingLog4j();
+ private static SchemaBinding binding;
+
+ static {
+ System.setProperty("log4j.configuration", log4jxml.toString());
+ }
+
+ public static void init ()
+ {
+ try {
+ InputStream stream = schema.openStream();
+ binding = XsdBinder.bind(stream, "UTF-8", null);
+
+ stream.close();
+ } catch (IOException e) {
+ Trace.trace(XMLBinding.class, e);
+ }
+ }
+
+ private static void binderSandbox (Runnable runnable)
+ {
+ ClassLoader original = Thread.currentThread().getContextClassLoader();
+ ClassLoader myCL = XMLBinding.class.getClassLoader();
+ Thread.currentThread().setContextClassLoader(myCL);
+ runnable.run();
+ Thread.currentThread().setContextClassLoader(original);
+ }
+
+ private static XbPackages element = null;
+
+ public static XbPackages unmarshal (final InputStream in, final IProgressMonitor
monitor)
+ {
+ element = null;
+
+ binderSandbox(new Runnable() {
+ public void run () {
+ try {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ monitor.worked(1);
+
+ Object xmlObject = unmarshaller.unmarshal(in, binding);
+ monitor.worked(1);
+
+ element = (XbPackages) xmlObject;
+ monitor.worked(1);
+
+ } catch (JBossXBException e) {
+ Trace.trace(XMLBinding.class, e);
+ }
+ }
+ });
+
+ return element;
+ }
+
+ public static void marshal (final XbPackages element, final Writer writer, final
IProgressMonitor monitor)
+ {
+ binderSandbox(new Runnable() {
+ public void run () {
+ try {
+ InputStream stream = schema.openStream();
+ monitor.worked(1);
+
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.marshal(new InputStreamReader(stream), new XbPackagesObjectProvider(),
element, writer);
+ monitor.worked(1);
+ stream.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFileSet.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFileSet.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFileSet.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+public class XbFileSet extends XbPackageNodeWithProperties {
+
+ private String dir, includes, excludes;
+ private boolean inWorkspace;
+
+ public XbFileSet ()
+ {
+ super();
+ inWorkspace = true;
+ }
+
+ public XbFileSet (XbFileSet fileset)
+ {
+ super(fileset);
+ copyFrom(fileset);
+ }
+
+ public void copyFrom (XbFileSet fileset)
+ {
+ this.dir = fileset.dir == null ? null : new String(fileset.dir);
+ this.includes = fileset.includes == null ? null : new String(fileset.includes);
+ this.excludes = fileset.excludes == null ? null : new String(fileset.excludes);
+ this.inWorkspace = fileset.inWorkspace;
+ }
+
+ protected Object clone() throws CloneNotSupportedException {
+ return new XbFileSet(this);
+ }
+
+ public String getDir() {
+ return dir;
+ }
+
+ public void setDir(String dir) {
+ this.dir = dir;
+ }
+
+ public String getExcludes() {
+ return excludes;
+ }
+
+ public void setExcludes(String excludes) {
+ this.excludes = excludes;
+ }
+
+ public String getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(String includes) {
+ this.includes = includes;
+ }
+
+ public boolean isInWorkspace() {
+ return inWorkspace;
+ }
+
+ public void setInWorkspace(boolean inWorkspace) {
+ this.inWorkspace = inWorkspace;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFolder.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFolder.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbFolder.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.util.List;
+
+public class XbFolder extends XbPackageNodeWithProperties {
+
+ private String name;
+
+ public XbFolder ()
+ {
+ super();
+ }
+
+ public XbFolder (XbFolder folder)
+ {
+ super(folder);
+ copyFrom(folder);
+ }
+
+ public void copyFrom (XbFolder folder)
+ {
+ this.name = folder.name == null ? null : new String(folder.name);
+ }
+
+ protected Object clone() throws CloneNotSupportedException {
+ return new XbFolder(this);
+ }
+
+ public List getPackages ()
+ {
+ return getChildren(XbPackage.class);
+ }
+
+ public List getFolders ()
+ {
+ return getChildren(XbFolder.class);
+ }
+
+ public List getFileSets()
+ {
+ return getChildren(XbFileSet.class);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackage.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackage.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackage.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.util.List;
+
+public class XbPackage extends XbPackageNodeWithProperties {
+
+ private String name, packageType, toDir, id;
+ private boolean exploded, inWorkspace;
+
+ public XbPackage () {
+ super();
+ exploded = false;
+ inWorkspace = true;
+ }
+
+ public XbPackage (XbPackage pkg)
+ {
+ super(pkg);
+ copyFrom (pkg);
+ }
+
+ public void copyFrom (XbPackage pkg)
+ {
+ this.name = pkg.name == null ? null: new String(pkg.name);
+ this.packageType = pkg.packageType == null ? null : new String(pkg.packageType);
+ this.toDir = pkg.toDir == null ? null : new String(pkg.toDir);
+ this.exploded = pkg.exploded;
+ this.inWorkspace = pkg.inWorkspace;
+ }
+
+ protected Object clone() throws CloneNotSupportedException {
+ return new XbPackage(this);
+ }
+
+ public List getPackages ()
+ {
+ return getChildren(XbPackage.class);
+ }
+
+ public List getFolders ()
+ {
+ return getChildren(XbFolder.class);
+ }
+
+ public List getFileSets()
+ {
+ return getChildren(XbFileSet.class);
+ }
+
+ public boolean isExploded() {
+ return exploded;
+ }
+
+ public void setExploded(boolean exploded) {
+ this.exploded = exploded;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getToDir() {
+ return toDir;
+ }
+
+ public void setToDir(String toDir) {
+ this.toDir = toDir;
+ }
+
+ public String getPackageType() {
+ return packageType;
+ }
+
+ public void setPackageType(String packageType) {
+ this.packageType = packageType;
+ }
+
+ /**
+ * Get the inWorkspace.
+ *
+ * @return the inWorkspace.
+ */
+ public boolean isInWorkspace() {
+ return inWorkspace;
+ }
+
+ /**
+ * Set the inWorkspace.
+ *
+ * @param inWorkspace The inWorkspace to set.
+ */
+ public void setInWorkspace(boolean inWorkspace) {
+ this.inWorkspace = inWorkspace;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNode.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNode.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNode.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+public abstract class XbPackageNode implements Cloneable {
+
+ protected XbPackageNode parent;
+
+ /**
+ * The children are a class -> arraylist[child] map hashmap
+ */
+ protected Hashtable children;
+
+ public XbPackageNode ()
+ {
+ children = new Hashtable();
+ }
+
+ public XbPackageNode(XbPackageNode node)
+ {
+ children = new Hashtable();
+ Object key;
+ for( Iterator i = node.children.keySet().iterator(); i.hasNext(); ) {
+ key = i.next();
+ children.put(key, ((ArrayList)node.children.get(key)).clone());
+ }
+ }
+
+ public void addChild (Object object)
+ {
+ addChild((XbPackageNode)object);
+ }
+
+ public void addChild (XbPackageNode child)
+ {
+ if (!children.containsKey(child.getClass()))
+ {
+ children.put(child.getClass(), new ArrayList());
+ }
+ getChildren(child.getClass()).add(child);
+ child.setParent(this);
+ }
+
+ public void removeChild (XbPackageNode child)
+ {
+ if (children.containsKey(child.getClass()))
+ {
+ getChildren(child.getClass()).remove(child);
+ }
+ }
+
+ public List getChildren(Class type)
+ {
+ return (List)children.get(type);
+ }
+
+ public boolean hasChildren ()
+ {
+ return children != null && children.size() > 0;
+ }
+
+ public List getAllChildren()
+ {
+ ArrayList allChildren = new ArrayList();
+
+ for (Iterator iter = children.keySet().iterator(); iter.hasNext();)
+ {
+ Class childType = (Class) iter.next();
+ allChildren.addAll(getChildren(childType));
+ }
+ return allChildren;
+ }
+
+ public XbPackageNode getParent()
+ {
+ return parent;
+ }
+
+ public void setParent (XbPackageNode parent)
+ {
+ this.parent = parent;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNodeWithProperties.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNodeWithProperties.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackageNodeWithProperties.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+public abstract class XbPackageNodeWithProperties extends XbPackageNode {
+
+ protected XbProperties properties;
+
+ public XbPackageNodeWithProperties () {
+ super();
+ properties = new XbProperties();
+ }
+
+ public XbPackageNodeWithProperties (XbPackageNodeWithProperties node) {
+ super(node);
+ properties = new XbProperties();
+ }
+
+ public void copyFrom (XbPackageNodeWithProperties node) {
+ properties.getProperties().clear();
+
+ Properties props = node.getProperties().getProperties();
+ for (Iterator iter = props.keySet().iterator(); iter.hasNext(); )
+ {
+ String key = (String) iter.next();
+
+ properties.getProperties().setProperty(key, (String) props.get(key));
+ }
+ }
+
+ public XbProperties getProperties () {
+ return properties;
+ }
+
+ public void setProperties (Object object) {
+ setProperties((XbProperties)object);
+ }
+
+ protected void setProperties (XbProperties properties) {
+ this.properties = properties;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.util.List;
+
+public class XbPackages extends XbPackageNodeWithProperties {
+
+ public XbPackages () {
+ super();
+ }
+
+ public XbPackages (XbPackages packages)
+ {
+ super(packages);
+ }
+
+ protected Object clone() throws CloneNotSupportedException {
+ return new XbPackages(this);
+ }
+
+ public List getPackages ()
+ {
+ return getChildren(XbPackage.class);
+ }
+}
Added:
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
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackagesObjectProvider.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,98 @@
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import org.jboss.xb.binding.GenericObjectModelProvider;
+import org.jboss.xb.binding.MarshallingContext;
+
+public class XbPackagesObjectProvider implements GenericObjectModelProvider {
+
+ public Object getRoot(Object o, MarshallingContext context, String namespaceURI, String
localName) {
+ return o;
+ }
+
+ protected Object getNodeChildren(XbPackageNode node, String name)
+ {
+ if ("package".equals(name))
+ {
+ return node.getChildren(XbPackage.class);
+ }
+ else if ("folder".equals(name))
+ {
+ return node.getChildren(XbFolder.class);
+ }
+ else if ("fileset".equals(name))
+ {
+ return node.getChildren(XbFileSet.class);
+ }
+ else if ("properties".equals(name) && node instanceof
XbPackageNodeWithProperties)
+ {
+ return ((XbPackageNodeWithProperties)node).getProperties();
+ }
+ else if ("property".equals(name) && node instanceof XbProperties)
+ {
+ return ((XbProperties)node).getProperties().getPropertyElements();
+ }
+
+ return null;
+ }
+
+ public Object getChildren(Object object, MarshallingContext context, String
namespaceURI, String localName)
+ {
+ if (object instanceof XbPackageNode) {
+ Object ret = getNodeChildren(((XbPackageNode)object), localName);
+ return ret;
+ }
+ return null;
+ }
+
+
+ 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();
+ } else if ("type".equals(localName))
+ return pkg.getPackageType();
+ else if ("name".equals(localName))
+ return pkg.getName();
+ else if ("exploded".equals(localName))
+ return Boolean.valueOf(pkg.isExploded());
+ else if ("todir".equals(localName))
+ return pkg.getToDir();
+ else if ("inWorkspace".equals(localName))
+ return ""+pkg.isInWorkspace();
+ }
+ else if (object instanceof XbFolder)
+ {
+ XbFolder folder = (XbFolder) object;
+ if ("name".equals(localName))
+ return folder.getName();
+ }
+ else if (object instanceof XbFileSet)
+ {
+ XbFileSet fileset = (XbFileSet)object;
+ if ("dir".equals(localName))
+ return fileset.getDir();
+ else if ("includes".equals(localName))
+ return fileset.getIncludes();
+ else if ("excludes".equals(localName))
+ return fileset.getExcludes();
+ else if ("inWorkspace".equals(localName))
+ return "" + fileset.isInWorkspace();
+ }
+ else if (object instanceof XbProperty)
+ {
+ XbProperty prop = (XbProperty) object;
+ if ("name".equals(localName))
+ return prop.getName();
+ else if ("value".equals(localName))
+ return prop.getValue();
+ }
+ return null;
+ }
+
+ public Object getElementValue(Object object, MarshallingContext context, String
namespaceURI, String localName) {
+ return null;
+ }
+}
Added:
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
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperties.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Properties;
+
+
+public class XbProperties extends XbPackageNode {
+
+ private PropertiesExt properties;
+
+ public XbProperties ()
+ {
+ super();
+ this.properties = new PropertiesExt();
+ }
+
+ public XbProperties (XbProperties props)
+ {
+ super(props);
+ this.properties = new PropertiesExt();
+ for (Iterator iter = getChildren(XbProperty.class).iterator(); iter.hasNext(); )
+ {
+ XbProperty element = (XbProperty) iter.next();
+ addProperty(element);
+ }
+ }
+
+ protected Object clone() throws CloneNotSupportedException {
+ return new XbProperties(this);
+ }
+
+ public class PropertiesExt extends Properties {
+ private static final long serialVersionUID = 1L;
+ private Hashtable propertyElements;
+
+ public PropertiesExt ()
+ {
+ propertyElements = new Hashtable();
+ }
+
+ public synchronized Object put(Object key, Object value) {
+ if (!propertyElements.containsKey(key))
+ {
+ XbProperty element = new XbProperty();
+ element.setName((String)key);
+ element.setValue((String)value);
+ propertyElements.put(key, element);
+
+ }
+ else {
+ XbProperty element = (XbProperty)propertyElements.get(key);
+ element.setValue((String)value);
+ }
+
+ return super.put(key, value);
+ }
+
+ public synchronized Object remove(Object key) {
+ propertyElements.remove(key);
+
+ return super.remove(key);
+ }
+
+ public Collection getPropertyElements ()
+ {
+ return propertyElements.values();
+ }
+ }
+
+ public PropertiesExt getProperties ()
+ {
+ return properties;
+ }
+
+ public void addProperty (Object property)
+ {
+ addProperty((XbProperty)property);
+ }
+
+ public void addProperty (XbProperty property)
+ {
+ properties.setProperty(property.getName(), property.getValue());
+ addChild(property);
+ }
+
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperty.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperty.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbProperty.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.internal.xb;
+
+
+public class XbProperty extends XbPackageNode {
+
+ private String name, value;
+
+ public XbProperty () {
+ super();
+ }
+
+ public XbProperty(XbProperty property) {
+ this.name = property.name == null ? null : new String(property.name);
+ this.value = property.value == null ? null : new String(property.value);
+ }
+
+ protected Object clone() throws CloneNotSupportedException {
+ return new XbProperty(this);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveBuildListener.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveBuildListener.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveBuildListener.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.other;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+
+/**
+ * This interface is inteded to be implemented by classes who are
+ * interested in receiving callbacks for various IArchive build events
+ *
+ * @author Marshall
+ */
+public interface IArchiveBuildListener {
+
+
+ /**
+ * A project has started being built by the Archives builder
+ * @param project the project being built
+ */
+ public void startedBuild (IPath project);
+
+ /**
+ * A project is finished being built by the Archives builder
+ * @param project the project being built
+ */
+ public void finishedBuild (IPath project);
+
+ /**
+ * The project is going to be rebuilt from scratch and all state should be discarded
+ * @param project
+ */
+ public void cleanProject(IPath project);
+
+ /**
+ * An Archive has started being built by the Archives builder
+ * This can be called from a full build, or from the incremental build
+ * if and only if one of the affected files matches a fileset in this archive.
+ *
+ * @param pkg the Archive being built
+ */
+ public void startedBuildingArchive (IArchive pkg);
+
+ /**
+ * An Archive is finished being built by the Archives builder
+ * This can be called from a full build, or from the incremental build
+ * if and only if one of the affected files matches a fileset in this archive.
+ *
+ * @param pkg the Archive being built
+ */
+ public void finishedBuildingArchive (IArchive pkg);
+
+ /**
+ * The archive is going to be rebuilt from scratch and all state should be discarded
+ * @param pkg
+ */
+ public void cleanArchive(IArchive pkg);
+
+
+ /**
+ * A fileset has started being collected for copying into a Archive
+ * This is *only* used during a FULL BUILD or after a MODEL CHANGE
+ * @param fileset the fileset being collected
+ */
+ public void startedCollectingFileSet (IArchiveFileSet fileset);
+
+ /**
+ * A fileset has finished being collected for copying into a Archive
+ * This is *only* used during a FULL BUILD or after a MODEL CHANGE
+ * @param fileset the fileset being collected
+ */
+ public void finishedCollectingFileSet (IArchiveFileSet fileset);
+
+ /**
+ * The build for the given project has failed
+ * @param pkg The Archive that failed to build
+ * @param status The status/exception that occurred
+ */
+ public void buildFailed (IArchive pkg, IStatus status);
+
+ /**
+ * A file has been updated, with the given IArchive / IArchiveFileSet context
+ * @param topLevelArchive The top level Archive that was updated
+ * @param fileset The fileset that matched the updated file
+ * @param filePath The path to the file that was copied (filesystem/workspace path)
+ */
+ public void fileUpdated (IArchive topLevelArchive, IArchiveFileSet fileset, IPath
filePath);
+
+ /**
+ * A file has been removed, with the given IArchive / IArchiveFileSet context
+ * @param topLevelArchive The top level Archive that was updated
+ * @param fileset The fileset that matched the removed file
+ * @param filePath The path to the file that was removed (filesystem/workspace path)
+ */
+ public void fileRemoved (IArchive topLevelArchive, IArchiveFileSet fileset, IPath
filePath);
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveModelListener.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveModelListener.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IArchiveModelListener.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.other;
+
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+
+/**
+ * Interface for model changes.
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ */
+public interface IArchiveModelListener {
+ public void modelChanged(IArchiveNodeDelta delta);
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IExtensionManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IExtensionManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IExtensionManager.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,9 @@
+package org.jboss.ide.eclipse.archives.core.model.other;
+
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+
+
+public interface IExtensionManager {
+ public IArchiveType[] getArchiveTypes();
+ public IArchiveType getArchiveType(String id);
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IPreferenceManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IPreferenceManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IPreferenceManager.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,10 @@
+package org.jboss.ide.eclipse.archives.core.model.other;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface IPreferenceManager {
+ public boolean isBuilderEnabled(IPath path);
+ public void setBuilderEnabled(IPath path, boolean val);
+ public boolean areProjectSpecificPrefsEnabled(IPath path);
+ public void setProjectSpecificPrefsEnabled(IPath path, boolean val);
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IRuntimeVariables.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IRuntimeVariables.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/IRuntimeVariables.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,18 @@
+package org.jboss.ide.eclipse.archives.core.model.other;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface IRuntimeVariables {
+ /**
+ * Is the debugging option provided enabled?
+ * If the option is null, is debugging enabled at all?
+ * @param option
+ * @return
+ */
+ public boolean isDebugging(String option);
+ public IPath getWorkspacePath();
+ public URL getBindingSchema();
+ public URL getBindingLog4j();
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/StandaloneVariables.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/StandaloneVariables.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/StandaloneVariables.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,30 @@
+package org.jboss.ide.eclipse.archives.core.model.other.internal;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.other.IRuntimeVariables;
+
+public class StandaloneVariables implements IRuntimeVariables {
+
+ public URL getBindingLog4j() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public URL getBindingSchema() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IPath getWorkspacePath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isDebugging(String option) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceExtensionManager.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.other.internal;
+
+import java.util.Collection;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.archives.core.Trace;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import org.jboss.ide.eclipse.archives.core.model.other.IExtensionManager;
+
+/**
+ * This class will be responsible for loading extension points in the core.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class WorkspaceExtensionManager implements IExtensionManager {
+ public static final String ARCHIVE_TYPES_EXTENSION_ID =
"org.jboss.ide.eclipse.archives.core.archiveTypes";
+
+ private IExtension[] findExtension (String extensionId) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+
+ private static Hashtable archiveTypes;
+ private void loadPackageTypes () {
+ archiveTypes = new Hashtable();
+ IExtension[] extensions = findExtension(ARCHIVE_TYPES_EXTENSION_ID);
+
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement elements[] = extensions[i].getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ try {
+ Object executable = elements[j].createExecutableExtension("class");
+ IArchiveType type = (IArchiveType)executable;
+ archiveTypes.put(type.getId(), type);
+ } catch (InvalidRegistryObjectException e) {
+ Trace.trace(WorkspaceExtensionManager.class, e);
+ } catch( CoreException e ) {
+ Trace.trace(WorkspaceExtensionManager.class, e);
+ }
+ }
+ }
+ }
+
+ public IArchiveType getArchiveType (String packageType) {
+ if (archiveTypes == null)
+ loadPackageTypes();
+ return (IArchiveType)archiveTypes.get(packageType);
+ }
+
+ public IArchiveType[] getArchiveTypes() {
+ if( archiveTypes == null )
+ loadPackageTypes();
+ Collection c = archiveTypes.values();
+ return (IArchiveType[]) c.toArray(new IArchiveType[c.size()]);
+ }
+
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspacePreferenceManager.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.other.internal;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.other.IPreferenceManager;
+import org.osgi.service.prefs.BackingStoreException;
+
+
+/**
+ * Sets default preferences for the plugin.
+ * By default, the builder is enabled for all projects with archives.
+ *
+ * @author rstryker
+ *
+ */
+public class WorkspacePreferenceManager extends AbstractPreferenceInitializer implements
IPreferenceManager {
+ public static final String AUTOMATIC_BUILDER_ENABLED =
"org.jboss.ide.eclipse.archives.core.automaticBuilderEnabled";
+ public static final String PROJECT_SPECIFIC_PREFS =
"org.jboss.ide.eclipse.archives.core.projectSpecificPreferencesEnabled";
+
+ private static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ private static IResource getResource(IPath path) {
+ if( path != null && workspaceRoot.getLocation().isPrefixOf(path) ) {
+ String relative =
path.toOSString().substring(workspaceRoot.getLocation().toOSString().length()+1);
+ return workspaceRoot.getProject(relative);
+ }
+
+ return null;
+ }
+
+ public boolean isBuilderEnabled(IPath path) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
AUTOMATIC_BUILDER_ENABLED);
+ IResource res = getResource(path);
+ if( res != null && areProjectSpecificPrefsEnabled(res)) {
+ try {
+ if( res.getPersistentProperty(name) != null) {
+ return Boolean.parseBoolean(res.getPersistentProperty(name));
+ }
+ } catch( CoreException ce ) {}
+ }
+ return new
InstanceScope().getNode(ArchivesCorePlugin.PLUGIN_ID).getBoolean(AUTOMATIC_BUILDER_ENABLED,
true);
+ }
+
+ public void setBuilderEnabled(IPath path, boolean value) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
AUTOMATIC_BUILDER_ENABLED);
+ IResource resource = getResource(path);
+ // if the resource is null or the resource has no preference val, use global val
+ try {
+ if( resource != null && resource.getPersistentProperty(name) != null) {
+ resource.setPersistentProperty(name, new Boolean(value).toString());
+ return;
+ }
+ } catch( CoreException ce ) {}
+ IEclipsePreferences prefs = new InstanceScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(AUTOMATIC_BUILDER_ENABLED, value);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+ prefs.putBoolean(AUTOMATIC_BUILDER_ENABLED, true);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+
+ public boolean areProjectSpecificPrefsEnabled(IPath path) {
+ return areProjectSpecificPrefsEnabled(getResource(path));
+ }
+ public boolean areProjectSpecificPrefsEnabled(IResource resource) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
PROJECT_SPECIFIC_PREFS);
+ try {
+ if( resource != null && resource.getPersistentProperty(name) != null) {
+ return Boolean.parseBoolean(resource.getPersistentProperty(name));
+ }
+ } catch( CoreException ce ) {}
+ return false;
+ }
+
+ public void setProjectSpecificPrefsEnabled(IPath path, boolean value) {
+ QualifiedName name = new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
PROJECT_SPECIFIC_PREFS);
+ IResource resource = getResource(path);
+ try {
+ if( resource != null) {
+ resource.setPersistentProperty(name, new Boolean(value).toString());
+ return;
+ }
+ } catch( CoreException ce ) {}
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,29 @@
+package org.jboss.ide.eclipse.archives.core.model.other.internal;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.other.IRuntimeVariables;
+
+public class WorkspaceVariables implements IRuntimeVariables {
+
+ public URL getBindingLog4j() {
+ return ArchivesCorePlugin.getDefault().getBundle().getEntry("log4j.xml");
+ }
+
+ public URL getBindingSchema() {
+ return
ArchivesCorePlugin.getDefault().getBundle().getEntry("xml/packages.xsd");
+ }
+
+ public IPath getWorkspacePath() {
+ return ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ }
+
+ public boolean isDebugging(String option) {
+ return ArchivesCorePlugin.getDefault().isDebugging()
+ && "true".equalsIgnoreCase(Platform.getDebugOption(option));
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/AbstractArchiveType.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/AbstractArchiveType.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/AbstractArchiveType.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,52 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.model.types;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+
+/**
+ *
+ * @author rob.stryker(a)jboss.com
+ */
+public abstract class AbstractArchiveType implements IArchiveType, IExecutableExtension
{
+
+ private IConfigurationElement element;
+ public void setInitializationData(IConfigurationElement config, String propertyName,
Object data) throws CoreException {
+ if( element == null ) element = config;
+ }
+ public String getId() {
+ return element.getAttribute("id");
+ }
+
+ public String getLabel() {
+ return element.getAttribute("label");
+ }
+
+ public abstract IArchive createDefaultConfiguration(IProject project, IProgressMonitor
monitor);
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/JARArchiveType.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/JARArchiveType.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/JARArchiveType.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,74 @@
+package org.jboss.ide.eclipse.archives.core.model.types;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.ide.eclipse.archives.core.Trace;
+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.internal.ArchiveFileSetImpl;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
+
+/**
+ * The default JAR package type will simply jar-up all the classes in a java
project's output directory, and place it in the top-level of the project.
+ * The name of the resulting JAR will be the project's name followed by a
".jar" extension.
+ * @author Marshall
+ */
+public class JARArchiveType extends AbstractArchiveType {
+
+ public static final String TYPE_ID = "jar";
+
+ public IArchive createDefaultConfiguration(IProject project, IProgressMonitor monitor)
{
+ //IPackageType t = this;
+ Assert.isNotNull(project);
+
+ IJavaProject javaProject = JavaCore.create(project);
+ Assert.isNotNull(javaProject);
+
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Creating default JAR configuration for java project
\"" + project.getName() + "\"", 2);
+
+ IPath outputPath;
+ try {
+ outputPath = javaProject.getOutputLocation();
+ } catch (JavaModelException e) {
+ Trace.trace(JARArchiveType.class, e);
+ return null;
+ }
+
+ outputPath = outputPath.removeFirstSegments(1);
+ IContainer outputContainer = project.getFolder(outputPath);
+
+ IArchive jar = new ArchiveImpl();
+
+ jar.setDestinationPath(project.getLocation());
+ jar.setInWorkspace(true);
+ jar.setExploded(false);
+ jar.setName(project.getName() + ".jar");
+ jar.setArchiveType(this);
+
+ IArchiveFileSet classes = new ArchiveFileSetImpl();
+ classes.setIncludesPattern("**/*");
+ classes.setSourcePath(outputContainer.getFullPath());
+ classes.setInWorkspace(true);
+
+ jar.addChild(classes);
+
+ monitor.worked(1);
+ monitor.done();
+
+ return jar;
+ }
+
+ // do nothing
+ public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel,
IProgressMonitor monitor) {
+ return null;
+ }
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.project;
+
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+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.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.util.internal.TrueZipUtil;
+
+/**
+ * This builder is responsible for building the archives
+ * It delegates to a delegate.
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ArchivesBuilder extends IncrementalProjectBuilder {
+
+ public static final String BUILDER_ID =
"org.jboss.ide.eclipse.archives.core.archivesBuilder";
+
+ /**
+ * Build.
+ * @see IncrementalProjectBuilder#build(int, Map, IProgressMonitor)
+ * @see IProject#build(int, String, Map, IProgressMonitor)
+ */
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws
CoreException {
+
+ // if we're not to build, get out of here
+ if(
!ArchivesCore.getInstance().getPreferenceManager().isBuilderEnabled(getProject().getLocation()))
+ return new IProject[]{};
+
+ IProject[] interestingProjects = getInterestingProjectsInternal();
+
+ final TreeSet addedChanged = createDefaultTreeSet();
+ final TreeSet removed = createDefaultTreeSet();
+
+ ArchiveBuildDelegate delegate = new ArchiveBuildDelegate();
+ if (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD || kind ==
IncrementalProjectBuilder.AUTO_BUILD) {
+ fillDeltas(interestingProjects, addedChanged, removed);
+ delegate.projectIncrementalBuild(addedChanged, removed);
+
+ } else if (kind == IncrementalProjectBuilder.FULL_BUILD){
+ // build each package fully
+ IProject p = getProject();
+ delegate.fullProjectBuild(p.getLocation());
+ }
+
+ return interestingProjects;
+ }
+
+ /**
+ * Delete all archives that were created or represented by this
+ * project's archive model.
+ */
+ protected void clean(IProgressMonitor monitor) throws CoreException {
+ IPath p = getProject().getLocation();
+ IArchiveModelNode root = ArchivesModel.instance().getRoot(p);
+ IArchiveNode[] nodes = root.getChildren(IArchiveNode.TYPE_ARCHIVE);
+ for( int i = 0; i < nodes.length; i++ ) {
+ IPath path = ((IArchive)nodes[i]).getDestinationPath();
+ TrueZipUtil.deleteAll(path);
+ }
+ }
+
+ /**
+ * Browse through the deltas and fill the treesets with
+ * affected resources.
+ * @param projects The interesting projects
+ * @param addedChanged A collection of resources that have been added or changed
+ * @param removed A collection of resources that have been removed.
+ */
+ protected void fillDeltas(IProject[] projects, final TreeSet addedChanged, final TreeSet
removed) {
+ for( int i = 0; i < projects.length; i++ ) {
+ final IProject proj = projects[i];
+ IResourceDelta delta = getDelta(proj);
+ try {
+ delta.accept(new IResourceDeltaVisitor () {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ if (delta.getResource().getType() == IResource.FILE) {
+ if( (delta.getKind() & IResourceDelta.ADDED) > 0
+ || (delta.getKind() & IResourceDelta.CHANGED) > 0) {
+
+ // ignore the packages project. that will it's own build call,
+ // or will handle the change in some other way
+ if(
!delta.getResource().equals(proj.findMember(ArchivesModel.PROJECT_PACKAGES_FILE)))
+ addedChanged.add(delta.getResource().getLocation());
+ } else if( (delta.getKind() & IResourceDelta.REMOVED ) > 0 ) {
+ removed.add(delta.getResource().getLocation());
+ }
+ }
+ return true;
+ }
+ });
+ } catch( CoreException ce) {
+
+ }
+ }
+ }
+
+ /**
+ * Get any projects that the current project may depend on
+ * (regarding it's archive model, if any filesets match files in
+ * another project).
+ * @return The list of projects that matter
+ */
+ protected IProject[] getInterestingProjectsInternal() {
+ final TreeSet set = createDefaultTreeSet();
+ set.add(getProject());
+
+ final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ final int count = workspaceRoot.getLocation().segmentCount();
+
+ ArchivesModel.instance().getRoot(getProject().getLocation()).accept(new
IArchiveNodeVisitor () {
+ public boolean visit (IArchiveNode node) {
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
+ IArchiveFileSet fileset = (IArchiveFileSet)node;
+ IPath p = fileset.getGlobalSourcePath();
+ if( workspaceRoot.getLocation().isPrefixOf(p)) {
+ IProject proj = workspaceRoot.getProject(p.segment(count));
+ set.add(proj);
+ }
+ }
+ return true;
+ }
+ });
+ return (IProject[]) set.toArray(new IProject[set.size()]);
+ }
+
+ /**
+ * Default treeset with default comparator
+ * @return
+ */
+ protected TreeSet createDefaultTreeSet() {
+ return new TreeSet(new Comparator () {
+ public int compare(Object o1, Object o2) {
+ if (o1.equals(o2)) return 0;
+ else return -1;
+ }
+ });
+ }
+
+}
\ No newline at end of file
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesNature.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesNature.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ArchivesNature.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.project;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+/**
+ * The nature associated with archives, specifically
+ * the builder is added or removed based on this nature.
+ *
+ * @author Rob Stryker (rob.stryker(a)redhat.com)
+ *
+ */
+public class ArchivesNature implements IProjectNature {
+
+ public static final String NATURE_ID =
"org.jboss.ide.eclipse.archives.core.archivesNature";
+
+ private IProject project;
+
+ public void configure() throws CoreException {
+ addProjectBuilder(project, ArchivesBuilder.BUILDER_ID);
+ }
+
+ public void deconfigure() throws CoreException {
+ removeProjectBuilder(project, ArchivesBuilder.BUILDER_ID);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public static boolean addProjectBuilder(IProject project, String builderId)
+ {
+ try
+ {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] commands = desc.getBuildSpec();
+
+ //add builders to project
+ ICommand builderCommand = desc.newCommand();
+ builderCommand.setBuilderName(builderId);
+
+ ICommand[] newCommands = new ICommand[commands.length + 1];
+ System.arraycopy(commands, 0, newCommands, 0, commands.length);
+ newCommands[newCommands.length - 1] = builderCommand;
+
+ desc.setBuildSpec(newCommands);
+
+ project.setDescription(desc, new NullProgressMonitor());
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Removes a specific builder from the end of a given project's builder list.
+ * @param project
+ * @param builderId
+ * @return Whether or not the builder was successfully removed
+ */
+ public static boolean removeProjectBuilder(IProject project, String builderId) {
+ try {
+ IProjectDescription desc = project.getDescription();
+ ICommand[] commands = desc.getBuildSpec();
+ ArrayList newCommands = new ArrayList();
+
+ for (int i = 0; i < commands.length; i++) {
+ if (!commands[i].getBuilderName().equals(builderId)) {
+ newCommands.add(commands[i]);
+ }
+ }
+
+ desc.setBuildSpec((ICommand[]) newCommands.toArray(new
ICommand[newCommands.size()]));
+
+ project.setDescription(desc, new NullProgressMonitor());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/project/ProjectUtils.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,46 @@
+package org.jboss.ide.eclipse.archives.core.project;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class ProjectUtils {
+
+ public static boolean addProjectNature(IPath path) {
+ String loc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
+ if( path.toOSString().startsWith(loc)) {
+ String proj = path.toOSString().substring(loc.length()+1);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(proj);
+ return addProjectNature(p, ArchivesNature.NATURE_ID);
+ }
+ return false;
+ }
+
+ public static boolean addProjectNature(IProject project, String natureId) {
+ boolean added = false;
+ try {
+ if (project != null && natureId != null) {
+ IProjectDescription desc = project.getDescription();
+
+ if (!project.hasNature(natureId)) {
+ String natureIds[] = desc.getNatureIds();
+ String newNatureIds[] = new String[natureIds.length + 1];
+
+ System.arraycopy(natureIds, 0, newNatureIds, 1, natureIds.length);
+ newNatureIds[0] = natureId;
+ desc.setNatureIds(newNatureIds);
+
+ project.getProject().setDescription(desc, new NullProgressMonitor());
+ added = true;
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return added;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,193 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveModelNode;
+
+/**
+ * Utility class for matching model elements and stuff
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ModelUtil {
+
+ /**
+ * Get any declared fileset that matches this path and are registered with the model
+ * @param path
+ * @return
+ */
+ public static IArchiveFileSet[] getMatchingFilesets(final IPath path) {
+ return getMatchingFilesets(null, path);
+ }
+
+ /**
+ * Get any declared filesets that match this path and are
+ * a child of the given node
+ * @param node
+ * @param path
+ * @return
+ */
+ public static IArchiveFileSet[] getMatchingFilesets(IArchiveNode node, final IPath path)
{
+ final ArrayList rets = new ArrayList();
+ IArchiveNodeVisitor visitor = new IArchiveNodeVisitor() {
+ public boolean visit(IArchiveNode node) {
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET &&
+ ((IArchiveFileSet)node).matchesPath(path)) {
+ rets.add((IArchiveFileSet)node);
+ }
+ return true;
+ }
+ };
+
+ if( node == null )
+ ArchivesModel.instance().accept(visitor);
+ else
+ node.accept(visitor);
+
+ return (IArchiveFileSet[]) rets.toArray(new IArchiveFileSet[rets.size()]);
+ }
+
+ /**
+ * Find all filesets that are a child to this node
+ * @param node
+ * @return
+ */
+ public static IArchiveFileSet[] findAllDescendentFilesets(IArchiveNode node) {
+ ArrayList matches = findAllDescendents(node, IArchiveNode.TYPE_ARCHIVE_FILESET);
+ return (IArchiveFileSet[]) matches.toArray(new IArchiveFileSet[matches.size()]);
+ }
+
+ /**
+ * Find all folders that are a child to this node
+ * @param node
+ * @return
+ */
+ public static IArchiveFolder[] findAllDescendentFolders(IArchiveNode node) {
+ ArrayList matches = findAllDescendents(node, IArchiveNode.TYPE_ARCHIVE_FOLDER);
+ return (IArchiveFolder[]) matches.toArray(new IArchiveFolder[matches.size()]);
+ }
+
+ /**
+ * Find all nodes of one type that are a child to this one
+ * @param node
+ * @return
+ */
+ public static ArrayList findAllDescendents(IArchiveNode node, final int type) {
+ final ArrayList matches = new ArrayList();
+ if( node.getNodeType() == type && !matches.contains(node) )
+ matches.add(node);
+
+ node.accept(new IArchiveNodeVisitor() {
+ public boolean visit(IArchiveNode node) {
+ if( node.getNodeType() == type && !matches.contains(node))
+ matches.add(node);
+ return true;
+ }
+ });
+ return matches;
+ }
+
+
+ /**
+ * Do any filesets other than the parameter match this path?
+ * @param fileset
+ * @param path
+ * @return
+ */
+ public static boolean otherFilesetMatchesPath(IArchiveFileSet fileset, IPath path) {
+ IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(path);
+ if( filesets.length == 0 || (filesets.length == 1 &&
Arrays.asList(filesets).contains(fileset))) {
+ return false;
+ } else {
+ // other filesets DO match... but are they at the same location in the archive?
+ for( int i = 0; i < filesets.length; i++ ) {
+ if( fileset.equals(filesets[i])) continue;
+ if(
fileset.getRootArchiveRelativePath(path).equals(filesets[i].getRootArchiveRelativePath(path)))
{
+ // the two put the file in the same spot! It's a match!
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the raw file for this node, specifically,
+ * the file actually saved as an OS file.
+ * @param node
+ * @return
+ */
+ public static IPath getBaseFile(IArchiveNode node) {
+ return getBaseFile(node, null);
+ }
+
+ /**
+ * Get the raw file for this node, specifically,
+ * the file actually saved as an OS file.
+ * @param node
+ * @return
+ */
+ public static IPath getBaseFile(IArchiveNode node, IPath absolutePath) {
+ ArrayList list = new ArrayList();
+ while( node != null && !(node instanceof ArchiveModelNode)) {
+ list.add(node);
+ node = node.getParent();
+ }
+ Collections.reverse(list);
+ IArchiveNode[] nodes = (IArchiveNode[]) list.toArray(new IArchiveNode[list.size()]);
+
+ IPath lastConcrete = null;
+ for( int i = 0; i < nodes.length; i++ ) {
+ if( nodes[i] instanceof IArchive) {
+ if( lastConcrete == null )
+ lastConcrete = ((IArchive)nodes[i]).getArchiveFilePath();
+ else
+ lastConcrete = lastConcrete.append(((IArchive)nodes[i]).getName());
+
+ if( !((IArchive)nodes[i]).isExploded())
+ return lastConcrete;
+ } else if( nodes[i] instanceof IArchiveFolder ) {
+ lastConcrete = lastConcrete.append(((IArchiveFolder)nodes[i]).getName());
+ }
+ }
+
+ if( absolutePath != null && node.getNodeType() ==
IArchiveNode.TYPE_ARCHIVE_FILESET ) {
+ IArchiveFileSet fs = ((IArchiveFileSet)node);
+ if( fs.getSourcePath().isPrefixOf(absolutePath)) {
+
lastConcrete.append(absolutePath.removeFirstSegments(fs.getSourcePath().segmentCount()));
+ }
+ }
+ return lastConcrete;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,233 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.util.internal;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IPath;
+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.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+
+import de.schlichtherle.io.ArchiveDetector;
+import de.schlichtherle.io.File;
+
+/**
+ * This class is meant to bridge between the model
+ * and the raw true-zip utility class. It is a higher level
+ * API which deals with filesets and packages instead of
+ * raw Strings and paths.
+ *
+ * It will also make sure that a de.schlichtherle.io.File is
+ * created with the proper ArchiveDetector for each and every
+ * level, rather than the TrueZipUtil class, which not accurately
+ * create the proper File type for exploded archives.
+ *
+ * @author rstryker
+ *
+ */
+public class ModelTruezipBridge {
+ public static void deleteArchive(IArchive archive) {
+ final File file = getFile(archive);
+ file.deleteAll();
+ TrueZipUtil.sync();
+ }
+
+ public static void cleanFolder(IArchiveFolder folder) {
+ cleanFolder(folder, true);
+ }
+
+ public static void cleanFolder(IArchiveFolder folder, boolean sync) {
+ final File file = getFile(folder);
+ TrueZipUtil.deleteEmptyFolders(file);
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+ public static void fullFilesetBuild(IArchiveFileSet fileset) {
+ fullFilesetBuild(fileset, true);
+ }
+ public static void fullFilesetBuild(final IArchiveFileSet fileset, boolean sync) {
+ IPath[] paths = fileset.findMatchingPaths();
+ copyFiles(fileset, paths, false);
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+ public static void fullFilesetsRemove(IArchiveFileSet[] filesets, boolean sync) {
+ for( int i = 0; i < filesets.length; i++ )
+ fullFilesetRemove(filesets[i], false);
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+ // Let them know which files were removed, for events
+ public static IPath[] fullFilesetRemove(final IArchiveFileSet fileset, boolean sync) {
+ IPath[] paths = fileset.findMatchingPaths();
+ ArrayList list = new ArrayList();
+ list.addAll(Arrays.asList(paths));
+ for( int i = 0; i < paths.length; i++ ) {
+ if( !ModelUtil.otherFilesetMatchesPath(fileset, paths[i])) {
+ // remove
+ deleteFiles(fileset, new IPath[] {paths[i]}, false);
+ } else {
+ list.remove(paths[i]);
+ }
+ }
+
+ if( sync )
+ TrueZipUtil.sync();
+
+ return (IPath[]) list.toArray(new IPath[list.size()]);
+ }
+
+
+ public static void copyFiles(IArchiveFileSet[] filesets, IPath[] paths) {
+ copyFiles(filesets, paths, true);
+ }
+
+ public static void copyFiles(final IArchiveFileSet[] filesets, final IPath[] paths,
boolean sync) {
+ for( int i = 0; i < filesets.length; i++ ) {
+ copyFiles(filesets[i], paths, false);
+ }
+ if( sync )
+ TrueZipUtil.sync();
+
+ }
+
+ public static void copyFiles(IArchiveFileSet fileset, final IPath[] paths) {
+ copyFiles(fileset, paths, true);
+ }
+ public static void copyFiles(IArchiveFileSet fileset, final IPath[] paths, boolean sync)
{
+ final File[] destFiles = getFiles(paths, fileset);
+ for( int i = 0; i < paths.length; i++ ) {
+ TrueZipUtil.copyFile(paths[i].toOSString(), destFiles[i]);
+ }
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+ /*
+ * Deleting files
+ */
+ public static void deleteFiles(IArchiveFileSet[] filesets, IPath[] paths ) {
+ deleteFiles(filesets, paths, true);
+ }
+ public static void deleteFiles(final IArchiveFileSet[] filesets, final IPath[] paths,
boolean sync ) {
+ for( int i = 0; i < filesets.length; i++ ) {
+ deleteFiles(filesets[i], paths, false);
+ }
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+ public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths ) {
+ deleteFiles(fileset, paths, true);
+ }
+ public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths, boolean
sync ) {
+ final File[] destFiles = getFiles(paths, fileset);
+ for( int i = 0; i < paths.length; i++ ) {
+ TrueZipUtil.deleteAll(destFiles[i]);
+ }
+
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+ /**
+ * Creates the file, folder, or archive represented by the node.
+ * Does nothing for filesets
+ * @param node
+ */
+ public static void createFile(final IArchiveNode node) {
+ createFile(node, true);
+ }
+ public static void createFile(final IArchiveNode node, boolean sync) {
+ File f = getFile(node);
+ if( f != null ) {
+ f.mkdirs();
+ }
+ if( sync )
+ TrueZipUtil.sync();
+ }
+
+
+
+ /**
+ * Gets all properly-created de.sch files for a fileset
+ * @param inputFiles
+ * @param fs
+ * @return
+ */
+ private static File[] getFiles(IPath[] inputFiles, IArchiveFileSet fs ) {
+ String filesetRelative;
+ File fsFile = getFile(fs);
+ File[] returnFiles = new File[inputFiles.length];
+ int fsLength = fs.getGlobalSourcePath().toOSString().length()+1;
+ for( int i = 0; i < inputFiles.length; i++ ) {
+ filesetRelative = inputFiles[i].toOSString().substring(fsLength);
+ returnFiles[i] = new File(fsFile, filesetRelative, ArchiveDetector.NULL);
+ }
+ return returnFiles;
+ }
+
+
+ /**
+ * This should go through the tree and create a file that is
+ * correctly perceived at each step of the way.
+ *
+ * To just create a new File would let the Archive Detector have too
+ * much control, and *ALL* war's and jars, including exploded ones,
+ * would be treated as archives instead of folders.
+ * @param node
+ * @return
+ */
+ private static File getFile(IArchiveNode node) {
+ if( node == null ) return null;
+
+ if( node.getNodeType() == IArchiveNode.TYPE_MODEL ) return null;
+
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET)
+ return getFile(node.getParent());
+
+ File parentFile = getFile(node.getParent());
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE ) {
+ IArchive node2 = ((IArchive)node);
+ boolean exploded = ((IArchive)node).isExploded();
+ ArchiveDetector detector = exploded ? ArchiveDetector.NULL : ArchiveDetector.DEFAULT;
+ if( parentFile == null )
+ return new File(node2.getDestinationPath().append(node2.getName()).toOSString(),
detector);
+ return new File(parentFile, node2.getName(), detector);
+ }
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {
+ return new File(parentFile, ((IArchiveFolder)node).getName(), ArchiveDetector.NULL);
+ }
+ return null;
+ }
+
+}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/TrueZipUtil.java 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,172 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.util.internal;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+
+import de.schlichtherle.io.ArchiveDetector;
+import de.schlichtherle.io.ArchiveException;
+
+/**
+ * Accesses raw files with the truezip filesystem
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class TrueZipUtil {
+
+ public static de.schlichtherle.io.File getFile(IPath path) {
+ return getFile(path, ArchiveDetector.DEFAULT);
+ }
+ public static de.schlichtherle.io.File getFile(IPath path, ArchiveDetector detector) {
+ return new de.schlichtherle.io.File(path.toOSString(), detector);
+ }
+
+ public static boolean pathExists(IPath path) {
+ return pathExists( getFile(path));
+ }
+ public static boolean pathExists( de.schlichtherle.io.File file) {
+ return file.exists();
+ }
+
+
+ public static long getTimestamp(IPath path) {
+ return getTimestamp( getFile(path));
+ }
+
+ public static long getTimestamp(de.schlichtherle.io.File file) {
+ return file.lastModified();
+ }
+
+
+ public static void copyFile(String source, IPath dest) throws IOException {
+ copyFile(source, getFile(dest));
+ }
+
+ public static void copyFile(String source, de.schlichtherle.io.File file) {
+ try {
+ // make parent folders
+ if( !file.getParentFile().exists() )
+ file.getParentFile().mkdirs();
+
+ de.schlichtherle.io.FileOutputStream fos = new
de.schlichtherle.io.FileOutputStream(file);
+ java.io.FileInputStream fis = new java.io.FileInputStream(source);
+
+ byte[] buf = new byte[1024];
+ int i = 0;
+ while((i=fis.read(buf))!=-1) {
+ fos.write(buf, 0, i);
+ }
+ fis.close();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ updateParentTimestamps(file);
+ }
+
+ public static void touchFile(IPath path) {
+ de.schlichtherle.io.File f = getFile(path);
+ f.setLastModified(System.currentTimeMillis());
+ updateParentTimestamps(path);
+ }
+
+
+ // Delete methods
+ public static void deleteAll(IPath path, String fileName) {
+ deleteAll(path.append(fileName));
+ }
+ public static void deleteAll(IPath path) {
+ deleteAll(getFile(path));
+ }
+ public static void deleteAll(de.schlichtherle.io.File file) {
+ file.deleteAll();
+ }
+
+ public static void deleteEmptyFolders(java.io.File file ) {
+ if( file.isDirectory() ) {
+ java.io.File[] children = file.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ deleteEmptyFolders(children[i]);
+ if( file.listFiles().length == 0 )
+ file.delete();
+ }
+ }
+
+
+ public static void createFolder(IPath parent, String folderName) {
+ createFolder(parent.append(folderName));
+ }
+ public static void createFolder(IPath path) {
+ getFile(path, ArchiveDetector.NULL).mkdirs();
+ updateParentTimestamps(path);
+ }
+ public static void createArchive(IPath parent, String folderName) {
+ createArchive(parent.append(folderName));
+ }
+ public static void createArchive(IPath path) {
+ getFile(path).mkdirs();
+ updateParentTimestamps(path);
+ }
+ public static void umount() {
+ try {
+ de.schlichtherle.io.File.umount();
+ } catch( ArchiveException ae ) {
+ }
+ }
+
+ /**
+ * Sync's with file system after executing a runnable
+ * @param run Runnable or null
+ */
+ public static void syncExec(Runnable run) {
+ try {
+ if( run != null )
+ run.run();
+ } catch (Exception e ) {}
+ umount();
+ }
+
+ public static void sync() {
+ syncExec(null);
+ }
+
+ public static void updateParentTimestamps(IPath path) {
+ updateParentTimestamps(getFile(path));
+ }
+ public static void updateParentTimestamps(de.schlichtherle.io.File file) {
+ long time = System.currentTimeMillis();
+ de.schlichtherle.io.File parent = file.getEnclArchive();
+ while( parent != null ) {
+ parent.setLastModified(time);
+ parent = parent.getEnclArchive();
+ }
+
+ }
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/xml/packages.xsd
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/xml/packages.xsd
(rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/xml/packages.xsd 2007-05-21
19:51:45 UTC (rev 2037)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and individual contributors as indicated
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+<xsd:schema
xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="packages" type="packages-type"/>
+
+ <xsd:complexType name="packages-type">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
impl="org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
name="package" type="package-type"/>
+ <xsd:element maxOccurs="1" minOccurs="0"
name="properties" type="properties-type"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="package-type">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
+ impl="org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage"
/>
+ <jbxb:addMethod name="addChild" />
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
+ name="package" type="package-type" />
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
+ name="fileset" type="fileset-type" />
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
+ name="folder" type="folder-type" />
+ <xsd:element maxOccurs="1" minOccurs="0"
name="properties"
+ type="properties-type" />
+ </xsd:sequence>
+
+ <xsd:attribute name="name" type="xsd:string"
use="optional" />
+ <xsd:attribute name="type" type="xsd:string"
use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="packageType" />
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="todir" type="xsd:string"
use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="toDir" />
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute default="false" name="exploded"
+ type="xsd:boolean" use="optional" />
+ <xsd:attribute name="inWorkspace" type="xsd:boolean"
use="optional" default="true"></xsd:attribute>
+ <xsd:attribute name="id" type="xsd:string"
use="optional" />
+ </xsd:complexType>
+
+ <xsd:complexType name="properties-type">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
impl="org.jboss.ide.eclipse.archives.core.model.internal.xb.XbProperties"/>
+ <jbxb:addMethod name="setProperties"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="1"
name="property" type="property-type"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="property-type">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
impl="org.jboss.ide.eclipse.archives.core.model.internal.xb.XbProperty"/>
+ <jbxb:addMethod name="addProperty"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:attribute name="name" type="xsd:string"
use="required"/>
+ <xsd:attribute name="value" type="xsd:string"
use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="folder-type">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
impl="org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFolder"/>
+ <jbxb:addMethod name="addChild"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
name="package" type="package-type"/>
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
name="fileset" type="fileset-type"/>
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
name="folder" type="folder-type"/>
+ <xsd:element maxOccurs="1" minOccurs="0"
name="properties" type="properties-type"/>
+ </xsd:sequence>
+
+ <xsd:attribute name="name" type="xsd:string"
use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="fileset-type">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
impl="org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet"/>
+ <jbxb:addMethod name="addChild"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="1" minOccurs="0"
name="properties" type="properties-type"/>
+ </xsd:sequence>
+
+ <xsd:attribute name="dir" type="xsd:string"
use="required"/>
+ <xsd:attribute name="includes" type="xsd:string"
use="required"/>
+ <xsd:attribute name="excludes" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="inWorkspace" type="xsd:boolean"
use="optional" default="true"/>
+ </xsd:complexType>
+
+</xsd:schema>